Lines Matching refs:adsp
120 int (*shutdown)(struct qcom_adsp *adsp);
123 static int qcom_rproc_pds_attach(struct device *dev, struct qcom_adsp *adsp, in qcom_rproc_pds_attach() argument
126 struct device **devs = adsp->proxy_pds; in qcom_rproc_pds_attach()
144 if (num_pds > ARRAY_SIZE(adsp->proxy_pds)) in qcom_rproc_pds_attach()
164 static void qcom_rproc_pds_detach(struct qcom_adsp *adsp, struct device **pds, in qcom_rproc_pds_detach() argument
167 struct device *dev = adsp->dev; in qcom_rproc_pds_detach()
180 static int qcom_rproc_pds_enable(struct qcom_adsp *adsp, struct device **pds, in qcom_rproc_pds_enable() argument
206 static void qcom_rproc_pds_disable(struct qcom_adsp *adsp, struct device **pds, in qcom_rproc_pds_disable() argument
217 static int qcom_wpss_shutdown(struct qcom_adsp *adsp) in qcom_wpss_shutdown() argument
221 regmap_write(adsp->halt_map, adsp->halt_lpass + LPASS_HALTREQ_REG, 1); in qcom_wpss_shutdown()
224 regmap_read_poll_timeout(adsp->halt_map, in qcom_wpss_shutdown()
225 adsp->halt_lpass + LPASS_HALTACK_REG, val, in qcom_wpss_shutdown()
229 reset_control_assert(adsp->pdc_sync_reset); in qcom_wpss_shutdown()
232 reset_control_assert(adsp->restart); in qcom_wpss_shutdown()
238 reset_control_deassert(adsp->restart); in qcom_wpss_shutdown()
241 reset_control_deassert(adsp->pdc_sync_reset); in qcom_wpss_shutdown()
245 clk_bulk_disable_unprepare(adsp->num_clks, adsp->clks); in qcom_wpss_shutdown()
247 regmap_write(adsp->halt_map, adsp->halt_lpass + LPASS_HALTREQ_REG, 0); in qcom_wpss_shutdown()
250 regmap_read_poll_timeout(adsp->halt_map, in qcom_wpss_shutdown()
251 adsp->halt_lpass + LPASS_HALTACK_REG, val, in qcom_wpss_shutdown()
257 static int qcom_adsp_shutdown(struct qcom_adsp *adsp) in qcom_adsp_shutdown() argument
264 val = readl(adsp->qdsp6ss_base + RET_CFG_REG); in qcom_adsp_shutdown()
266 writel(val, adsp->qdsp6ss_base + RET_CFG_REG); in qcom_adsp_shutdown()
268 clk_bulk_disable_unprepare(adsp->num_clks, adsp->clks); in qcom_adsp_shutdown()
271 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
272 adsp->halt_lpass + LPASS_PWR_ON_REG, &val); in qcom_adsp_shutdown()
276 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
277 adsp->halt_lpass + LPASS_MASTER_IDLE_REG, in qcom_adsp_shutdown()
282 regmap_write(adsp->halt_map, in qcom_adsp_shutdown()
283 adsp->halt_lpass + LPASS_HALTREQ_REG, 1); in qcom_adsp_shutdown()
288 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
289 adsp->halt_lpass + LPASS_HALTACK_REG, &val); in qcom_adsp_shutdown()
296 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
297 adsp->halt_lpass + LPASS_MASTER_IDLE_REG, &val); in qcom_adsp_shutdown()
299 dev_err(adsp->dev, "port failed halt\n"); in qcom_adsp_shutdown()
303 reset_control_assert(adsp->pdc_sync_reset); in qcom_adsp_shutdown()
305 reset_control_assert(adsp->restart); in qcom_adsp_shutdown()
310 regmap_write(adsp->halt_map, adsp->halt_lpass + LPASS_HALTREQ_REG, 0); in qcom_adsp_shutdown()
313 reset_control_deassert(adsp->pdc_sync_reset); in qcom_adsp_shutdown()
315 reset_control_deassert(adsp->restart); in qcom_adsp_shutdown()
324 struct qcom_adsp *adsp = rproc->priv; in adsp_load() local
327 ret = qcom_mdt_load_no_init(adsp->dev, fw, rproc->firmware, 0, in adsp_load()
328 adsp->mem_region, adsp->mem_phys, in adsp_load()
329 adsp->mem_size, &adsp->mem_reloc); in adsp_load()
333 qcom_pil_info_store(adsp->info_name, adsp->mem_phys, adsp->mem_size); in adsp_load()
340 struct qcom_adsp *adsp = rproc->priv; in adsp_unmap_carveout() local
342 if (adsp->has_iommu) in adsp_unmap_carveout()
343 iommu_unmap(rproc->domain, adsp->mem_phys, adsp->mem_size); in adsp_unmap_carveout()
348 struct qcom_adsp *adsp = rproc->priv; in adsp_map_carveout() local
354 if (!adsp->has_iommu) in adsp_map_carveout()
360 ret = of_parse_phandle_with_args(adsp->dev->of_node, "iommus", "#iommu-cells", 0, &args); in adsp_map_carveout()
367 iova = adsp->mem_phys | (sid << 32); in adsp_map_carveout()
369 ret = iommu_map(rproc->domain, iova, adsp->mem_phys, in adsp_map_carveout()
370 adsp->mem_size, IOMMU_READ | IOMMU_WRITE, in adsp_map_carveout()
373 dev_err(adsp->dev, "Unable to map ADSP Physical Memory\n"); in adsp_map_carveout()
382 struct qcom_adsp *adsp = rproc->priv; in adsp_start() local
386 ret = qcom_q6v5_prepare(&adsp->q6v5); in adsp_start()
392 dev_err(adsp->dev, "ADSP smmu mapping failed\n"); in adsp_start()
396 ret = clk_prepare_enable(adsp->xo); in adsp_start()
400 ret = qcom_rproc_pds_enable(adsp, adsp->proxy_pds, in adsp_start()
401 adsp->proxy_pd_count); in adsp_start()
405 ret = clk_bulk_prepare_enable(adsp->num_clks, adsp->clks); in adsp_start()
407 dev_err(adsp->dev, "adsp clk_enable failed\n"); in adsp_start()
412 writel(1, adsp->qdsp6ss_base + QDSP6SS_XO_CBCR); in adsp_start()
415 writel(1, adsp->qdsp6ss_base + QDSP6SS_SLEEP_CBCR); in adsp_start()
418 writel(1, adsp->qdsp6ss_base + QDSP6SS_CORE_CBCR); in adsp_start()
421 writel(adsp->mem_phys >> 4, adsp->qdsp6ss_base + RST_EVB_REG); in adsp_start()
423 if (adsp->lpass_efuse) in adsp_start()
424 writel(LPASS_EFUSE_Q6SS_EVB_SEL, adsp->lpass_efuse); in adsp_start()
427 writel(LPASS_BOOT_CORE_START, adsp->qdsp6ss_base + CORE_START_REG); in adsp_start()
430 writel(LPASS_BOOT_CMD_START, adsp->qdsp6ss_base + BOOT_CMD_REG); in adsp_start()
433 ret = readl_poll_timeout(adsp->qdsp6ss_base + BOOT_STATUS_REG, in adsp_start()
436 dev_err(adsp->dev, "failed to bootup adsp\n"); in adsp_start()
440 ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5 * HZ)); in adsp_start()
442 dev_err(adsp->dev, "start timed out\n"); in adsp_start()
449 clk_bulk_disable_unprepare(adsp->num_clks, adsp->clks); in adsp_start()
451 qcom_rproc_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_start()
453 clk_disable_unprepare(adsp->xo); in adsp_start()
457 qcom_q6v5_unprepare(&adsp->q6v5); in adsp_start()
464 struct qcom_adsp *adsp = container_of(q6v5, struct qcom_adsp, q6v5); in qcom_adsp_pil_handover() local
466 clk_disable_unprepare(adsp->xo); in qcom_adsp_pil_handover()
467 qcom_rproc_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in qcom_adsp_pil_handover()
472 struct qcom_adsp *adsp = rproc->priv; in adsp_stop() local
476 ret = qcom_q6v5_request_stop(&adsp->q6v5, adsp->sysmon); in adsp_stop()
478 dev_err(adsp->dev, "timed out on wait\n"); in adsp_stop()
480 ret = adsp->shutdown(adsp); in adsp_stop()
482 dev_err(adsp->dev, "failed to shutdown: %d\n", ret); in adsp_stop()
486 handover = qcom_q6v5_unprepare(&adsp->q6v5); in adsp_stop()
488 qcom_adsp_pil_handover(&adsp->q6v5); in adsp_stop()
495 struct qcom_adsp *adsp = rproc->priv; in adsp_da_to_va() local
498 offset = da - adsp->mem_reloc; in adsp_da_to_va()
499 if (offset < 0 || offset + len > adsp->mem_size) in adsp_da_to_va()
502 return adsp->mem_region + offset; in adsp_da_to_va()
507 struct qcom_adsp *adsp = rproc->priv; in adsp_parse_firmware() local
516 if (adsp->has_iommu) { in adsp_parse_firmware()
528 struct qcom_adsp *adsp = rproc->priv; in adsp_panic() local
530 return qcom_q6v5_panic(&adsp->q6v5); in adsp_panic()
542 static int adsp_init_clock(struct qcom_adsp *adsp, const char **clk_ids) in adsp_init_clock() argument
547 adsp->xo = devm_clk_get(adsp->dev, "xo"); in adsp_init_clock()
548 if (IS_ERR(adsp->xo)) { in adsp_init_clock()
549 ret = PTR_ERR(adsp->xo); in adsp_init_clock()
551 dev_err(adsp->dev, "failed to get xo clock"); in adsp_init_clock()
558 adsp->num_clks = num_clks; in adsp_init_clock()
559 adsp->clks = devm_kcalloc(adsp->dev, adsp->num_clks, in adsp_init_clock()
560 sizeof(*adsp->clks), GFP_KERNEL); in adsp_init_clock()
561 if (!adsp->clks) in adsp_init_clock()
564 for (i = 0; i < adsp->num_clks; i++) in adsp_init_clock()
565 adsp->clks[i].id = clk_ids[i]; in adsp_init_clock()
567 return devm_clk_bulk_get(adsp->dev, adsp->num_clks, adsp->clks); in adsp_init_clock()
570 static int adsp_init_reset(struct qcom_adsp *adsp) in adsp_init_reset() argument
572 adsp->pdc_sync_reset = devm_reset_control_get_optional_exclusive(adsp->dev, in adsp_init_reset()
574 if (IS_ERR(adsp->pdc_sync_reset)) { in adsp_init_reset()
575 dev_err(adsp->dev, "failed to acquire pdc_sync reset\n"); in adsp_init_reset()
576 return PTR_ERR(adsp->pdc_sync_reset); in adsp_init_reset()
579 adsp->restart = devm_reset_control_get_optional_exclusive(adsp->dev, "restart"); in adsp_init_reset()
582 if (!adsp->restart) in adsp_init_reset()
583 adsp->restart = devm_reset_control_get_exclusive(adsp->dev, "cc_lpass"); in adsp_init_reset()
585 if (IS_ERR(adsp->restart)) { in adsp_init_reset()
586 dev_err(adsp->dev, "failed to acquire restart\n"); in adsp_init_reset()
587 return PTR_ERR(adsp->restart); in adsp_init_reset()
593 static int adsp_init_mmio(struct qcom_adsp *adsp, in adsp_init_mmio() argument
600 adsp->qdsp6ss_base = devm_platform_ioremap_resource(pdev, 0); in adsp_init_mmio()
601 if (IS_ERR(adsp->qdsp6ss_base)) { in adsp_init_mmio()
602 dev_err(adsp->dev, "failed to map QDSP6SS registers\n"); in adsp_init_mmio()
603 return PTR_ERR(adsp->qdsp6ss_base); in adsp_init_mmio()
608 adsp->lpass_efuse = NULL; in adsp_init_mmio()
609 dev_dbg(adsp->dev, "failed to get efuse memory region\n"); in adsp_init_mmio()
611 adsp->lpass_efuse = devm_ioremap_resource(&pdev->dev, efuse_region); in adsp_init_mmio()
612 if (IS_ERR(adsp->lpass_efuse)) { in adsp_init_mmio()
613 dev_err(adsp->dev, "failed to map efuse registers\n"); in adsp_init_mmio()
614 return PTR_ERR(adsp->lpass_efuse); in adsp_init_mmio()
623 adsp->halt_map = syscon_node_to_regmap(syscon); in adsp_init_mmio()
625 if (IS_ERR(adsp->halt_map)) in adsp_init_mmio()
626 return PTR_ERR(adsp->halt_map); in adsp_init_mmio()
629 1, &adsp->halt_lpass); in adsp_init_mmio()
638 static int adsp_alloc_memory_region(struct qcom_adsp *adsp) in adsp_alloc_memory_region() argument
643 node = of_parse_phandle(adsp->dev->of_node, "memory-region", 0); in adsp_alloc_memory_region()
649 dev_err(adsp->dev, "unable to resolve memory-region\n"); in adsp_alloc_memory_region()
653 adsp->mem_phys = adsp->mem_reloc = rmem->base; in adsp_alloc_memory_region()
654 adsp->mem_size = rmem->size; in adsp_alloc_memory_region()
655 adsp->mem_region = devm_ioremap_wc(adsp->dev, in adsp_alloc_memory_region()
656 adsp->mem_phys, adsp->mem_size); in adsp_alloc_memory_region()
657 if (!adsp->mem_region) { in adsp_alloc_memory_region()
658 dev_err(adsp->dev, "unable to map memory region: %pa+%zx\n", in adsp_alloc_memory_region()
659 &rmem->base, adsp->mem_size); in adsp_alloc_memory_region()
670 struct qcom_adsp *adsp; in adsp_probe() local
687 firmware_name, sizeof(*adsp)); in adsp_probe()
697 adsp = rproc->priv; in adsp_probe()
698 adsp->dev = &pdev->dev; in adsp_probe()
699 adsp->rproc = rproc; in adsp_probe()
700 adsp->info_name = desc->sysmon_name; in adsp_probe()
701 adsp->has_iommu = desc->has_iommu; in adsp_probe()
703 platform_set_drvdata(pdev, adsp); in adsp_probe()
706 adsp->shutdown = qcom_wpss_shutdown; in adsp_probe()
708 adsp->shutdown = qcom_adsp_shutdown; in adsp_probe()
710 ret = adsp_alloc_memory_region(adsp); in adsp_probe()
714 ret = adsp_init_clock(adsp, desc->clk_ids); in adsp_probe()
718 ret = qcom_rproc_pds_attach(adsp->dev, adsp, in adsp_probe()
724 adsp->proxy_pd_count = ret; in adsp_probe()
726 ret = adsp_init_reset(adsp); in adsp_probe()
730 ret = adsp_init_mmio(adsp, pdev); in adsp_probe()
734 ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem, in adsp_probe()
739 qcom_add_glink_subdev(rproc, &adsp->glink_subdev, desc->ssr_name); in adsp_probe()
740 qcom_add_ssr_subdev(rproc, &adsp->ssr_subdev, desc->ssr_name); in adsp_probe()
741 adsp->sysmon = qcom_add_sysmon_subdev(rproc, in adsp_probe()
744 if (IS_ERR(adsp->sysmon)) { in adsp_probe()
745 ret = PTR_ERR(adsp->sysmon); in adsp_probe()
756 qcom_rproc_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_probe()
766 struct qcom_adsp *adsp = platform_get_drvdata(pdev); in adsp_remove() local
768 rproc_del(adsp->rproc); in adsp_remove()
770 qcom_q6v5_deinit(&adsp->q6v5); in adsp_remove()
771 qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev); in adsp_remove()
772 qcom_remove_sysmon_subdev(adsp->sysmon); in adsp_remove()
773 qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev); in adsp_remove()
774 qcom_rproc_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_remove()
775 rproc_free(adsp->rproc); in adsp_remove()