• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2 //
3 // Copyright(c) 2022 Mediatek Inc. All rights reserved.
4 //
5 // Author: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
6 //         Tinghan Shen <tinghan.shen@mediatek.com>
7 
8 /*
9  * Hardware interface for audio DSP on mt8186
10  */
11 
12 #include <linux/delay.h>
13 #include <linux/firmware.h>
14 #include <linux/io.h>
15 #include <linux/of_address.h>
16 #include <linux/of_irq.h>
17 #include <linux/of_platform.h>
18 #include <linux/of_reserved_mem.h>
19 #include <linux/module.h>
20 
21 #include <sound/sof.h>
22 #include <sound/sof/xtensa.h>
23 #include "../../ops.h"
24 #include "../../sof-of-dev.h"
25 #include "../../sof-audio.h"
26 #include "../adsp_helper.h"
27 #include "mt8186.h"
28 #include "mt8186-clk.h"
29 
mt8186_get_mailbox_offset(struct snd_sof_dev * sdev)30 static int mt8186_get_mailbox_offset(struct snd_sof_dev *sdev)
31 {
32 	return MBOX_OFFSET;
33 }
34 
mt8186_get_window_offset(struct snd_sof_dev * sdev,u32 id)35 static int mt8186_get_window_offset(struct snd_sof_dev *sdev, u32 id)
36 {
37 	return MBOX_OFFSET;
38 }
39 
mt8186_send_msg(struct snd_sof_dev * sdev,struct snd_sof_ipc_msg * msg)40 static int mt8186_send_msg(struct snd_sof_dev *sdev,
41 			   struct snd_sof_ipc_msg *msg)
42 {
43 	struct adsp_priv *priv = sdev->pdata->hw_pdata;
44 
45 	sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
46 			  msg->msg_size);
47 
48 	return mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_REQ, MTK_ADSP_IPC_OP_REQ);
49 }
50 
mt8186_get_reply(struct snd_sof_dev * sdev)51 static void mt8186_get_reply(struct snd_sof_dev *sdev)
52 {
53 	struct snd_sof_ipc_msg *msg = sdev->msg;
54 	struct sof_ipc_reply reply;
55 	int ret = 0;
56 
57 	if (!msg) {
58 		dev_warn(sdev->dev, "unexpected ipc interrupt\n");
59 		return;
60 	}
61 
62 	/* get reply */
63 	sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply));
64 	if (reply.error < 0) {
65 		memcpy(msg->reply_data, &reply, sizeof(reply));
66 		ret = reply.error;
67 	} else {
68 		/* reply has correct size? */
69 		if (reply.hdr.size != msg->reply_size) {
70 			dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n",
71 				msg->reply_size, reply.hdr.size);
72 			ret = -EINVAL;
73 		}
74 
75 		/* read the message */
76 		if (msg->reply_size > 0)
77 			sof_mailbox_read(sdev, sdev->host_box.offset,
78 					 msg->reply_data, msg->reply_size);
79 	}
80 
81 	msg->reply_error = ret;
82 }
83 
mt8186_dsp_handle_reply(struct mtk_adsp_ipc * ipc)84 static void mt8186_dsp_handle_reply(struct mtk_adsp_ipc *ipc)
85 {
86 	struct adsp_priv *priv = mtk_adsp_ipc_get_data(ipc);
87 	unsigned long flags;
88 
89 	spin_lock_irqsave(&priv->sdev->ipc_lock, flags);
90 	mt8186_get_reply(priv->sdev);
91 	snd_sof_ipc_reply(priv->sdev, 0);
92 	spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags);
93 }
94 
mt8186_dsp_handle_request(struct mtk_adsp_ipc * ipc)95 static void mt8186_dsp_handle_request(struct mtk_adsp_ipc *ipc)
96 {
97 	struct adsp_priv *priv = mtk_adsp_ipc_get_data(ipc);
98 	u32 p; /* panic code */
99 	int ret;
100 
101 	/* Read the message from the debug box. */
102 	sof_mailbox_read(priv->sdev, priv->sdev->debug_box.offset + 4,
103 			 &p, sizeof(p));
104 
105 	/* Check to see if the message is a panic code 0x0dead*** */
106 	if ((p & SOF_IPC_PANIC_MAGIC_MASK) == SOF_IPC_PANIC_MAGIC) {
107 		snd_sof_dsp_panic(priv->sdev, p, true);
108 	} else {
109 		snd_sof_ipc_msgs_rx(priv->sdev);
110 
111 		/* tell DSP cmd is done */
112 		ret = mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_RSP, MTK_ADSP_IPC_OP_RSP);
113 		if (ret)
114 			dev_err(priv->dev, "request send ipc failed");
115 	}
116 }
117 
118 static struct mtk_adsp_ipc_ops dsp_ops = {
119 	.handle_reply		= mt8186_dsp_handle_reply,
120 	.handle_request		= mt8186_dsp_handle_request,
121 };
122 
platform_parse_resource(struct platform_device * pdev,void * data)123 static int platform_parse_resource(struct platform_device *pdev, void *data)
124 {
125 	struct resource *mmio;
126 	struct resource res;
127 	struct device_node *mem_region;
128 	struct device *dev = &pdev->dev;
129 	struct mtk_adsp_chip_info *adsp = data;
130 	int ret;
131 
132 	mem_region = of_parse_phandle(dev->of_node, "memory-region", 0);
133 	if (!mem_region) {
134 		dev_err(dev, "no dma memory-region phandle\n");
135 		return -ENODEV;
136 	}
137 
138 	ret = of_address_to_resource(mem_region, 0, &res);
139 	of_node_put(mem_region);
140 	if (ret) {
141 		dev_err(dev, "of_address_to_resource dma failed\n");
142 		return ret;
143 	}
144 
145 	dev_dbg(dev, "DMA %pR\n", &res);
146 
147 	ret = of_reserved_mem_device_init(dev);
148 	if (ret) {
149 		dev_err(dev, "of_reserved_mem_device_init failed\n");
150 		return ret;
151 	}
152 
153 	mem_region = of_parse_phandle(dev->of_node, "memory-region", 1);
154 	if (!mem_region) {
155 		dev_err(dev, "no memory-region sysmem phandle\n");
156 		return -ENODEV;
157 	}
158 
159 	ret = of_address_to_resource(mem_region, 0, &res);
160 	of_node_put(mem_region);
161 	if (ret) {
162 		dev_err(dev, "of_address_to_resource sysmem failed\n");
163 		return ret;
164 	}
165 
166 	adsp->pa_dram = (phys_addr_t)res.start;
167 	if (adsp->pa_dram & DRAM_REMAP_MASK) {
168 		dev_err(dev, "adsp memory(%#x) is not 4K-aligned\n",
169 			(u32)adsp->pa_dram);
170 		return -EINVAL;
171 	}
172 
173 	adsp->dramsize = resource_size(&res);
174 	if (adsp->dramsize < TOTAL_SIZE_SHARED_DRAM_FROM_TAIL) {
175 		dev_err(dev, "adsp memory(%#x) is not enough for share\n",
176 			adsp->dramsize);
177 		return -EINVAL;
178 	}
179 
180 	dev_dbg(dev, "dram pbase=%pa size=%#x\n", &adsp->pa_dram, adsp->dramsize);
181 
182 	mmio = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg");
183 	if (!mmio) {
184 		dev_err(dev, "no ADSP-CFG register resource\n");
185 		return -ENXIO;
186 	}
187 
188 	adsp->va_cfgreg = devm_ioremap_resource(dev, mmio);
189 	if (IS_ERR(adsp->va_cfgreg))
190 		return PTR_ERR(adsp->va_cfgreg);
191 
192 	adsp->pa_cfgreg = (phys_addr_t)mmio->start;
193 	adsp->cfgregsize = resource_size(mmio);
194 
195 	dev_dbg(dev, "cfgreg pbase=%pa size=%#x\n", &adsp->pa_cfgreg, adsp->cfgregsize);
196 
197 	mmio = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram");
198 	if (!mmio) {
199 		dev_err(dev, "no SRAM resource\n");
200 		return -ENXIO;
201 	}
202 
203 	adsp->pa_sram = (phys_addr_t)mmio->start;
204 	adsp->sramsize = resource_size(mmio);
205 
206 	dev_dbg(dev, "sram pbase=%pa size=%#x\n", &adsp->pa_sram, adsp->sramsize);
207 
208 	mmio = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sec");
209 	if (!mmio) {
210 		dev_err(dev, "no SEC register resource\n");
211 		return -ENXIO;
212 	}
213 
214 	adsp->va_secreg = devm_ioremap_resource(dev, mmio);
215 	if (IS_ERR(adsp->va_secreg))
216 		return PTR_ERR(adsp->va_secreg);
217 
218 	adsp->pa_secreg = (phys_addr_t)mmio->start;
219 	adsp->secregsize = resource_size(mmio);
220 
221 	dev_dbg(dev, "secreg pbase=%pa size=%#x\n", &adsp->pa_secreg, adsp->secregsize);
222 
223 	mmio = platform_get_resource_byname(pdev, IORESOURCE_MEM, "bus");
224 	if (!mmio) {
225 		dev_err(dev, "no BUS register resource\n");
226 		return -ENXIO;
227 	}
228 
229 	adsp->va_busreg = devm_ioremap_resource(dev, mmio);
230 	if (IS_ERR(adsp->va_busreg))
231 		return PTR_ERR(adsp->va_busreg);
232 
233 	adsp->pa_busreg = (phys_addr_t)mmio->start;
234 	adsp->busregsize = resource_size(mmio);
235 
236 	dev_dbg(dev, "busreg pbase=%pa size=%#x\n", &adsp->pa_busreg, adsp->busregsize);
237 
238 	return 0;
239 }
240 
adsp_sram_power_on(struct snd_sof_dev * sdev)241 static void adsp_sram_power_on(struct snd_sof_dev *sdev)
242 {
243 	snd_sof_dsp_update_bits(sdev, DSP_BUSREG_BAR, ADSP_SRAM_POOL_CON,
244 				DSP_SRAM_POOL_PD_MASK, 0);
245 }
246 
adsp_sram_power_off(struct snd_sof_dev * sdev)247 static void adsp_sram_power_off(struct snd_sof_dev *sdev)
248 {
249 	snd_sof_dsp_update_bits(sdev, DSP_BUSREG_BAR, ADSP_SRAM_POOL_CON,
250 				DSP_SRAM_POOL_PD_MASK, DSP_SRAM_POOL_PD_MASK);
251 }
252 
253 /*  Init the basic DSP DRAM address */
adsp_memory_remap_init(struct snd_sof_dev * sdev,struct mtk_adsp_chip_info * adsp)254 static int adsp_memory_remap_init(struct snd_sof_dev *sdev, struct mtk_adsp_chip_info *adsp)
255 {
256 	u32 offset;
257 
258 	offset = adsp->pa_dram - DRAM_PHYS_BASE_FROM_DSP_VIEW;
259 	adsp->dram_offset = offset;
260 	offset >>= DRAM_REMAP_SHIFT;
261 
262 	dev_dbg(sdev->dev, "adsp->pa_dram %pa, offset %#x\n", &adsp->pa_dram, offset);
263 
264 	snd_sof_dsp_write(sdev, DSP_BUSREG_BAR, DSP_C0_EMI_MAP_ADDR, offset);
265 	snd_sof_dsp_write(sdev, DSP_BUSREG_BAR, DSP_C0_DMAEMI_MAP_ADDR, offset);
266 
267 	if (offset != snd_sof_dsp_read(sdev, DSP_BUSREG_BAR, DSP_C0_EMI_MAP_ADDR) ||
268 	    offset != snd_sof_dsp_read(sdev, DSP_BUSREG_BAR, DSP_C0_DMAEMI_MAP_ADDR)) {
269 		dev_err(sdev->dev, "emi remap fail\n");
270 		return -EIO;
271 	}
272 
273 	return 0;
274 }
275 
adsp_shared_base_ioremap(struct platform_device * pdev,void * data)276 static int adsp_shared_base_ioremap(struct platform_device *pdev, void *data)
277 {
278 	struct device *dev = &pdev->dev;
279 	struct mtk_adsp_chip_info *adsp = data;
280 	u32 shared_size;
281 
282 	/* remap shared-dram base to be non-cachable */
283 	shared_size = TOTAL_SIZE_SHARED_DRAM_FROM_TAIL;
284 	adsp->pa_shared_dram = adsp->pa_dram + adsp->dramsize - shared_size;
285 	if (adsp->va_dram) {
286 		adsp->shared_dram = adsp->va_dram + DSP_DRAM_SIZE - shared_size;
287 	} else {
288 		adsp->shared_dram = devm_ioremap(dev, adsp->pa_shared_dram,
289 						 shared_size);
290 		if (!adsp->shared_dram) {
291 			dev_err(dev, "ioremap failed for shared DRAM\n");
292 			return -ENOMEM;
293 		}
294 	}
295 	dev_dbg(dev, "shared-dram vbase=%p, phy addr :%pa, size=%#x\n",
296 		adsp->shared_dram, &adsp->pa_shared_dram, shared_size);
297 
298 	return 0;
299 }
300 
mt8186_run(struct snd_sof_dev * sdev)301 static int mt8186_run(struct snd_sof_dev *sdev)
302 {
303 	u32 adsp_bootup_addr;
304 
305 	adsp_bootup_addr = SRAM_PHYS_BASE_FROM_DSP_VIEW;
306 	dev_dbg(sdev->dev, "HIFIxDSP boot from base : 0x%08X\n", adsp_bootup_addr);
307 	mt8186_sof_hifixdsp_boot_sequence(sdev, adsp_bootup_addr);
308 
309 	return 0;
310 }
311 
mt8186_dsp_probe(struct snd_sof_dev * sdev)312 static int mt8186_dsp_probe(struct snd_sof_dev *sdev)
313 {
314 	struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev);
315 	struct adsp_priv *priv;
316 	int ret;
317 
318 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
319 	if (!priv)
320 		return -ENOMEM;
321 
322 	sdev->pdata->hw_pdata = priv;
323 	priv->dev = sdev->dev;
324 	priv->sdev = sdev;
325 
326 	priv->adsp = devm_kzalloc(&pdev->dev, sizeof(struct mtk_adsp_chip_info), GFP_KERNEL);
327 	if (!priv->adsp)
328 		return -ENOMEM;
329 
330 	ret = platform_parse_resource(pdev, priv->adsp);
331 	if (ret)
332 		return ret;
333 
334 	sdev->bar[SOF_FW_BLK_TYPE_IRAM] = devm_ioremap(sdev->dev,
335 						       priv->adsp->pa_sram,
336 						       priv->adsp->sramsize);
337 	if (!sdev->bar[SOF_FW_BLK_TYPE_IRAM]) {
338 		dev_err(sdev->dev, "failed to ioremap base %pa size %#x\n",
339 			&priv->adsp->pa_sram, priv->adsp->sramsize);
340 		return -ENOMEM;
341 	}
342 
343 	sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap_wc(sdev->dev,
344 							  priv->adsp->pa_dram,
345 							  priv->adsp->dramsize);
346 	if (!sdev->bar[SOF_FW_BLK_TYPE_SRAM]) {
347 		dev_err(sdev->dev, "failed to ioremap base %pa size %#x\n",
348 			&priv->adsp->pa_dram, priv->adsp->dramsize);
349 		return -ENOMEM;
350 	}
351 
352 	priv->adsp->va_dram = sdev->bar[SOF_FW_BLK_TYPE_SRAM];
353 
354 	ret = adsp_shared_base_ioremap(pdev, priv->adsp);
355 	if (ret) {
356 		dev_err(sdev->dev, "adsp_shared_base_ioremap fail!\n");
357 		return ret;
358 	}
359 
360 	sdev->bar[DSP_REG_BAR] = priv->adsp->va_cfgreg;
361 	sdev->bar[DSP_SECREG_BAR] = priv->adsp->va_secreg;
362 	sdev->bar[DSP_BUSREG_BAR] = priv->adsp->va_busreg;
363 
364 	sdev->mmio_bar = SOF_FW_BLK_TYPE_SRAM;
365 	sdev->mailbox_bar = SOF_FW_BLK_TYPE_SRAM;
366 
367 	/* set default mailbox offset for FW ready message */
368 	sdev->dsp_box.offset = mt8186_get_mailbox_offset(sdev);
369 
370 	ret = adsp_memory_remap_init(sdev, priv->adsp);
371 	if (ret) {
372 		dev_err(sdev->dev, "adsp_memory_remap_init fail!\n");
373 		return ret;
374 	}
375 
376 	/* enable adsp clock before touching registers */
377 	ret = mt8186_adsp_init_clock(sdev);
378 	if (ret) {
379 		dev_err(sdev->dev, "mt8186_adsp_init_clock failed\n");
380 		return ret;
381 	}
382 
383 	ret = mt8186_adsp_clock_on(sdev);
384 	if (ret) {
385 		dev_err(sdev->dev, "mt8186_adsp_clock_on fail!\n");
386 		return ret;
387 	}
388 
389 	adsp_sram_power_on(sdev);
390 
391 	priv->ipc_dev = platform_device_register_data(&pdev->dev, "mtk-adsp-ipc",
392 						      PLATFORM_DEVID_NONE,
393 						      pdev, sizeof(*pdev));
394 	if (IS_ERR(priv->ipc_dev)) {
395 		ret = PTR_ERR(priv->ipc_dev);
396 		dev_err(sdev->dev, "failed to create mtk-adsp-ipc device\n");
397 		goto err_adsp_off;
398 	}
399 
400 	priv->dsp_ipc = dev_get_drvdata(&priv->ipc_dev->dev);
401 	if (!priv->dsp_ipc) {
402 		ret = -EPROBE_DEFER;
403 		dev_err(sdev->dev, "failed to get drvdata\n");
404 		goto exit_pdev_unregister;
405 	}
406 
407 	mtk_adsp_ipc_set_data(priv->dsp_ipc, priv);
408 	priv->dsp_ipc->ops = &dsp_ops;
409 
410 	return 0;
411 
412 exit_pdev_unregister:
413 	platform_device_unregister(priv->ipc_dev);
414 err_adsp_off:
415 	adsp_sram_power_off(sdev);
416 	mt8186_adsp_clock_off(sdev);
417 
418 	return ret;
419 }
420 
mt8186_dsp_remove(struct snd_sof_dev * sdev)421 static int mt8186_dsp_remove(struct snd_sof_dev *sdev)
422 {
423 	struct adsp_priv *priv = sdev->pdata->hw_pdata;
424 
425 	platform_device_unregister(priv->ipc_dev);
426 	mt8186_sof_hifixdsp_shutdown(sdev);
427 	adsp_sram_power_off(sdev);
428 	mt8186_adsp_clock_off(sdev);
429 
430 	return 0;
431 }
432 
mt8186_dsp_suspend(struct snd_sof_dev * sdev,u32 target_state)433 static int mt8186_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state)
434 {
435 	mt8186_sof_hifixdsp_shutdown(sdev);
436 	adsp_sram_power_off(sdev);
437 	mt8186_adsp_clock_off(sdev);
438 
439 	return 0;
440 }
441 
mt8186_dsp_resume(struct snd_sof_dev * sdev)442 static int mt8186_dsp_resume(struct snd_sof_dev *sdev)
443 {
444 	int ret;
445 
446 	ret = mt8186_adsp_clock_on(sdev);
447 	if (ret) {
448 		dev_err(sdev->dev, "mt8186_adsp_clock_on fail!\n");
449 		return ret;
450 	}
451 
452 	adsp_sram_power_on(sdev);
453 
454 	return ret;
455 }
456 
457 /* on mt8186 there is 1 to 1 match between type and BAR idx */
mt8186_get_bar_index(struct snd_sof_dev * sdev,u32 type)458 static int mt8186_get_bar_index(struct snd_sof_dev *sdev, u32 type)
459 {
460 	return type;
461 }
462 
mt8186_pcm_hw_params(struct snd_sof_dev * sdev,struct snd_pcm_substream * substream,struct snd_pcm_hw_params * params,struct snd_sof_platform_stream_params * platform_params)463 static int mt8186_pcm_hw_params(struct snd_sof_dev *sdev,
464 				struct snd_pcm_substream *substream,
465 				struct snd_pcm_hw_params *params,
466 				struct snd_sof_platform_stream_params *platform_params)
467 {
468 	platform_params->cont_update_posn = 1;
469 
470 	return 0;
471 }
472 
mt8186_pcm_pointer(struct snd_sof_dev * sdev,struct snd_pcm_substream * substream)473 static snd_pcm_uframes_t mt8186_pcm_pointer(struct snd_sof_dev *sdev,
474 					    struct snd_pcm_substream *substream)
475 {
476 	int ret;
477 	snd_pcm_uframes_t pos;
478 	struct snd_sof_pcm *spcm;
479 	struct sof_ipc_stream_posn posn;
480 	struct snd_sof_pcm_stream *stream;
481 	struct snd_soc_component *scomp = sdev->component;
482 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
483 
484 	spcm = snd_sof_find_spcm_dai(scomp, rtd);
485 	if (!spcm) {
486 		dev_warn_ratelimited(sdev->dev, "warn: can't find PCM with DAI ID %d\n",
487 				     rtd->dai_link->id);
488 		return 0;
489 	}
490 
491 	stream = &spcm->stream[substream->stream];
492 	ret = snd_sof_ipc_msg_data(sdev, stream->substream, &posn, sizeof(posn));
493 	if (ret < 0) {
494 		dev_warn(sdev->dev, "failed to read stream position: %d\n", ret);
495 		return 0;
496 	}
497 
498 	memcpy(&stream->posn, &posn, sizeof(posn));
499 	pos = spcm->stream[substream->stream].posn.host_posn;
500 	pos = bytes_to_frames(substream->runtime, pos);
501 
502 	return pos;
503 }
504 
505 static struct snd_soc_dai_driver mt8186_dai[] = {
506 {
507 	.name = "SOF_DL1",
508 	.playback = {
509 		.channels_min = 1,
510 		.channels_max = 2,
511 	},
512 },
513 {
514 	.name = "SOF_DL2",
515 	.playback = {
516 		.channels_min = 1,
517 		.channels_max = 2,
518 	},
519 },
520 {
521 	.name = "SOF_UL1",
522 	.capture = {
523 		.channels_min = 1,
524 		.channels_max = 2,
525 	},
526 },
527 {
528 	.name = "SOF_UL2",
529 	.capture = {
530 		.channels_min = 1,
531 		.channels_max = 2,
532 	},
533 },
534 };
535 
536 /* mt8186 ops */
537 static struct snd_sof_dsp_ops sof_mt8186_ops = {
538 	/* probe and remove */
539 	.probe		= mt8186_dsp_probe,
540 	.remove		= mt8186_dsp_remove,
541 
542 	/* DSP core boot */
543 	.run		= mt8186_run,
544 
545 	/* Block IO */
546 	.block_read	= sof_block_read,
547 	.block_write	= sof_block_write,
548 
549 	/* Mailbox IO */
550 	.mailbox_read	= sof_mailbox_read,
551 	.mailbox_write	= sof_mailbox_write,
552 
553 	/* Register IO */
554 	.write		= sof_io_write,
555 	.read		= sof_io_read,
556 	.write64	= sof_io_write64,
557 	.read64		= sof_io_read64,
558 
559 	/* ipc */
560 	.send_msg		= mt8186_send_msg,
561 	.get_mailbox_offset	= mt8186_get_mailbox_offset,
562 	.get_window_offset	= mt8186_get_window_offset,
563 	.ipc_msg_data		= sof_ipc_msg_data,
564 	.set_stream_data_offset = sof_set_stream_data_offset,
565 
566 	/* misc */
567 	.get_bar_index	= mt8186_get_bar_index,
568 
569 	/* stream callbacks */
570 	.pcm_open	= sof_stream_pcm_open,
571 	.pcm_hw_params	= mt8186_pcm_hw_params,
572 	.pcm_pointer	= mt8186_pcm_pointer,
573 	.pcm_close	= sof_stream_pcm_close,
574 
575 	/* firmware loading */
576 	.load_firmware	= snd_sof_load_firmware_memcpy,
577 
578 	/* Firmware ops */
579 	.dsp_arch_ops = &sof_xtensa_arch_ops,
580 
581 	/* DAI drivers */
582 	.drv		= mt8186_dai,
583 	.num_drv	= ARRAY_SIZE(mt8186_dai),
584 
585 	/* PM */
586 	.suspend	= mt8186_dsp_suspend,
587 	.resume		= mt8186_dsp_resume,
588 
589 	/* ALSA HW info flags */
590 	.hw_info =	SNDRV_PCM_INFO_MMAP |
591 			SNDRV_PCM_INFO_MMAP_VALID |
592 			SNDRV_PCM_INFO_INTERLEAVED |
593 			SNDRV_PCM_INFO_PAUSE |
594 			SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
595 };
596 
597 static struct snd_sof_of_mach sof_mt8186_machs[] = {
598 	{
599 		.compatible = "mediatek,mt8186",
600 		.sof_tplg_filename = "sof-mt8186.tplg",
601 	},
602 	{}
603 };
604 
605 static const struct sof_dev_desc sof_of_mt8186_desc = {
606 	.of_machines = sof_mt8186_machs,
607 	.ipc_supported_mask	= BIT(SOF_IPC),
608 	.ipc_default		= SOF_IPC,
609 	.default_fw_path = {
610 		[SOF_IPC] = "mediatek/sof",
611 	},
612 	.default_tplg_path = {
613 		[SOF_IPC] = "mediatek/sof-tplg",
614 	},
615 	.default_fw_filename = {
616 		[SOF_IPC] = "sof-mt8186.ri",
617 	},
618 	.nocodec_tplg_filename = "sof-mt8186-nocodec.tplg",
619 	.ops = &sof_mt8186_ops,
620 };
621 
622 static const struct of_device_id sof_of_mt8186_ids[] = {
623 	{ .compatible = "mediatek,mt8186-dsp", .data = &sof_of_mt8186_desc},
624 	{ }
625 };
626 MODULE_DEVICE_TABLE(of, sof_of_mt8186_ids);
627 
628 /* DT driver definition */
629 static struct platform_driver snd_sof_of_mt8186_driver = {
630 	.probe = sof_of_probe,
631 	.remove = sof_of_remove,
632 	.driver = {
633 	.name = "sof-audio-of-mt8186",
634 		.pm = &sof_of_pm,
635 		.of_match_table = sof_of_mt8186_ids,
636 	},
637 };
638 module_platform_driver(snd_sof_of_mt8186_driver);
639 
640 MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA);
641 MODULE_IMPORT_NS(SND_SOC_SOF_MTK_COMMON);
642 MODULE_LICENSE("Dual BSD/GPL");
643