xref: /openbmc/linux/sound/soc/sof/intel/bdw.c (revision c1d3fb8a)
1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2 //
3 // This file is provided under a dual BSD/GPLv2 license.  When using or
4 // redistributing this file, you may do so under either license.
5 //
6 // Copyright(c) 2018 Intel Corporation. All rights reserved.
7 //
8 // Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
9 //
10 
11 /*
12  * Hardware interface for audio DSP on Broadwell
13  */
14 
15 #include <linux/module.h>
16 #include <sound/sof.h>
17 #include <sound/sof/xtensa.h>
18 #include "../ops.h"
19 #include "shim.h"
20 
21 /* BARs */
22 #define BDW_DSP_BAR 0
23 #define BDW_PCI_BAR 1
24 
25 /*
26  * Debug
27  */
28 
29 /* DSP memories for BDW */
30 #define IRAM_OFFSET     0xA0000
31 #define BDW_IRAM_SIZE       (10 * 32 * 1024)
32 #define DRAM_OFFSET     0x00000
33 #define BDW_DRAM_SIZE       (20 * 32 * 1024)
34 #define SHIM_OFFSET     0xFB000
35 #define SHIM_SIZE       0x100
36 #define MBOX_OFFSET     0x9E000
37 #define MBOX_SIZE       0x1000
38 #define MBOX_DUMP_SIZE 0x30
39 #define EXCEPT_OFFSET	0x800
40 #define EXCEPT_MAX_HDR_SIZE	0x400
41 
42 /* DSP peripherals */
43 #define DMAC0_OFFSET    0xFE000
44 #define DMAC1_OFFSET    0xFF000
45 #define DMAC_SIZE       0x420
46 #define SSP0_OFFSET     0xFC000
47 #define SSP1_OFFSET     0xFD000
48 #define SSP_SIZE	0x100
49 
50 #define BDW_STACK_DUMP_SIZE	32
51 
52 #define BDW_PANIC_OFFSET(x)	((x) & 0xFFFF)
53 
54 static const struct snd_sof_debugfs_map bdw_debugfs[] = {
55 	{"dmac0", BDW_DSP_BAR, DMAC0_OFFSET, DMAC_SIZE,
56 	 SOF_DEBUGFS_ACCESS_ALWAYS},
57 	{"dmac1", BDW_DSP_BAR, DMAC1_OFFSET, DMAC_SIZE,
58 	 SOF_DEBUGFS_ACCESS_ALWAYS},
59 	{"ssp0", BDW_DSP_BAR, SSP0_OFFSET, SSP_SIZE,
60 	 SOF_DEBUGFS_ACCESS_ALWAYS},
61 	{"ssp1", BDW_DSP_BAR, SSP1_OFFSET, SSP_SIZE,
62 	 SOF_DEBUGFS_ACCESS_ALWAYS},
63 	{"iram", BDW_DSP_BAR, IRAM_OFFSET, BDW_IRAM_SIZE,
64 	 SOF_DEBUGFS_ACCESS_D0_ONLY},
65 	{"dram", BDW_DSP_BAR, DRAM_OFFSET, BDW_DRAM_SIZE,
66 	 SOF_DEBUGFS_ACCESS_D0_ONLY},
67 	{"shim", BDW_DSP_BAR, SHIM_OFFSET, SHIM_SIZE,
68 	 SOF_DEBUGFS_ACCESS_ALWAYS},
69 };
70 
71 static void bdw_host_done(struct snd_sof_dev *sdev);
72 static void bdw_dsp_done(struct snd_sof_dev *sdev);
73 static void bdw_get_reply(struct snd_sof_dev *sdev);
74 
75 /*
76  * DSP Control.
77  */
78 
79 static int bdw_run(struct snd_sof_dev *sdev)
80 {
81 	/* set opportunistic mode on engine 0,1 for all channels */
82 	snd_sof_dsp_update_bits(sdev, BDW_DSP_BAR, SHIM_HMDC,
83 				SHIM_HMDC_HDDA_E0_ALLCH |
84 				SHIM_HMDC_HDDA_E1_ALLCH, 0);
85 
86 	/* set DSP to RUN */
87 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_CSR,
88 					 SHIM_CSR_STALL, 0x0);
89 
90 	/* return init core mask */
91 	return 1;
92 }
93 
94 static int bdw_reset(struct snd_sof_dev *sdev)
95 {
96 	/* put DSP into reset and stall */
97 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_CSR,
98 					 SHIM_CSR_RST | SHIM_CSR_STALL,
99 					 SHIM_CSR_RST | SHIM_CSR_STALL);
100 
101 	/* keep in reset for 10ms */
102 	mdelay(10);
103 
104 	/* take DSP out of reset and keep stalled for FW loading */
105 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_CSR,
106 					 SHIM_CSR_RST | SHIM_CSR_STALL,
107 					 SHIM_CSR_STALL);
108 
109 	return 0;
110 }
111 
112 static int bdw_set_dsp_D0(struct snd_sof_dev *sdev)
113 {
114 	int tries = 10;
115 	u32 reg;
116 
117 	/* Disable core clock gating (VDRTCTL2.DCLCGE = 0) */
118 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_PCI_BAR, PCI_VDRTCTL2,
119 					 PCI_VDRTCL2_DCLCGE |
120 					 PCI_VDRTCL2_DTCGE, 0);
121 
122 	/* Disable D3PG (VDRTCTL0.D3PGD = 1) */
123 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_PCI_BAR, PCI_VDRTCTL0,
124 					 PCI_VDRTCL0_D3PGD, PCI_VDRTCL0_D3PGD);
125 
126 	/* Set D0 state */
127 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_PCI_BAR, PCI_PMCS,
128 					 PCI_PMCS_PS_MASK, 0);
129 
130 	/* check that ADSP shim is enabled */
131 	while (tries--) {
132 		reg = readl(sdev->bar[BDW_PCI_BAR] + PCI_PMCS)
133 			& PCI_PMCS_PS_MASK;
134 		if (reg == 0)
135 			goto finish;
136 
137 		msleep(20);
138 	}
139 
140 	return -ENODEV;
141 
142 finish:
143 	/*
144 	 * select SSP1 19.2MHz base clock, SSP clock 0,
145 	 * turn off Low Power Clock
146 	 */
147 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_CSR,
148 					 SHIM_CSR_S1IOCS | SHIM_CSR_SBCS1 |
149 					 SHIM_CSR_LPCS, 0x0);
150 
151 	/* stall DSP core, set clk to 192/96Mhz */
152 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR,
153 					 SHIM_CSR, SHIM_CSR_STALL |
154 					 SHIM_CSR_DCS_MASK,
155 					 SHIM_CSR_STALL |
156 					 SHIM_CSR_DCS(4));
157 
158 	/* Set 24MHz MCLK, prevent local clock gating, enable SSP0 clock */
159 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_CLKCTL,
160 					 SHIM_CLKCTL_MASK |
161 					 SHIM_CLKCTL_DCPLCG |
162 					 SHIM_CLKCTL_SCOE0,
163 					 SHIM_CLKCTL_MASK |
164 					 SHIM_CLKCTL_DCPLCG |
165 					 SHIM_CLKCTL_SCOE0);
166 
167 	/* Stall and reset core, set CSR */
168 	bdw_reset(sdev);
169 
170 	/* Enable core clock gating (VDRTCTL2.DCLCGE = 1), delay 50 us */
171 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_PCI_BAR, PCI_VDRTCTL2,
172 					 PCI_VDRTCL2_DCLCGE |
173 					 PCI_VDRTCL2_DTCGE,
174 					 PCI_VDRTCL2_DCLCGE |
175 					 PCI_VDRTCL2_DTCGE);
176 
177 	usleep_range(50, 55);
178 
179 	/* switch on audio PLL */
180 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_PCI_BAR, PCI_VDRTCTL2,
181 					 PCI_VDRTCL2_APLLSE_MASK, 0);
182 
183 	/*
184 	 * set default power gating control, enable power gating control for
185 	 * all blocks. that is, can't be accessed, please enable each block
186 	 * before accessing.
187 	 */
188 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_PCI_BAR, PCI_VDRTCTL0,
189 					 0xfffffffC, 0x0);
190 
191 	/* disable DMA finish function for SSP0 & SSP1 */
192 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR,  SHIM_CSR2,
193 					 SHIM_CSR2_SDFD_SSP1,
194 					 SHIM_CSR2_SDFD_SSP1);
195 
196 	/* set on-demond mode on engine 0,1 for all channels */
197 	snd_sof_dsp_update_bits(sdev, BDW_DSP_BAR, SHIM_HMDC,
198 				SHIM_HMDC_HDDA_E0_ALLCH |
199 				SHIM_HMDC_HDDA_E1_ALLCH,
200 				SHIM_HMDC_HDDA_E0_ALLCH |
201 				SHIM_HMDC_HDDA_E1_ALLCH);
202 
203 	/* Enable Interrupt from both sides */
204 	snd_sof_dsp_update_bits(sdev, BDW_DSP_BAR, SHIM_IMRX,
205 				(SHIM_IMRX_BUSY | SHIM_IMRX_DONE), 0x0);
206 	snd_sof_dsp_update_bits(sdev, BDW_DSP_BAR, SHIM_IMRD,
207 				(SHIM_IMRD_DONE | SHIM_IMRD_BUSY |
208 				SHIM_IMRD_SSP0 | SHIM_IMRD_DMAC), 0x0);
209 
210 	/* clear IPC registers */
211 	snd_sof_dsp_write(sdev, BDW_DSP_BAR, SHIM_IPCX, 0x0);
212 	snd_sof_dsp_write(sdev, BDW_DSP_BAR, SHIM_IPCD, 0x0);
213 	snd_sof_dsp_write(sdev, BDW_DSP_BAR, 0x80, 0x6);
214 	snd_sof_dsp_write(sdev, BDW_DSP_BAR, 0xe0, 0x300a);
215 
216 	return 0;
217 }
218 
219 static void bdw_get_registers(struct snd_sof_dev *sdev,
220 			      struct sof_ipc_dsp_oops_xtensa *xoops,
221 			      struct sof_ipc_panic_info *panic_info,
222 			      u32 *stack, size_t stack_words)
223 {
224 	u32 offset = sdev->dsp_oops_offset;
225 
226 	/* first read registers */
227 	sof_mailbox_read(sdev, offset, xoops, sizeof(*xoops));
228 
229 	/* note: variable AR register array is not read */
230 
231 	/* then get panic info */
232 	if (xoops->arch_hdr.totalsize > EXCEPT_MAX_HDR_SIZE) {
233 		dev_err(sdev->dev, "invalid header size 0x%x. FW oops is bogus\n",
234 			xoops->arch_hdr.totalsize);
235 		return;
236 	}
237 	offset += xoops->arch_hdr.totalsize;
238 	sof_mailbox_read(sdev, offset, panic_info, sizeof(*panic_info));
239 
240 	/* then get the stack */
241 	offset += sizeof(*panic_info);
242 	sof_mailbox_read(sdev, offset, stack, stack_words * sizeof(u32));
243 }
244 
245 static void bdw_dump(struct snd_sof_dev *sdev, u32 flags)
246 {
247 	struct sof_ipc_dsp_oops_xtensa xoops;
248 	struct sof_ipc_panic_info panic_info;
249 	u32 stack[BDW_STACK_DUMP_SIZE];
250 	u32 status, panic, imrx, imrd;
251 
252 	/* now try generic SOF status messages */
253 	status = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IPCD);
254 	panic = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IPCX);
255 	bdw_get_registers(sdev, &xoops, &panic_info, stack,
256 			  BDW_STACK_DUMP_SIZE);
257 	snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, stack,
258 			   BDW_STACK_DUMP_SIZE);
259 
260 	/* provide some context for firmware debug */
261 	imrx = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IMRX);
262 	imrd = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IMRD);
263 	dev_err(sdev->dev,
264 		"error: ipc host -> DSP: pending %s complete %s raw 0x%8.8x\n",
265 		(panic & SHIM_IPCX_BUSY) ? "yes" : "no",
266 		(panic & SHIM_IPCX_DONE) ? "yes" : "no", panic);
267 	dev_err(sdev->dev,
268 		"error: mask host: pending %s complete %s raw 0x%8.8x\n",
269 		(imrx & SHIM_IMRX_BUSY) ? "yes" : "no",
270 		(imrx & SHIM_IMRX_DONE) ? "yes" : "no", imrx);
271 	dev_err(sdev->dev,
272 		"error: ipc DSP -> host: pending %s complete %s raw 0x%8.8x\n",
273 		(status & SHIM_IPCD_BUSY) ? "yes" : "no",
274 		(status & SHIM_IPCD_DONE) ? "yes" : "no", status);
275 	dev_err(sdev->dev,
276 		"error: mask DSP: pending %s complete %s raw 0x%8.8x\n",
277 		(imrd & SHIM_IMRD_BUSY) ? "yes" : "no",
278 		(imrd & SHIM_IMRD_DONE) ? "yes" : "no", imrd);
279 }
280 
281 /*
282  * IPC Doorbell IRQ handler and thread.
283  */
284 
285 static irqreturn_t bdw_irq_handler(int irq, void *context)
286 {
287 	struct snd_sof_dev *sdev = context;
288 	u32 isr;
289 	int ret = IRQ_NONE;
290 
291 	/* Interrupt arrived, check src */
292 	isr = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_ISRX);
293 	if (isr & (SHIM_ISRX_DONE | SHIM_ISRX_BUSY))
294 		ret = IRQ_WAKE_THREAD;
295 
296 	return ret;
297 }
298 
299 static irqreturn_t bdw_irq_thread(int irq, void *context)
300 {
301 	struct snd_sof_dev *sdev = context;
302 	u32 ipcx, ipcd, imrx;
303 
304 	imrx = snd_sof_dsp_read64(sdev, BDW_DSP_BAR, SHIM_IMRX);
305 	ipcx = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IPCX);
306 
307 	/* reply message from DSP */
308 	if (ipcx & SHIM_IPCX_DONE &&
309 	    !(imrx & SHIM_IMRX_DONE)) {
310 		/* Mask Done interrupt before return */
311 		snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR,
312 						 SHIM_IMRX, SHIM_IMRX_DONE,
313 						 SHIM_IMRX_DONE);
314 
315 		spin_lock_irq(&sdev->ipc_lock);
316 
317 		/*
318 		 * handle immediate reply from DSP core. If the msg is
319 		 * found, set done bit in cmd_done which is called at the
320 		 * end of message processing function, else set it here
321 		 * because the done bit can't be set in cmd_done function
322 		 * which is triggered by msg
323 		 */
324 		bdw_get_reply(sdev);
325 		snd_sof_ipc_reply(sdev, ipcx);
326 
327 		bdw_dsp_done(sdev);
328 
329 		spin_unlock_irq(&sdev->ipc_lock);
330 	}
331 
332 	ipcd = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IPCD);
333 
334 	/* new message from DSP */
335 	if (ipcd & SHIM_IPCD_BUSY &&
336 	    !(imrx & SHIM_IMRX_BUSY)) {
337 		/* Mask Busy interrupt before return */
338 		snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR,
339 						 SHIM_IMRX, SHIM_IMRX_BUSY,
340 						 SHIM_IMRX_BUSY);
341 
342 		/* Handle messages from DSP Core */
343 		if ((ipcd & SOF_IPC_PANIC_MAGIC_MASK) == SOF_IPC_PANIC_MAGIC) {
344 			snd_sof_dsp_panic(sdev, BDW_PANIC_OFFSET(ipcx) +
345 					  MBOX_OFFSET);
346 		} else {
347 			snd_sof_ipc_msgs_rx(sdev);
348 		}
349 
350 		bdw_host_done(sdev);
351 	}
352 
353 	return IRQ_HANDLED;
354 }
355 
356 /*
357  * IPC Mailbox IO
358  */
359 
360 static int bdw_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
361 {
362 	/* send the message */
363 	sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
364 			  msg->msg_size);
365 	snd_sof_dsp_write(sdev, BDW_DSP_BAR, SHIM_IPCX, SHIM_IPCX_BUSY);
366 
367 	return 0;
368 }
369 
370 static void bdw_get_reply(struct snd_sof_dev *sdev)
371 {
372 	struct snd_sof_ipc_msg *msg = sdev->msg;
373 	struct sof_ipc_reply reply;
374 	int ret = 0;
375 
376 	/*
377 	 * Sometimes, there is unexpected reply ipc arriving. The reply
378 	 * ipc belongs to none of the ipcs sent from driver.
379 	 * In this case, the driver must ignore the ipc.
380 	 */
381 	if (!msg) {
382 		dev_warn(sdev->dev, "unexpected ipc interrupt raised!\n");
383 		return;
384 	}
385 
386 	/* get reply */
387 	sof_mailbox_read(sdev, sdev->host_box.offset, &reply, sizeof(reply));
388 
389 	if (reply.error < 0) {
390 		memcpy(msg->reply_data, &reply, sizeof(reply));
391 		ret = reply.error;
392 	} else {
393 		/* reply correct size ? */
394 		if (reply.hdr.size != msg->reply_size) {
395 			dev_err(sdev->dev, "error: reply expected %zu got %u bytes\n",
396 				msg->reply_size, reply.hdr.size);
397 			ret = -EINVAL;
398 		}
399 
400 		/* read the message */
401 		if (msg->reply_size > 0)
402 			sof_mailbox_read(sdev, sdev->host_box.offset,
403 					 msg->reply_data, msg->reply_size);
404 	}
405 
406 	msg->reply_error = ret;
407 }
408 
409 static int bdw_get_mailbox_offset(struct snd_sof_dev *sdev)
410 {
411 	return MBOX_OFFSET;
412 }
413 
414 static int bdw_get_window_offset(struct snd_sof_dev *sdev, u32 id)
415 {
416 	return MBOX_OFFSET;
417 }
418 
419 static void bdw_host_done(struct snd_sof_dev *sdev)
420 {
421 	/* clear BUSY bit and set DONE bit - accept new messages */
422 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IPCD,
423 					 SHIM_IPCD_BUSY | SHIM_IPCD_DONE,
424 					 SHIM_IPCD_DONE);
425 
426 	/* unmask busy interrupt */
427 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IMRX,
428 					 SHIM_IMRX_BUSY, 0);
429 }
430 
431 static void bdw_dsp_done(struct snd_sof_dev *sdev)
432 {
433 	/* clear DONE bit - tell DSP we have completed */
434 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IPCX,
435 					 SHIM_IPCX_DONE, 0);
436 
437 	/* unmask Done interrupt */
438 	snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR, SHIM_IMRX,
439 					 SHIM_IMRX_DONE, 0);
440 }
441 
442 /*
443  * Probe and remove.
444  */
445 static int bdw_probe(struct snd_sof_dev *sdev)
446 {
447 	struct snd_sof_pdata *pdata = sdev->pdata;
448 	const struct sof_dev_desc *desc = pdata->desc;
449 	struct platform_device *pdev =
450 		container_of(sdev->dev, struct platform_device, dev);
451 	struct resource *mmio;
452 	u32 base, size;
453 	int ret;
454 
455 	/* LPE base */
456 	mmio = platform_get_resource(pdev, IORESOURCE_MEM,
457 				     desc->resindex_lpe_base);
458 	if (mmio) {
459 		base = mmio->start;
460 		size = resource_size(mmio);
461 	} else {
462 		dev_err(sdev->dev, "error: failed to get LPE base at idx %d\n",
463 			desc->resindex_lpe_base);
464 		return -EINVAL;
465 	}
466 
467 	dev_dbg(sdev->dev, "LPE PHY base at 0x%x size 0x%x", base, size);
468 	sdev->bar[BDW_DSP_BAR] = devm_ioremap(sdev->dev, base, size);
469 	if (!sdev->bar[BDW_DSP_BAR]) {
470 		dev_err(sdev->dev,
471 			"error: failed to ioremap LPE base 0x%x size 0x%x\n",
472 			base, size);
473 		return -ENODEV;
474 	}
475 	dev_dbg(sdev->dev, "LPE VADDR %p\n", sdev->bar[BDW_DSP_BAR]);
476 
477 	/* TODO: add offsets */
478 	sdev->mmio_bar = BDW_DSP_BAR;
479 	sdev->mailbox_bar = BDW_DSP_BAR;
480 	sdev->dsp_oops_offset = MBOX_OFFSET;
481 
482 	/* PCI base */
483 	mmio = platform_get_resource(pdev, IORESOURCE_MEM,
484 				     desc->resindex_pcicfg_base);
485 	if (mmio) {
486 		base = mmio->start;
487 		size = resource_size(mmio);
488 	} else {
489 		dev_err(sdev->dev, "error: failed to get PCI base at idx %d\n",
490 			desc->resindex_pcicfg_base);
491 		return -ENODEV;
492 	}
493 
494 	dev_dbg(sdev->dev, "PCI base at 0x%x size 0x%x", base, size);
495 	sdev->bar[BDW_PCI_BAR] = devm_ioremap(sdev->dev, base, size);
496 	if (!sdev->bar[BDW_PCI_BAR]) {
497 		dev_err(sdev->dev,
498 			"error: failed to ioremap PCI base 0x%x size 0x%x\n",
499 			base, size);
500 		return -ENODEV;
501 	}
502 	dev_dbg(sdev->dev, "PCI VADDR %p\n", sdev->bar[BDW_PCI_BAR]);
503 
504 	/* register our IRQ */
505 	sdev->ipc_irq = platform_get_irq(pdev, desc->irqindex_host_ipc);
506 	if (sdev->ipc_irq < 0)
507 		return sdev->ipc_irq;
508 
509 	dev_dbg(sdev->dev, "using IRQ %d\n", sdev->ipc_irq);
510 	ret = devm_request_threaded_irq(sdev->dev, sdev->ipc_irq,
511 					bdw_irq_handler, bdw_irq_thread,
512 					IRQF_SHARED, "AudioDSP", sdev);
513 	if (ret < 0) {
514 		dev_err(sdev->dev, "error: failed to register IRQ %d\n",
515 			sdev->ipc_irq);
516 		return ret;
517 	}
518 
519 	/* enable the DSP SHIM */
520 	ret = bdw_set_dsp_D0(sdev);
521 	if (ret < 0) {
522 		dev_err(sdev->dev, "error: failed to set DSP D0\n");
523 		return ret;
524 	}
525 
526 	/* DSP DMA can only access low 31 bits of host memory */
527 	ret = dma_coerce_mask_and_coherent(sdev->dev, DMA_BIT_MASK(31));
528 	if (ret < 0) {
529 		dev_err(sdev->dev, "error: failed to set DMA mask %d\n", ret);
530 		return ret;
531 	}
532 
533 	/* set default mailbox */
534 	snd_sof_dsp_mailbox_init(sdev, MBOX_OFFSET, MBOX_SIZE, 0, 0);
535 
536 	return ret;
537 }
538 
539 /* Broadwell DAIs */
540 static struct snd_soc_dai_driver bdw_dai[] = {
541 {
542 	.name = "ssp0-port",
543 },
544 {
545 	.name = "ssp1-port",
546 },
547 };
548 
549 /* broadwell ops */
550 const struct snd_sof_dsp_ops sof_bdw_ops = {
551 	/*Device init */
552 	.probe          = bdw_probe,
553 
554 	/* DSP Core Control */
555 	.run            = bdw_run,
556 	.reset          = bdw_reset,
557 
558 	/* Register IO */
559 	.write		= sof_io_write,
560 	.read		= sof_io_read,
561 	.write64	= sof_io_write64,
562 	.read64		= sof_io_read64,
563 
564 	/* Block IO */
565 	.block_read	= sof_block_read,
566 	.block_write	= sof_block_write,
567 
568 	/* ipc */
569 	.send_msg	= bdw_send_msg,
570 	.fw_ready	= sof_fw_ready,
571 	.get_mailbox_offset = bdw_get_mailbox_offset,
572 	.get_window_offset = bdw_get_window_offset,
573 
574 	.ipc_msg_data	= intel_ipc_msg_data,
575 	.ipc_pcm_params	= intel_ipc_pcm_params,
576 
577 	/* debug */
578 	.debug_map  = bdw_debugfs,
579 	.debug_map_count    = ARRAY_SIZE(bdw_debugfs),
580 	.dbg_dump   = bdw_dump,
581 
582 	/* stream callbacks */
583 	.pcm_open	= intel_pcm_open,
584 	.pcm_close	= intel_pcm_close,
585 
586 	/* Module loading */
587 	.load_module    = snd_sof_parse_module_memcpy,
588 
589 	/*Firmware loading */
590 	.load_firmware	= snd_sof_load_firmware_memcpy,
591 
592 	/* DAI drivers */
593 	.drv = bdw_dai,
594 	.num_drv = ARRAY_SIZE(bdw_dai),
595 
596 	/* ALSA HW info flags */
597 	.hw_info =	SNDRV_PCM_INFO_MMAP |
598 			SNDRV_PCM_INFO_MMAP_VALID |
599 			SNDRV_PCM_INFO_INTERLEAVED |
600 			SNDRV_PCM_INFO_PAUSE |
601 			SNDRV_PCM_INFO_BATCH,
602 };
603 EXPORT_SYMBOL(sof_bdw_ops);
604 
605 const struct sof_intel_dsp_desc bdw_chip_info = {
606 	.cores_num = 1,
607 	.cores_mask = 1,
608 };
609 EXPORT_SYMBOL(bdw_chip_info);
610 
611 MODULE_LICENSE("Dual BSD/GPL");
612