amdgpu_acp.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /*
  2. * Copyright 2015 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. *
  24. */
  25. #include <linux/irqdomain.h>
  26. #include <linux/pm_domain.h>
  27. #include <linux/platform_device.h>
  28. #include <sound/designware_i2s.h>
  29. #include <sound/pcm.h>
  30. #include "amdgpu.h"
  31. #include "atom.h"
  32. #include "amdgpu_acp.h"
  33. #include "acp_gfx_if.h"
  34. #define ACP_TILE_ON_MASK 0x03
  35. #define ACP_TILE_OFF_MASK 0x02
  36. #define ACP_TILE_ON_RETAIN_REG_MASK 0x1f
  37. #define ACP_TILE_OFF_RETAIN_REG_MASK 0x20
  38. #define ACP_TILE_P1_MASK 0x3e
  39. #define ACP_TILE_P2_MASK 0x3d
  40. #define ACP_TILE_DSP0_MASK 0x3b
  41. #define ACP_TILE_DSP1_MASK 0x37
  42. #define ACP_TILE_DSP2_MASK 0x2f
  43. #define ACP_DMA_REGS_END 0x146c0
  44. #define ACP_I2S_PLAY_REGS_START 0x14840
  45. #define ACP_I2S_PLAY_REGS_END 0x148b4
  46. #define ACP_I2S_CAP_REGS_START 0x148b8
  47. #define ACP_I2S_CAP_REGS_END 0x1496c
  48. #define ACP_I2S_COMP1_CAP_REG_OFFSET 0xac
  49. #define ACP_I2S_COMP2_CAP_REG_OFFSET 0xa8
  50. #define ACP_I2S_COMP1_PLAY_REG_OFFSET 0x6c
  51. #define ACP_I2S_COMP2_PLAY_REG_OFFSET 0x68
  52. #define mmACP_PGFSM_RETAIN_REG 0x51c9
  53. #define mmACP_PGFSM_CONFIG_REG 0x51ca
  54. #define mmACP_PGFSM_READ_REG_0 0x51cc
  55. #define mmACP_MEM_SHUT_DOWN_REQ_LO 0x51f8
  56. #define mmACP_MEM_SHUT_DOWN_REQ_HI 0x51f9
  57. #define mmACP_MEM_SHUT_DOWN_STS_LO 0x51fa
  58. #define mmACP_MEM_SHUT_DOWN_STS_HI 0x51fb
  59. #define mmACP_CONTROL 0x5131
  60. #define mmACP_STATUS 0x5133
  61. #define mmACP_SOFT_RESET 0x5134
  62. #define ACP_CONTROL__ClkEn_MASK 0x1
  63. #define ACP_SOFT_RESET__SoftResetAud_MASK 0x100
  64. #define ACP_SOFT_RESET__SoftResetAudDone_MASK 0x1000000
  65. #define ACP_CLOCK_EN_TIME_OUT_VALUE 0x000000FF
  66. #define ACP_SOFT_RESET_DONE_TIME_OUT_VALUE 0x000000FF
  67. #define ACP_TIMEOUT_LOOP 0x000000FF
  68. #define ACP_DEVS 3
  69. #define ACP_SRC_ID 162
  70. enum {
  71. ACP_TILE_P1 = 0,
  72. ACP_TILE_P2,
  73. ACP_TILE_DSP0,
  74. ACP_TILE_DSP1,
  75. ACP_TILE_DSP2,
  76. };
  77. static int acp_sw_init(void *handle)
  78. {
  79. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  80. adev->acp.parent = adev->dev;
  81. adev->acp.cgs_device =
  82. amdgpu_cgs_create_device(adev);
  83. if (!adev->acp.cgs_device)
  84. return -EINVAL;
  85. return 0;
  86. }
  87. static int acp_sw_fini(void *handle)
  88. {
  89. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  90. if (adev->acp.cgs_device)
  91. amdgpu_cgs_destroy_device(adev->acp.cgs_device);
  92. return 0;
  93. }
  94. /* power off a tile/block within ACP */
  95. static int acp_suspend_tile(void *cgs_dev, int tile)
  96. {
  97. u32 val = 0;
  98. u32 count = 0;
  99. if ((tile < ACP_TILE_P1) || (tile > ACP_TILE_DSP2)) {
  100. pr_err("Invalid ACP tile : %d to suspend\n", tile);
  101. return -1;
  102. }
  103. val = cgs_read_register(cgs_dev, mmACP_PGFSM_READ_REG_0 + tile);
  104. val &= ACP_TILE_ON_MASK;
  105. if (val == 0x0) {
  106. val = cgs_read_register(cgs_dev, mmACP_PGFSM_RETAIN_REG);
  107. val = val | (1 << tile);
  108. cgs_write_register(cgs_dev, mmACP_PGFSM_RETAIN_REG, val);
  109. cgs_write_register(cgs_dev, mmACP_PGFSM_CONFIG_REG,
  110. 0x500 + tile);
  111. count = ACP_TIMEOUT_LOOP;
  112. while (true) {
  113. val = cgs_read_register(cgs_dev, mmACP_PGFSM_READ_REG_0
  114. + tile);
  115. val = val & ACP_TILE_ON_MASK;
  116. if (val == ACP_TILE_OFF_MASK)
  117. break;
  118. if (--count == 0) {
  119. pr_err("Timeout reading ACP PGFSM status\n");
  120. return -ETIMEDOUT;
  121. }
  122. udelay(100);
  123. }
  124. val = cgs_read_register(cgs_dev, mmACP_PGFSM_RETAIN_REG);
  125. val |= ACP_TILE_OFF_RETAIN_REG_MASK;
  126. cgs_write_register(cgs_dev, mmACP_PGFSM_RETAIN_REG, val);
  127. }
  128. return 0;
  129. }
  130. /* power on a tile/block within ACP */
  131. static int acp_resume_tile(void *cgs_dev, int tile)
  132. {
  133. u32 val = 0;
  134. u32 count = 0;
  135. if ((tile < ACP_TILE_P1) || (tile > ACP_TILE_DSP2)) {
  136. pr_err("Invalid ACP tile to resume\n");
  137. return -1;
  138. }
  139. val = cgs_read_register(cgs_dev, mmACP_PGFSM_READ_REG_0 + tile);
  140. val = val & ACP_TILE_ON_MASK;
  141. if (val != 0x0) {
  142. cgs_write_register(cgs_dev, mmACP_PGFSM_CONFIG_REG,
  143. 0x600 + tile);
  144. count = ACP_TIMEOUT_LOOP;
  145. while (true) {
  146. val = cgs_read_register(cgs_dev, mmACP_PGFSM_READ_REG_0
  147. + tile);
  148. val = val & ACP_TILE_ON_MASK;
  149. if (val == 0x0)
  150. break;
  151. if (--count == 0) {
  152. pr_err("Timeout reading ACP PGFSM status\n");
  153. return -ETIMEDOUT;
  154. }
  155. udelay(100);
  156. }
  157. val = cgs_read_register(cgs_dev, mmACP_PGFSM_RETAIN_REG);
  158. if (tile == ACP_TILE_P1)
  159. val = val & (ACP_TILE_P1_MASK);
  160. else if (tile == ACP_TILE_P2)
  161. val = val & (ACP_TILE_P2_MASK);
  162. cgs_write_register(cgs_dev, mmACP_PGFSM_RETAIN_REG, val);
  163. }
  164. return 0;
  165. }
  166. struct acp_pm_domain {
  167. void *cgs_dev;
  168. struct generic_pm_domain gpd;
  169. };
  170. static int acp_poweroff(struct generic_pm_domain *genpd)
  171. {
  172. int i, ret;
  173. struct acp_pm_domain *apd;
  174. apd = container_of(genpd, struct acp_pm_domain, gpd);
  175. if (apd != NULL) {
  176. /* Donot return abruptly if any of power tile fails to suspend.
  177. * Log it and continue powering off other tile
  178. */
  179. for (i = 4; i >= 0 ; i--) {
  180. ret = acp_suspend_tile(apd->cgs_dev, ACP_TILE_P1 + i);
  181. if (ret)
  182. pr_err("ACP tile %d tile suspend failed\n", i);
  183. }
  184. }
  185. return 0;
  186. }
  187. static int acp_poweron(struct generic_pm_domain *genpd)
  188. {
  189. int i, ret;
  190. struct acp_pm_domain *apd;
  191. apd = container_of(genpd, struct acp_pm_domain, gpd);
  192. if (apd != NULL) {
  193. for (i = 0; i < 2; i++) {
  194. ret = acp_resume_tile(apd->cgs_dev, ACP_TILE_P1 + i);
  195. if (ret) {
  196. pr_err("ACP tile %d resume failed\n", i);
  197. break;
  198. }
  199. }
  200. /* Disable DSPs which are not going to be used */
  201. for (i = 0; i < 3; i++) {
  202. ret = acp_suspend_tile(apd->cgs_dev, ACP_TILE_DSP0 + i);
  203. /* Continue suspending other DSP, even if one fails */
  204. if (ret)
  205. pr_err("ACP DSP %d suspend failed\n", i);
  206. }
  207. }
  208. return 0;
  209. }
  210. static struct device *get_mfd_cell_dev(const char *device_name, int r)
  211. {
  212. char auto_dev_name[25];
  213. struct device *dev;
  214. snprintf(auto_dev_name, sizeof(auto_dev_name),
  215. "%s.%d.auto", device_name, r);
  216. dev = bus_find_device_by_name(&platform_bus_type, NULL, auto_dev_name);
  217. dev_info(dev, "device %s added to pm domain\n", auto_dev_name);
  218. return dev;
  219. }
  220. /**
  221. * acp_hw_init - start and test ACP block
  222. *
  223. * @adev: amdgpu_device pointer
  224. *
  225. */
  226. static int acp_hw_init(void *handle)
  227. {
  228. int r, i;
  229. uint64_t acp_base;
  230. u32 val = 0;
  231. u32 count = 0;
  232. struct device *dev;
  233. struct i2s_platform_data *i2s_pdata;
  234. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  235. const struct amdgpu_ip_block *ip_block =
  236. amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_ACP);
  237. if (!ip_block)
  238. return -EINVAL;
  239. r = amd_acp_hw_init(adev->acp.cgs_device,
  240. ip_block->version->major, ip_block->version->minor);
  241. /* -ENODEV means board uses AZ rather than ACP */
  242. if (r == -ENODEV)
  243. return 0;
  244. else if (r)
  245. return r;
  246. r = cgs_get_pci_resource(adev->acp.cgs_device, CGS_RESOURCE_TYPE_MMIO,
  247. 0x5289, 0, &acp_base);
  248. if (r == -ENODEV)
  249. return 0;
  250. else if (r)
  251. return r;
  252. if (adev->asic_type != CHIP_STONEY) {
  253. adev->acp.acp_genpd = kzalloc(sizeof(struct acp_pm_domain), GFP_KERNEL);
  254. if (adev->acp.acp_genpd == NULL)
  255. return -ENOMEM;
  256. adev->acp.acp_genpd->gpd.name = "ACP_AUDIO";
  257. adev->acp.acp_genpd->gpd.power_off = acp_poweroff;
  258. adev->acp.acp_genpd->gpd.power_on = acp_poweron;
  259. adev->acp.acp_genpd->cgs_dev = adev->acp.cgs_device;
  260. pm_genpd_init(&adev->acp.acp_genpd->gpd, NULL, false);
  261. }
  262. adev->acp.acp_cell = kzalloc(sizeof(struct mfd_cell) * ACP_DEVS,
  263. GFP_KERNEL);
  264. if (adev->acp.acp_cell == NULL)
  265. return -ENOMEM;
  266. adev->acp.acp_res = kzalloc(sizeof(struct resource) * 4, GFP_KERNEL);
  267. if (adev->acp.acp_res == NULL) {
  268. kfree(adev->acp.acp_cell);
  269. return -ENOMEM;
  270. }
  271. i2s_pdata = kzalloc(sizeof(struct i2s_platform_data) * 2, GFP_KERNEL);
  272. if (i2s_pdata == NULL) {
  273. kfree(adev->acp.acp_res);
  274. kfree(adev->acp.acp_cell);
  275. return -ENOMEM;
  276. }
  277. switch (adev->asic_type) {
  278. case CHIP_STONEY:
  279. i2s_pdata[0].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET |
  280. DW_I2S_QUIRK_16BIT_IDX_OVERRIDE;
  281. break;
  282. default:
  283. i2s_pdata[0].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET;
  284. }
  285. i2s_pdata[0].cap = DWC_I2S_PLAY;
  286. i2s_pdata[0].snd_rates = SNDRV_PCM_RATE_8000_96000;
  287. i2s_pdata[0].i2s_reg_comp1 = ACP_I2S_COMP1_PLAY_REG_OFFSET;
  288. i2s_pdata[0].i2s_reg_comp2 = ACP_I2S_COMP2_PLAY_REG_OFFSET;
  289. switch (adev->asic_type) {
  290. case CHIP_STONEY:
  291. i2s_pdata[1].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET |
  292. DW_I2S_QUIRK_COMP_PARAM1 |
  293. DW_I2S_QUIRK_16BIT_IDX_OVERRIDE;
  294. break;
  295. default:
  296. i2s_pdata[1].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET |
  297. DW_I2S_QUIRK_COMP_PARAM1;
  298. }
  299. i2s_pdata[1].cap = DWC_I2S_RECORD;
  300. i2s_pdata[1].snd_rates = SNDRV_PCM_RATE_8000_96000;
  301. i2s_pdata[1].i2s_reg_comp1 = ACP_I2S_COMP1_CAP_REG_OFFSET;
  302. i2s_pdata[1].i2s_reg_comp2 = ACP_I2S_COMP2_CAP_REG_OFFSET;
  303. adev->acp.acp_res[0].name = "acp2x_dma";
  304. adev->acp.acp_res[0].flags = IORESOURCE_MEM;
  305. adev->acp.acp_res[0].start = acp_base;
  306. adev->acp.acp_res[0].end = acp_base + ACP_DMA_REGS_END;
  307. adev->acp.acp_res[1].name = "acp2x_dw_i2s_play";
  308. adev->acp.acp_res[1].flags = IORESOURCE_MEM;
  309. adev->acp.acp_res[1].start = acp_base + ACP_I2S_PLAY_REGS_START;
  310. adev->acp.acp_res[1].end = acp_base + ACP_I2S_PLAY_REGS_END;
  311. adev->acp.acp_res[2].name = "acp2x_dw_i2s_cap";
  312. adev->acp.acp_res[2].flags = IORESOURCE_MEM;
  313. adev->acp.acp_res[2].start = acp_base + ACP_I2S_CAP_REGS_START;
  314. adev->acp.acp_res[2].end = acp_base + ACP_I2S_CAP_REGS_END;
  315. adev->acp.acp_res[3].name = "acp2x_dma_irq";
  316. adev->acp.acp_res[3].flags = IORESOURCE_IRQ;
  317. adev->acp.acp_res[3].start = amdgpu_irq_create_mapping(adev, 162);
  318. adev->acp.acp_res[3].end = adev->acp.acp_res[3].start;
  319. adev->acp.acp_cell[0].name = "acp_audio_dma";
  320. adev->acp.acp_cell[0].num_resources = 4;
  321. adev->acp.acp_cell[0].resources = &adev->acp.acp_res[0];
  322. adev->acp.acp_cell[0].platform_data = &adev->asic_type;
  323. adev->acp.acp_cell[0].pdata_size = sizeof(adev->asic_type);
  324. adev->acp.acp_cell[1].name = "designware-i2s";
  325. adev->acp.acp_cell[1].num_resources = 1;
  326. adev->acp.acp_cell[1].resources = &adev->acp.acp_res[1];
  327. adev->acp.acp_cell[1].platform_data = &i2s_pdata[0];
  328. adev->acp.acp_cell[1].pdata_size = sizeof(struct i2s_platform_data);
  329. adev->acp.acp_cell[2].name = "designware-i2s";
  330. adev->acp.acp_cell[2].num_resources = 1;
  331. adev->acp.acp_cell[2].resources = &adev->acp.acp_res[2];
  332. adev->acp.acp_cell[2].platform_data = &i2s_pdata[1];
  333. adev->acp.acp_cell[2].pdata_size = sizeof(struct i2s_platform_data);
  334. r = mfd_add_hotplug_devices(adev->acp.parent, adev->acp.acp_cell,
  335. ACP_DEVS);
  336. if (r)
  337. return r;
  338. if (adev->asic_type != CHIP_STONEY) {
  339. for (i = 0; i < ACP_DEVS ; i++) {
  340. dev = get_mfd_cell_dev(adev->acp.acp_cell[i].name, i);
  341. r = pm_genpd_add_device(&adev->acp.acp_genpd->gpd, dev);
  342. if (r) {
  343. dev_err(dev, "Failed to add dev to genpd\n");
  344. return r;
  345. }
  346. }
  347. }
  348. /* Assert Soft reset of ACP */
  349. val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET);
  350. val |= ACP_SOFT_RESET__SoftResetAud_MASK;
  351. cgs_write_register(adev->acp.cgs_device, mmACP_SOFT_RESET, val);
  352. count = ACP_SOFT_RESET_DONE_TIME_OUT_VALUE;
  353. while (true) {
  354. val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET);
  355. if (ACP_SOFT_RESET__SoftResetAudDone_MASK ==
  356. (val & ACP_SOFT_RESET__SoftResetAudDone_MASK))
  357. break;
  358. if (--count == 0) {
  359. dev_err(&adev->pdev->dev, "Failed to reset ACP\n");
  360. return -ETIMEDOUT;
  361. }
  362. udelay(100);
  363. }
  364. /* Enable clock to ACP and wait until the clock is enabled */
  365. val = cgs_read_register(adev->acp.cgs_device, mmACP_CONTROL);
  366. val = val | ACP_CONTROL__ClkEn_MASK;
  367. cgs_write_register(adev->acp.cgs_device, mmACP_CONTROL, val);
  368. count = ACP_CLOCK_EN_TIME_OUT_VALUE;
  369. while (true) {
  370. val = cgs_read_register(adev->acp.cgs_device, mmACP_STATUS);
  371. if (val & (u32) 0x1)
  372. break;
  373. if (--count == 0) {
  374. dev_err(&adev->pdev->dev, "Failed to reset ACP\n");
  375. return -ETIMEDOUT;
  376. }
  377. udelay(100);
  378. }
  379. /* Deassert the SOFT RESET flags */
  380. val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET);
  381. val &= ~ACP_SOFT_RESET__SoftResetAud_MASK;
  382. cgs_write_register(adev->acp.cgs_device, mmACP_SOFT_RESET, val);
  383. return 0;
  384. }
  385. /**
  386. * acp_hw_fini - stop the hardware block
  387. *
  388. * @adev: amdgpu_device pointer
  389. *
  390. */
  391. static int acp_hw_fini(void *handle)
  392. {
  393. int i, ret;
  394. u32 val = 0;
  395. u32 count = 0;
  396. struct device *dev;
  397. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  398. /* return early if no ACP */
  399. if (!adev->acp.acp_cell)
  400. return 0;
  401. /* Assert Soft reset of ACP */
  402. val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET);
  403. val |= ACP_SOFT_RESET__SoftResetAud_MASK;
  404. cgs_write_register(adev->acp.cgs_device, mmACP_SOFT_RESET, val);
  405. count = ACP_SOFT_RESET_DONE_TIME_OUT_VALUE;
  406. while (true) {
  407. val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET);
  408. if (ACP_SOFT_RESET__SoftResetAudDone_MASK ==
  409. (val & ACP_SOFT_RESET__SoftResetAudDone_MASK))
  410. break;
  411. if (--count == 0) {
  412. dev_err(&adev->pdev->dev, "Failed to reset ACP\n");
  413. return -ETIMEDOUT;
  414. }
  415. udelay(100);
  416. }
  417. /* Disable ACP clock */
  418. val = cgs_read_register(adev->acp.cgs_device, mmACP_CONTROL);
  419. val &= ~ACP_CONTROL__ClkEn_MASK;
  420. cgs_write_register(adev->acp.cgs_device, mmACP_CONTROL, val);
  421. count = ACP_CLOCK_EN_TIME_OUT_VALUE;
  422. while (true) {
  423. val = cgs_read_register(adev->acp.cgs_device, mmACP_STATUS);
  424. if (val & (u32) 0x1)
  425. break;
  426. if (--count == 0) {
  427. dev_err(&adev->pdev->dev, "Failed to reset ACP\n");
  428. return -ETIMEDOUT;
  429. }
  430. udelay(100);
  431. }
  432. if (adev->acp.acp_genpd) {
  433. for (i = 0; i < ACP_DEVS ; i++) {
  434. dev = get_mfd_cell_dev(adev->acp.acp_cell[i].name, i);
  435. ret = pm_genpd_remove_device(&adev->acp.acp_genpd->gpd, dev);
  436. /* If removal fails, dont giveup and try rest */
  437. if (ret)
  438. dev_err(dev, "remove dev from genpd failed\n");
  439. }
  440. kfree(adev->acp.acp_genpd);
  441. }
  442. mfd_remove_devices(adev->acp.parent);
  443. kfree(adev->acp.acp_res);
  444. kfree(adev->acp.acp_cell);
  445. return 0;
  446. }
  447. static int acp_suspend(void *handle)
  448. {
  449. return 0;
  450. }
  451. static int acp_resume(void *handle)
  452. {
  453. return 0;
  454. }
  455. static int acp_early_init(void *handle)
  456. {
  457. return 0;
  458. }
  459. static bool acp_is_idle(void *handle)
  460. {
  461. return true;
  462. }
  463. static int acp_wait_for_idle(void *handle)
  464. {
  465. return 0;
  466. }
  467. static int acp_soft_reset(void *handle)
  468. {
  469. return 0;
  470. }
  471. static int acp_set_clockgating_state(void *handle,
  472. enum amd_clockgating_state state)
  473. {
  474. return 0;
  475. }
  476. static int acp_set_powergating_state(void *handle,
  477. enum amd_powergating_state state)
  478. {
  479. return 0;
  480. }
  481. static const struct amd_ip_funcs acp_ip_funcs = {
  482. .name = "acp_ip",
  483. .early_init = acp_early_init,
  484. .late_init = NULL,
  485. .sw_init = acp_sw_init,
  486. .sw_fini = acp_sw_fini,
  487. .hw_init = acp_hw_init,
  488. .hw_fini = acp_hw_fini,
  489. .suspend = acp_suspend,
  490. .resume = acp_resume,
  491. .is_idle = acp_is_idle,
  492. .wait_for_idle = acp_wait_for_idle,
  493. .soft_reset = acp_soft_reset,
  494. .set_clockgating_state = acp_set_clockgating_state,
  495. .set_powergating_state = acp_set_powergating_state,
  496. };
  497. const struct amdgpu_ip_block_version acp_ip_block =
  498. {
  499. .type = AMD_IP_BLOCK_TYPE_ACP,
  500. .major = 2,
  501. .minor = 2,
  502. .rev = 0,
  503. .funcs = &acp_ip_funcs,
  504. };