qcom_q6v5_adsp.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Qualcomm Technology Inc. ADSP Peripheral Image Loader for SDM845.
  4. * Copyright (c) 2018, The Linux Foundation. All rights reserved.
  5. */
  6. #include <linux/clk.h>
  7. #include <linux/delay.h>
  8. #include <linux/firmware.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/io.h>
  11. #include <linux/iopoll.h>
  12. #include <linux/kernel.h>
  13. #include <linux/mfd/syscon.h>
  14. #include <linux/module.h>
  15. #include <linux/of_address.h>
  16. #include <linux/of_device.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/pm_domain.h>
  19. #include <linux/pm_runtime.h>
  20. #include <linux/regmap.h>
  21. #include <linux/remoteproc.h>
  22. #include <linux/reset.h>
  23. #include <linux/soc/qcom/mdt_loader.h>
  24. #include <linux/soc/qcom/smem.h>
  25. #include <linux/soc/qcom/smem_state.h>
  26. #include "qcom_common.h"
  27. #include "qcom_pil_info.h"
  28. #include "qcom_q6v5.h"
  29. #include "remoteproc_internal.h"
  30. /* time out value */
  31. #define ACK_TIMEOUT 1000
  32. #define BOOT_FSM_TIMEOUT 10000
  33. /* mask values */
  34. #define EVB_MASK GENMASK(27, 4)
  35. /*QDSP6SS register offsets*/
  36. #define RST_EVB_REG 0x10
  37. #define CORE_START_REG 0x400
  38. #define BOOT_CMD_REG 0x404
  39. #define BOOT_STATUS_REG 0x408
  40. #define RET_CFG_REG 0x1C
  41. /*TCSR register offsets*/
  42. #define LPASS_MASTER_IDLE_REG 0x8
  43. #define LPASS_HALTACK_REG 0x4
  44. #define LPASS_PWR_ON_REG 0x10
  45. #define LPASS_HALTREQ_REG 0x0
  46. #define QDSP6SS_XO_CBCR 0x38
  47. #define QDSP6SS_CORE_CBCR 0x20
  48. #define QDSP6SS_SLEEP_CBCR 0x3c
  49. struct adsp_pil_data {
  50. int crash_reason_smem;
  51. const char *firmware_name;
  52. const char *ssr_name;
  53. const char *sysmon_name;
  54. int ssctl_id;
  55. const char **clk_ids;
  56. int num_clks;
  57. };
  58. struct qcom_adsp {
  59. struct device *dev;
  60. struct rproc *rproc;
  61. struct qcom_q6v5 q6v5;
  62. struct clk *xo;
  63. int num_clks;
  64. struct clk_bulk_data *clks;
  65. void __iomem *qdsp6ss_base;
  66. struct reset_control *pdc_sync_reset;
  67. struct reset_control *restart;
  68. struct regmap *halt_map;
  69. unsigned int halt_lpass;
  70. int crash_reason_smem;
  71. const char *info_name;
  72. struct completion start_done;
  73. struct completion stop_done;
  74. phys_addr_t mem_phys;
  75. phys_addr_t mem_reloc;
  76. void *mem_region;
  77. size_t mem_size;
  78. struct qcom_rproc_glink glink_subdev;
  79. struct qcom_rproc_ssr ssr_subdev;
  80. struct qcom_sysmon *sysmon;
  81. };
  82. static int qcom_rproc_pds_attach(struct device *dev, struct qcom_adsp *adsp,
  83. const char **pd_names)
  84. {
  85. struct device **devs = adsp->proxy_pds;
  86. size_t num_pds = 0;
  87. int ret;
  88. int i;
  89. if (!pd_names)
  90. return 0;
  91. /* Handle single power domain */
  92. if (dev->pm_domain) {
  93. devs[0] = dev;
  94. pm_runtime_enable(dev);
  95. return 1;
  96. }
  97. while (pd_names[num_pds])
  98. num_pds++;
  99. if (num_pds > ARRAY_SIZE(adsp->proxy_pds))
  100. return -E2BIG;
  101. for (i = 0; i < num_pds; i++) {
  102. devs[i] = dev_pm_domain_attach_by_name(dev, pd_names[i]);
  103. if (IS_ERR_OR_NULL(devs[i])) {
  104. ret = PTR_ERR(devs[i]) ? : -ENODATA;
  105. goto unroll_attach;
  106. }
  107. }
  108. return num_pds;
  109. unroll_attach:
  110. for (i--; i >= 0; i--)
  111. dev_pm_domain_detach(devs[i], false);
  112. return ret;
  113. }
  114. static void qcom_rproc_pds_detach(struct qcom_adsp *adsp, struct device **pds,
  115. size_t pd_count)
  116. {
  117. struct device *dev = adsp->dev;
  118. int i;
  119. /* Handle single power domain */
  120. if (dev->pm_domain && pd_count) {
  121. pm_runtime_disable(dev);
  122. return;
  123. }
  124. for (i = 0; i < pd_count; i++)
  125. dev_pm_domain_detach(pds[i], false);
  126. }
  127. static int qcom_rproc_pds_enable(struct qcom_adsp *adsp, struct device **pds,
  128. size_t pd_count)
  129. {
  130. int ret;
  131. int i;
  132. for (i = 0; i < pd_count; i++) {
  133. dev_pm_genpd_set_performance_state(pds[i], INT_MAX);
  134. ret = pm_runtime_resume_and_get(pds[i]);
  135. if (ret < 0) {
  136. dev_pm_genpd_set_performance_state(pds[i], 0);
  137. goto unroll_pd_votes;
  138. }
  139. }
  140. return 0;
  141. unroll_pd_votes:
  142. for (i--; i >= 0; i--) {
  143. dev_pm_genpd_set_performance_state(pds[i], 0);
  144. pm_runtime_put(pds[i]);
  145. }
  146. return ret;
  147. }
  148. static void qcom_rproc_pds_disable(struct qcom_adsp *adsp, struct device **pds,
  149. size_t pd_count)
  150. {
  151. int i;
  152. for (i = 0; i < pd_count; i++) {
  153. dev_pm_genpd_set_performance_state(pds[i], 0);
  154. pm_runtime_put(pds[i]);
  155. }
  156. }
  157. static int qcom_wpss_shutdown(struct qcom_adsp *adsp)
  158. {
  159. unsigned int val;
  160. regmap_write(adsp->halt_map, adsp->halt_lpass + LPASS_HALTREQ_REG, 1);
  161. /* Wait for halt ACK from QDSP6 */
  162. regmap_read_poll_timeout(adsp->halt_map,
  163. adsp->halt_lpass + LPASS_HALTACK_REG, val,
  164. val, 1000, ACK_TIMEOUT_US);
  165. /* Assert the WPSS PDC Reset */
  166. reset_control_assert(adsp->pdc_sync_reset);
  167. /* Place the WPSS processor into reset */
  168. reset_control_assert(adsp->restart);
  169. /* wait after asserting subsystem restart from AOSS */
  170. usleep_range(200, 205);
  171. /* Remove the WPSS reset */
  172. reset_control_deassert(adsp->restart);
  173. /* De-assert the WPSS PDC Reset */
  174. reset_control_deassert(adsp->pdc_sync_reset);
  175. usleep_range(100, 105);
  176. clk_bulk_disable_unprepare(adsp->num_clks, adsp->clks);
  177. regmap_write(adsp->halt_map, adsp->halt_lpass + LPASS_HALTREQ_REG, 0);
  178. /* Wait for halt ACK from QDSP6 */
  179. regmap_read_poll_timeout(adsp->halt_map,
  180. adsp->halt_lpass + LPASS_HALTACK_REG, val,
  181. !val, 1000, ACK_TIMEOUT_US);
  182. return 0;
  183. }
  184. static int qcom_adsp_shutdown(struct qcom_adsp *adsp)
  185. {
  186. unsigned long timeout;
  187. unsigned int val;
  188. int ret;
  189. /* Reset the retention logic */
  190. val = readl(adsp->qdsp6ss_base + RET_CFG_REG);
  191. val |= 0x1;
  192. writel(val, adsp->qdsp6ss_base + RET_CFG_REG);
  193. clk_bulk_disable_unprepare(adsp->num_clks, adsp->clks);
  194. /* QDSP6 master port needs to be explicitly halted */
  195. ret = regmap_read(adsp->halt_map,
  196. adsp->halt_lpass + LPASS_PWR_ON_REG, &val);
  197. if (ret || !val)
  198. goto reset;
  199. ret = regmap_read(adsp->halt_map,
  200. adsp->halt_lpass + LPASS_MASTER_IDLE_REG,
  201. &val);
  202. if (ret || val)
  203. goto reset;
  204. regmap_write(adsp->halt_map,
  205. adsp->halt_lpass + LPASS_HALTREQ_REG, 1);
  206. /* Wait for halt ACK from QDSP6 */
  207. timeout = jiffies + msecs_to_jiffies(ACK_TIMEOUT);
  208. for (;;) {
  209. ret = regmap_read(adsp->halt_map,
  210. adsp->halt_lpass + LPASS_HALTACK_REG, &val);
  211. if (ret || val || time_after(jiffies, timeout))
  212. break;
  213. usleep_range(1000, 1100);
  214. }
  215. ret = regmap_read(adsp->halt_map,
  216. adsp->halt_lpass + LPASS_MASTER_IDLE_REG, &val);
  217. if (ret || !val)
  218. dev_err(adsp->dev, "port failed halt\n");
  219. reset:
  220. /* Assert the LPASS PDC Reset */
  221. reset_control_assert(adsp->pdc_sync_reset);
  222. /* Place the LPASS processor into reset */
  223. reset_control_assert(adsp->restart);
  224. /* wait after asserting subsystem restart from AOSS */
  225. usleep_range(200, 300);
  226. /* Clear the halt request for the AXIM and AHBM for Q6 */
  227. regmap_write(adsp->halt_map, adsp->halt_lpass + LPASS_HALTREQ_REG, 0);
  228. /* De-assert the LPASS PDC Reset */
  229. reset_control_deassert(adsp->pdc_sync_reset);
  230. /* Remove the LPASS reset */
  231. reset_control_deassert(adsp->restart);
  232. /* wait after de-asserting subsystem restart from AOSS */
  233. usleep_range(200, 300);
  234. return 0;
  235. }
  236. static int adsp_load(struct rproc *rproc, const struct firmware *fw)
  237. {
  238. struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
  239. int ret;
  240. ret = qcom_mdt_load_no_init(adsp->dev, fw, rproc->firmware, 0,
  241. adsp->mem_region, adsp->mem_phys,
  242. adsp->mem_size, &adsp->mem_reloc);
  243. if (ret)
  244. return ret;
  245. qcom_pil_info_store(adsp->info_name, adsp->mem_phys, adsp->mem_size);
  246. return 0;
  247. }
  248. static int adsp_start(struct rproc *rproc)
  249. {
  250. struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
  251. int ret;
  252. unsigned int val;
  253. qcom_q6v5_prepare(&adsp->q6v5);
  254. ret = clk_prepare_enable(adsp->xo);
  255. if (ret)
  256. goto disable_irqs;
  257. dev_pm_genpd_set_performance_state(adsp->dev, INT_MAX);
  258. ret = pm_runtime_get_sync(adsp->dev);
  259. if (ret) {
  260. pm_runtime_put_noidle(adsp->dev);
  261. goto disable_xo_clk;
  262. }
  263. ret = clk_bulk_prepare_enable(adsp->num_clks, adsp->clks);
  264. if (ret) {
  265. dev_err(adsp->dev, "adsp clk_enable failed\n");
  266. goto disable_power_domain;
  267. }
  268. /* Enable the XO clock */
  269. writel(1, adsp->qdsp6ss_base + QDSP6SS_XO_CBCR);
  270. /* Enable the QDSP6SS sleep clock */
  271. writel(1, adsp->qdsp6ss_base + QDSP6SS_SLEEP_CBCR);
  272. /* Enable the QDSP6 core clock */
  273. writel(1, adsp->qdsp6ss_base + QDSP6SS_CORE_CBCR);
  274. /* Program boot address */
  275. writel(adsp->mem_phys >> 4, adsp->qdsp6ss_base + RST_EVB_REG);
  276. /* De-assert QDSP6 stop core. QDSP6 will execute after out of reset */
  277. writel(0x1, adsp->qdsp6ss_base + CORE_START_REG);
  278. /* Trigger boot FSM to start QDSP6 */
  279. writel(0x1, adsp->qdsp6ss_base + BOOT_CMD_REG);
  280. /* Wait for core to come out of reset */
  281. ret = readl_poll_timeout(adsp->qdsp6ss_base + BOOT_STATUS_REG,
  282. val, (val & BIT(0)) != 0, 10, BOOT_FSM_TIMEOUT);
  283. if (ret) {
  284. dev_err(adsp->dev, "failed to bootup adsp\n");
  285. goto disable_adsp_clks;
  286. }
  287. ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5 * HZ));
  288. if (ret == -ETIMEDOUT) {
  289. dev_err(adsp->dev, "start timed out\n");
  290. goto disable_adsp_clks;
  291. }
  292. return 0;
  293. disable_adsp_clks:
  294. clk_bulk_disable_unprepare(adsp->num_clks, adsp->clks);
  295. disable_power_domain:
  296. dev_pm_genpd_set_performance_state(adsp->dev, 0);
  297. pm_runtime_put(adsp->dev);
  298. disable_xo_clk:
  299. clk_disable_unprepare(adsp->xo);
  300. disable_irqs:
  301. qcom_q6v5_unprepare(&adsp->q6v5);
  302. return ret;
  303. }
  304. static void qcom_adsp_pil_handover(struct qcom_q6v5 *q6v5)
  305. {
  306. struct qcom_adsp *adsp = container_of(q6v5, struct qcom_adsp, q6v5);
  307. clk_disable_unprepare(adsp->xo);
  308. dev_pm_genpd_set_performance_state(adsp->dev, 0);
  309. pm_runtime_put(adsp->dev);
  310. }
  311. static int adsp_stop(struct rproc *rproc)
  312. {
  313. struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
  314. int handover;
  315. int ret;
  316. ret = qcom_q6v5_request_stop(&adsp->q6v5, adsp->sysmon);
  317. if (ret == -ETIMEDOUT)
  318. dev_err(adsp->dev, "timed out on wait\n");
  319. ret = qcom_adsp_shutdown(adsp);
  320. if (ret)
  321. dev_err(adsp->dev, "failed to shutdown: %d\n", ret);
  322. handover = qcom_q6v5_unprepare(&adsp->q6v5);
  323. if (handover)
  324. qcom_adsp_pil_handover(&adsp->q6v5);
  325. return ret;
  326. }
  327. static void *adsp_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
  328. {
  329. struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
  330. int offset;
  331. offset = da - adsp->mem_reloc;
  332. if (offset < 0 || offset + len > adsp->mem_size)
  333. return NULL;
  334. return adsp->mem_region + offset;
  335. }
  336. static unsigned long adsp_panic(struct rproc *rproc)
  337. {
  338. struct qcom_adsp *adsp = rproc->priv;
  339. return qcom_q6v5_panic(&adsp->q6v5);
  340. }
  341. static const struct rproc_ops adsp_ops = {
  342. .start = adsp_start,
  343. .stop = adsp_stop,
  344. .da_to_va = adsp_da_to_va,
  345. .parse_fw = qcom_register_dump_segments,
  346. .load = adsp_load,
  347. .panic = adsp_panic,
  348. };
  349. static int adsp_init_clock(struct qcom_adsp *adsp, const char **clk_ids)
  350. {
  351. int num_clks = 0;
  352. int i, ret;
  353. adsp->xo = devm_clk_get(adsp->dev, "xo");
  354. if (IS_ERR(adsp->xo)) {
  355. ret = PTR_ERR(adsp->xo);
  356. if (ret != -EPROBE_DEFER)
  357. dev_err(adsp->dev, "failed to get xo clock");
  358. return ret;
  359. }
  360. for (i = 0; clk_ids[i]; i++)
  361. num_clks++;
  362. adsp->num_clks = num_clks;
  363. adsp->clks = devm_kcalloc(adsp->dev, adsp->num_clks,
  364. sizeof(*adsp->clks), GFP_KERNEL);
  365. if (!adsp->clks)
  366. return -ENOMEM;
  367. for (i = 0; i < adsp->num_clks; i++)
  368. adsp->clks[i].id = clk_ids[i];
  369. return devm_clk_bulk_get(adsp->dev, adsp->num_clks, adsp->clks);
  370. }
  371. static int adsp_init_reset(struct qcom_adsp *adsp)
  372. {
  373. adsp->pdc_sync_reset = devm_reset_control_get_optional_exclusive(adsp->dev,
  374. "pdc_sync");
  375. if (IS_ERR(adsp->pdc_sync_reset)) {
  376. dev_err(adsp->dev, "failed to acquire pdc_sync reset\n");
  377. return PTR_ERR(adsp->pdc_sync_reset);
  378. }
  379. adsp->restart = devm_reset_control_get_optional_exclusive(adsp->dev, "restart");
  380. /* Fall back to the old "cc_lpass" if "restart" is absent */
  381. if (!adsp->restart)
  382. adsp->restart = devm_reset_control_get_exclusive(adsp->dev, "cc_lpass");
  383. if (IS_ERR(adsp->restart)) {
  384. dev_err(adsp->dev, "failed to acquire restart\n");
  385. return PTR_ERR(adsp->restart);
  386. }
  387. return 0;
  388. }
  389. static int adsp_init_mmio(struct qcom_adsp *adsp,
  390. struct platform_device *pdev)
  391. {
  392. struct device_node *syscon;
  393. int ret;
  394. adsp->qdsp6ss_base = devm_platform_ioremap_resource(pdev, 0);
  395. if (IS_ERR(adsp->qdsp6ss_base)) {
  396. dev_err(adsp->dev, "failed to map QDSP6SS registers\n");
  397. return PTR_ERR(adsp->qdsp6ss_base);
  398. }
  399. syscon = of_parse_phandle(pdev->dev.of_node, "qcom,halt-regs", 0);
  400. if (!syscon) {
  401. dev_err(&pdev->dev, "failed to parse qcom,halt-regs\n");
  402. return -EINVAL;
  403. }
  404. adsp->halt_map = syscon_node_to_regmap(syscon);
  405. of_node_put(syscon);
  406. if (IS_ERR(adsp->halt_map))
  407. return PTR_ERR(adsp->halt_map);
  408. ret = of_property_read_u32_index(pdev->dev.of_node, "qcom,halt-regs",
  409. 1, &adsp->halt_lpass);
  410. if (ret < 0) {
  411. dev_err(&pdev->dev, "no offset in syscon\n");
  412. return ret;
  413. }
  414. return 0;
  415. }
  416. static int adsp_alloc_memory_region(struct qcom_adsp *adsp)
  417. {
  418. struct device_node *node;
  419. struct resource r;
  420. int ret;
  421. node = of_parse_phandle(adsp->dev->of_node, "memory-region", 0);
  422. if (!node) {
  423. dev_err(adsp->dev, "no memory-region specified\n");
  424. return -EINVAL;
  425. }
  426. ret = of_address_to_resource(node, 0, &r);
  427. of_node_put(node);
  428. if (ret)
  429. return ret;
  430. adsp->mem_phys = adsp->mem_reloc = r.start;
  431. adsp->mem_size = resource_size(&r);
  432. adsp->mem_region = devm_ioremap_wc(adsp->dev,
  433. adsp->mem_phys, adsp->mem_size);
  434. if (!adsp->mem_region) {
  435. dev_err(adsp->dev, "unable to map memory region: %pa+%zx\n",
  436. &r.start, adsp->mem_size);
  437. return -EBUSY;
  438. }
  439. return 0;
  440. }
  441. static int adsp_probe(struct platform_device *pdev)
  442. {
  443. const struct adsp_pil_data *desc;
  444. struct qcom_adsp *adsp;
  445. struct rproc *rproc;
  446. int ret;
  447. desc = of_device_get_match_data(&pdev->dev);
  448. if (!desc)
  449. return -EINVAL;
  450. rproc = rproc_alloc(&pdev->dev, pdev->name, &adsp_ops,
  451. desc->firmware_name, sizeof(*adsp));
  452. if (!rproc) {
  453. dev_err(&pdev->dev, "unable to allocate remoteproc\n");
  454. return -ENOMEM;
  455. }
  456. rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_NONE);
  457. adsp = (struct qcom_adsp *)rproc->priv;
  458. adsp->dev = &pdev->dev;
  459. adsp->rproc = rproc;
  460. adsp->info_name = desc->sysmon_name;
  461. platform_set_drvdata(pdev, adsp);
  462. ret = adsp_alloc_memory_region(adsp);
  463. if (ret)
  464. goto free_rproc;
  465. ret = adsp_init_clock(adsp, desc->clk_ids);
  466. if (ret)
  467. goto free_rproc;
  468. pm_runtime_enable(adsp->dev);
  469. ret = adsp_init_reset(adsp);
  470. if (ret)
  471. goto disable_pm;
  472. ret = adsp_init_mmio(adsp, pdev);
  473. if (ret)
  474. goto disable_pm;
  475. ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem,
  476. qcom_adsp_pil_handover);
  477. if (ret)
  478. goto disable_pm;
  479. qcom_add_glink_subdev(rproc, &adsp->glink_subdev, desc->ssr_name);
  480. qcom_add_ssr_subdev(rproc, &adsp->ssr_subdev, desc->ssr_name);
  481. adsp->sysmon = qcom_add_sysmon_subdev(rproc,
  482. desc->sysmon_name,
  483. desc->ssctl_id);
  484. if (IS_ERR(adsp->sysmon)) {
  485. ret = PTR_ERR(adsp->sysmon);
  486. goto disable_pm;
  487. }
  488. ret = rproc_add(rproc);
  489. if (ret)
  490. goto disable_pm;
  491. return 0;
  492. disable_pm:
  493. pm_runtime_disable(adsp->dev);
  494. free_rproc:
  495. rproc_free(rproc);
  496. return ret;
  497. }
  498. static int adsp_remove(struct platform_device *pdev)
  499. {
  500. struct qcom_adsp *adsp = platform_get_drvdata(pdev);
  501. rproc_del(adsp->rproc);
  502. qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev);
  503. qcom_remove_sysmon_subdev(adsp->sysmon);
  504. qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev);
  505. pm_runtime_disable(adsp->dev);
  506. rproc_free(adsp->rproc);
  507. return 0;
  508. }
  509. static const struct adsp_pil_data adsp_resource_init = {
  510. .crash_reason_smem = 423,
  511. .firmware_name = "adsp.mdt",
  512. .ssr_name = "lpass",
  513. .sysmon_name = "adsp",
  514. .ssctl_id = 0x14,
  515. .clk_ids = (const char*[]) {
  516. "sway_cbcr", "lpass_ahbs_aon_cbcr", "lpass_ahbm_aon_cbcr",
  517. "qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core", NULL
  518. },
  519. .num_clks = 7,
  520. };
  521. static const struct adsp_pil_data cdsp_resource_init = {
  522. .crash_reason_smem = 601,
  523. .firmware_name = "cdsp.mdt",
  524. .ssr_name = "cdsp",
  525. .sysmon_name = "cdsp",
  526. .ssctl_id = 0x17,
  527. .clk_ids = (const char*[]) {
  528. "sway", "tbu", "bimc", "ahb_aon", "q6ss_slave", "q6ss_master",
  529. "q6_axim", NULL
  530. },
  531. .num_clks = 7,
  532. };
  533. static const struct of_device_id adsp_of_match[] = {
  534. { .compatible = "qcom,qcs404-cdsp-pil", .data = &cdsp_resource_init },
  535. { .compatible = "qcom,sdm845-adsp-pil", .data = &adsp_resource_init },
  536. { },
  537. };
  538. MODULE_DEVICE_TABLE(of, adsp_of_match);
  539. static struct platform_driver adsp_pil_driver = {
  540. .probe = adsp_probe,
  541. .remove = adsp_remove,
  542. .driver = {
  543. .name = "qcom_q6v5_adsp",
  544. .of_match_table = adsp_of_match,
  545. },
  546. };
  547. module_platform_driver(adsp_pil_driver);
  548. MODULE_DESCRIPTION("QTI SDM845 ADSP Peripheral Image Loader");
  549. MODULE_LICENSE("GPL v2");