Lines Matching +full:de +full:- +full:asserting

1 // SPDX-License-Identifier: GPL-2.0
126 struct device **devs = adsp->proxy_pds; in qcom_rproc_pds_attach()
135 if (dev->pm_domain) { in qcom_rproc_pds_attach()
144 if (num_pds > ARRAY_SIZE(adsp->proxy_pds)) in qcom_rproc_pds_attach()
145 return -E2BIG; in qcom_rproc_pds_attach()
150 ret = PTR_ERR(devs[i]) ? : -ENODATA; in qcom_rproc_pds_attach()
158 for (i--; i >= 0; i--) in qcom_rproc_pds_attach()
167 struct device *dev = adsp->dev; in qcom_rproc_pds_detach()
171 if (dev->pm_domain && pd_count) { in qcom_rproc_pds_detach()
198 for (i--; i >= 0; i--) { in qcom_rproc_pds_enable()
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()
234 /* wait after asserting subsystem restart from AOSS */ in qcom_wpss_shutdown()
238 reset_control_deassert(adsp->restart); in qcom_wpss_shutdown()
240 /* De-assert the WPSS PDC Reset */ 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()
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()
306 /* wait after asserting subsystem restart from AOSS */ in qcom_adsp_shutdown()
310 regmap_write(adsp->halt_map, adsp->halt_lpass + LPASS_HALTREQ_REG, 0); in qcom_adsp_shutdown()
312 /* De-assert the LPASS PDC Reset */ 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()
316 /* wait after de-asserting subsystem restart from AOSS */ in qcom_adsp_shutdown()
324 struct qcom_adsp *adsp = rproc->priv; in adsp_load()
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()
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()
354 if (!adsp->has_iommu) in adsp_map_carveout()
357 if (!rproc->domain) in adsp_map_carveout()
358 return -EINVAL; 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()
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()
426 /* De-assert QDSP6 stop core. QDSP6 will execute after out of reset */ 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()
441 if (ret == -ETIMEDOUT) { 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()
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()
476 ret = qcom_q6v5_request_stop(&adsp->q6v5, adsp->sysmon); in adsp_stop()
477 if (ret == -ETIMEDOUT) 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()
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()
512 dev_err(&rproc->dev, "Error in registering dump segments\n"); in adsp_parse_firmware()
516 if (adsp->has_iommu) { in adsp_parse_firmware()
519 dev_err(&rproc->dev, "Error in loading resource table\n"); in adsp_parse_firmware()
528 struct qcom_adsp *adsp = rproc->priv; in adsp_panic()
530 return qcom_q6v5_panic(&adsp->q6v5); in adsp_panic()
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()
550 if (ret != -EPROBE_DEFER) 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()
562 return -ENOMEM; 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()
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()
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()
617 syscon = of_parse_phandle(pdev->dev.of_node, "qcom,halt-regs", 0); in adsp_init_mmio()
619 dev_err(&pdev->dev, "failed to parse qcom,halt-regs\n"); in adsp_init_mmio()
620 return -EINVAL; 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()
628 ret = of_property_read_u32_index(pdev->dev.of_node, "qcom,halt-regs", in adsp_init_mmio()
629 1, &adsp->halt_lpass); in adsp_init_mmio()
631 dev_err(&pdev->dev, "no offset in syscon\n"); in adsp_init_mmio()
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()
650 return -EINVAL; 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()
660 return -EBUSY; in adsp_alloc_memory_region()
674 desc = of_device_get_match_data(&pdev->dev); in adsp_probe()
676 return -EINVAL; in adsp_probe()
678 firmware_name = desc->firmware_name; in adsp_probe()
679 ret = of_property_read_string(pdev->dev.of_node, "firmware-name", in adsp_probe()
681 if (ret < 0 && ret != -EINVAL) { in adsp_probe()
682 dev_err(&pdev->dev, "unable to read firmware-name\n"); in adsp_probe()
686 rproc = rproc_alloc(&pdev->dev, pdev->name, &adsp_ops, in adsp_probe()
689 dev_err(&pdev->dev, "unable to allocate remoteproc\n"); in adsp_probe()
690 return -ENOMEM; in adsp_probe()
693 rproc->auto_boot = desc->auto_boot; in adsp_probe()
694 rproc->has_iommu = desc->has_iommu; 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()
705 if (desc->is_wpss) in adsp_probe()
706 adsp->shutdown = qcom_wpss_shutdown; in adsp_probe()
708 adsp->shutdown = qcom_adsp_shutdown; 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()
719 desc->proxy_pd_names); in adsp_probe()
721 dev_err(&pdev->dev, "Failed to attach proxy power domains\n"); in adsp_probe()
724 adsp->proxy_pd_count = ret; in adsp_probe()
734 ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem, in adsp_probe()
735 desc->load_state, qcom_adsp_pil_handover); 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()
742 desc->sysmon_name, in adsp_probe()
743 desc->ssctl_id); 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()
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()
848 { .compatible = "qcom,qcs404-cdsp-pil", .data = &cdsp_resource_init },
849 { .compatible = "qcom,sc7280-adsp-pil", .data = &adsp_sc7280_resource_init },
850 { .compatible = "qcom,sc7280-wpss-pil", .data = &wpss_resource_init },
851 { .compatible = "qcom,sdm845-adsp-pil", .data = &adsp_resource_init },