Lines Matching +full:dsp +full:- +full:reset
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
7 // Hardware interface for audio DSP on i.MX8M
20 #include <linux/firmware/imx/dsp.h>
23 #include "../sof-of-dev.h"
24 #include "imx-common.h"
35 /* DSP audio mix registers */
47 /* DSP IPC handler */
73 spin_lock_irqsave(&priv->sdev->ipc_lock, flags); in imx8m_dsp_handle_reply()
74 snd_sof_ipc_process_reply(priv->sdev, 0); in imx8m_dsp_handle_reply()
75 spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags); in imx8m_dsp_handle_reply()
84 sof_mailbox_read(priv->sdev, priv->sdev->debug_box.offset + 4, &p, sizeof(p)); in imx8m_dsp_handle_request()
88 snd_sof_dsp_panic(priv->sdev, p, true); in imx8m_dsp_handle_request()
90 snd_sof_ipc_msgs_rx(priv->sdev); in imx8m_dsp_handle_request()
100 struct imx8m_priv *priv = sdev->pdata->hw_pdata; in imx8m_send_msg()
102 sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data, in imx8m_send_msg()
103 msg->msg_size); in imx8m_send_msg()
104 imx_dsp_ring_doorbell(priv->dsp_ipc, 0); in imx8m_send_msg()
110 * DSP control.
114 struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; in imx8m_run()
116 regmap_update_bits(priv->regmap, AudioDSP_REG2, AudioDSP_REG2_RUNSTALL, 0); in imx8m_run()
123 struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; in imx8m_reset()
126 /* put DSP into reset and stall */ in imx8m_reset()
127 pwrctl = readl(priv->dap + IMX8M_DAP_PWRCTL); in imx8m_reset()
129 writel(pwrctl, priv->dap + IMX8M_DAP_PWRCTL); in imx8m_reset()
131 /* keep reset asserted for 10 cycles */ in imx8m_reset()
134 regmap_update_bits(priv->regmap, AudioDSP_REG2, in imx8m_reset()
137 /* take the DSP out of reset and keep stalled for FW loading */ in imx8m_reset()
138 pwrctl = readl(priv->dap + IMX8M_DAP_PWRCTL); in imx8m_reset()
140 writel(pwrctl, priv->dap + IMX8M_DAP_PWRCTL); in imx8m_reset()
148 container_of(sdev->dev, struct platform_device, dev); in imx8m_probe()
149 struct device_node *np = pdev->dev.of_node; in imx8m_probe()
157 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in imx8m_probe()
159 return -ENOMEM; in imx8m_probe()
161 sdev->num_cores = 1; in imx8m_probe()
162 sdev->pdata->hw_pdata = priv; in imx8m_probe()
163 priv->dev = sdev->dev; in imx8m_probe()
164 priv->sdev = sdev; in imx8m_probe()
166 priv->ipc_dev = platform_device_register_data(sdev->dev, "imx-dsp", in imx8m_probe()
169 if (IS_ERR(priv->ipc_dev)) in imx8m_probe()
170 return PTR_ERR(priv->ipc_dev); in imx8m_probe()
172 priv->dsp_ipc = dev_get_drvdata(&priv->ipc_dev->dev); in imx8m_probe()
173 if (!priv->dsp_ipc) { in imx8m_probe()
174 /* DSP IPC driver not probed yet, try later */ in imx8m_probe()
175 ret = -EPROBE_DEFER; in imx8m_probe()
176 dev_err(sdev->dev, "Failed to get drvdata\n"); in imx8m_probe()
180 imx_dsp_set_data(priv->dsp_ipc, priv); in imx8m_probe()
181 priv->dsp_ipc->ops = &imx8m_dsp_ops; in imx8m_probe()
183 /* DSP base */ in imx8m_probe()
186 base = mmio->start; in imx8m_probe()
189 dev_err(sdev->dev, "error: failed to get DSP base at idx 0\n"); in imx8m_probe()
190 ret = -EINVAL; in imx8m_probe()
194 priv->dap = devm_ioremap(sdev->dev, IMX8M_DAP_DEBUG, IMX8M_DAP_DEBUG_SIZE); in imx8m_probe()
195 if (!priv->dap) { in imx8m_probe()
196 dev_err(sdev->dev, "error: failed to map DAP debug memory area"); in imx8m_probe()
197 ret = -ENODEV; in imx8m_probe()
201 sdev->bar[SOF_FW_BLK_TYPE_IRAM] = devm_ioremap(sdev->dev, base, size); in imx8m_probe()
202 if (!sdev->bar[SOF_FW_BLK_TYPE_IRAM]) { in imx8m_probe()
203 dev_err(sdev->dev, "failed to ioremap base 0x%x size 0x%x\n", in imx8m_probe()
205 ret = -ENODEV; in imx8m_probe()
208 sdev->mmio_bar = SOF_FW_BLK_TYPE_IRAM; in imx8m_probe()
210 res_node = of_parse_phandle(np, "memory-region", 0); in imx8m_probe()
212 dev_err(&pdev->dev, "failed to get memory region node\n"); in imx8m_probe()
213 ret = -ENODEV; in imx8m_probe()
220 dev_err(&pdev->dev, "failed to get reserved region address\n"); in imx8m_probe()
224 sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap_wc(sdev->dev, res.start, in imx8m_probe()
226 if (!sdev->bar[SOF_FW_BLK_TYPE_SRAM]) { in imx8m_probe()
227 dev_err(sdev->dev, "failed to ioremap mem 0x%x size 0x%x\n", in imx8m_probe()
229 ret = -ENOMEM; in imx8m_probe()
232 sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM; in imx8m_probe()
235 sdev->dsp_box.offset = MBOX_OFFSET; in imx8m_probe()
237 priv->regmap = syscon_regmap_lookup_by_phandle(np, "fsl,dsp-ctrl"); in imx8m_probe()
238 if (IS_ERR(priv->regmap)) { in imx8m_probe()
239 dev_err(sdev->dev, "cannot find dsp-ctrl registers"); in imx8m_probe()
240 ret = PTR_ERR(priv->regmap); in imx8m_probe()
244 ret = devm_clk_bulk_get_all(sdev->dev, &priv->clks); in imx8m_probe()
246 dev_err(sdev->dev, "failed to fetch clocks: %d\n", ret); in imx8m_probe()
249 priv->clk_num = ret; in imx8m_probe()
251 ret = clk_bulk_prepare_enable(priv->clk_num, priv->clks); in imx8m_probe()
253 dev_err(sdev->dev, "failed to enable clocks: %d\n", ret); in imx8m_probe()
260 platform_device_unregister(priv->ipc_dev); in imx8m_probe()
266 struct imx8m_priv *priv = sdev->pdata->hw_pdata; in imx8m_remove()
268 clk_bulk_disable_unprepare(priv->clk_num, priv->clks); in imx8m_remove()
269 platform_device_unregister(priv->ipc_dev); in imx8m_remove()
281 return -EINVAL; in imx8m_get_bar_index()
320 sdev->dsp_power_state = *target_state; in imx8m_dsp_set_power_state()
327 struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; in imx8m_resume()
331 ret = clk_bulk_prepare_enable(priv->clk_num, priv->clks); in imx8m_resume()
333 dev_err(sdev->dev, "failed to enable clocks: %d\n", ret); in imx8m_resume()
338 imx_dsp_request_channel(priv->dsp_ipc, i); in imx8m_resume()
345 struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; in imx8m_suspend()
349 imx_dsp_free_channel(priv->dsp_ipc, i); in imx8m_suspend()
351 clk_bulk_disable_unprepare(priv->clk_num, priv->clks); in imx8m_suspend()
390 if (pm_runtime_suspended(sdev->dev)) { in imx8m_dsp_resume()
391 pm_runtime_disable(sdev->dev); in imx8m_dsp_resume()
392 pm_runtime_set_active(sdev->dev); in imx8m_dsp_resume()
393 pm_runtime_mark_last_busy(sdev->dev); in imx8m_dsp_resume()
394 pm_runtime_enable(sdev->dev); in imx8m_dsp_resume()
395 pm_runtime_idle(sdev->dev); in imx8m_dsp_resume()
407 if (!pm_runtime_suspended(sdev->dev)) in imx8m_dsp_suspend()
418 /* DSP core boot */
420 .reset = imx8m_reset,
475 .compatible = "fsl,imx8mp-evk",
476 .sof_tplg_filename = "sof-imx8mp-wm8960.tplg",
477 .drv_name = "asoc-audio-graph-card2",
490 [SOF_IPC_TYPE_3] = "imx/sof-tplg",
493 [SOF_IPC_TYPE_3] = "sof-imx8m.ri",
495 .nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
500 { .compatible = "fsl,imx8mp-dsp", .data = &sof_of_imx8mp_desc},
510 .name = "sof-audio-of-imx8m",