Lines Matching +full:dt +full:- +full:mmio
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
22 #include <dt-bindings/firmware/imx/rsrc.h>
24 #include "../sof-of-dev.h"
25 #include "imx-common.h"
79 spin_lock_irqsave(&priv->sdev->ipc_lock, flags); in imx8_dsp_handle_reply()
80 snd_sof_ipc_process_reply(priv->sdev, 0); in imx8_dsp_handle_reply()
81 spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags); in imx8_dsp_handle_reply()
90 sof_mailbox_read(priv->sdev, priv->sdev->debug_box.offset + 4, &p, sizeof(p)); in imx8_dsp_handle_request()
94 snd_sof_dsp_panic(priv->sdev, p, true); in imx8_dsp_handle_request()
96 snd_sof_ipc_msgs_rx(priv->sdev); in imx8_dsp_handle_request()
106 struct imx8_priv *priv = sdev->pdata->hw_pdata; in imx8_send_msg()
108 sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data, in imx8_send_msg()
109 msg->msg_size); in imx8_send_msg()
110 imx_dsp_ring_doorbell(priv->dsp_ipc, 0); in imx8_send_msg()
120 struct imx8_priv *dsp_priv = sdev->pdata->hw_pdata; in imx8x_run()
123 ret = imx_sc_misc_set_control(dsp_priv->sc_ipc, IMX_SC_R_DSP, in imx8x_run()
126 dev_err(sdev->dev, "Error system address offset source select\n"); in imx8x_run()
130 ret = imx_sc_misc_set_control(dsp_priv->sc_ipc, IMX_SC_R_DSP, in imx8x_run()
133 dev_err(sdev->dev, "Error system address offset of AUDIO\n"); in imx8x_run()
137 ret = imx_sc_misc_set_control(dsp_priv->sc_ipc, IMX_SC_R_DSP, in imx8x_run()
140 dev_err(sdev->dev, "Error system address offset of PERIPH %d\n", in imx8x_run()
145 ret = imx_sc_misc_set_control(dsp_priv->sc_ipc, IMX_SC_R_DSP, in imx8x_run()
148 dev_err(sdev->dev, "Error system address offset of IRQ\n"); in imx8x_run()
152 imx_sc_pm_cpu_start(dsp_priv->sc_ipc, IMX_SC_R_DSP, true, in imx8x_run()
160 struct imx8_priv *dsp_priv = sdev->pdata->hw_pdata; in imx8_run()
163 ret = imx_sc_misc_set_control(dsp_priv->sc_ipc, IMX_SC_R_DSP, in imx8_run()
166 dev_err(sdev->dev, "Error system address offset source select\n"); in imx8_run()
170 imx_sc_pm_cpu_start(dsp_priv->sc_ipc, IMX_SC_R_DSP, true, in imx8_run()
179 container_of(sdev->dev, struct platform_device, dev); in imx8_probe()
180 struct device_node *np = pdev->dev.of_node; in imx8_probe()
182 struct resource *mmio; in imx8_probe() local
189 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in imx8_probe()
191 return -ENOMEM; in imx8_probe()
193 sdev->num_cores = 1; in imx8_probe()
194 sdev->pdata->hw_pdata = priv; in imx8_probe()
195 priv->dev = sdev->dev; in imx8_probe()
196 priv->sdev = sdev; in imx8_probe()
199 priv->num_domains = of_count_phandle_with_args(np, "power-domains", in imx8_probe()
200 "#power-domain-cells"); in imx8_probe()
201 if (priv->num_domains < 0) { in imx8_probe()
202 dev_err(sdev->dev, "no power-domains property in %pOF\n", np); in imx8_probe()
203 return priv->num_domains; in imx8_probe()
206 priv->pd_dev = devm_kmalloc_array(&pdev->dev, priv->num_domains, in imx8_probe()
207 sizeof(*priv->pd_dev), GFP_KERNEL); in imx8_probe()
208 if (!priv->pd_dev) in imx8_probe()
209 return -ENOMEM; in imx8_probe()
211 priv->link = devm_kmalloc_array(&pdev->dev, priv->num_domains, in imx8_probe()
212 sizeof(*priv->link), GFP_KERNEL); in imx8_probe()
213 if (!priv->link) in imx8_probe()
214 return -ENOMEM; in imx8_probe()
216 for (i = 0; i < priv->num_domains; i++) { in imx8_probe()
217 priv->pd_dev[i] = dev_pm_domain_attach_by_id(&pdev->dev, i); in imx8_probe()
218 if (IS_ERR(priv->pd_dev[i])) { in imx8_probe()
219 ret = PTR_ERR(priv->pd_dev[i]); in imx8_probe()
222 priv->link[i] = device_link_add(&pdev->dev, priv->pd_dev[i], in imx8_probe()
226 if (!priv->link[i]) { in imx8_probe()
227 ret = -ENOMEM; in imx8_probe()
228 dev_pm_domain_detach(priv->pd_dev[i], false); in imx8_probe()
233 ret = imx_scu_get_handle(&priv->sc_ipc); in imx8_probe()
235 dev_err(sdev->dev, "Cannot obtain SCU handle (err = %d)\n", in imx8_probe()
240 priv->ipc_dev = platform_device_register_data(sdev->dev, "imx-dsp", in imx8_probe()
243 if (IS_ERR(priv->ipc_dev)) { in imx8_probe()
244 ret = PTR_ERR(priv->ipc_dev); in imx8_probe()
248 priv->dsp_ipc = dev_get_drvdata(&priv->ipc_dev->dev); in imx8_probe()
249 if (!priv->dsp_ipc) { in imx8_probe()
251 ret = -EPROBE_DEFER; in imx8_probe()
252 dev_err(sdev->dev, "Failed to get drvdata\n"); in imx8_probe()
256 imx_dsp_set_data(priv->dsp_ipc, priv); in imx8_probe()
257 priv->dsp_ipc->ops = &dsp_ops; in imx8_probe()
260 mmio = platform_get_resource(pdev, IORESOURCE_MEM, 0); in imx8_probe()
261 if (mmio) { in imx8_probe()
262 base = mmio->start; in imx8_probe()
263 size = resource_size(mmio); in imx8_probe()
265 dev_err(sdev->dev, "error: failed to get DSP base at idx 0\n"); in imx8_probe()
266 ret = -EINVAL; in imx8_probe()
270 sdev->bar[SOF_FW_BLK_TYPE_IRAM] = devm_ioremap(sdev->dev, base, size); in imx8_probe()
271 if (!sdev->bar[SOF_FW_BLK_TYPE_IRAM]) { in imx8_probe()
272 dev_err(sdev->dev, "failed to ioremap base 0x%x size 0x%x\n", in imx8_probe()
274 ret = -ENODEV; in imx8_probe()
277 sdev->mmio_bar = SOF_FW_BLK_TYPE_IRAM; in imx8_probe()
279 res_node = of_parse_phandle(np, "memory-region", 0); in imx8_probe()
281 dev_err(&pdev->dev, "failed to get memory region node\n"); in imx8_probe()
282 ret = -ENODEV; in imx8_probe()
289 dev_err(&pdev->dev, "failed to get reserved region address\n"); in imx8_probe()
293 sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap_wc(sdev->dev, res.start, in imx8_probe()
295 if (!sdev->bar[SOF_FW_BLK_TYPE_SRAM]) { in imx8_probe()
296 dev_err(sdev->dev, "failed to ioremap mem 0x%x size 0x%x\n", in imx8_probe()
298 ret = -ENOMEM; in imx8_probe()
301 sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM; in imx8_probe()
304 sdev->dsp_box.offset = MBOX_OFFSET; in imx8_probe()
306 ret = devm_clk_bulk_get_all(sdev->dev, &priv->clks); in imx8_probe()
308 dev_err(sdev->dev, "failed to fetch clocks: %d\n", ret); in imx8_probe()
311 priv->clk_num = ret; in imx8_probe()
313 ret = clk_bulk_prepare_enable(priv->clk_num, priv->clks); in imx8_probe()
315 dev_err(sdev->dev, "failed to enable clocks: %d\n", ret); in imx8_probe()
322 platform_device_unregister(priv->ipc_dev); in imx8_probe()
324 while (--i >= 0) { in imx8_probe()
325 device_link_del(priv->link[i]); in imx8_probe()
326 dev_pm_domain_detach(priv->pd_dev[i], false); in imx8_probe()
334 struct imx8_priv *priv = sdev->pdata->hw_pdata; in imx8_remove()
337 clk_bulk_disable_unprepare(priv->clk_num, priv->clks); in imx8_remove()
338 platform_device_unregister(priv->ipc_dev); in imx8_remove()
340 for (i = 0; i < priv->num_domains; i++) { in imx8_remove()
341 device_link_del(priv->link[i]); in imx8_remove()
342 dev_pm_domain_detach(priv->pd_dev[i], false); in imx8_remove()
355 return -EINVAL; in imx8_get_bar_index()
362 struct imx8_priv *priv = (struct imx8_priv *)sdev->pdata->hw_pdata; in imx8_suspend()
365 imx_dsp_free_channel(priv->dsp_ipc, i); in imx8_suspend()
367 clk_bulk_disable_unprepare(priv->clk_num, priv->clks); in imx8_suspend()
372 struct imx8_priv *priv = (struct imx8_priv *)sdev->pdata->hw_pdata; in imx8_resume()
376 ret = clk_bulk_prepare_enable(priv->clk_num, priv->clks); in imx8_resume()
378 dev_err(sdev->dev, "failed to enable clocks: %d\n", ret); in imx8_resume()
383 imx_dsp_request_channel(priv->dsp_ipc, i); in imx8_resume()
419 if (!pm_runtime_suspended(sdev->dev)) in imx8_dsp_suspend()
436 if (pm_runtime_suspended(sdev->dev)) { in imx8_dsp_resume()
437 pm_runtime_disable(sdev->dev); in imx8_dsp_resume()
438 pm_runtime_set_active(sdev->dev); in imx8_dsp_resume()
439 pm_runtime_mark_last_busy(sdev->dev); in imx8_dsp_resume()
440 pm_runtime_enable(sdev->dev); in imx8_dsp_resume()
441 pm_runtime_idle(sdev->dev); in imx8_dsp_resume()
475 sdev->dsp_power_state = *target_state; in imx8_dsp_set_power_state()
605 .compatible = "fsl,imx8qxp-mek",
606 .sof_tplg_filename = "sof-imx8-wm8960.tplg",
607 .drv_name = "asoc-audio-graph-card2",
610 .compatible = "fsl,imx8qm-mek",
611 .sof_tplg_filename = "sof-imx8-wm8960.tplg",
612 .drv_name = "asoc-audio-graph-card2",
625 [SOF_IPC_TYPE_3] = "imx/sof-tplg",
628 [SOF_IPC_TYPE_3] = "sof-imx8x.ri",
630 .nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
642 [SOF_IPC_TYPE_3] = "imx/sof-tplg",
645 [SOF_IPC_TYPE_3] = "sof-imx8.ri",
647 .nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
652 { .compatible = "fsl,imx8qxp-dsp", .data = &sof_of_imx8qxp_desc},
653 { .compatible = "fsl,imx8qm-dsp", .data = &sof_of_imx8qm_desc},
658 /* DT driver definition */
663 .name = "sof-audio-of-imx8",