Lines Matching full:adsp
3 * Qualcomm ADSP/SLPI Peripheral Image Loader for MSM8974 and MSM8996
112 struct qcom_adsp *adsp = rproc->priv; in adsp_segment_dump() local
115 total_offset = segment->da + segment->offset + offset - adsp->mem_phys; in adsp_segment_dump()
116 if (total_offset < 0 || total_offset + size > adsp->mem_size) { in adsp_segment_dump()
117 dev_err(adsp->dev, in adsp_segment_dump()
124 memcpy_fromio(dest, adsp->mem_region + total_offset, size); in adsp_segment_dump()
129 struct qcom_adsp *adsp = rproc->priv; in adsp_minidump() local
134 qcom_minidump(rproc, adsp->minidump_id, adsp_segment_dump); in adsp_minidump()
137 static int adsp_pds_enable(struct qcom_adsp *adsp, struct device **pds, in adsp_pds_enable() argument
164 static void adsp_pds_disable(struct qcom_adsp *adsp, struct device **pds, in adsp_pds_disable() argument
175 static int adsp_shutdown_poll_decrypt(struct qcom_adsp *adsp) in adsp_shutdown_poll_decrypt() argument
182 ret = qcom_scm_pas_shutdown(adsp->pas_id); in adsp_shutdown_poll_decrypt()
190 struct qcom_adsp *adsp = rproc->priv; in adsp_unprepare() local
198 qcom_scm_pas_metadata_release(&adsp->pas_metadata); in adsp_unprepare()
199 if (adsp->dtb_pas_id) in adsp_unprepare()
200 qcom_scm_pas_metadata_release(&adsp->dtb_pas_metadata); in adsp_unprepare()
207 struct qcom_adsp *adsp = rproc->priv; in adsp_load() local
211 adsp->firmware = fw; in adsp_load()
213 if (adsp->dtb_pas_id) { in adsp_load()
214 ret = request_firmware(&adsp->dtb_firmware, adsp->dtb_firmware_name, adsp->dev); in adsp_load()
216 dev_err(adsp->dev, "request_firmware failed for %s: %d\n", in adsp_load()
217 adsp->dtb_firmware_name, ret); in adsp_load()
221 ret = qcom_mdt_pas_init(adsp->dev, adsp->dtb_firmware, adsp->dtb_firmware_name, in adsp_load()
222 adsp->dtb_pas_id, adsp->dtb_mem_phys, in adsp_load()
223 &adsp->dtb_pas_metadata); in adsp_load()
227 ret = qcom_mdt_load_no_init(adsp->dev, adsp->dtb_firmware, adsp->dtb_firmware_name, in adsp_load()
228 adsp->dtb_pas_id, adsp->dtb_mem_region, in adsp_load()
229 adsp->dtb_mem_phys, adsp->dtb_mem_size, in adsp_load()
230 &adsp->dtb_mem_reloc); in adsp_load()
238 qcom_scm_pas_metadata_release(&adsp->dtb_pas_metadata); in adsp_load()
241 release_firmware(adsp->dtb_firmware); in adsp_load()
248 struct qcom_adsp *adsp = rproc->priv; in adsp_start() local
251 ret = qcom_q6v5_prepare(&adsp->q6v5); in adsp_start()
255 ret = adsp_pds_enable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_start()
259 ret = clk_prepare_enable(adsp->xo); in adsp_start()
263 ret = clk_prepare_enable(adsp->aggre2_clk); in adsp_start()
267 if (adsp->cx_supply) { in adsp_start()
268 ret = regulator_enable(adsp->cx_supply); in adsp_start()
273 if (adsp->px_supply) { in adsp_start()
274 ret = regulator_enable(adsp->px_supply); in adsp_start()
279 if (adsp->dtb_pas_id) { in adsp_start()
280 ret = qcom_scm_pas_auth_and_reset(adsp->dtb_pas_id); in adsp_start()
282 dev_err(adsp->dev, in adsp_start()
288 ret = qcom_mdt_pas_init(adsp->dev, adsp->firmware, rproc->firmware, adsp->pas_id, in adsp_start()
289 adsp->mem_phys, &adsp->pas_metadata); in adsp_start()
293 ret = qcom_mdt_load_no_init(adsp->dev, adsp->firmware, rproc->firmware, adsp->pas_id, in adsp_start()
294 adsp->mem_region, adsp->mem_phys, adsp->mem_size, in adsp_start()
295 &adsp->mem_reloc); in adsp_start()
299 qcom_pil_info_store(adsp->info_name, adsp->mem_phys, adsp->mem_size); in adsp_start()
301 ret = qcom_scm_pas_auth_and_reset(adsp->pas_id); in adsp_start()
303 dev_err(adsp->dev, in adsp_start()
308 ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5000)); in adsp_start()
310 dev_err(adsp->dev, "start timed out\n"); in adsp_start()
311 qcom_scm_pas_shutdown(adsp->pas_id); in adsp_start()
315 qcom_scm_pas_metadata_release(&adsp->pas_metadata); in adsp_start()
316 if (adsp->dtb_pas_id) in adsp_start()
317 qcom_scm_pas_metadata_release(&adsp->dtb_pas_metadata); in adsp_start()
320 adsp->firmware = NULL; in adsp_start()
325 qcom_scm_pas_metadata_release(&adsp->pas_metadata); in adsp_start()
326 if (adsp->dtb_pas_id) in adsp_start()
327 qcom_scm_pas_metadata_release(&adsp->dtb_pas_metadata); in adsp_start()
329 if (adsp->px_supply) in adsp_start()
330 regulator_disable(adsp->px_supply); in adsp_start()
332 if (adsp->cx_supply) in adsp_start()
333 regulator_disable(adsp->cx_supply); in adsp_start()
335 clk_disable_unprepare(adsp->aggre2_clk); in adsp_start()
337 clk_disable_unprepare(adsp->xo); in adsp_start()
339 adsp_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_start()
341 qcom_q6v5_unprepare(&adsp->q6v5); in adsp_start()
344 adsp->firmware = NULL; in adsp_start()
351 struct qcom_adsp *adsp = container_of(q6v5, struct qcom_adsp, q6v5); in qcom_pas_handover() local
353 if (adsp->px_supply) in qcom_pas_handover()
354 regulator_disable(adsp->px_supply); in qcom_pas_handover()
355 if (adsp->cx_supply) in qcom_pas_handover()
356 regulator_disable(adsp->cx_supply); in qcom_pas_handover()
357 clk_disable_unprepare(adsp->aggre2_clk); in qcom_pas_handover()
358 clk_disable_unprepare(adsp->xo); in qcom_pas_handover()
359 adsp_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in qcom_pas_handover()
364 struct qcom_adsp *adsp = rproc->priv; in adsp_stop() local
368 ret = qcom_q6v5_request_stop(&adsp->q6v5, adsp->sysmon); in adsp_stop()
370 dev_err(adsp->dev, "timed out on wait\n"); in adsp_stop()
372 ret = qcom_scm_pas_shutdown(adsp->pas_id); in adsp_stop()
373 if (ret && adsp->decrypt_shutdown) in adsp_stop()
374 ret = adsp_shutdown_poll_decrypt(adsp); in adsp_stop()
377 dev_err(adsp->dev, "failed to shutdown: %d\n", ret); in adsp_stop()
379 if (adsp->dtb_pas_id) { in adsp_stop()
380 ret = qcom_scm_pas_shutdown(adsp->dtb_pas_id); in adsp_stop()
382 dev_err(adsp->dev, "failed to shutdown dtb: %d\n", ret); in adsp_stop()
385 handover = qcom_q6v5_unprepare(&adsp->q6v5); in adsp_stop()
387 qcom_pas_handover(&adsp->q6v5); in adsp_stop()
394 struct qcom_adsp *adsp = rproc->priv; in adsp_da_to_va() local
397 offset = da - adsp->mem_reloc; in adsp_da_to_va()
398 if (offset < 0 || offset + len > adsp->mem_size) in adsp_da_to_va()
404 return adsp->mem_region + offset; in adsp_da_to_va()
409 struct qcom_adsp *adsp = rproc->priv; in adsp_panic() local
411 return qcom_q6v5_panic(&adsp->q6v5); in adsp_panic()
435 static int adsp_init_clock(struct qcom_adsp *adsp) in adsp_init_clock() argument
439 adsp->xo = devm_clk_get(adsp->dev, "xo"); in adsp_init_clock()
440 if (IS_ERR(adsp->xo)) { in adsp_init_clock()
441 ret = PTR_ERR(adsp->xo); in adsp_init_clock()
443 dev_err(adsp->dev, "failed to get xo clock"); in adsp_init_clock()
447 adsp->aggre2_clk = devm_clk_get_optional(adsp->dev, "aggre2"); in adsp_init_clock()
448 if (IS_ERR(adsp->aggre2_clk)) { in adsp_init_clock()
449 ret = PTR_ERR(adsp->aggre2_clk); in adsp_init_clock()
451 dev_err(adsp->dev, in adsp_init_clock()
459 static int adsp_init_regulator(struct qcom_adsp *adsp) in adsp_init_regulator() argument
461 adsp->cx_supply = devm_regulator_get_optional(adsp->dev, "cx"); in adsp_init_regulator()
462 if (IS_ERR(adsp->cx_supply)) { in adsp_init_regulator()
463 if (PTR_ERR(adsp->cx_supply) == -ENODEV) in adsp_init_regulator()
464 adsp->cx_supply = NULL; in adsp_init_regulator()
466 return PTR_ERR(adsp->cx_supply); in adsp_init_regulator()
469 if (adsp->cx_supply) in adsp_init_regulator()
470 regulator_set_load(adsp->cx_supply, 100000); in adsp_init_regulator()
472 adsp->px_supply = devm_regulator_get_optional(adsp->dev, "px"); in adsp_init_regulator()
473 if (IS_ERR(adsp->px_supply)) { in adsp_init_regulator()
474 if (PTR_ERR(adsp->px_supply) == -ENODEV) in adsp_init_regulator()
475 adsp->px_supply = NULL; in adsp_init_regulator()
477 return PTR_ERR(adsp->px_supply); in adsp_init_regulator()
520 static void adsp_pds_detach(struct qcom_adsp *adsp, struct device **pds, in adsp_pds_detach() argument
523 struct device *dev = adsp->dev; in adsp_pds_detach()
536 static int adsp_alloc_memory_region(struct qcom_adsp *adsp) in adsp_alloc_memory_region() argument
541 node = of_parse_phandle(adsp->dev->of_node, "memory-region", 0); in adsp_alloc_memory_region()
543 dev_err(adsp->dev, "no memory-region specified\n"); in adsp_alloc_memory_region()
550 dev_err(adsp->dev, "unable to resolve memory-region\n"); in adsp_alloc_memory_region()
554 adsp->mem_phys = adsp->mem_reloc = rmem->base; in adsp_alloc_memory_region()
555 adsp->mem_size = rmem->size; in adsp_alloc_memory_region()
556 adsp->mem_region = devm_ioremap_wc(adsp->dev, adsp->mem_phys, adsp->mem_size); in adsp_alloc_memory_region()
557 if (!adsp->mem_region) { in adsp_alloc_memory_region()
558 dev_err(adsp->dev, "unable to map memory region: %pa+%zx\n", in adsp_alloc_memory_region()
559 &rmem->base, adsp->mem_size); in adsp_alloc_memory_region()
563 if (!adsp->dtb_pas_id) in adsp_alloc_memory_region()
566 node = of_parse_phandle(adsp->dev->of_node, "memory-region", 1); in adsp_alloc_memory_region()
568 dev_err(adsp->dev, "no dtb memory-region specified\n"); in adsp_alloc_memory_region()
575 dev_err(adsp->dev, "unable to resolve dtb memory-region\n"); in adsp_alloc_memory_region()
579 adsp->dtb_mem_phys = adsp->dtb_mem_reloc = rmem->base; in adsp_alloc_memory_region()
580 adsp->dtb_mem_size = rmem->size; in adsp_alloc_memory_region()
581 adsp->dtb_mem_region = devm_ioremap_wc(adsp->dev, adsp->dtb_mem_phys, adsp->dtb_mem_size); in adsp_alloc_memory_region()
582 if (!adsp->dtb_mem_region) { in adsp_alloc_memory_region()
583 dev_err(adsp->dev, "unable to map dtb memory region: %pa+%zx\n", in adsp_alloc_memory_region()
584 &rmem->base, adsp->dtb_mem_size); in adsp_alloc_memory_region()
591 static int adsp_assign_memory_region(struct qcom_adsp *adsp) in adsp_assign_memory_region() argument
598 if (!adsp->region_assign_idx) in adsp_assign_memory_region()
601 node = of_parse_phandle(adsp->dev->of_node, "memory-region", adsp->region_assign_idx); in adsp_assign_memory_region()
606 dev_err(adsp->dev, "unable to resolve shareable memory-region\n"); in adsp_assign_memory_region()
613 adsp->region_assign_phys = rmem->base; in adsp_assign_memory_region()
614 adsp->region_assign_size = rmem->size; in adsp_assign_memory_region()
615 adsp->region_assign_perms = BIT(QCOM_SCM_VMID_HLOS); in adsp_assign_memory_region()
617 ret = qcom_scm_assign_mem(adsp->region_assign_phys, in adsp_assign_memory_region()
618 adsp->region_assign_size, in adsp_assign_memory_region()
619 &adsp->region_assign_perms, in adsp_assign_memory_region()
622 dev_err(adsp->dev, "assign memory failed\n"); in adsp_assign_memory_region()
629 static void adsp_unassign_memory_region(struct qcom_adsp *adsp) in adsp_unassign_memory_region() argument
634 if (!adsp->region_assign_idx) in adsp_unassign_memory_region()
640 ret = qcom_scm_assign_mem(adsp->region_assign_phys, in adsp_unassign_memory_region()
641 adsp->region_assign_size, in adsp_unassign_memory_region()
642 &adsp->region_assign_perms, in adsp_unassign_memory_region()
645 dev_err(adsp->dev, "unassign memory failed\n"); in adsp_unassign_memory_region()
651 struct qcom_adsp *adsp; in adsp_probe() local
681 rproc = rproc_alloc(&pdev->dev, pdev->name, ops, fw_name, sizeof(*adsp)); in adsp_probe()
691 adsp = rproc->priv; in adsp_probe()
692 adsp->dev = &pdev->dev; in adsp_probe()
693 adsp->rproc = rproc; in adsp_probe()
694 adsp->minidump_id = desc->minidump_id; in adsp_probe()
695 adsp->pas_id = desc->pas_id; in adsp_probe()
696 adsp->info_name = desc->sysmon_name; in adsp_probe()
697 adsp->decrypt_shutdown = desc->decrypt_shutdown; in adsp_probe()
698 adsp->region_assign_idx = desc->region_assign_idx; in adsp_probe()
700 adsp->dtb_firmware_name = dtb_fw_name; in adsp_probe()
701 adsp->dtb_pas_id = desc->dtb_pas_id; in adsp_probe()
703 platform_set_drvdata(pdev, adsp); in adsp_probe()
705 ret = device_init_wakeup(adsp->dev, true); in adsp_probe()
709 ret = adsp_alloc_memory_region(adsp); in adsp_probe()
713 ret = adsp_assign_memory_region(adsp); in adsp_probe()
717 ret = adsp_init_clock(adsp); in adsp_probe()
721 ret = adsp_init_regulator(adsp); in adsp_probe()
725 ret = adsp_pds_attach(&pdev->dev, adsp->proxy_pds, in adsp_probe()
729 adsp->proxy_pd_count = ret; in adsp_probe()
731 ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem, desc->load_state, in adsp_probe()
736 qcom_add_glink_subdev(rproc, &adsp->glink_subdev, desc->ssr_name); in adsp_probe()
737 qcom_add_smd_subdev(rproc, &adsp->smd_subdev); in adsp_probe()
738 adsp->sysmon = qcom_add_sysmon_subdev(rproc, in adsp_probe()
741 if (IS_ERR(adsp->sysmon)) { in adsp_probe()
742 ret = PTR_ERR(adsp->sysmon); in adsp_probe()
746 qcom_add_ssr_subdev(rproc, &adsp->ssr_subdev, desc->ssr_name); in adsp_probe()
754 adsp_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_probe()
756 device_init_wakeup(adsp->dev, false); in adsp_probe()
764 struct qcom_adsp *adsp = platform_get_drvdata(pdev); in adsp_remove() local
766 rproc_del(adsp->rproc); in adsp_remove()
768 qcom_q6v5_deinit(&adsp->q6v5); in adsp_remove()
769 adsp_unassign_memory_region(adsp); in adsp_remove()
770 qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev); in adsp_remove()
771 qcom_remove_sysmon_subdev(adsp->sysmon); in adsp_remove()
772 qcom_remove_smd_subdev(adsp->rproc, &adsp->smd_subdev); in adsp_remove()
773 qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev); in adsp_remove()
774 adsp_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_remove()
775 device_init_wakeup(adsp->dev, false); in adsp_remove()
776 rproc_free(adsp->rproc); in adsp_remove()
781 .firmware_name = "adsp.mdt",
785 .sysmon_name = "adsp",
791 .firmware_name = "adsp.mdt",
794 .load_state = "adsp",
796 .sysmon_name = "adsp",
802 .firmware_name = "adsp.mdt",
810 .load_state = "adsp",
812 .sysmon_name = "adsp",
818 .firmware_name = "adsp.mdt",
825 .load_state = "adsp",
827 .sysmon_name = "adsp",
833 .firmware_name = "adsp.mdt",
842 .load_state = "adsp",
844 .sysmon_name = "adsp",
850 .firmware_name = "adsp.mdt",
858 .load_state = "adsp",
860 .sysmon_name = "adsp",
866 .firmware_name = "adsp.mdt",
874 .sysmon_name = "adsp",
1097 .firmware_name = "adsp.mdt",
1108 .load_state = "adsp",
1110 .sysmon_name = "adsp",
1156 { .compatible = "qcom,msm8226-adsp-pil", .data = &adsp_resource_init},
1157 { .compatible = "qcom,msm8953-adsp-pil", .data = &msm8996_adsp_resource},
1158 { .compatible = "qcom,msm8974-adsp-pil", .data = &adsp_resource_init},
1159 { .compatible = "qcom,msm8996-adsp-pil", .data = &msm8996_adsp_resource},
1161 { .compatible = "qcom,msm8998-adsp-pas", .data = &msm8996_adsp_resource},
1163 { .compatible = "qcom,qcs404-adsp-pas", .data = &adsp_resource_init },
1168 { .compatible = "qcom,sc8180x-adsp-pas", .data = &sm8150_adsp_resource},
1171 { .compatible = "qcom,sc8280xp-adsp-pas", .data = &sm8250_adsp_resource},
1174 { .compatible = "qcom,sdm660-adsp-pas", .data = &adsp_resource_init},
1175 { .compatible = "qcom,sdm845-adsp-pas", .data = &sdm845_adsp_resource_init},
1179 { .compatible = "qcom,sm6115-adsp-pas", .data = &adsp_resource_init},
1182 { .compatible = "qcom,sm6350-adsp-pas", .data = &sm6350_adsp_resource},
1185 { .compatible = "qcom,sm8150-adsp-pas", .data = &sm8150_adsp_resource},
1189 { .compatible = "qcom,sm8250-adsp-pas", .data = &sm8250_adsp_resource},
1192 { .compatible = "qcom,sm8350-adsp-pas", .data = &sm8350_adsp_resource},
1196 { .compatible = "qcom,sm8450-adsp-pas", .data = &sm8350_adsp_resource},
1200 { .compatible = "qcom,sm8550-adsp-pas", .data = &sm8550_adsp_resource},