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"
41 /* DSP audio mix registers */
53 /* DSP IPC handler */
78 spin_lock_irqsave(&priv->sdev->ipc_lock, flags); in imx8m_dsp_handle_reply()
79 snd_sof_ipc_process_reply(priv->sdev, 0); in imx8m_dsp_handle_reply()
80 spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags); in imx8m_dsp_handle_reply()
89 sof_mailbox_read(priv->sdev, priv->sdev->debug_box.offset + 4, &p, sizeof(p)); in imx8m_dsp_handle_request()
93 snd_sof_dsp_panic(priv->sdev, p, true); in imx8m_dsp_handle_request()
95 snd_sof_ipc_msgs_rx(priv->sdev); in imx8m_dsp_handle_request()
105 struct imx8m_priv *priv = sdev->pdata->hw_pdata; in imx8m_send_msg()
107 sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data, in imx8m_send_msg()
108 msg->msg_size); in imx8m_send_msg()
109 imx_dsp_ring_doorbell(priv->dsp_ipc, 0); in imx8m_send_msg()
115 * DSP control.
119 struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; in imx8m_run()
121 regmap_update_bits(priv->regmap, AudioDSP_REG2, AudioDSP_REG2_RUNSTALL, 0); in imx8m_run()
128 struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; in imx8m_reset()
131 /* put DSP into reset and stall */ in imx8m_reset()
132 pwrctl = readl(priv->dap + IMX8M_DAP_PWRCTL); in imx8m_reset()
134 writel(pwrctl, priv->dap + IMX8M_DAP_PWRCTL); in imx8m_reset()
136 /* keep reset asserted for 10 cycles */ in imx8m_reset()
139 regmap_update_bits(priv->regmap, AudioDSP_REG2, in imx8m_reset()
142 /* take the DSP out of reset and keep stalled for FW loading */ in imx8m_reset()
143 pwrctl = readl(priv->dap + IMX8M_DAP_PWRCTL); in imx8m_reset()
145 writel(pwrctl, priv->dap + IMX8M_DAP_PWRCTL); in imx8m_reset()
153 container_of(sdev->dev, struct platform_device, dev); in imx8m_probe()
154 struct device_node *np = pdev->dev.of_node; in imx8m_probe()
162 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in imx8m_probe()
164 return -ENOMEM; in imx8m_probe()
166 priv->clks = devm_kzalloc(&pdev->dev, sizeof(*priv->clks), GFP_KERNEL); in imx8m_probe()
167 if (!priv->clks) in imx8m_probe()
168 return -ENOMEM; in imx8m_probe()
170 sdev->num_cores = 1; in imx8m_probe()
171 sdev->pdata->hw_pdata = priv; in imx8m_probe()
172 priv->dev = sdev->dev; in imx8m_probe()
173 priv->sdev = sdev; in imx8m_probe()
175 priv->ipc_dev = platform_device_register_data(sdev->dev, "imx-dsp", in imx8m_probe()
178 if (IS_ERR(priv->ipc_dev)) in imx8m_probe()
179 return PTR_ERR(priv->ipc_dev); in imx8m_probe()
181 priv->dsp_ipc = dev_get_drvdata(&priv->ipc_dev->dev); in imx8m_probe()
182 if (!priv->dsp_ipc) { in imx8m_probe()
183 /* DSP IPC driver not probed yet, try later */ in imx8m_probe()
184 ret = -EPROBE_DEFER; in imx8m_probe()
185 dev_err(sdev->dev, "Failed to get drvdata\n"); in imx8m_probe()
189 imx_dsp_set_data(priv->dsp_ipc, priv); in imx8m_probe()
190 priv->dsp_ipc->ops = &imx8m_dsp_ops; in imx8m_probe()
192 /* DSP base */ in imx8m_probe()
195 base = mmio->start; in imx8m_probe()
198 dev_err(sdev->dev, "error: failed to get DSP base at idx 0\n"); in imx8m_probe()
199 ret = -EINVAL; in imx8m_probe()
203 priv->dap = devm_ioremap(sdev->dev, IMX8M_DAP_DEBUG, IMX8M_DAP_DEBUG_SIZE); in imx8m_probe()
204 if (!priv->dap) { in imx8m_probe()
205 dev_err(sdev->dev, "error: failed to map DAP debug memory area"); in imx8m_probe()
206 ret = -ENODEV; in imx8m_probe()
210 sdev->bar[SOF_FW_BLK_TYPE_IRAM] = devm_ioremap(sdev->dev, base, size); in imx8m_probe()
211 if (!sdev->bar[SOF_FW_BLK_TYPE_IRAM]) { in imx8m_probe()
212 dev_err(sdev->dev, "failed to ioremap base 0x%x size 0x%x\n", in imx8m_probe()
214 ret = -ENODEV; in imx8m_probe()
217 sdev->mmio_bar = SOF_FW_BLK_TYPE_IRAM; in imx8m_probe()
219 res_node = of_parse_phandle(np, "memory-region", 0); in imx8m_probe()
221 dev_err(&pdev->dev, "failed to get memory region node\n"); in imx8m_probe()
222 ret = -ENODEV; in imx8m_probe()
229 dev_err(&pdev->dev, "failed to get reserved region address\n"); in imx8m_probe()
233 sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap_wc(sdev->dev, res.start, in imx8m_probe()
235 if (!sdev->bar[SOF_FW_BLK_TYPE_SRAM]) { in imx8m_probe()
236 dev_err(sdev->dev, "failed to ioremap mem 0x%x size 0x%x\n", in imx8m_probe()
238 ret = -ENOMEM; in imx8m_probe()
241 sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM; in imx8m_probe()
244 sdev->dsp_box.offset = MBOX_OFFSET; in imx8m_probe()
246 priv->regmap = syscon_regmap_lookup_by_phandle(np, "fsl,dsp-ctrl"); in imx8m_probe()
247 if (IS_ERR(priv->regmap)) { in imx8m_probe()
248 dev_err(sdev->dev, "cannot find dsp-ctrl registers"); in imx8m_probe()
249 ret = PTR_ERR(priv->regmap); in imx8m_probe()
254 priv->clks->dsp_clks = imx8m_dsp_clks; in imx8m_probe()
255 priv->clks->num_dsp_clks = ARRAY_SIZE(imx8m_dsp_clks); in imx8m_probe()
257 ret = imx8_parse_clocks(sdev, priv->clks); in imx8m_probe()
261 ret = imx8_enable_clocks(sdev, priv->clks); in imx8m_probe()
268 platform_device_unregister(priv->ipc_dev); in imx8m_probe()
274 struct imx8m_priv *priv = sdev->pdata->hw_pdata; in imx8m_remove()
276 imx8_disable_clocks(sdev, priv->clks); in imx8m_remove()
277 platform_device_unregister(priv->ipc_dev); in imx8m_remove()
291 return -EINVAL; in imx8m_get_bar_index()
323 sdev->dsp_power_state = *target_state; in imx8m_dsp_set_power_state()
330 struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; in imx8m_resume()
334 ret = imx8_enable_clocks(sdev, priv->clks); in imx8m_resume()
339 imx_dsp_request_channel(priv->dsp_ipc, i); in imx8m_resume()
346 struct imx8m_priv *priv = (struct imx8m_priv *)sdev->pdata->hw_pdata; in imx8m_suspend()
350 imx_dsp_free_channel(priv->dsp_ipc, i); in imx8m_suspend()
352 imx8_disable_clocks(sdev, priv->clks); in imx8m_suspend()
391 if (pm_runtime_suspended(sdev->dev)) { in imx8m_dsp_resume()
392 pm_runtime_disable(sdev->dev); in imx8m_dsp_resume()
393 pm_runtime_set_active(sdev->dev); in imx8m_dsp_resume()
394 pm_runtime_mark_last_busy(sdev->dev); in imx8m_dsp_resume()
395 pm_runtime_enable(sdev->dev); in imx8m_dsp_resume()
396 pm_runtime_idle(sdev->dev); in imx8m_dsp_resume()
408 if (!pm_runtime_suspended(sdev->dev)) in imx8m_dsp_suspend()
419 /* DSP core boot */
421 .reset = imx8m_reset,
480 [SOF_IPC] = "imx/sof-tplg",
483 [SOF_IPC] = "sof-imx8m.ri",
485 .nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
490 { .compatible = "fsl,imx8mp-dsp", .data = &sof_of_imx8mp_desc},
500 .name = "sof-audio-of-imx8m",