Commit | Line | Data |
---|---|---|
dd96daca LG |
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) 2017 Intel Corporation. All rights reserved. | |
7 | * | |
8 | * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> | |
9 | */ | |
10 | ||
11 | #ifndef __SOF_INTEL_HDA_H | |
12 | #define __SOF_INTEL_HDA_H | |
13 | ||
14 | #include <sound/hda_codec.h> | |
15 | #include <sound/hdaudio_ext.h> | |
16 | #include "shim.h" | |
17 | ||
18 | /* PCI registers */ | |
19 | #define PCI_TCSEL 0x44 | |
20 | #define PCI_PGCTL PCI_TCSEL | |
21 | #define PCI_CGCTL 0x48 | |
22 | ||
23 | /* PCI_PGCTL bits */ | |
24 | #define PCI_PGCTL_ADSPPGD BIT(2) | |
25 | #define PCI_PGCTL_LSRMD_MASK BIT(4) | |
26 | ||
27 | /* PCI_CGCTL bits */ | |
28 | #define PCI_CGCTL_MISCBDCGE_MASK BIT(6) | |
29 | #define PCI_CGCTL_ADSPDCGE BIT(1) | |
30 | ||
31 | /* Legacy HDA registers and bits used - widths are variable */ | |
32 | #define SOF_HDA_GCAP 0x0 | |
33 | #define SOF_HDA_GCTL 0x8 | |
34 | /* accept unsol. response enable */ | |
35 | #define SOF_HDA_GCTL_UNSOL BIT(8) | |
36 | #define SOF_HDA_LLCH 0x14 | |
37 | #define SOF_HDA_INTCTL 0x20 | |
38 | #define SOF_HDA_INTSTS 0x24 | |
39 | #define SOF_HDA_WAKESTS 0x0E | |
40 | #define SOF_HDA_WAKESTS_INT_MASK ((1 << 8) - 1) | |
41 | #define SOF_HDA_RIRBSTS 0x5d | |
42 | #define SOF_HDA_VS_EM2_L1SEN BIT(13) | |
43 | ||
44 | /* SOF_HDA_GCTL register bist */ | |
45 | #define SOF_HDA_GCTL_RESET BIT(0) | |
46 | ||
47 | /* SOF_HDA_INCTL and SOF_HDA_INTSTS regs */ | |
48 | #define SOF_HDA_INT_GLOBAL_EN BIT(31) | |
49 | #define SOF_HDA_INT_CTRL_EN BIT(30) | |
50 | #define SOF_HDA_INT_ALL_STREAM 0xff | |
51 | ||
52 | #define SOF_HDA_MAX_CAPS 10 | |
53 | #define SOF_HDA_CAP_ID_OFF 16 | |
54 | #define SOF_HDA_CAP_ID_MASK GENMASK(SOF_HDA_CAP_ID_OFF + 11,\ | |
55 | SOF_HDA_CAP_ID_OFF) | |
56 | #define SOF_HDA_CAP_NEXT_MASK 0xFFFF | |
57 | ||
58 | #define SOF_HDA_GTS_CAP_ID 0x1 | |
59 | #define SOF_HDA_ML_CAP_ID 0x2 | |
60 | ||
61 | #define SOF_HDA_PP_CAP_ID 0x3 | |
62 | #define SOF_HDA_REG_PP_PPCH 0x10 | |
63 | #define SOF_HDA_REG_PP_PPCTL 0x04 | |
f1fd9d0e | 64 | #define SOF_HDA_REG_PP_PPSTS 0x08 |
dd96daca LG |
65 | #define SOF_HDA_PPCTL_PIE BIT(31) |
66 | #define SOF_HDA_PPCTL_GPROCEN BIT(30) | |
67 | ||
68 | /* DPIB entry size: 8 Bytes = 2 DWords */ | |
69 | #define SOF_HDA_DPIB_ENTRY_SIZE 0x8 | |
70 | ||
71 | #define SOF_HDA_SPIB_CAP_ID 0x4 | |
72 | #define SOF_HDA_DRSM_CAP_ID 0x5 | |
73 | ||
74 | #define SOF_HDA_SPIB_BASE 0x08 | |
75 | #define SOF_HDA_SPIB_INTERVAL 0x08 | |
76 | #define SOF_HDA_SPIB_SPIB 0x00 | |
77 | #define SOF_HDA_SPIB_MAXFIFO 0x04 | |
78 | ||
79 | #define SOF_HDA_PPHC_BASE 0x10 | |
80 | #define SOF_HDA_PPHC_INTERVAL 0x10 | |
81 | ||
82 | #define SOF_HDA_PPLC_BASE 0x10 | |
83 | #define SOF_HDA_PPLC_MULTI 0x10 | |
84 | #define SOF_HDA_PPLC_INTERVAL 0x10 | |
85 | ||
86 | #define SOF_HDA_DRSM_BASE 0x08 | |
87 | #define SOF_HDA_DRSM_INTERVAL 0x08 | |
88 | ||
89 | /* Descriptor error interrupt */ | |
90 | #define SOF_HDA_CL_DMA_SD_INT_DESC_ERR 0x10 | |
91 | ||
92 | /* FIFO error interrupt */ | |
93 | #define SOF_HDA_CL_DMA_SD_INT_FIFO_ERR 0x08 | |
94 | ||
95 | /* Buffer completion interrupt */ | |
96 | #define SOF_HDA_CL_DMA_SD_INT_COMPLETE 0x04 | |
97 | ||
98 | #define SOF_HDA_CL_DMA_SD_INT_MASK \ | |
99 | (SOF_HDA_CL_DMA_SD_INT_DESC_ERR | \ | |
100 | SOF_HDA_CL_DMA_SD_INT_FIFO_ERR | \ | |
101 | SOF_HDA_CL_DMA_SD_INT_COMPLETE) | |
102 | #define SOF_HDA_SD_CTL_DMA_START 0x02 /* Stream DMA start bit */ | |
103 | ||
104 | /* Intel HD Audio Code Loader DMA Registers */ | |
105 | #define SOF_HDA_ADSP_LOADER_BASE 0x80 | |
106 | #define SOF_HDA_ADSP_DPLBASE 0x70 | |
107 | #define SOF_HDA_ADSP_DPUBASE 0x74 | |
108 | #define SOF_HDA_ADSP_DPLBASE_ENABLE 0x01 | |
109 | ||
110 | /* Stream Registers */ | |
111 | #define SOF_HDA_ADSP_REG_CL_SD_CTL 0x00 | |
112 | #define SOF_HDA_ADSP_REG_CL_SD_STS 0x03 | |
113 | #define SOF_HDA_ADSP_REG_CL_SD_LPIB 0x04 | |
114 | #define SOF_HDA_ADSP_REG_CL_SD_CBL 0x08 | |
115 | #define SOF_HDA_ADSP_REG_CL_SD_LVI 0x0C | |
116 | #define SOF_HDA_ADSP_REG_CL_SD_FIFOW 0x0E | |
117 | #define SOF_HDA_ADSP_REG_CL_SD_FIFOSIZE 0x10 | |
118 | #define SOF_HDA_ADSP_REG_CL_SD_FORMAT 0x12 | |
119 | #define SOF_HDA_ADSP_REG_CL_SD_FIFOL 0x14 | |
120 | #define SOF_HDA_ADSP_REG_CL_SD_BDLPL 0x18 | |
121 | #define SOF_HDA_ADSP_REG_CL_SD_BDLPU 0x1C | |
122 | #define SOF_HDA_ADSP_SD_ENTRY_SIZE 0x20 | |
123 | ||
124 | /* CL: Software Position Based FIFO Capability Registers */ | |
125 | #define SOF_DSP_REG_CL_SPBFIFO \ | |
126 | (SOF_HDA_ADSP_LOADER_BASE + 0x20) | |
127 | #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCH 0x0 | |
128 | #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCCTL 0x4 | |
129 | #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPIB 0x8 | |
130 | #define SOF_HDA_ADSP_REG_CL_SPBFIFO_MAXFIFOS 0xc | |
131 | ||
132 | /* Stream Number */ | |
133 | #define SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT 20 | |
134 | #define SOF_HDA_CL_SD_CTL_STREAM_TAG_MASK \ | |
135 | GENMASK(SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT + 3,\ | |
136 | SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT) | |
137 | ||
138 | #define HDA_DSP_HDA_BAR 0 | |
139 | #define HDA_DSP_PP_BAR 1 | |
140 | #define HDA_DSP_SPIB_BAR 2 | |
141 | #define HDA_DSP_DRSM_BAR 3 | |
142 | #define HDA_DSP_BAR 4 | |
143 | ||
144 | #define SRAM_WINDOW_OFFSET(x) (0x80000 + (x) * 0x20000) | |
145 | ||
146 | #define HDA_DSP_MBOX_OFFSET SRAM_WINDOW_OFFSET(0) | |
147 | ||
148 | #define HDA_DSP_PANIC_OFFSET(x) \ | |
149 | (((x) & 0xFFFFFF) + HDA_DSP_MBOX_OFFSET) | |
150 | ||
151 | /* SRAM window 0 FW "registers" */ | |
152 | #define HDA_DSP_SRAM_REG_ROM_STATUS (HDA_DSP_MBOX_OFFSET + 0x0) | |
153 | #define HDA_DSP_SRAM_REG_ROM_ERROR (HDA_DSP_MBOX_OFFSET + 0x4) | |
154 | /* FW and ROM share offset 4 */ | |
155 | #define HDA_DSP_SRAM_REG_FW_STATUS (HDA_DSP_MBOX_OFFSET + 0x4) | |
156 | #define HDA_DSP_SRAM_REG_FW_TRACEP (HDA_DSP_MBOX_OFFSET + 0x8) | |
157 | #define HDA_DSP_SRAM_REG_FW_END (HDA_DSP_MBOX_OFFSET + 0xc) | |
158 | ||
159 | #define HDA_DSP_MBOX_UPLINK_OFFSET 0x81000 | |
160 | ||
161 | #define HDA_DSP_STREAM_RESET_TIMEOUT 300 | |
162 | #define HDA_DSP_CL_TRIGGER_TIMEOUT 300 | |
163 | ||
164 | #define HDA_DSP_SPIB_ENABLE 1 | |
165 | #define HDA_DSP_SPIB_DISABLE 0 | |
166 | ||
167 | #define SOF_HDA_MAX_BUFFER_SIZE (32 * PAGE_SIZE) | |
168 | ||
169 | #define HDA_DSP_STACK_DUMP_SIZE 32 | |
170 | ||
171 | /* ROM status/error values */ | |
172 | #define HDA_DSP_ROM_STS_MASK 0xf | |
173 | #define HDA_DSP_ROM_INIT 0x1 | |
174 | #define HDA_DSP_ROM_FW_MANIFEST_LOADED 0x3 | |
175 | #define HDA_DSP_ROM_FW_FW_LOADED 0x4 | |
176 | #define HDA_DSP_ROM_FW_ENTERED 0x5 | |
177 | #define HDA_DSP_ROM_RFW_START 0xf | |
178 | #define HDA_DSP_ROM_CSE_ERROR 40 | |
179 | #define HDA_DSP_ROM_CSE_WRONG_RESPONSE 41 | |
180 | #define HDA_DSP_ROM_IMR_TO_SMALL 42 | |
181 | #define HDA_DSP_ROM_BASE_FW_NOT_FOUND 43 | |
182 | #define HDA_DSP_ROM_CSE_VALIDATION_FAILED 44 | |
183 | #define HDA_DSP_ROM_IPC_FATAL_ERROR 45 | |
184 | #define HDA_DSP_ROM_L2_CACHE_ERROR 46 | |
185 | #define HDA_DSP_ROM_LOAD_OFFSET_TO_SMALL 47 | |
186 | #define HDA_DSP_ROM_API_PTR_INVALID 50 | |
187 | #define HDA_DSP_ROM_BASEFW_INCOMPAT 51 | |
188 | #define HDA_DSP_ROM_UNHANDLED_INTERRUPT 0xBEE00000 | |
189 | #define HDA_DSP_ROM_MEMORY_HOLE_ECC 0xECC00000 | |
190 | #define HDA_DSP_ROM_KERNEL_EXCEPTION 0xCAFE0000 | |
191 | #define HDA_DSP_ROM_USER_EXCEPTION 0xBEEF0000 | |
192 | #define HDA_DSP_ROM_UNEXPECTED_RESET 0xDECAF000 | |
193 | #define HDA_DSP_ROM_NULL_FW_ENTRY 0x4c4c4e55 | |
194 | #define HDA_DSP_IPC_PURGE_FW 0x01004000 | |
195 | ||
196 | /* various timeout values */ | |
197 | #define HDA_DSP_PU_TIMEOUT 50 | |
198 | #define HDA_DSP_PD_TIMEOUT 50 | |
199 | #define HDA_DSP_RESET_TIMEOUT_US 50000 | |
200 | #define HDA_DSP_BASEFW_TIMEOUT_US 3000000 | |
201 | #define HDA_DSP_INIT_TIMEOUT_US 500000 | |
202 | #define HDA_DSP_CTRL_RESET_TIMEOUT 100 | |
203 | #define HDA_DSP_WAIT_TIMEOUT 500 /* 500 msec */ | |
204 | #define HDA_DSP_REG_POLL_INTERVAL_US 500 /* 0.5 msec */ | |
205 | ||
206 | #define HDA_DSP_ADSPIC_IPC 1 | |
207 | #define HDA_DSP_ADSPIS_IPC 1 | |
208 | ||
209 | /* Intel HD Audio General DSP Registers */ | |
210 | #define HDA_DSP_GEN_BASE 0x0 | |
211 | #define HDA_DSP_REG_ADSPCS (HDA_DSP_GEN_BASE + 0x04) | |
212 | #define HDA_DSP_REG_ADSPIC (HDA_DSP_GEN_BASE + 0x08) | |
213 | #define HDA_DSP_REG_ADSPIS (HDA_DSP_GEN_BASE + 0x0C) | |
214 | #define HDA_DSP_REG_ADSPIC2 (HDA_DSP_GEN_BASE + 0x10) | |
215 | #define HDA_DSP_REG_ADSPIS2 (HDA_DSP_GEN_BASE + 0x14) | |
216 | ||
217 | /* Intel HD Audio Inter-Processor Communication Registers */ | |
218 | #define HDA_DSP_IPC_BASE 0x40 | |
219 | #define HDA_DSP_REG_HIPCT (HDA_DSP_IPC_BASE + 0x00) | |
220 | #define HDA_DSP_REG_HIPCTE (HDA_DSP_IPC_BASE + 0x04) | |
221 | #define HDA_DSP_REG_HIPCI (HDA_DSP_IPC_BASE + 0x08) | |
222 | #define HDA_DSP_REG_HIPCIE (HDA_DSP_IPC_BASE + 0x0C) | |
223 | #define HDA_DSP_REG_HIPCCTL (HDA_DSP_IPC_BASE + 0x10) | |
224 | ||
225 | /* HIPCI */ | |
226 | #define HDA_DSP_REG_HIPCI_BUSY BIT(31) | |
227 | #define HDA_DSP_REG_HIPCI_MSG_MASK 0x7FFFFFFF | |
228 | ||
229 | /* HIPCIE */ | |
230 | #define HDA_DSP_REG_HIPCIE_DONE BIT(30) | |
231 | #define HDA_DSP_REG_HIPCIE_MSG_MASK 0x3FFFFFFF | |
232 | ||
233 | /* HIPCCTL */ | |
234 | #define HDA_DSP_REG_HIPCCTL_DONE BIT(1) | |
235 | #define HDA_DSP_REG_HIPCCTL_BUSY BIT(0) | |
236 | ||
237 | /* HIPCT */ | |
238 | #define HDA_DSP_REG_HIPCT_BUSY BIT(31) | |
239 | #define HDA_DSP_REG_HIPCT_MSG_MASK 0x7FFFFFFF | |
240 | ||
241 | /* HIPCTE */ | |
242 | #define HDA_DSP_REG_HIPCTE_MSG_MASK 0x3FFFFFFF | |
243 | ||
244 | #define HDA_DSP_ADSPIC_CL_DMA 0x2 | |
245 | #define HDA_DSP_ADSPIS_CL_DMA 0x2 | |
246 | ||
247 | /* Delay before scheduling D0i3 entry */ | |
248 | #define BXT_D0I3_DELAY 5000 | |
249 | ||
250 | #define FW_CL_STREAM_NUMBER 0x1 | |
251 | ||
252 | /* ADSPCS - Audio DSP Control & Status */ | |
253 | ||
254 | /* | |
255 | * Core Reset - asserted high | |
256 | * CRST Mask for a given core mask pattern, cm | |
257 | */ | |
258 | #define HDA_DSP_ADSPCS_CRST_SHIFT 0 | |
259 | #define HDA_DSP_ADSPCS_CRST_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CRST_SHIFT) | |
260 | ||
261 | /* | |
262 | * Core run/stall - when set to '1' core is stalled | |
263 | * CSTALL Mask for a given core mask pattern, cm | |
264 | */ | |
265 | #define HDA_DSP_ADSPCS_CSTALL_SHIFT 8 | |
266 | #define HDA_DSP_ADSPCS_CSTALL_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CSTALL_SHIFT) | |
267 | ||
268 | /* | |
269 | * Set Power Active - when set to '1' turn cores on | |
270 | * SPA Mask for a given core mask pattern, cm | |
271 | */ | |
272 | #define HDA_DSP_ADSPCS_SPA_SHIFT 16 | |
273 | #define HDA_DSP_ADSPCS_SPA_MASK(cm) ((cm) << HDA_DSP_ADSPCS_SPA_SHIFT) | |
274 | ||
275 | /* | |
276 | * Current Power Active - power status of cores, set by hardware | |
277 | * CPA Mask for a given core mask pattern, cm | |
278 | */ | |
279 | #define HDA_DSP_ADSPCS_CPA_SHIFT 24 | |
280 | #define HDA_DSP_ADSPCS_CPA_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CPA_SHIFT) | |
281 | ||
282 | /* Mask for a given core index, c = 0.. number of supported cores - 1 */ | |
283 | #define HDA_DSP_CORE_MASK(c) BIT(c) | |
284 | ||
285 | /* | |
286 | * Mask for a given number of cores | |
287 | * nc = number of supported cores | |
288 | */ | |
289 | #define SOF_DSP_CORES_MASK(nc) GENMASK(((nc) - 1), 0) | |
290 | ||
291 | /* Intel HD Audio Inter-Processor Communication Registers for Cannonlake*/ | |
292 | #define CNL_DSP_IPC_BASE 0xc0 | |
293 | #define CNL_DSP_REG_HIPCTDR (CNL_DSP_IPC_BASE + 0x00) | |
294 | #define CNL_DSP_REG_HIPCTDA (CNL_DSP_IPC_BASE + 0x04) | |
295 | #define CNL_DSP_REG_HIPCTDD (CNL_DSP_IPC_BASE + 0x08) | |
296 | #define CNL_DSP_REG_HIPCIDR (CNL_DSP_IPC_BASE + 0x10) | |
297 | #define CNL_DSP_REG_HIPCIDA (CNL_DSP_IPC_BASE + 0x14) | |
298 | #define CNL_DSP_REG_HIPCCTL (CNL_DSP_IPC_BASE + 0x28) | |
299 | ||
300 | /* HIPCI */ | |
301 | #define CNL_DSP_REG_HIPCIDR_BUSY BIT(31) | |
302 | #define CNL_DSP_REG_HIPCIDR_MSG_MASK 0x7FFFFFFF | |
303 | ||
304 | /* HIPCIE */ | |
305 | #define CNL_DSP_REG_HIPCIDA_DONE BIT(31) | |
306 | #define CNL_DSP_REG_HIPCIDA_MSG_MASK 0x7FFFFFFF | |
307 | ||
308 | /* HIPCCTL */ | |
309 | #define CNL_DSP_REG_HIPCCTL_DONE BIT(1) | |
310 | #define CNL_DSP_REG_HIPCCTL_BUSY BIT(0) | |
311 | ||
312 | /* HIPCT */ | |
313 | #define CNL_DSP_REG_HIPCTDR_BUSY BIT(31) | |
314 | #define CNL_DSP_REG_HIPCTDR_MSG_MASK 0x7FFFFFFF | |
315 | ||
316 | /* HIPCTDA */ | |
317 | #define CNL_DSP_REG_HIPCTDA_DONE BIT(31) | |
318 | #define CNL_DSP_REG_HIPCTDA_MSG_MASK 0x7FFFFFFF | |
319 | ||
320 | /* HIPCTDD */ | |
321 | #define CNL_DSP_REG_HIPCTDD_MSG_MASK 0x7FFFFFFF | |
322 | ||
323 | /* BDL */ | |
324 | #define HDA_DSP_BDL_SIZE 4096 | |
325 | #define HDA_DSP_MAX_BDL_ENTRIES \ | |
326 | (HDA_DSP_BDL_SIZE / sizeof(struct sof_intel_dsp_bdl)) | |
327 | ||
328 | /* Number of DAIs */ | |
329 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) | |
330 | #define SOF_SKL_NUM_DAIS 14 | |
331 | #else | |
332 | #define SOF_SKL_NUM_DAIS 8 | |
333 | #endif | |
334 | ||
335 | /* Intel HD Audio SRAM Window 0*/ | |
336 | #define HDA_ADSP_SRAM0_BASE_SKL 0x8000 | |
337 | ||
338 | /* Firmware status window */ | |
339 | #define HDA_ADSP_FW_STATUS_SKL HDA_ADSP_SRAM0_BASE_SKL | |
340 | #define HDA_ADSP_ERROR_CODE_SKL (HDA_ADSP_FW_STATUS_SKL + 0x4) | |
341 | ||
df7e0de5 ZY |
342 | /* Host Device Memory Space */ |
343 | #define APL_SSP_BASE_OFFSET 0x2000 | |
344 | #define CNL_SSP_BASE_OFFSET 0x10000 | |
345 | ||
346 | /* Host Device Memory Size of a Single SSP */ | |
347 | #define SSP_DEV_MEM_SIZE 0x1000 | |
348 | ||
b095fe47 ZY |
349 | /* SSP Count of the Platform */ |
350 | #define APL_SSP_COUNT 6 | |
351 | #define CNL_SSP_COUNT 3 | |
ec836daa | 352 | #define ICL_SSP_COUNT 6 |
b095fe47 | 353 | |
74ed4097 ZY |
354 | /* SSP Registers */ |
355 | #define SSP_SSC1_OFFSET 0x4 | |
356 | #define SSP_SET_SCLK_SLAVE BIT(25) | |
357 | #define SSP_SET_SFRM_SLAVE BIT(24) | |
358 | #define SSP_SET_SLAVE (SSP_SET_SCLK_SLAVE | SSP_SET_SFRM_SLAVE) | |
359 | ||
dd96daca LG |
360 | #define HDA_IDISP_CODEC(x) ((x) & BIT(2)) |
361 | ||
362 | struct sof_intel_dsp_bdl { | |
363 | __le32 addr_l; | |
364 | __le32 addr_h; | |
365 | __le32 size; | |
366 | __le32 ioc; | |
367 | } __attribute((packed)); | |
368 | ||
369 | #define SOF_HDA_PLAYBACK_STREAMS 16 | |
370 | #define SOF_HDA_CAPTURE_STREAMS 16 | |
371 | #define SOF_HDA_PLAYBACK 0 | |
372 | #define SOF_HDA_CAPTURE 1 | |
373 | ||
374 | /* represents DSP HDA controller frontend - i.e. host facing control */ | |
375 | struct sof_intel_hda_dev { | |
376 | ||
377 | struct hda_bus hbus; | |
378 | ||
379 | /* hw config */ | |
380 | const struct sof_intel_dsp_desc *desc; | |
381 | ||
382 | /* trace */ | |
383 | struct hdac_ext_stream *dtrace_stream; | |
384 | ||
385 | /* if position update IPC needed */ | |
386 | u32 no_ipc_position; | |
387 | ||
e8e55dbe KJ |
388 | /* the maximum number of streams (playback + capture) supported */ |
389 | u32 stream_max; | |
390 | ||
dd96daca LG |
391 | int irq; |
392 | ||
393 | /* DMIC device */ | |
394 | struct platform_device *dmic_dev; | |
395 | }; | |
396 | ||
397 | static inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s) | |
398 | { | |
399 | struct sof_intel_hda_dev *hda = s->pdata->hw_pdata; | |
400 | ||
401 | return &hda->hbus.core; | |
402 | } | |
403 | ||
404 | static inline struct hda_bus *sof_to_hbus(struct snd_sof_dev *s) | |
405 | { | |
406 | struct sof_intel_hda_dev *hda = s->pdata->hw_pdata; | |
407 | ||
408 | return &hda->hbus; | |
409 | } | |
410 | ||
411 | struct sof_intel_hda_stream { | |
7623ae79 | 412 | struct snd_sof_dev *sdev; |
dd96daca LG |
413 | struct hdac_ext_stream hda_stream; |
414 | struct sof_intel_stream stream; | |
ed3baacd | 415 | int hw_params_upon_resume; /* set up hw_params upon resume */ |
6b2239e3 | 416 | int host_reserved; /* reserve host DMA channel */ |
dd96daca LG |
417 | }; |
418 | ||
f5dbba9f RS |
419 | #define hstream_to_sof_hda_stream(hstream) \ |
420 | container_of(hstream, struct sof_intel_hda_stream, hda_stream) | |
421 | ||
dd96daca LG |
422 | #define bus_to_sof_hda(bus) \ |
423 | container_of(bus, struct sof_intel_hda_dev, hbus.core) | |
424 | ||
425 | #define SOF_STREAM_SD_OFFSET(s) \ | |
426 | (SOF_HDA_ADSP_SD_ENTRY_SIZE * ((s)->index) \ | |
427 | + SOF_HDA_ADSP_LOADER_BASE) | |
428 | ||
429 | /* | |
430 | * DSP Core services. | |
431 | */ | |
432 | int hda_dsp_probe(struct snd_sof_dev *sdev); | |
433 | int hda_dsp_remove(struct snd_sof_dev *sdev); | |
434 | int hda_dsp_core_reset_enter(struct snd_sof_dev *sdev, | |
435 | unsigned int core_mask); | |
436 | int hda_dsp_core_reset_leave(struct snd_sof_dev *sdev, | |
437 | unsigned int core_mask); | |
438 | int hda_dsp_core_stall_reset(struct snd_sof_dev *sdev, unsigned int core_mask); | |
439 | int hda_dsp_core_run(struct snd_sof_dev *sdev, unsigned int core_mask); | |
440 | int hda_dsp_core_power_up(struct snd_sof_dev *sdev, unsigned int core_mask); | |
441 | int hda_dsp_enable_core(struct snd_sof_dev *sdev, unsigned int core_mask); | |
442 | int hda_dsp_core_power_down(struct snd_sof_dev *sdev, unsigned int core_mask); | |
443 | bool hda_dsp_core_is_enabled(struct snd_sof_dev *sdev, | |
444 | unsigned int core_mask); | |
445 | int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev, | |
446 | unsigned int core_mask); | |
447 | void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev); | |
448 | void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev); | |
449 | ||
450 | int hda_dsp_suspend(struct snd_sof_dev *sdev, int state); | |
451 | int hda_dsp_resume(struct snd_sof_dev *sdev); | |
452 | int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev, int state); | |
453 | int hda_dsp_runtime_resume(struct snd_sof_dev *sdev); | |
7077a07a | 454 | int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev); |
dd96daca LG |
455 | void hda_dsp_dump_skl(struct snd_sof_dev *sdev, u32 flags); |
456 | void hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags); | |
f3da49f0 | 457 | void hda_ipc_dump(struct snd_sof_dev *sdev); |
f1fd9d0e | 458 | void hda_ipc_irq_dump(struct snd_sof_dev *sdev); |
dd96daca LG |
459 | |
460 | /* | |
461 | * DSP PCM Operations. | |
462 | */ | |
463 | int hda_dsp_pcm_open(struct snd_sof_dev *sdev, | |
464 | struct snd_pcm_substream *substream); | |
465 | int hda_dsp_pcm_close(struct snd_sof_dev *sdev, | |
466 | struct snd_pcm_substream *substream); | |
467 | int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev, | |
468 | struct snd_pcm_substream *substream, | |
469 | struct snd_pcm_hw_params *params, | |
470 | struct sof_ipc_stream_params *ipc_params); | |
471 | int hda_dsp_pcm_trigger(struct snd_sof_dev *sdev, | |
472 | struct snd_pcm_substream *substream, int cmd); | |
473 | snd_pcm_uframes_t hda_dsp_pcm_pointer(struct snd_sof_dev *sdev, | |
474 | struct snd_pcm_substream *substream); | |
475 | ||
476 | /* | |
477 | * DSP Stream Operations. | |
478 | */ | |
479 | ||
480 | int hda_dsp_stream_init(struct snd_sof_dev *sdev); | |
481 | void hda_dsp_stream_free(struct snd_sof_dev *sdev); | |
482 | int hda_dsp_stream_hw_params(struct snd_sof_dev *sdev, | |
483 | struct hdac_ext_stream *stream, | |
484 | struct snd_dma_buffer *dmab, | |
485 | struct snd_pcm_hw_params *params); | |
486 | int hda_dsp_stream_trigger(struct snd_sof_dev *sdev, | |
487 | struct hdac_ext_stream *stream, int cmd); | |
488 | irqreturn_t hda_dsp_stream_interrupt(int irq, void *context); | |
489 | irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context); | |
490 | int hda_dsp_stream_setup_bdl(struct snd_sof_dev *sdev, | |
491 | struct snd_dma_buffer *dmab, | |
492 | struct hdac_stream *stream); | |
493 | ||
494 | struct hdac_ext_stream * | |
495 | hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction); | |
496 | int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag); | |
497 | int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev, | |
498 | struct hdac_ext_stream *stream, | |
499 | int enable, u32 size); | |
500 | ||
501 | void hda_ipc_msg_data(struct snd_sof_dev *sdev, | |
502 | struct snd_pcm_substream *substream, | |
503 | void *p, size_t sz); | |
504 | int hda_ipc_pcm_params(struct snd_sof_dev *sdev, | |
505 | struct snd_pcm_substream *substream, | |
506 | const struct sof_ipc_pcm_params_reply *reply); | |
507 | ||
508 | /* | |
509 | * DSP IPC Operations. | |
510 | */ | |
511 | int hda_dsp_ipc_send_msg(struct snd_sof_dev *sdev, | |
512 | struct snd_sof_ipc_msg *msg); | |
513 | void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev); | |
514 | int hda_dsp_ipc_fw_ready(struct snd_sof_dev *sdev, u32 msg_id); | |
515 | irqreturn_t hda_dsp_ipc_irq_handler(int irq, void *context); | |
516 | irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context); | |
517 | int hda_dsp_ipc_cmd_done(struct snd_sof_dev *sdev, int dir); | |
518 | ||
519 | /* | |
520 | * DSP Code loader. | |
521 | */ | |
522 | int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev); | |
523 | int hda_dsp_cl_boot_firmware_skl(struct snd_sof_dev *sdev); | |
524 | ||
525 | /* pre and post fw run ops */ | |
526 | int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev); | |
527 | int hda_dsp_post_fw_run(struct snd_sof_dev *sdev); | |
528 | ||
529 | /* | |
530 | * HDA Controller Operations. | |
531 | */ | |
532 | int hda_dsp_ctrl_get_caps(struct snd_sof_dev *sdev); | |
533 | void hda_dsp_ctrl_ppcap_enable(struct snd_sof_dev *sdev, bool enable); | |
534 | void hda_dsp_ctrl_ppcap_int_enable(struct snd_sof_dev *sdev, bool enable); | |
535 | int hda_dsp_ctrl_link_reset(struct snd_sof_dev *sdev, bool reset); | |
536 | void hda_dsp_ctrl_misc_clock_gating(struct snd_sof_dev *sdev, bool enable); | |
537 | int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable); | |
538 | int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev, bool full_reset); | |
539 | ||
540 | /* | |
541 | * HDA bus operations. | |
542 | */ | |
543 | void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev, | |
544 | const struct hdac_ext_bus_ops *ext_ops); | |
545 | ||
546 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) | |
547 | /* | |
548 | * HDA Codec operations. | |
549 | */ | |
550 | int hda_codec_probe_bus(struct snd_sof_dev *sdev); | |
551 | ||
552 | #endif /* CONFIG_SND_SOC_SOF_HDA */ | |
553 | ||
554 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) && IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI) | |
555 | ||
556 | void hda_codec_i915_get(struct snd_sof_dev *sdev); | |
557 | void hda_codec_i915_put(struct snd_sof_dev *sdev); | |
558 | int hda_codec_i915_init(struct snd_sof_dev *sdev); | |
559 | int hda_codec_i915_exit(struct snd_sof_dev *sdev); | |
560 | ||
561 | #else | |
562 | ||
563 | static inline void hda_codec_i915_get(struct snd_sof_dev *sdev) { } | |
564 | static inline void hda_codec_i915_put(struct snd_sof_dev *sdev) { } | |
565 | static inline int hda_codec_i915_init(struct snd_sof_dev *sdev) { return 0; } | |
566 | static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; } | |
567 | ||
568 | #endif /* CONFIG_SND_SOC_SOF_HDA && CONFIG_SND_SOC_HDAC_HDMI */ | |
569 | ||
570 | /* | |
571 | * Trace Control. | |
572 | */ | |
573 | int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag); | |
574 | int hda_dsp_trace_release(struct snd_sof_dev *sdev); | |
575 | int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd); | |
576 | ||
577 | /* common dai driver */ | |
578 | extern struct snd_soc_dai_driver skl_dai[]; | |
579 | ||
580 | /* | |
581 | * Platform Specific HW abstraction Ops. | |
582 | */ | |
583 | extern const struct snd_sof_dsp_ops sof_apl_ops; | |
584 | extern const struct snd_sof_dsp_ops sof_cnl_ops; | |
585 | extern const struct snd_sof_dsp_ops sof_skl_ops; | |
586 | ||
587 | extern const struct sof_intel_dsp_desc apl_chip_info; | |
588 | extern const struct sof_intel_dsp_desc cnl_chip_info; | |
589 | extern const struct sof_intel_dsp_desc skl_chip_info; | |
630be964 | 590 | extern const struct sof_intel_dsp_desc icl_chip_info; |
dd96daca LG |
591 | |
592 | #endif |