Lines Matching +full:msm8974 +full:- +full:adsp +full:- +full:pil

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Qualcomm ADSP/SLPI Peripheral Image Loader for MSM8974 and MSM8996
7 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
93 struct qcom_adsp *adsp = rproc->priv; in adsp_minidump() local
95 if (rproc->dump_conf == RPROC_COREDUMP_DISABLED) in adsp_minidump()
98 qcom_minidump(rproc, adsp->minidump_id); in adsp_minidump()
101 static int adsp_pds_enable(struct qcom_adsp *adsp, struct device **pds, in adsp_pds_enable() argument
120 for (i--; i >= 0; i--) { in adsp_pds_enable()
128 static void adsp_pds_disable(struct qcom_adsp *adsp, struct device **pds, in adsp_pds_disable() argument
139 static int adsp_shutdown_poll_decrypt(struct qcom_adsp *adsp) in adsp_shutdown_poll_decrypt() argument
146 ret = qcom_scm_pas_shutdown(adsp->pas_id); in adsp_shutdown_poll_decrypt()
147 } while (ret == -EINVAL && --retry_num); in adsp_shutdown_poll_decrypt()
154 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_unprepare() local
162 qcom_scm_pas_metadata_release(&adsp->pas_metadata); in adsp_unprepare()
169 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_load() local
172 ret = qcom_mdt_pas_init(adsp->dev, fw, rproc->firmware, adsp->pas_id, in adsp_load()
173 adsp->mem_phys, &adsp->pas_metadata); in adsp_load()
177 ret = qcom_mdt_load_no_init(adsp->dev, fw, rproc->firmware, adsp->pas_id, in adsp_load()
178 adsp->mem_region, adsp->mem_phys, adsp->mem_size, in adsp_load()
179 &adsp->mem_reloc); in adsp_load()
183 qcom_pil_info_store(adsp->info_name, adsp->mem_phys, adsp->mem_size); in adsp_load()
190 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_start() local
193 ret = qcom_q6v5_prepare(&adsp->q6v5); in adsp_start()
197 ret = adsp_pds_enable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_start()
201 ret = clk_prepare_enable(adsp->xo); in adsp_start()
205 ret = clk_prepare_enable(adsp->aggre2_clk); in adsp_start()
209 if (adsp->cx_supply) { in adsp_start()
210 ret = regulator_enable(adsp->cx_supply); in adsp_start()
215 if (adsp->px_supply) { in adsp_start()
216 ret = regulator_enable(adsp->px_supply); in adsp_start()
221 ret = qcom_scm_pas_auth_and_reset(adsp->pas_id); in adsp_start()
223 dev_err(adsp->dev, in adsp_start()
228 ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5000)); in adsp_start()
229 if (ret == -ETIMEDOUT) { in adsp_start()
230 dev_err(adsp->dev, "start timed out\n"); in adsp_start()
231 qcom_scm_pas_shutdown(adsp->pas_id); in adsp_start()
235 qcom_scm_pas_metadata_release(&adsp->pas_metadata); in adsp_start()
240 if (adsp->px_supply) in adsp_start()
241 regulator_disable(adsp->px_supply); in adsp_start()
243 if (adsp->cx_supply) in adsp_start()
244 regulator_disable(adsp->cx_supply); in adsp_start()
246 clk_disable_unprepare(adsp->aggre2_clk); in adsp_start()
248 clk_disable_unprepare(adsp->xo); in adsp_start()
250 adsp_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_start()
252 qcom_q6v5_unprepare(&adsp->q6v5); in adsp_start()
259 struct qcom_adsp *adsp = container_of(q6v5, struct qcom_adsp, q6v5); in qcom_pas_handover() local
261 if (adsp->px_supply) in qcom_pas_handover()
262 regulator_disable(adsp->px_supply); in qcom_pas_handover()
263 if (adsp->cx_supply) in qcom_pas_handover()
264 regulator_disable(adsp->cx_supply); in qcom_pas_handover()
265 clk_disable_unprepare(adsp->aggre2_clk); in qcom_pas_handover()
266 clk_disable_unprepare(adsp->xo); in qcom_pas_handover()
267 adsp_pds_disable(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in qcom_pas_handover()
272 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_stop() local
276 ret = qcom_q6v5_request_stop(&adsp->q6v5, adsp->sysmon); in adsp_stop()
277 if (ret == -ETIMEDOUT) in adsp_stop()
278 dev_err(adsp->dev, "timed out on wait\n"); in adsp_stop()
280 ret = qcom_scm_pas_shutdown(adsp->pas_id); in adsp_stop()
281 if (ret && adsp->decrypt_shutdown) in adsp_stop()
282 ret = adsp_shutdown_poll_decrypt(adsp); in adsp_stop()
285 dev_err(adsp->dev, "failed to shutdown: %d\n", ret); in adsp_stop()
287 handover = qcom_q6v5_unprepare(&adsp->q6v5); in adsp_stop()
289 qcom_pas_handover(&adsp->q6v5); in adsp_stop()
296 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_da_to_va() local
299 offset = da - adsp->mem_reloc; in adsp_da_to_va()
300 if (offset < 0 || offset + len > adsp->mem_size) in adsp_da_to_va()
306 return adsp->mem_region + offset; in adsp_da_to_va()
311 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_panic() local
313 return qcom_q6v5_panic(&adsp->q6v5); in adsp_panic()
336 static int adsp_init_clock(struct qcom_adsp *adsp) in adsp_init_clock() argument
340 adsp->xo = devm_clk_get(adsp->dev, "xo"); in adsp_init_clock()
341 if (IS_ERR(adsp->xo)) { in adsp_init_clock()
342 ret = PTR_ERR(adsp->xo); in adsp_init_clock()
343 if (ret != -EPROBE_DEFER) in adsp_init_clock()
344 dev_err(adsp->dev, "failed to get xo clock"); in adsp_init_clock()
348 if (adsp->has_aggre2_clk) { in adsp_init_clock()
349 adsp->aggre2_clk = devm_clk_get(adsp->dev, "aggre2"); in adsp_init_clock()
350 if (IS_ERR(adsp->aggre2_clk)) { in adsp_init_clock()
351 ret = PTR_ERR(adsp->aggre2_clk); in adsp_init_clock()
352 if (ret != -EPROBE_DEFER) in adsp_init_clock()
353 dev_err(adsp->dev, in adsp_init_clock()
362 static int adsp_init_regulator(struct qcom_adsp *adsp) in adsp_init_regulator() argument
364 adsp->cx_supply = devm_regulator_get_optional(adsp->dev, "cx"); in adsp_init_regulator()
365 if (IS_ERR(adsp->cx_supply)) { in adsp_init_regulator()
366 if (PTR_ERR(adsp->cx_supply) == -ENODEV) in adsp_init_regulator()
367 adsp->cx_supply = NULL; in adsp_init_regulator()
369 return PTR_ERR(adsp->cx_supply); in adsp_init_regulator()
372 if (adsp->cx_supply) in adsp_init_regulator()
373 regulator_set_load(adsp->cx_supply, 100000); in adsp_init_regulator()
375 adsp->px_supply = devm_regulator_get_optional(adsp->dev, "px"); in adsp_init_regulator()
376 if (IS_ERR(adsp->px_supply)) { in adsp_init_regulator()
377 if (PTR_ERR(adsp->px_supply) == -ENODEV) in adsp_init_regulator()
378 adsp->px_supply = NULL; in adsp_init_regulator()
380 return PTR_ERR(adsp->px_supply); in adsp_init_regulator()
397 if (dev->pm_domain) { in adsp_pds_attach()
409 ret = PTR_ERR(devs[i]) ? : -ENODATA; in adsp_pds_attach()
417 for (i--; i >= 0; i--) in adsp_pds_attach()
423 static void adsp_pds_detach(struct qcom_adsp *adsp, struct device **pds, in adsp_pds_detach() argument
426 struct device *dev = adsp->dev; in adsp_pds_detach()
430 if (dev->pm_domain && pd_count) { in adsp_pds_detach()
439 static int adsp_alloc_memory_region(struct qcom_adsp *adsp) in adsp_alloc_memory_region() argument
445 node = of_parse_phandle(adsp->dev->of_node, "memory-region", 0); in adsp_alloc_memory_region()
447 dev_err(adsp->dev, "no memory-region specified\n"); in adsp_alloc_memory_region()
448 return -EINVAL; in adsp_alloc_memory_region()
455 adsp->mem_phys = adsp->mem_reloc = r.start; in adsp_alloc_memory_region()
456 adsp->mem_size = resource_size(&r); in adsp_alloc_memory_region()
457 adsp->mem_region = devm_ioremap_wc(adsp->dev, adsp->mem_phys, adsp->mem_size); in adsp_alloc_memory_region()
458 if (!adsp->mem_region) { in adsp_alloc_memory_region()
459 dev_err(adsp->dev, "unable to map memory region: %pa+%zx\n", in adsp_alloc_memory_region()
460 &r.start, adsp->mem_size); in adsp_alloc_memory_region()
461 return -EBUSY; in adsp_alloc_memory_region()
470 struct qcom_adsp *adsp; in adsp_probe() local
476 desc = of_device_get_match_data(&pdev->dev); in adsp_probe()
478 return -EINVAL; in adsp_probe()
481 return -EPROBE_DEFER; in adsp_probe()
483 fw_name = desc->firmware_name; in adsp_probe()
484 ret = of_property_read_string(pdev->dev.of_node, "firmware-name", in adsp_probe()
486 if (ret < 0 && ret != -EINVAL) in adsp_probe()
489 if (desc->minidump_id) in adsp_probe()
492 rproc = rproc_alloc(&pdev->dev, pdev->name, ops, fw_name, sizeof(*adsp)); in adsp_probe()
495 dev_err(&pdev->dev, "unable to allocate remoteproc\n"); in adsp_probe()
496 return -ENOMEM; in adsp_probe()
499 rproc->auto_boot = desc->auto_boot; in adsp_probe()
502 adsp = (struct qcom_adsp *)rproc->priv; in adsp_probe()
503 adsp->dev = &pdev->dev; in adsp_probe()
504 adsp->rproc = rproc; in adsp_probe()
505 adsp->minidump_id = desc->minidump_id; in adsp_probe()
506 adsp->pas_id = desc->pas_id; in adsp_probe()
507 adsp->has_aggre2_clk = desc->has_aggre2_clk; in adsp_probe()
508 adsp->info_name = desc->sysmon_name; in adsp_probe()
509 adsp->decrypt_shutdown = desc->decrypt_shutdown; in adsp_probe()
510 platform_set_drvdata(pdev, adsp); in adsp_probe()
512 ret = device_init_wakeup(adsp->dev, true); in adsp_probe()
516 ret = adsp_alloc_memory_region(adsp); in adsp_probe()
520 ret = adsp_init_clock(adsp); in adsp_probe()
524 ret = adsp_init_regulator(adsp); in adsp_probe()
528 ret = adsp_pds_attach(&pdev->dev, adsp->proxy_pds, in adsp_probe()
529 desc->proxy_pd_names); in adsp_probe()
532 adsp->proxy_pd_count = ret; in adsp_probe()
534 ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem, desc->load_state, in adsp_probe()
539 qcom_add_glink_subdev(rproc, &adsp->glink_subdev, desc->ssr_name); in adsp_probe()
540 qcom_add_smd_subdev(rproc, &adsp->smd_subdev); in adsp_probe()
541 qcom_add_ssr_subdev(rproc, &adsp->ssr_subdev, desc->ssr_name); in adsp_probe()
542 adsp->sysmon = qcom_add_sysmon_subdev(rproc, in adsp_probe()
543 desc->sysmon_name, in adsp_probe()
544 desc->ssctl_id); in adsp_probe()
545 if (IS_ERR(adsp->sysmon)) { in adsp_probe()
546 ret = PTR_ERR(adsp->sysmon); in adsp_probe()
557 adsp_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count); in adsp_probe()
566 struct qcom_adsp *adsp = platform_get_drvdata(pdev); in adsp_remove() local
568 rproc_del(adsp->rproc); in adsp_remove()
570 qcom_q6v5_deinit(&adsp->q6v5); in adsp_remove()
571 qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev); in adsp_remove()
572 qcom_remove_sysmon_subdev(adsp->sysmon); in adsp_remove()
573 qcom_remove_smd_subdev(adsp->rproc, &adsp->smd_subdev); in adsp_remove()
574 qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev); in adsp_remove()
575 rproc_free(adsp->rproc); in adsp_remove()
582 .firmware_name = "adsp.mdt",
587 .sysmon_name = "adsp",
593 .firmware_name = "adsp.mdt",
597 .load_state = "adsp",
599 .sysmon_name = "adsp",
605 .firmware_name = "adsp.mdt",
614 .load_state = "adsp",
616 .sysmon_name = "adsp",
622 .firmware_name = "adsp.mdt",
630 .load_state = "adsp",
632 .sysmon_name = "adsp",
638 .firmware_name = "adsp.mdt",
647 .load_state = "adsp",
649 .sysmon_name = "adsp",
655 .firmware_name = "adsp.mdt",
664 .load_state = "adsp",
666 .sysmon_name = "adsp",
672 .firmware_name = "adsp.mdt",
681 .sysmon_name = "adsp",
950 { .compatible = "qcom,msm8226-adsp-pil", .data = &adsp_resource_init},
951 { .compatible = "qcom,msm8974-adsp-pil", .data = &adsp_resource_init},
952 { .compatible = "qcom,msm8996-adsp-pil", .data = &msm8996_adsp_resource},
953 { .compatible = "qcom,msm8996-slpi-pil", .data = &slpi_resource_init},
954 { .compatible = "qcom,msm8998-adsp-pas", .data = &msm8996_adsp_resource},
955 { .compatible = "qcom,msm8998-slpi-pas", .data = &slpi_resource_init},
956 { .compatible = "qcom,qcs404-adsp-pas", .data = &adsp_resource_init },
957 { .compatible = "qcom,qcs404-cdsp-pas", .data = &cdsp_resource_init },
958 { .compatible = "qcom,qcs404-wcss-pas", .data = &wcss_resource_init },
959 { .compatible = "qcom,sc7180-mpss-pas", .data = &mpss_resource_init},
960 { .compatible = "qcom,sc7280-mpss-pas", .data = &mpss_resource_init},
961 { .compatible = "qcom,sc8180x-adsp-pas", .data = &sm8150_adsp_resource},
962 { .compatible = "qcom,sc8180x-cdsp-pas", .data = &sm8150_cdsp_resource},
963 { .compatible = "qcom,sc8180x-mpss-pas", .data = &sc8180x_mpss_resource},
964 { .compatible = "qcom,sc8280xp-adsp-pas", .data = &sm8250_adsp_resource},
965 { .compatible = "qcom,sc8280xp-nsp0-pas", .data = &sc8280xp_nsp0_resource},
966 { .compatible = "qcom,sc8280xp-nsp1-pas", .data = &sc8280xp_nsp1_resource},
967 { .compatible = "qcom,sdm660-adsp-pas", .data = &adsp_resource_init},
968 { .compatible = "qcom,sdm845-adsp-pas", .data = &sdm845_adsp_resource_init},
969 { .compatible = "qcom,sdm845-cdsp-pas", .data = &sdm845_cdsp_resource_init},
970 { .compatible = "qcom,sdx55-mpss-pas", .data = &sdx55_mpss_resource},
971 { .compatible = "qcom,sm6350-adsp-pas", .data = &sm6350_adsp_resource},
972 { .compatible = "qcom,sm6350-cdsp-pas", .data = &sm6350_cdsp_resource},
973 { .compatible = "qcom,sm6350-mpss-pas", .data = &mpss_resource_init},
974 { .compatible = "qcom,sm8150-adsp-pas", .data = &sm8150_adsp_resource},
975 { .compatible = "qcom,sm8150-cdsp-pas", .data = &sm8150_cdsp_resource},
976 { .compatible = "qcom,sm8150-mpss-pas", .data = &mpss_resource_init},
977 { .compatible = "qcom,sm8150-slpi-pas", .data = &sm8150_slpi_resource},
978 { .compatible = "qcom,sm8250-adsp-pas", .data = &sm8250_adsp_resource},
979 { .compatible = "qcom,sm8250-cdsp-pas", .data = &sm8250_cdsp_resource},
980 { .compatible = "qcom,sm8250-slpi-pas", .data = &sm8250_slpi_resource},
981 { .compatible = "qcom,sm8350-adsp-pas", .data = &sm8350_adsp_resource},
982 { .compatible = "qcom,sm8350-cdsp-pas", .data = &sm8350_cdsp_resource},
983 { .compatible = "qcom,sm8350-slpi-pas", .data = &sm8350_slpi_resource},
984 { .compatible = "qcom,sm8350-mpss-pas", .data = &mpss_resource_init},
985 { .compatible = "qcom,sm8450-adsp-pas", .data = &sm8350_adsp_resource},
986 { .compatible = "qcom,sm8450-cdsp-pas", .data = &sm8350_cdsp_resource},
987 { .compatible = "qcom,sm8450-slpi-pas", .data = &sm8350_slpi_resource},
988 { .compatible = "qcom,sm8450-mpss-pas", .data = &sm8450_mpss_resource},