Lines Matching +full:qcs404 +full:- +full:bimc
1 // SPDX-License-Identifier: GPL-2.0
108 val = readl(adsp->qdsp6ss_base + RET_CFG_REG); in qcom_adsp_shutdown()
110 writel(val, adsp->qdsp6ss_base + RET_CFG_REG); in qcom_adsp_shutdown()
112 clk_bulk_disable_unprepare(adsp->num_clks, adsp->clks); in qcom_adsp_shutdown()
115 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
116 adsp->halt_lpass + LPASS_PWR_ON_REG, &val); in qcom_adsp_shutdown()
120 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
121 adsp->halt_lpass + LPASS_MASTER_IDLE_REG, in qcom_adsp_shutdown()
126 regmap_write(adsp->halt_map, in qcom_adsp_shutdown()
127 adsp->halt_lpass + LPASS_HALTREQ_REG, 1); in qcom_adsp_shutdown()
132 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
133 adsp->halt_lpass + LPASS_HALTACK_REG, &val); in qcom_adsp_shutdown()
140 ret = regmap_read(adsp->halt_map, in qcom_adsp_shutdown()
141 adsp->halt_lpass + LPASS_MASTER_IDLE_REG, &val); in qcom_adsp_shutdown()
143 dev_err(adsp->dev, "port failed halt\n"); in qcom_adsp_shutdown()
147 reset_control_assert(adsp->pdc_sync_reset); in qcom_adsp_shutdown()
149 reset_control_assert(adsp->restart); in qcom_adsp_shutdown()
154 regmap_write(adsp->halt_map, adsp->halt_lpass + LPASS_HALTREQ_REG, 0); in qcom_adsp_shutdown()
156 /* De-assert the LPASS PDC Reset */ in qcom_adsp_shutdown()
157 reset_control_deassert(adsp->pdc_sync_reset); in qcom_adsp_shutdown()
159 reset_control_deassert(adsp->restart); in qcom_adsp_shutdown()
160 /* wait after de-asserting subsystem restart from AOSS */ in qcom_adsp_shutdown()
168 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_load()
171 ret = qcom_mdt_load_no_init(adsp->dev, fw, rproc->firmware, 0, in adsp_load()
172 adsp->mem_region, adsp->mem_phys, in adsp_load()
173 adsp->mem_size, &adsp->mem_reloc); in adsp_load()
177 qcom_pil_info_store(adsp->info_name, adsp->mem_phys, adsp->mem_size); in adsp_load()
184 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_start()
188 qcom_q6v5_prepare(&adsp->q6v5); in adsp_start()
190 ret = clk_prepare_enable(adsp->xo); in adsp_start()
194 dev_pm_genpd_set_performance_state(adsp->dev, INT_MAX); in adsp_start()
195 ret = pm_runtime_get_sync(adsp->dev); in adsp_start()
199 ret = clk_bulk_prepare_enable(adsp->num_clks, adsp->clks); in adsp_start()
201 dev_err(adsp->dev, "adsp clk_enable failed\n"); in adsp_start()
206 writel(1, adsp->qdsp6ss_base + QDSP6SS_XO_CBCR); in adsp_start()
209 writel(1, adsp->qdsp6ss_base + QDSP6SS_SLEEP_CBCR); in adsp_start()
212 writel(1, adsp->qdsp6ss_base + QDSP6SS_CORE_CBCR); in adsp_start()
215 writel(adsp->mem_phys >> 4, adsp->qdsp6ss_base + RST_EVB_REG); in adsp_start()
217 /* De-assert QDSP6 stop core. QDSP6 will execute after out of reset */ in adsp_start()
218 writel(0x1, adsp->qdsp6ss_base + CORE_START_REG); in adsp_start()
221 writel(0x1, adsp->qdsp6ss_base + BOOT_CMD_REG); in adsp_start()
224 ret = readl_poll_timeout(adsp->qdsp6ss_base + BOOT_STATUS_REG, in adsp_start()
227 dev_err(adsp->dev, "failed to bootup adsp\n"); in adsp_start()
231 ret = qcom_q6v5_wait_for_start(&adsp->q6v5, msecs_to_jiffies(5 * HZ)); in adsp_start()
232 if (ret == -ETIMEDOUT) { in adsp_start()
233 dev_err(adsp->dev, "start timed out\n"); in adsp_start()
240 clk_bulk_disable_unprepare(adsp->num_clks, adsp->clks); in adsp_start()
242 dev_pm_genpd_set_performance_state(adsp->dev, 0); in adsp_start()
243 pm_runtime_put(adsp->dev); in adsp_start()
245 clk_disable_unprepare(adsp->xo); in adsp_start()
247 qcom_q6v5_unprepare(&adsp->q6v5); in adsp_start()
256 clk_disable_unprepare(adsp->xo); in qcom_adsp_pil_handover()
257 dev_pm_genpd_set_performance_state(adsp->dev, 0); in qcom_adsp_pil_handover()
258 pm_runtime_put(adsp->dev); in qcom_adsp_pil_handover()
263 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_stop()
267 ret = qcom_q6v5_request_stop(&adsp->q6v5); in adsp_stop()
268 if (ret == -ETIMEDOUT) in adsp_stop()
269 dev_err(adsp->dev, "timed out on wait\n"); in adsp_stop()
273 dev_err(adsp->dev, "failed to shutdown: %d\n", ret); in adsp_stop()
275 handover = qcom_q6v5_unprepare(&adsp->q6v5); in adsp_stop()
277 qcom_adsp_pil_handover(&adsp->q6v5); in adsp_stop()
284 struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv; in adsp_da_to_va()
287 offset = da - adsp->mem_reloc; in adsp_da_to_va()
288 if (offset < 0 || offset + len > adsp->mem_size) in adsp_da_to_va()
291 return adsp->mem_region + offset; in adsp_da_to_va()
296 struct qcom_adsp *adsp = rproc->priv; in adsp_panic()
298 return qcom_q6v5_panic(&adsp->q6v5); in adsp_panic()
315 adsp->xo = devm_clk_get(adsp->dev, "xo"); in adsp_init_clock()
316 if (IS_ERR(adsp->xo)) { in adsp_init_clock()
317 ret = PTR_ERR(adsp->xo); in adsp_init_clock()
318 if (ret != -EPROBE_DEFER) in adsp_init_clock()
319 dev_err(adsp->dev, "failed to get xo clock"); in adsp_init_clock()
326 adsp->num_clks = num_clks; in adsp_init_clock()
327 adsp->clks = devm_kcalloc(adsp->dev, adsp->num_clks, in adsp_init_clock()
328 sizeof(*adsp->clks), GFP_KERNEL); in adsp_init_clock()
329 if (!adsp->clks) in adsp_init_clock()
330 return -ENOMEM; in adsp_init_clock()
332 for (i = 0; i < adsp->num_clks; i++) in adsp_init_clock()
333 adsp->clks[i].id = clk_ids[i]; in adsp_init_clock()
335 return devm_clk_bulk_get(adsp->dev, adsp->num_clks, adsp->clks); in adsp_init_clock()
340 adsp->pdc_sync_reset = devm_reset_control_get_optional_exclusive(adsp->dev, in adsp_init_reset()
342 if (IS_ERR(adsp->pdc_sync_reset)) { in adsp_init_reset()
343 dev_err(adsp->dev, "failed to acquire pdc_sync reset\n"); in adsp_init_reset()
344 return PTR_ERR(adsp->pdc_sync_reset); in adsp_init_reset()
347 adsp->restart = devm_reset_control_get_optional_exclusive(adsp->dev, "restart"); in adsp_init_reset()
350 if (!adsp->restart) in adsp_init_reset()
351 adsp->restart = devm_reset_control_get_exclusive(adsp->dev, "cc_lpass"); in adsp_init_reset()
353 if (IS_ERR(adsp->restart)) { in adsp_init_reset()
354 dev_err(adsp->dev, "failed to acquire restart\n"); in adsp_init_reset()
355 return PTR_ERR(adsp->restart); in adsp_init_reset()
369 adsp->qdsp6ss_base = devm_ioremap(&pdev->dev, res->start, in adsp_init_mmio()
371 if (!adsp->qdsp6ss_base) { in adsp_init_mmio()
372 dev_err(adsp->dev, "failed to map QDSP6SS registers\n"); in adsp_init_mmio()
373 return -ENOMEM; in adsp_init_mmio()
376 syscon = of_parse_phandle(pdev->dev.of_node, "qcom,halt-regs", 0); in adsp_init_mmio()
378 dev_err(&pdev->dev, "failed to parse qcom,halt-regs\n"); in adsp_init_mmio()
379 return -EINVAL; in adsp_init_mmio()
382 adsp->halt_map = syscon_node_to_regmap(syscon); in adsp_init_mmio()
384 if (IS_ERR(adsp->halt_map)) in adsp_init_mmio()
385 return PTR_ERR(adsp->halt_map); in adsp_init_mmio()
387 ret = of_property_read_u32_index(pdev->dev.of_node, "qcom,halt-regs", in adsp_init_mmio()
388 1, &adsp->halt_lpass); in adsp_init_mmio()
390 dev_err(&pdev->dev, "no offset in syscon\n"); in adsp_init_mmio()
403 node = of_parse_phandle(adsp->dev->of_node, "memory-region", 0); in adsp_alloc_memory_region()
405 dev_err(adsp->dev, "no memory-region specified\n"); in adsp_alloc_memory_region()
406 return -EINVAL; in adsp_alloc_memory_region()
413 adsp->mem_phys = adsp->mem_reloc = r.start; in adsp_alloc_memory_region()
414 adsp->mem_size = resource_size(&r); in adsp_alloc_memory_region()
415 adsp->mem_region = devm_ioremap_wc(adsp->dev, in adsp_alloc_memory_region()
416 adsp->mem_phys, adsp->mem_size); in adsp_alloc_memory_region()
417 if (!adsp->mem_region) { in adsp_alloc_memory_region()
418 dev_err(adsp->dev, "unable to map memory region: %pa+%zx\n", in adsp_alloc_memory_region()
419 &r.start, adsp->mem_size); in adsp_alloc_memory_region()
420 return -EBUSY; in adsp_alloc_memory_region()
433 desc = of_device_get_match_data(&pdev->dev); in adsp_probe()
435 return -EINVAL; in adsp_probe()
437 rproc = rproc_alloc(&pdev->dev, pdev->name, &adsp_ops, in adsp_probe()
438 desc->firmware_name, sizeof(*adsp)); in adsp_probe()
440 dev_err(&pdev->dev, "unable to allocate remoteproc\n"); in adsp_probe()
441 return -ENOMEM; in adsp_probe()
445 adsp = (struct qcom_adsp *)rproc->priv; in adsp_probe()
446 adsp->dev = &pdev->dev; in adsp_probe()
447 adsp->rproc = rproc; in adsp_probe()
448 adsp->info_name = desc->sysmon_name; in adsp_probe()
455 ret = adsp_init_clock(adsp, desc->clk_ids); in adsp_probe()
459 pm_runtime_enable(adsp->dev); in adsp_probe()
469 ret = qcom_q6v5_init(&adsp->q6v5, pdev, rproc, desc->crash_reason_smem, in adsp_probe()
474 qcom_add_glink_subdev(rproc, &adsp->glink_subdev, desc->ssr_name); in adsp_probe()
475 qcom_add_ssr_subdev(rproc, &adsp->ssr_subdev, desc->ssr_name); in adsp_probe()
476 adsp->sysmon = qcom_add_sysmon_subdev(rproc, in adsp_probe()
477 desc->sysmon_name, in adsp_probe()
478 desc->ssctl_id); in adsp_probe()
479 if (IS_ERR(adsp->sysmon)) { in adsp_probe()
480 ret = PTR_ERR(adsp->sysmon); in adsp_probe()
491 pm_runtime_disable(adsp->dev); in adsp_probe()
502 rproc_del(adsp->rproc); in adsp_remove()
504 qcom_remove_glink_subdev(adsp->rproc, &adsp->glink_subdev); in adsp_remove()
505 qcom_remove_sysmon_subdev(adsp->sysmon); in adsp_remove()
506 qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev); in adsp_remove()
507 pm_runtime_disable(adsp->dev); in adsp_remove()
508 rproc_free(adsp->rproc); in adsp_remove()
533 "sway", "tbu", "bimc", "ahb_aon", "q6ss_slave", "q6ss_master",
540 { .compatible = "qcom,qcs404-cdsp-pil", .data = &cdsp_resource_init },
541 { .compatible = "qcom,sdm845-adsp-pil", .data = &adsp_resource_init },