Lines Matching full:adsp

3  * Qualcomm Technology Inc. ADSP Peripheral Image Loader for SDM845.
110 int (*shutdown)(struct qcom_adsp *adsp);
113 static int qcom_rproc_pds_attach(struct device *dev, struct qcom_adsp *adsp, in qcom_rproc_pds_attach() argument
116 struct device **devs = adsp->proxy_pds; in qcom_rproc_pds_attach()
134 if (num_pds > ARRAY_SIZE(adsp->proxy_pds)) in qcom_rproc_pds_attach()
154 static void qcom_rproc_pds_detach(struct qcom_adsp *adsp, struct device **pds, in qcom_rproc_pds_detach() argument
157 struct device *dev = adsp->dev; in qcom_rproc_pds_detach()
170 static int qcom_rproc_pds_enable(struct qcom_adsp *adsp, struct device **pds, in qcom_rproc_pds_enable() argument
196 static void qcom_rproc_pds_disable(struct qcom_adsp *adsp, struct device **pds, in qcom_rproc_pds_disable() argument
207 static int qcom_wpss_shutdown(struct qcom_adsp *adsp) in qcom_wpss_shutdown() argument
211 regmap_write(adsp->halt_map, adsp->halt_lpass + LPASS_HALTREQ_REG, 1); in qcom_wpss_shutdown()
214 regmap_read_poll_timeout(adsp->halt_map, in qcom_wpss_shutdown()
215 adsp->halt_lpass + LPASS_HALTACK_REG, val, in qcom_wpss_shutdown()
219 reset_control_assert(adsp->pdc_sync_reset); in qcom_wpss_shutdown()
222 reset_control_assert(adsp->restart); in qcom_wpss_shutdown()
228 reset_control_deassert(adsp->restart); in qcom_wpss_shutdown()
231 reset_control_deassert(adsp->pdc_sync_reset); in qcom_wpss_shutdown()
235 clk_bulk_disable_unprepare(adsp->num_clks, adsp->clks); in qcom_wpss_shutdown()
237 regmap_write(adsp->halt_map, adsp->halt_lpass + LPASS_HALTREQ_REG, 0); in qcom_wpss_shutdown()
240 regmap_read_poll_timeout(adsp->halt_map, in qcom_wpss_shutdown()
241 adsp->halt_lpass + LPASS_HALTACK_REG, val, in qcom_wpss_shutdown()
247 static int qcom_adsp_shutdown(struct qcom_adsp *adsp) in qcom_adsp_shutdown() argument
254 val = readl(adsp->qdsp6ss_base + RET_CFG_REG); in qcom_adsp_shutdown()
256 writel(val, adsp->qdsp6ss_base + RET_CFG_REG); in qcom_adsp_shutdown()
258 clk_bulk_disable_unprepare(adsp->num_clks, adsp->clks); in qcom_adsp_shutdown()
261 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
262 adsp->halt_lpass + LPASS_PWR_ON_REG, &val); in qcom_adsp_shutdown()
266 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
267 adsp->halt_lpass + LPASS_MASTER_IDLE_REG, in qcom_adsp_shutdown()
272 regmap_write(adsp->halt_map, in qcom_adsp_shutdown()
273 adsp->halt_lpass + LPASS_HALTREQ_REG, 1); in qcom_adsp_shutdown()
278 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
279 adsp->halt_lpass + LPASS_HALTACK_REG, &val); in qcom_adsp_shutdown()
286 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
287 adsp->halt_lpass + LPASS_MASTER_IDLE_REG, &val); in qcom_adsp_shutdown()
289 dev_err(adsp->dev, "port failed halt\n"); in qcom_adsp_shutdown()
293 reset_control_assert(adsp->pdc_sync_reset); in qcom_adsp_shutdown()
295 reset_control_assert(adsp->restart); in qcom_adsp_shutdown()
300 regmap_write(adsp->halt_map, adsp->halt_lpass + LPASS_HALTREQ_REG, 0); in qcom_adsp_shutdown()
303 reset_control_deassert(adsp->pdc_sync_reset); in qcom_adsp_shutdown()
305 reset_control_deassert(adsp->restart); in qcom_adsp_shutdown()
314 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_load() local
317 ret = qcom_mdt_load_no_init(adsp->dev, fw, rproc->firmware, 0, in adsp_load()
318 adsp->mem_region, adsp->mem_phys, in adsp_load()
319 adsp->mem_size, &adsp->mem_reloc); in adsp_load()
323 qcom_pil_info_store(adsp->info_name, adsp->mem_phys, adsp->mem_size); in adsp_load()
330 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_start() local
334 ret = qcom_q6v5_prepare(&adsp->q6v5); in adsp_start()
338 ret = clk_prepare_enable(adsp->xo); in adsp_start()
342 ret = qcom_rproc_pds_enable(adsp, adsp->proxy_pds, in adsp_start()
343 adsp->proxy_pd_count); in adsp_start()
347 ret = clk_bulk_prepare_enable(adsp->num_clks, adsp->clks); in adsp_start()
349 dev_err(adsp->dev, "adsp clk_enable failed\n"); in adsp_start()
354 writel(1, adsp->qdsp6ss_base + QDSP6SS_XO_CBCR); in adsp_start()
357 writel(1, adsp->qdsp6ss_base + QDSP6SS_SLEEP_CBCR); in adsp_start()
360 writel(1, adsp->qdsp6ss_base + QDSP6SS_CORE_CBCR); in adsp_start()
363 writel(adsp->mem_phys >> 4, adsp->qdsp6ss_base + RST_EVB_REG); in adsp_start()
366 writel(0x1, adsp->qdsp6ss_base + CORE_START_REG); in adsp_start()
369 writel(0x1, adsp->qdsp6ss_base + BOOT_CMD_REG); in adsp_start()
372 ret = readl_poll_timeout(adsp->qdsp6ss_base + BOOT_STATUS_REG, in adsp_start()
375 dev_err(adsp->dev, "failed to bootup adsp\n"); in adsp_start()
379 ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5 * HZ)); in adsp_start()
381 dev_err(adsp->dev, "start timed out\n"); in adsp_start()
388 clk_bulk_disable_unprepare(adsp->num_clks, adsp->clks); in adsp_start()
390 qcom_rproc_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_start()
392 clk_disable_unprepare(adsp->xo); in adsp_start()
394 qcom_q6v5_unprepare(&adsp->q6v5); in adsp_start()
401 struct qcom_adsp *adsp = container_of(q6v5, struct qcom_adsp, q6v5); in qcom_adsp_pil_handover() local
403 clk_disable_unprepare(adsp->xo); in qcom_adsp_pil_handover()
404 qcom_rproc_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in qcom_adsp_pil_handover()
409 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_stop() local
413 ret = qcom_q6v5_request_stop(&adsp->q6v5, adsp->sysmon); in adsp_stop()
415 dev_err(adsp->dev, "timed out on wait\n"); in adsp_stop()
417 ret = adsp->shutdown(adsp); in adsp_stop()
419 dev_err(adsp->dev, "failed to shutdown: %d\n", ret); in adsp_stop()
421 handover = qcom_q6v5_unprepare(&adsp->q6v5); in adsp_stop()
423 qcom_adsp_pil_handover(&adsp->q6v5); in adsp_stop()
430 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_da_to_va() local
433 offset = da - adsp->mem_reloc; in adsp_da_to_va()
434 if (offset < 0 || offset + len > adsp->mem_size) in adsp_da_to_va()
437 return adsp->mem_region + offset; in adsp_da_to_va()
442 struct qcom_adsp *adsp = rproc->priv; in adsp_panic() local
444 return qcom_q6v5_panic(&adsp->q6v5); in adsp_panic()
456 static int adsp_init_clock(struct qcom_adsp *adsp, const char **clk_ids) in adsp_init_clock() argument
461 adsp->xo = devm_clk_get(adsp->dev, "xo"); in adsp_init_clock()
462 if (IS_ERR(adsp->xo)) { in adsp_init_clock()
463 ret = PTR_ERR(adsp->xo); in adsp_init_clock()
465 dev_err(adsp->dev, "failed to get xo clock"); in adsp_init_clock()
472 adsp->num_clks = num_clks; in adsp_init_clock()
473 adsp->clks = devm_kcalloc(adsp->dev, adsp->num_clks, in adsp_init_clock()
474 sizeof(*adsp->clks), GFP_KERNEL); in adsp_init_clock()
475 if (!adsp->clks) in adsp_init_clock()
478 for (i = 0; i < adsp->num_clks; i++) in adsp_init_clock()
479 adsp->clks[i].id = clk_ids[i]; in adsp_init_clock()
481 return devm_clk_bulk_get(adsp->dev, adsp->num_clks, adsp->clks); in adsp_init_clock()
484 static int adsp_init_reset(struct qcom_adsp *adsp) in adsp_init_reset() argument
486 adsp->pdc_sync_reset = devm_reset_control_get_optional_exclusive(adsp->dev, in adsp_init_reset()
488 if (IS_ERR(adsp->pdc_sync_reset)) { in adsp_init_reset()
489 dev_err(adsp->dev, "failed to acquire pdc_sync reset\n"); in adsp_init_reset()
490 return PTR_ERR(adsp->pdc_sync_reset); in adsp_init_reset()
493 adsp->restart = devm_reset_control_get_optional_exclusive(adsp->dev, "restart"); in adsp_init_reset()
496 if (!adsp->restart) in adsp_init_reset()
497 adsp->restart = devm_reset_control_get_exclusive(adsp->dev, "cc_lpass"); in adsp_init_reset()
499 if (IS_ERR(adsp->restart)) { in adsp_init_reset()
500 dev_err(adsp->dev, "failed to acquire restart\n"); in adsp_init_reset()
501 return PTR_ERR(adsp->restart); in adsp_init_reset()
507 static int adsp_init_mmio(struct qcom_adsp *adsp, in adsp_init_mmio() argument
513 adsp->qdsp6ss_base = devm_platform_ioremap_resource(pdev, 0); in adsp_init_mmio()
514 if (IS_ERR(adsp->qdsp6ss_base)) { in adsp_init_mmio()
515 dev_err(adsp->dev, "failed to map QDSP6SS registers\n"); in adsp_init_mmio()
516 return PTR_ERR(adsp->qdsp6ss_base); in adsp_init_mmio()
525 adsp->halt_map = syscon_node_to_regmap(syscon); in adsp_init_mmio()
527 if (IS_ERR(adsp->halt_map)) in adsp_init_mmio()
528 return PTR_ERR(adsp->halt_map); in adsp_init_mmio()
531 1, &adsp->halt_lpass); in adsp_init_mmio()
540 static int adsp_alloc_memory_region(struct qcom_adsp *adsp) in adsp_alloc_memory_region() argument
546 node = of_parse_phandle(adsp->dev->of_node, "memory-region", 0); in adsp_alloc_memory_region()
548 dev_err(adsp->dev, "no memory-region specified\n"); in adsp_alloc_memory_region()
557 adsp->mem_phys = adsp->mem_reloc = r.start; in adsp_alloc_memory_region()
558 adsp->mem_size = resource_size(&r); in adsp_alloc_memory_region()
559 adsp->mem_region = devm_ioremap_wc(adsp->dev, in adsp_alloc_memory_region()
560 adsp->mem_phys, adsp->mem_size); in adsp_alloc_memory_region()
561 if (!adsp->mem_region) { in adsp_alloc_memory_region()
562 dev_err(adsp->dev, "unable to map memory region: %pa+%zx\n", in adsp_alloc_memory_region()
563 &r.start, adsp->mem_size); in adsp_alloc_memory_region()
574 struct qcom_adsp *adsp; in adsp_probe() local
591 firmware_name, sizeof(*adsp)); in adsp_probe()
600 adsp = (struct qcom_adsp *)rproc->priv; in adsp_probe()
601 adsp->dev = &pdev->dev; in adsp_probe()
602 adsp->rproc = rproc; in adsp_probe()
603 adsp->info_name = desc->sysmon_name; in adsp_probe()
604 platform_set_drvdata(pdev, adsp); in adsp_probe()
607 adsp->shutdown = qcom_wpss_shutdown; in adsp_probe()
609 adsp->shutdown = qcom_adsp_shutdown; in adsp_probe()
611 ret = adsp_alloc_memory_region(adsp); in adsp_probe()
615 ret = adsp_init_clock(adsp, desc->clk_ids); in adsp_probe()
619 ret = qcom_rproc_pds_attach(adsp->dev, adsp, in adsp_probe()
625 adsp->proxy_pd_count = ret; in adsp_probe()
627 ret = adsp_init_reset(adsp); in adsp_probe()
631 ret = adsp_init_mmio(adsp, pdev); in adsp_probe()
635 ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem, in adsp_probe()
640 qcom_add_glink_subdev(rproc, &adsp->glink_subdev, desc->ssr_name); in adsp_probe()
641 qcom_add_ssr_subdev(rproc, &adsp->ssr_subdev, desc->ssr_name); in adsp_probe()
642 adsp->sysmon = qcom_add_sysmon_subdev(rproc, in adsp_probe()
645 if (IS_ERR(adsp->sysmon)) { in adsp_probe()
646 ret = PTR_ERR(adsp->sysmon); in adsp_probe()
657 qcom_rproc_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_probe()
667 struct qcom_adsp *adsp = platform_get_drvdata(pdev); in adsp_remove() local
669 rproc_del(adsp->rproc); in adsp_remove()
671 qcom_q6v5_deinit(&adsp->q6v5); in adsp_remove()
672 qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev); in adsp_remove()
673 qcom_remove_sysmon_subdev(adsp->sysmon); in adsp_remove()
674 qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev); in adsp_remove()
675 qcom_rproc_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_remove()
676 rproc_free(adsp->rproc); in adsp_remove()
683 .firmware_name = "adsp.mdt",
685 .sysmon_name = "adsp",
738 { .compatible = "qcom,sdm845-adsp-pil", .data = &adsp_resource_init },
753 MODULE_DESCRIPTION("QTI SDM845 ADSP Peripheral Image Loader");