Lines Matching +full:fw +full:- +full:cfg +full:- +full:mmio
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
24 #include "../../sof-of-dev.h"
25 #include "../../sof-audio.h"
27 #include "../mtk-adsp-common.h"
29 #include "mt8195-clk.h"
44 struct adsp_priv *priv = sdev->pdata->hw_pdata; in mt8195_send_msg()
46 sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data, in mt8195_send_msg()
47 msg->msg_size); in mt8195_send_msg()
49 return mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_REQ, MTK_ADSP_IPC_OP_REQ); in mt8195_send_msg()
57 spin_lock_irqsave(&priv->sdev->ipc_lock, flags); in mt8195_dsp_handle_reply()
58 snd_sof_ipc_process_reply(priv->sdev, 0); in mt8195_dsp_handle_reply()
59 spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags); in mt8195_dsp_handle_reply()
69 sof_mailbox_read(priv->sdev, priv->sdev->debug_box.offset + 4, in mt8195_dsp_handle_request()
74 snd_sof_dsp_panic(priv->sdev, p, true); in mt8195_dsp_handle_request()
76 snd_sof_ipc_msgs_rx(priv->sdev); in mt8195_dsp_handle_request()
79 ret = mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_RSP, MTK_ADSP_IPC_OP_RSP); in mt8195_dsp_handle_request()
81 dev_err(priv->dev, "request send ipc failed"); in mt8195_dsp_handle_request()
92 struct resource *mmio; in platform_parse_resource() local
95 struct device *dev = &pdev->dev; in platform_parse_resource()
105 mem_region = of_parse_phandle(dev->of_node, "memory-region", 1); in platform_parse_resource()
107 dev_err(dev, "no memory-region sysmem phandle\n"); in platform_parse_resource()
108 return -ENODEV; in platform_parse_resource()
118 adsp->pa_dram = (phys_addr_t)res.start; in platform_parse_resource()
119 adsp->dramsize = resource_size(&res); in platform_parse_resource()
120 if (adsp->pa_dram & DRAM_REMAP_MASK) { in platform_parse_resource()
121 dev_err(dev, "adsp memory(%#x) is not 4K-aligned\n", in platform_parse_resource()
122 (u32)adsp->pa_dram); in platform_parse_resource()
123 return -EINVAL; in platform_parse_resource()
126 if (adsp->dramsize < TOTAL_SIZE_SHARED_DRAM_FROM_TAIL) { in platform_parse_resource()
128 adsp->dramsize); in platform_parse_resource()
129 return -EINVAL; in platform_parse_resource()
133 &adsp->pa_dram, adsp->dramsize); in platform_parse_resource()
135 /* Parse CFG base */ in platform_parse_resource()
136 mmio = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); in platform_parse_resource()
137 if (!mmio) { in platform_parse_resource()
138 dev_err(dev, "no ADSP-CFG register resource\n"); in platform_parse_resource()
139 return -ENXIO; in platform_parse_resource()
142 adsp->va_cfgreg = devm_ioremap_resource(dev, mmio); in platform_parse_resource()
143 if (IS_ERR(adsp->va_cfgreg)) in platform_parse_resource()
144 return PTR_ERR(adsp->va_cfgreg); in platform_parse_resource()
146 adsp->pa_cfgreg = (phys_addr_t)mmio->start; in platform_parse_resource()
147 adsp->cfgregsize = resource_size(mmio); in platform_parse_resource()
149 dev_dbg(dev, "cfgreg-vbase=%p, cfgregsize=%#x\n", in platform_parse_resource()
150 adsp->va_cfgreg, adsp->cfgregsize); in platform_parse_resource()
153 mmio = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram"); in platform_parse_resource()
154 if (!mmio) { in platform_parse_resource()
156 return -ENXIO; in platform_parse_resource()
159 adsp->pa_sram = (phys_addr_t)mmio->start; in platform_parse_resource()
160 adsp->sramsize = resource_size(mmio); in platform_parse_resource()
162 dev_dbg(dev, "sram pbase=%pa,%#x\n", &adsp->pa_sram, adsp->sramsize); in platform_parse_resource()
176 return -ENOMEM; in adsp_sram_power_on()
196 return -ENXIO; in adsp_memory_remap_init()
202 return -ENOMEM; in adsp_memory_remap_init()
205 offset = adsp->pa_dram - DRAM_PHYS_BASE_FROM_DSP_VIEW; in adsp_memory_remap_init()
206 adsp->dram_offset = offset; in adsp_memory_remap_init()
208 dev_dbg(dev, "adsp->pa_dram %pa, offset %#x\n", &adsp->pa_dram, offset); in adsp_memory_remap_init()
212 return -EIO; in adsp_memory_remap_init()
223 dev_dbg(sdev->dev, "HIFIxDSP boot from base : 0x%08X\n", adsp_bootup_addr); in mt8195_run()
231 struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev); in mt8195_dsp_probe()
235 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in mt8195_dsp_probe()
237 return -ENOMEM; in mt8195_dsp_probe()
239 sdev->pdata->hw_pdata = priv; in mt8195_dsp_probe()
240 priv->dev = sdev->dev; in mt8195_dsp_probe()
241 priv->sdev = sdev; in mt8195_dsp_probe()
243 priv->adsp = devm_kzalloc(&pdev->dev, sizeof(struct mtk_adsp_chip_info), GFP_KERNEL); in mt8195_dsp_probe()
244 if (!priv->adsp) in mt8195_dsp_probe()
245 return -ENOMEM; in mt8195_dsp_probe()
247 ret = platform_parse_resource(pdev, priv->adsp); in mt8195_dsp_probe()
253 dev_err(sdev->dev, "mt8195_adsp_init_clock failed\n"); in mt8195_dsp_probe()
254 return -EINVAL; in mt8195_dsp_probe()
259 dev_err(sdev->dev, "adsp_clock_on fail!\n"); in mt8195_dsp_probe()
260 return -EINVAL; in mt8195_dsp_probe()
263 ret = adsp_sram_power_on(sdev->dev, true); in mt8195_dsp_probe()
265 dev_err(sdev->dev, "adsp_sram_power_on fail!\n"); in mt8195_dsp_probe()
269 ret = adsp_memory_remap_init(&pdev->dev, priv->adsp); in mt8195_dsp_probe()
271 dev_err(sdev->dev, "adsp_memory_remap_init fail!\n"); in mt8195_dsp_probe()
275 sdev->bar[SOF_FW_BLK_TYPE_IRAM] = devm_ioremap(sdev->dev, in mt8195_dsp_probe()
276 priv->adsp->pa_sram, in mt8195_dsp_probe()
277 priv->adsp->sramsize); in mt8195_dsp_probe()
278 if (!sdev->bar[SOF_FW_BLK_TYPE_IRAM]) { in mt8195_dsp_probe()
279 dev_err(sdev->dev, "failed to ioremap base %pa size %#x\n", in mt8195_dsp_probe()
280 &priv->adsp->pa_sram, priv->adsp->sramsize); in mt8195_dsp_probe()
281 ret = -EINVAL; in mt8195_dsp_probe()
285 priv->adsp->va_sram = sdev->bar[SOF_FW_BLK_TYPE_IRAM]; in mt8195_dsp_probe()
287 sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap(sdev->dev, in mt8195_dsp_probe()
288 priv->adsp->pa_dram, in mt8195_dsp_probe()
289 priv->adsp->dramsize); in mt8195_dsp_probe()
290 if (!sdev->bar[SOF_FW_BLK_TYPE_SRAM]) { in mt8195_dsp_probe()
291 dev_err(sdev->dev, "failed to ioremap base %pa size %#x\n", in mt8195_dsp_probe()
292 &priv->adsp->pa_dram, priv->adsp->dramsize); in mt8195_dsp_probe()
293 ret = -EINVAL; in mt8195_dsp_probe()
296 priv->adsp->va_dram = sdev->bar[SOF_FW_BLK_TYPE_SRAM]; in mt8195_dsp_probe()
298 sdev->bar[DSP_REG_BAR] = priv->adsp->va_cfgreg; in mt8195_dsp_probe()
300 sdev->mmio_bar = SOF_FW_BLK_TYPE_SRAM; in mt8195_dsp_probe()
301 sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM; in mt8195_dsp_probe()
303 /* set default mailbox offset for FW ready message */ in mt8195_dsp_probe()
304 sdev->dsp_box.offset = mt8195_get_mailbox_offset(sdev); in mt8195_dsp_probe()
306 priv->ipc_dev = platform_device_register_data(&pdev->dev, "mtk-adsp-ipc", in mt8195_dsp_probe()
309 if (IS_ERR(priv->ipc_dev)) { in mt8195_dsp_probe()
310 ret = PTR_ERR(priv->ipc_dev); in mt8195_dsp_probe()
311 dev_err(sdev->dev, "failed to register mtk-adsp-ipc device\n"); in mt8195_dsp_probe()
315 priv->dsp_ipc = dev_get_drvdata(&priv->ipc_dev->dev); in mt8195_dsp_probe()
316 if (!priv->dsp_ipc) { in mt8195_dsp_probe()
317 ret = -EPROBE_DEFER; in mt8195_dsp_probe()
318 dev_err(sdev->dev, "failed to get drvdata\n"); in mt8195_dsp_probe()
322 mtk_adsp_ipc_set_data(priv->dsp_ipc, priv); in mt8195_dsp_probe()
323 priv->dsp_ipc->ops = &dsp_ops; in mt8195_dsp_probe()
328 platform_device_unregister(priv->ipc_dev); in mt8195_dsp_probe()
330 adsp_sram_power_on(&pdev->dev, false); in mt8195_dsp_probe()
339 return snd_sof_suspend(sdev->dev); in mt8195_dsp_shutdown()
344 struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev); in mt8195_dsp_remove()
345 struct adsp_priv *priv = sdev->pdata->hw_pdata; in mt8195_dsp_remove()
347 platform_device_unregister(priv->ipc_dev); in mt8195_dsp_remove()
348 adsp_sram_power_on(&pdev->dev, false); in mt8195_dsp_remove()
354 struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev); in mt8195_dsp_suspend()
366 dev_warn(sdev->dev, "dsp not idle, powering off anyway : swrest %#x, pc %#x, ret %d\n", in mt8195_dsp_suspend()
374 ret = adsp_sram_power_on(&pdev->dev, false); in mt8195_dsp_suspend()
376 dev_err(sdev->dev, "adsp_sram_power_off fail!\n"); in mt8195_dsp_suspend()
391 dev_err(sdev->dev, "adsp_clock_on fail!\n"); in mt8195_dsp_resume()
396 ret = adsp_sram_power_on(sdev->dev, true); in mt8195_dsp_resume()
398 dev_err(sdev->dev, "adsp_sram_power_on fail!\n"); in mt8195_dsp_resume()
414 platform_params->cont_update_posn = 1; in mt8195_pcm_hw_params()
427 struct snd_soc_component *scomp = sdev->component; in mt8195_pcm_pointer()
432 dev_warn_ratelimited(sdev->dev, "warn: can't find PCM with DAI ID %d\n", in mt8195_pcm_pointer()
433 rtd->dai_link->id); in mt8195_pcm_pointer()
437 stream = &spcm->stream[substream->stream]; in mt8195_pcm_pointer()
440 dev_warn(sdev->dev, "failed to read stream position: %d\n", ret); in mt8195_pcm_pointer()
444 memcpy(&stream->posn, &posn, sizeof(posn)); in mt8195_pcm_pointer()
445 pos = spcm->stream[substream->stream].posn.host_posn; in mt8195_pcm_pointer()
446 pos = bytes_to_frames(substream->runtime, pos); in mt8195_pcm_pointer()
468 dev_info(sdev->dev, "adsp dump : pc %#x, data %#x, bus0 %#x, bus1 %#x, swrest %#x", in mt8195_adsp_dump()
470 dev_info(sdev->dev, "dbg_inst %#x, ls0stat %#x, ls1stat %#x, faultbus %#x, faultinfo %#x", in mt8195_adsp_dump()
576 .sof_tplg_filename = "sof-mt8195-mt6359-rt1019-rt5682.tplg"
579 .sof_tplg_filename = "sof-mt8195-mt6359-max98390-rt5682.tplg"
582 .sof_tplg_filename = "sof-mt8195.tplg"
596 [SOF_IPC_TYPE_3] = "mediatek/sof-tplg",
599 [SOF_IPC_TYPE_3] = "sof-mt8195.ri",
601 .nocodec_tplg_filename = "sof-mt8195-nocodec.tplg",
607 { .compatible = "mediatek,mt8195-dsp", .data = &sof_of_mt8195_desc},
618 .name = "sof-audio-of-mt8195",