xref: /openbmc/linux/sound/soc/sof/intel/hda.h (revision 194fe0fc)
1e149ca29SPierre-Louis Bossart /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2dd96dacaSLiam Girdwood /*
3dd96dacaSLiam Girdwood  * This file is provided under a dual BSD/GPLv2 license.  When using or
4dd96dacaSLiam Girdwood  * redistributing this file, you may do so under either license.
5dd96dacaSLiam Girdwood  *
6dd96dacaSLiam Girdwood  * Copyright(c) 2017 Intel Corporation. All rights reserved.
7dd96dacaSLiam Girdwood  *
8dd96dacaSLiam Girdwood  * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
9dd96dacaSLiam Girdwood  */
10dd96dacaSLiam Girdwood 
11dd96dacaSLiam Girdwood #ifndef __SOF_INTEL_HDA_H
12dd96dacaSLiam Girdwood #define __SOF_INTEL_HDA_H
13dd96dacaSLiam Girdwood 
1451dfed1eSPierre-Louis Bossart #include <linux/soundwire/sdw.h>
1551dfed1eSPierre-Louis Bossart #include <linux/soundwire/sdw_intel.h>
164c414da9SCezary Rojewski #include <sound/compress_driver.h>
17dd96dacaSLiam Girdwood #include <sound/hda_codec.h>
18dd96dacaSLiam Girdwood #include <sound/hdaudio_ext.h>
19dd96dacaSLiam Girdwood #include "shim.h"
20dd96dacaSLiam Girdwood 
21dd96dacaSLiam Girdwood /* PCI registers */
22dd96dacaSLiam Girdwood #define PCI_TCSEL			0x44
23dd96dacaSLiam Girdwood #define PCI_PGCTL			PCI_TCSEL
24dd96dacaSLiam Girdwood #define PCI_CGCTL			0x48
25dd96dacaSLiam Girdwood 
26dd96dacaSLiam Girdwood /* PCI_PGCTL bits */
27dd96dacaSLiam Girdwood #define PCI_PGCTL_ADSPPGD               BIT(2)
28dd96dacaSLiam Girdwood #define PCI_PGCTL_LSRMD_MASK		BIT(4)
29dd96dacaSLiam Girdwood 
30dd96dacaSLiam Girdwood /* PCI_CGCTL bits */
31dd96dacaSLiam Girdwood #define PCI_CGCTL_MISCBDCGE_MASK	BIT(6)
32dd96dacaSLiam Girdwood #define PCI_CGCTL_ADSPDCGE              BIT(1)
33dd96dacaSLiam Girdwood 
34dd96dacaSLiam Girdwood /* Legacy HDA registers and bits used - widths are variable */
35dd96dacaSLiam Girdwood #define SOF_HDA_GCAP			0x0
36dd96dacaSLiam Girdwood #define SOF_HDA_GCTL			0x8
37dd96dacaSLiam Girdwood /* accept unsol. response enable */
38dd96dacaSLiam Girdwood #define SOF_HDA_GCTL_UNSOL		BIT(8)
39dd96dacaSLiam Girdwood #define SOF_HDA_LLCH			0x14
40dd96dacaSLiam Girdwood #define SOF_HDA_INTCTL			0x20
41dd96dacaSLiam Girdwood #define SOF_HDA_INTSTS			0x24
42dd96dacaSLiam Girdwood #define SOF_HDA_WAKESTS			0x0E
43dd96dacaSLiam Girdwood #define SOF_HDA_WAKESTS_INT_MASK	((1 << 8) - 1)
44dd96dacaSLiam Girdwood #define SOF_HDA_RIRBSTS			0x5d
45dd96dacaSLiam Girdwood 
46dd96dacaSLiam Girdwood /* SOF_HDA_GCTL register bist */
47dd96dacaSLiam Girdwood #define SOF_HDA_GCTL_RESET		BIT(0)
48dd96dacaSLiam Girdwood 
497c11af9fSBard Liao /* SOF_HDA_INCTL regs */
50dd96dacaSLiam Girdwood #define SOF_HDA_INT_GLOBAL_EN		BIT(31)
51dd96dacaSLiam Girdwood #define SOF_HDA_INT_CTRL_EN		BIT(30)
52dd96dacaSLiam Girdwood #define SOF_HDA_INT_ALL_STREAM		0xff
53dd96dacaSLiam Girdwood 
547c11af9fSBard Liao /* SOF_HDA_INTSTS regs */
557c11af9fSBard Liao #define SOF_HDA_INTSTS_GIS		BIT(31)
567c11af9fSBard Liao 
57dd96dacaSLiam Girdwood #define SOF_HDA_MAX_CAPS		10
58dd96dacaSLiam Girdwood #define SOF_HDA_CAP_ID_OFF		16
59dd96dacaSLiam Girdwood #define SOF_HDA_CAP_ID_MASK		GENMASK(SOF_HDA_CAP_ID_OFF + 11,\
60dd96dacaSLiam Girdwood 						SOF_HDA_CAP_ID_OFF)
61dd96dacaSLiam Girdwood #define SOF_HDA_CAP_NEXT_MASK		0xFFFF
62dd96dacaSLiam Girdwood 
63dd96dacaSLiam Girdwood #define SOF_HDA_GTS_CAP_ID			0x1
64dd96dacaSLiam Girdwood #define SOF_HDA_ML_CAP_ID			0x2
65dd96dacaSLiam Girdwood 
66dd96dacaSLiam Girdwood #define SOF_HDA_PP_CAP_ID		0x3
67dd96dacaSLiam Girdwood #define SOF_HDA_REG_PP_PPCH		0x10
68dd96dacaSLiam Girdwood #define SOF_HDA_REG_PP_PPCTL		0x04
69f1fd9d0eSKai Vehmanen #define SOF_HDA_REG_PP_PPSTS		0x08
70dd96dacaSLiam Girdwood #define SOF_HDA_PPCTL_PIE		BIT(31)
71dd96dacaSLiam Girdwood #define SOF_HDA_PPCTL_GPROCEN		BIT(30)
72dd96dacaSLiam Girdwood 
7362f8f766SKeyon Jie /*Vendor Specific Registers*/
7462f8f766SKeyon Jie #define SOF_HDA_VS_D0I3C		0x104A
7562f8f766SKeyon Jie 
7662f8f766SKeyon Jie /* D0I3C Register fields */
7762f8f766SKeyon Jie #define SOF_HDA_VS_D0I3C_CIP		BIT(0) /* Command-In-Progress */
7862f8f766SKeyon Jie #define SOF_HDA_VS_D0I3C_I3		BIT(2) /* D0i3 enable bit */
7962f8f766SKeyon Jie 
80dd96dacaSLiam Girdwood /* DPIB entry size: 8 Bytes = 2 DWords */
81dd96dacaSLiam Girdwood #define SOF_HDA_DPIB_ENTRY_SIZE	0x8
82dd96dacaSLiam Girdwood 
83dd96dacaSLiam Girdwood #define SOF_HDA_SPIB_CAP_ID		0x4
84dd96dacaSLiam Girdwood #define SOF_HDA_DRSM_CAP_ID		0x5
85dd96dacaSLiam Girdwood 
86dd96dacaSLiam Girdwood #define SOF_HDA_SPIB_BASE		0x08
87dd96dacaSLiam Girdwood #define SOF_HDA_SPIB_INTERVAL		0x08
88dd96dacaSLiam Girdwood #define SOF_HDA_SPIB_SPIB		0x00
89dd96dacaSLiam Girdwood #define SOF_HDA_SPIB_MAXFIFO		0x04
90dd96dacaSLiam Girdwood 
91dd96dacaSLiam Girdwood #define SOF_HDA_PPHC_BASE		0x10
92dd96dacaSLiam Girdwood #define SOF_HDA_PPHC_INTERVAL		0x10
93dd96dacaSLiam Girdwood 
94dd96dacaSLiam Girdwood #define SOF_HDA_PPLC_BASE		0x10
95dd96dacaSLiam Girdwood #define SOF_HDA_PPLC_MULTI		0x10
96dd96dacaSLiam Girdwood #define SOF_HDA_PPLC_INTERVAL		0x10
97dd96dacaSLiam Girdwood 
98dd96dacaSLiam Girdwood #define SOF_HDA_DRSM_BASE		0x08
99dd96dacaSLiam Girdwood #define SOF_HDA_DRSM_INTERVAL		0x08
100dd96dacaSLiam Girdwood 
101dd96dacaSLiam Girdwood /* Descriptor error interrupt */
102dd96dacaSLiam Girdwood #define SOF_HDA_CL_DMA_SD_INT_DESC_ERR		0x10
103dd96dacaSLiam Girdwood 
104dd96dacaSLiam Girdwood /* FIFO error interrupt */
105dd96dacaSLiam Girdwood #define SOF_HDA_CL_DMA_SD_INT_FIFO_ERR		0x08
106dd96dacaSLiam Girdwood 
107dd96dacaSLiam Girdwood /* Buffer completion interrupt */
108dd96dacaSLiam Girdwood #define SOF_HDA_CL_DMA_SD_INT_COMPLETE		0x04
109dd96dacaSLiam Girdwood 
110dd96dacaSLiam Girdwood #define SOF_HDA_CL_DMA_SD_INT_MASK \
111dd96dacaSLiam Girdwood 	(SOF_HDA_CL_DMA_SD_INT_DESC_ERR | \
112dd96dacaSLiam Girdwood 	SOF_HDA_CL_DMA_SD_INT_FIFO_ERR | \
113dd96dacaSLiam Girdwood 	SOF_HDA_CL_DMA_SD_INT_COMPLETE)
114dd96dacaSLiam Girdwood #define SOF_HDA_SD_CTL_DMA_START		0x02 /* Stream DMA start bit */
115dd96dacaSLiam Girdwood 
116dd96dacaSLiam Girdwood /* Intel HD Audio Code Loader DMA Registers */
117dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_LOADER_BASE		0x80
118dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_DPLBASE			0x70
119dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_DPUBASE			0x74
120dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_DPLBASE_ENABLE		0x01
121dd96dacaSLiam Girdwood 
122dd96dacaSLiam Girdwood /* Stream Registers */
123dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SD_CTL		0x00
124dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SD_STS		0x03
125dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SD_LPIB		0x04
126dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SD_CBL		0x08
127dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SD_LVI		0x0C
128dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SD_FIFOW		0x0E
129dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SD_FIFOSIZE		0x10
130dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SD_FORMAT		0x12
131dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SD_FIFOL		0x14
132dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SD_BDLPL		0x18
133dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SD_BDLPU		0x1C
134dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_SD_ENTRY_SIZE		0x20
135dd96dacaSLiam Girdwood 
136dd96dacaSLiam Girdwood /* CL: Software Position Based FIFO Capability Registers */
137dd96dacaSLiam Girdwood #define SOF_DSP_REG_CL_SPBFIFO \
138dd96dacaSLiam Girdwood 	(SOF_HDA_ADSP_LOADER_BASE + 0x20)
139dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCH	0x0
140dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCCTL	0x4
141dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPIB	0x8
142dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SPBFIFO_MAXFIFOS	0xc
143dd96dacaSLiam Girdwood 
144dd96dacaSLiam Girdwood /* Stream Number */
145dd96dacaSLiam Girdwood #define SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT	20
146dd96dacaSLiam Girdwood #define SOF_HDA_CL_SD_CTL_STREAM_TAG_MASK \
147dd96dacaSLiam Girdwood 	GENMASK(SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT + 3,\
148dd96dacaSLiam Girdwood 		SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT)
149dd96dacaSLiam Girdwood 
150dd96dacaSLiam Girdwood #define HDA_DSP_HDA_BAR				0
151dd96dacaSLiam Girdwood #define HDA_DSP_PP_BAR				1
152dd96dacaSLiam Girdwood #define HDA_DSP_SPIB_BAR			2
153dd96dacaSLiam Girdwood #define HDA_DSP_DRSM_BAR			3
154dd96dacaSLiam Girdwood #define HDA_DSP_BAR				4
155dd96dacaSLiam Girdwood 
156dd96dacaSLiam Girdwood #define SRAM_WINDOW_OFFSET(x)			(0x80000 + (x) * 0x20000)
157dd96dacaSLiam Girdwood 
158dd96dacaSLiam Girdwood #define HDA_DSP_MBOX_OFFSET			SRAM_WINDOW_OFFSET(0)
159dd96dacaSLiam Girdwood 
160dd96dacaSLiam Girdwood #define HDA_DSP_PANIC_OFFSET(x) \
161dd96dacaSLiam Girdwood 	(((x) & 0xFFFFFF) + HDA_DSP_MBOX_OFFSET)
162dd96dacaSLiam Girdwood 
163dd96dacaSLiam Girdwood /* SRAM window 0 FW "registers" */
164dd96dacaSLiam Girdwood #define HDA_DSP_SRAM_REG_ROM_STATUS		(HDA_DSP_MBOX_OFFSET + 0x0)
165dd96dacaSLiam Girdwood #define HDA_DSP_SRAM_REG_ROM_ERROR		(HDA_DSP_MBOX_OFFSET + 0x4)
166dd96dacaSLiam Girdwood /* FW and ROM share offset 4 */
167dd96dacaSLiam Girdwood #define HDA_DSP_SRAM_REG_FW_STATUS		(HDA_DSP_MBOX_OFFSET + 0x4)
168dd96dacaSLiam Girdwood #define HDA_DSP_SRAM_REG_FW_TRACEP		(HDA_DSP_MBOX_OFFSET + 0x8)
169dd96dacaSLiam Girdwood #define HDA_DSP_SRAM_REG_FW_END			(HDA_DSP_MBOX_OFFSET + 0xc)
170dd96dacaSLiam Girdwood 
171dd96dacaSLiam Girdwood #define HDA_DSP_MBOX_UPLINK_OFFSET		0x81000
172dd96dacaSLiam Girdwood 
173dd96dacaSLiam Girdwood #define HDA_DSP_STREAM_RESET_TIMEOUT		300
1747bcaf0f2SZhu Yingjiang /*
1757bcaf0f2SZhu Yingjiang  * Timeout in us, for setting the stream RUN bit, during
1767bcaf0f2SZhu Yingjiang  * start/stop the stream. The timeout expires if new RUN bit
1777bcaf0f2SZhu Yingjiang  * value cannot be read back within the specified time.
1787bcaf0f2SZhu Yingjiang  */
1797bcaf0f2SZhu Yingjiang #define HDA_DSP_STREAM_RUN_TIMEOUT		300
180dd96dacaSLiam Girdwood 
181dd96dacaSLiam Girdwood #define HDA_DSP_SPIB_ENABLE			1
182dd96dacaSLiam Girdwood #define HDA_DSP_SPIB_DISABLE			0
183dd96dacaSLiam Girdwood 
184dd96dacaSLiam Girdwood #define SOF_HDA_MAX_BUFFER_SIZE			(32 * PAGE_SIZE)
185dd96dacaSLiam Girdwood 
186dd96dacaSLiam Girdwood #define HDA_DSP_STACK_DUMP_SIZE			32
187dd96dacaSLiam Girdwood 
188dd96dacaSLiam Girdwood /* ROM  status/error values */
189184fdfcaSKeyon Jie #define HDA_DSP_ROM_STS_MASK			GENMASK(23, 0)
190dd96dacaSLiam Girdwood #define HDA_DSP_ROM_INIT			0x1
191dd96dacaSLiam Girdwood #define HDA_DSP_ROM_FW_MANIFEST_LOADED		0x3
192dd96dacaSLiam Girdwood #define HDA_DSP_ROM_FW_FW_LOADED		0x4
193dd96dacaSLiam Girdwood #define HDA_DSP_ROM_FW_ENTERED			0x5
194dd96dacaSLiam Girdwood #define HDA_DSP_ROM_RFW_START			0xf
195dd96dacaSLiam Girdwood #define HDA_DSP_ROM_CSE_ERROR			40
196dd96dacaSLiam Girdwood #define HDA_DSP_ROM_CSE_WRONG_RESPONSE		41
197dd96dacaSLiam Girdwood #define HDA_DSP_ROM_IMR_TO_SMALL		42
198dd96dacaSLiam Girdwood #define HDA_DSP_ROM_BASE_FW_NOT_FOUND		43
199dd96dacaSLiam Girdwood #define HDA_DSP_ROM_CSE_VALIDATION_FAILED	44
200dd96dacaSLiam Girdwood #define HDA_DSP_ROM_IPC_FATAL_ERROR		45
201dd96dacaSLiam Girdwood #define HDA_DSP_ROM_L2_CACHE_ERROR		46
202dd96dacaSLiam Girdwood #define HDA_DSP_ROM_LOAD_OFFSET_TO_SMALL	47
203dd96dacaSLiam Girdwood #define HDA_DSP_ROM_API_PTR_INVALID		50
204dd96dacaSLiam Girdwood #define HDA_DSP_ROM_BASEFW_INCOMPAT		51
205dd96dacaSLiam Girdwood #define HDA_DSP_ROM_UNHANDLED_INTERRUPT		0xBEE00000
206dd96dacaSLiam Girdwood #define HDA_DSP_ROM_MEMORY_HOLE_ECC		0xECC00000
207dd96dacaSLiam Girdwood #define HDA_DSP_ROM_KERNEL_EXCEPTION		0xCAFE0000
208dd96dacaSLiam Girdwood #define HDA_DSP_ROM_USER_EXCEPTION		0xBEEF0000
209dd96dacaSLiam Girdwood #define HDA_DSP_ROM_UNEXPECTED_RESET		0xDECAF000
210dd96dacaSLiam Girdwood #define HDA_DSP_ROM_NULL_FW_ENTRY		0x4c4c4e55
211dd96dacaSLiam Girdwood #define HDA_DSP_IPC_PURGE_FW			0x01004000
212dd96dacaSLiam Girdwood 
213dd96dacaSLiam Girdwood /* various timeout values */
214dd96dacaSLiam Girdwood #define HDA_DSP_PU_TIMEOUT		50
215dd96dacaSLiam Girdwood #define HDA_DSP_PD_TIMEOUT		50
216dd96dacaSLiam Girdwood #define HDA_DSP_RESET_TIMEOUT_US	50000
217dd96dacaSLiam Girdwood #define HDA_DSP_BASEFW_TIMEOUT_US       3000000
218dd96dacaSLiam Girdwood #define HDA_DSP_INIT_TIMEOUT_US	500000
219dd96dacaSLiam Girdwood #define HDA_DSP_CTRL_RESET_TIMEOUT		100
220dd96dacaSLiam Girdwood #define HDA_DSP_WAIT_TIMEOUT		500	/* 500 msec */
221dd96dacaSLiam Girdwood #define HDA_DSP_REG_POLL_INTERVAL_US		500	/* 0.5 msec */
22292f4beb7SKeyon Jie #define HDA_DSP_REG_POLL_RETRY_COUNT		50
223dd96dacaSLiam Girdwood 
224dd96dacaSLiam Girdwood #define HDA_DSP_ADSPIC_IPC			1
225dd96dacaSLiam Girdwood #define HDA_DSP_ADSPIS_IPC			1
226dd96dacaSLiam Girdwood 
227dd96dacaSLiam Girdwood /* Intel HD Audio General DSP Registers */
228dd96dacaSLiam Girdwood #define HDA_DSP_GEN_BASE		0x0
229dd96dacaSLiam Girdwood #define HDA_DSP_REG_ADSPCS		(HDA_DSP_GEN_BASE + 0x04)
230dd96dacaSLiam Girdwood #define HDA_DSP_REG_ADSPIC		(HDA_DSP_GEN_BASE + 0x08)
231dd96dacaSLiam Girdwood #define HDA_DSP_REG_ADSPIS		(HDA_DSP_GEN_BASE + 0x0C)
232dd96dacaSLiam Girdwood #define HDA_DSP_REG_ADSPIC2		(HDA_DSP_GEN_BASE + 0x10)
233dd96dacaSLiam Girdwood #define HDA_DSP_REG_ADSPIS2		(HDA_DSP_GEN_BASE + 0x14)
234dd96dacaSLiam Girdwood 
235722ba5f1SBard Liao #define HDA_DSP_REG_ADSPIS2_SNDW	BIT(5)
23690de3281SRander Wang #define HDA_DSP_REG_SNDW_WAKE_STS      0x2C192
237722ba5f1SBard Liao 
238dd96dacaSLiam Girdwood /* Intel HD Audio Inter-Processor Communication Registers */
239dd96dacaSLiam Girdwood #define HDA_DSP_IPC_BASE		0x40
240dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCT		(HDA_DSP_IPC_BASE + 0x00)
241dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCTE		(HDA_DSP_IPC_BASE + 0x04)
242dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCI		(HDA_DSP_IPC_BASE + 0x08)
243dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCIE		(HDA_DSP_IPC_BASE + 0x0C)
244dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCCTL		(HDA_DSP_IPC_BASE + 0x10)
245dd96dacaSLiam Girdwood 
24643b2ab90SRanjani Sridharan /* Intel Vendor Specific Registers */
24743b2ab90SRanjani Sridharan #define HDA_VS_INTEL_EM2		0x1030
24843b2ab90SRanjani Sridharan #define HDA_VS_INTEL_EM2_L1SEN		BIT(13)
249aca961f1SRanjani Sridharan #define HDA_VS_INTEL_LTRP_GB_MASK	0x3F
25043b2ab90SRanjani Sridharan 
251dd96dacaSLiam Girdwood /*  HIPCI */
252dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCI_BUSY		BIT(31)
253dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCI_MSG_MASK	0x7FFFFFFF
254dd96dacaSLiam Girdwood 
255dd96dacaSLiam Girdwood /* HIPCIE */
256dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCIE_DONE	BIT(30)
257dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCIE_MSG_MASK	0x3FFFFFFF
258dd96dacaSLiam Girdwood 
259dd96dacaSLiam Girdwood /* HIPCCTL */
260dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCCTL_DONE	BIT(1)
261dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCCTL_BUSY	BIT(0)
262dd96dacaSLiam Girdwood 
263dd96dacaSLiam Girdwood /* HIPCT */
264dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCT_BUSY		BIT(31)
265dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCT_MSG_MASK	0x7FFFFFFF
266dd96dacaSLiam Girdwood 
267dd96dacaSLiam Girdwood /* HIPCTE */
268dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCTE_MSG_MASK	0x3FFFFFFF
269dd96dacaSLiam Girdwood 
270dd96dacaSLiam Girdwood #define HDA_DSP_ADSPIC_CL_DMA		0x2
271dd96dacaSLiam Girdwood #define HDA_DSP_ADSPIS_CL_DMA		0x2
272dd96dacaSLiam Girdwood 
273dd96dacaSLiam Girdwood /* Delay before scheduling D0i3 entry */
274dd96dacaSLiam Girdwood #define BXT_D0I3_DELAY 5000
275dd96dacaSLiam Girdwood 
276dd96dacaSLiam Girdwood #define FW_CL_STREAM_NUMBER		0x1
277776100a4SPierre-Louis Bossart #define HDA_FW_BOOT_ATTEMPTS	3
278dd96dacaSLiam Girdwood 
279dd96dacaSLiam Girdwood /* ADSPCS - Audio DSP Control & Status */
280dd96dacaSLiam Girdwood 
281dd96dacaSLiam Girdwood /*
282dd96dacaSLiam Girdwood  * Core Reset - asserted high
283dd96dacaSLiam Girdwood  * CRST Mask for a given core mask pattern, cm
284dd96dacaSLiam Girdwood  */
285dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CRST_SHIFT	0
286dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CRST_MASK(cm)	((cm) << HDA_DSP_ADSPCS_CRST_SHIFT)
287dd96dacaSLiam Girdwood 
288dd96dacaSLiam Girdwood /*
289dd96dacaSLiam Girdwood  * Core run/stall - when set to '1' core is stalled
290dd96dacaSLiam Girdwood  * CSTALL Mask for a given core mask pattern, cm
291dd96dacaSLiam Girdwood  */
292dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CSTALL_SHIFT	8
293dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CSTALL_MASK(cm)	((cm) << HDA_DSP_ADSPCS_CSTALL_SHIFT)
294dd96dacaSLiam Girdwood 
295dd96dacaSLiam Girdwood /*
296dd96dacaSLiam Girdwood  * Set Power Active - when set to '1' turn cores on
297dd96dacaSLiam Girdwood  * SPA Mask for a given core mask pattern, cm
298dd96dacaSLiam Girdwood  */
299dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_SPA_SHIFT	16
300dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_SPA_MASK(cm)	((cm) << HDA_DSP_ADSPCS_SPA_SHIFT)
301dd96dacaSLiam Girdwood 
302dd96dacaSLiam Girdwood /*
303dd96dacaSLiam Girdwood  * Current Power Active - power status of cores, set by hardware
304dd96dacaSLiam Girdwood  * CPA Mask for a given core mask pattern, cm
305dd96dacaSLiam Girdwood  */
306dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CPA_SHIFT	24
307dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CPA_MASK(cm)	((cm) << HDA_DSP_ADSPCS_CPA_SHIFT)
308dd96dacaSLiam Girdwood 
309dd96dacaSLiam Girdwood /*
310dd96dacaSLiam Girdwood  * Mask for a given number of cores
311dd96dacaSLiam Girdwood  * nc = number of supported cores
312dd96dacaSLiam Girdwood  */
313dd96dacaSLiam Girdwood #define SOF_DSP_CORES_MASK(nc)	GENMASK(((nc) - 1), 0)
314dd96dacaSLiam Girdwood 
315dd96dacaSLiam Girdwood /* Intel HD Audio Inter-Processor Communication Registers for Cannonlake*/
316dd96dacaSLiam Girdwood #define CNL_DSP_IPC_BASE		0xc0
317dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDR		(CNL_DSP_IPC_BASE + 0x00)
318dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDA		(CNL_DSP_IPC_BASE + 0x04)
319dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDD		(CNL_DSP_IPC_BASE + 0x08)
320dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDR		(CNL_DSP_IPC_BASE + 0x10)
321dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDA		(CNL_DSP_IPC_BASE + 0x14)
3220267de58SKeyon Jie #define CNL_DSP_REG_HIPCIDD		(CNL_DSP_IPC_BASE + 0x18)
323dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCCTL		(CNL_DSP_IPC_BASE + 0x28)
324dd96dacaSLiam Girdwood 
325dd96dacaSLiam Girdwood /*  HIPCI */
326dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDR_BUSY		BIT(31)
327dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDR_MSG_MASK	0x7FFFFFFF
328dd96dacaSLiam Girdwood 
329dd96dacaSLiam Girdwood /* HIPCIE */
330dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDA_DONE	BIT(31)
331dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDA_MSG_MASK	0x7FFFFFFF
332dd96dacaSLiam Girdwood 
333dd96dacaSLiam Girdwood /* HIPCCTL */
334dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCCTL_DONE	BIT(1)
335dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCCTL_BUSY	BIT(0)
336dd96dacaSLiam Girdwood 
337dd96dacaSLiam Girdwood /* HIPCT */
338dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDR_BUSY		BIT(31)
339dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDR_MSG_MASK	0x7FFFFFFF
340dd96dacaSLiam Girdwood 
341dd96dacaSLiam Girdwood /* HIPCTDA */
342dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDA_DONE	BIT(31)
343dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDA_MSG_MASK	0x7FFFFFFF
344dd96dacaSLiam Girdwood 
345dd96dacaSLiam Girdwood /* HIPCTDD */
346dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDD_MSG_MASK	0x7FFFFFFF
347dd96dacaSLiam Girdwood 
348dd96dacaSLiam Girdwood /* BDL */
349dd96dacaSLiam Girdwood #define HDA_DSP_BDL_SIZE			4096
350dd96dacaSLiam Girdwood #define HDA_DSP_MAX_BDL_ENTRIES			\
351dd96dacaSLiam Girdwood 	(HDA_DSP_BDL_SIZE / sizeof(struct sof_intel_dsp_bdl))
352dd96dacaSLiam Girdwood 
353dd96dacaSLiam Girdwood /* Number of DAIs */
354dd96dacaSLiam Girdwood #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
35570368106SCezary Rojewski 
35670368106SCezary Rojewski #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_PROBES)
35770368106SCezary Rojewski #define SOF_SKL_NUM_DAIS		16
35870368106SCezary Rojewski #else
359a6947c9dSCezary Rojewski #define SOF_SKL_NUM_DAIS		15
36070368106SCezary Rojewski #endif
36170368106SCezary Rojewski 
362dd96dacaSLiam Girdwood #else
363dd96dacaSLiam Girdwood #define SOF_SKL_NUM_DAIS		8
364dd96dacaSLiam Girdwood #endif
365dd96dacaSLiam Girdwood 
366dd96dacaSLiam Girdwood /* Intel HD Audio SRAM Window 0*/
367dd96dacaSLiam Girdwood #define HDA_ADSP_SRAM0_BASE_SKL		0x8000
368dd96dacaSLiam Girdwood 
369dd96dacaSLiam Girdwood /* Firmware status window */
370dd96dacaSLiam Girdwood #define HDA_ADSP_FW_STATUS_SKL		HDA_ADSP_SRAM0_BASE_SKL
371dd96dacaSLiam Girdwood #define HDA_ADSP_ERROR_CODE_SKL		(HDA_ADSP_FW_STATUS_SKL + 0x4)
372dd96dacaSLiam Girdwood 
373df7e0de5SZhu Yingjiang /* Host Device Memory Space */
374df7e0de5SZhu Yingjiang #define APL_SSP_BASE_OFFSET	0x2000
375df7e0de5SZhu Yingjiang #define CNL_SSP_BASE_OFFSET	0x10000
376df7e0de5SZhu Yingjiang 
377df7e0de5SZhu Yingjiang /* Host Device Memory Size of a Single SSP */
378df7e0de5SZhu Yingjiang #define SSP_DEV_MEM_SIZE	0x1000
379df7e0de5SZhu Yingjiang 
380b095fe47SZhu Yingjiang /* SSP Count of the Platform */
381b095fe47SZhu Yingjiang #define APL_SSP_COUNT		6
382b095fe47SZhu Yingjiang #define CNL_SSP_COUNT		3
383ec836daaSZhu Yingjiang #define ICL_SSP_COUNT		6
384b095fe47SZhu Yingjiang 
38574ed4097SZhu Yingjiang /* SSP Registers */
38674ed4097SZhu Yingjiang #define SSP_SSC1_OFFSET		0x4
38774ed4097SZhu Yingjiang #define SSP_SET_SCLK_SLAVE	BIT(25)
38874ed4097SZhu Yingjiang #define SSP_SET_SFRM_SLAVE	BIT(24)
38974ed4097SZhu Yingjiang #define SSP_SET_SLAVE		(SSP_SET_SCLK_SLAVE | SSP_SET_SFRM_SLAVE)
39074ed4097SZhu Yingjiang 
391c99fafdfSKai Vehmanen #define HDA_IDISP_ADDR		2
392c99fafdfSKai Vehmanen #define HDA_IDISP_CODEC(x) ((x) & BIT(HDA_IDISP_ADDR))
393dd96dacaSLiam Girdwood 
394dd96dacaSLiam Girdwood struct sof_intel_dsp_bdl {
395dd96dacaSLiam Girdwood 	__le32 addr_l;
396dd96dacaSLiam Girdwood 	__le32 addr_h;
397dd96dacaSLiam Girdwood 	__le32 size;
398dd96dacaSLiam Girdwood 	__le32 ioc;
399dd96dacaSLiam Girdwood } __attribute((packed));
400dd96dacaSLiam Girdwood 
401dd96dacaSLiam Girdwood #define SOF_HDA_PLAYBACK_STREAMS	16
402dd96dacaSLiam Girdwood #define SOF_HDA_CAPTURE_STREAMS		16
403dd96dacaSLiam Girdwood #define SOF_HDA_PLAYBACK		0
404dd96dacaSLiam Girdwood #define SOF_HDA_CAPTURE			1
405dd96dacaSLiam Girdwood 
40689a400bdSRanjani Sridharan /* stream flags */
40789a400bdSRanjani Sridharan #define SOF_HDA_STREAM_DMI_L1_COMPATIBLE	1
40889a400bdSRanjani Sridharan 
40963e51fd3SRanjani Sridharan /*
41063e51fd3SRanjani Sridharan  * Time in ms for opportunistic D0I3 entry delay.
41163e51fd3SRanjani Sridharan  * This has been deliberately chosen to be long to avoid race conditions.
41263e51fd3SRanjani Sridharan  * Could be optimized in future.
41363e51fd3SRanjani Sridharan  */
41463e51fd3SRanjani Sridharan #define SOF_HDA_D0I3_WORK_DELAY_MS	5000
41563e51fd3SRanjani Sridharan 
41661e285caSRanjani Sridharan /* HDA DSP D0 substate */
41761e285caSRanjani Sridharan enum sof_hda_D0_substate {
41861e285caSRanjani Sridharan 	SOF_HDA_DSP_PM_D0I0,	/* default D0 substate */
41961e285caSRanjani Sridharan 	SOF_HDA_DSP_PM_D0I3,	/* low power D0 substate */
42061e285caSRanjani Sridharan };
42161e285caSRanjani Sridharan 
422dd96dacaSLiam Girdwood /* represents DSP HDA controller frontend - i.e. host facing control */
423dd96dacaSLiam Girdwood struct sof_intel_hda_dev {
424776100a4SPierre-Louis Bossart 	int boot_iteration;
425dd96dacaSLiam Girdwood 
426dd96dacaSLiam Girdwood 	struct hda_bus hbus;
427dd96dacaSLiam Girdwood 
428dd96dacaSLiam Girdwood 	/* hw config */
429dd96dacaSLiam Girdwood 	const struct sof_intel_dsp_desc *desc;
430dd96dacaSLiam Girdwood 
431dd96dacaSLiam Girdwood 	/* trace */
432dd96dacaSLiam Girdwood 	struct hdac_ext_stream *dtrace_stream;
433dd96dacaSLiam Girdwood 
434dd96dacaSLiam Girdwood 	/* if position update IPC needed */
435dd96dacaSLiam Girdwood 	u32 no_ipc_position;
436dd96dacaSLiam Girdwood 
437e8e55dbeSKeyon Jie 	/* the maximum number of streams (playback + capture) supported */
438e8e55dbeSKeyon Jie 	u32 stream_max;
439e8e55dbeSKeyon Jie 
44016299326SKeyon Jie 	/* PM related */
44116299326SKeyon Jie 	bool l1_support_changed;/* during suspend, is L1SEN changed or not */
44216299326SKeyon Jie 
443dd96dacaSLiam Girdwood 	/* DMIC device */
444dd96dacaSLiam Girdwood 	struct platform_device *dmic_dev;
44563e51fd3SRanjani Sridharan 
44663e51fd3SRanjani Sridharan 	/* delayed work to enter D0I3 opportunistically */
44763e51fd3SRanjani Sridharan 	struct delayed_work d0i3_work;
44851dfed1eSPierre-Louis Bossart 
44951dfed1eSPierre-Louis Bossart 	/* ACPI information stored between scan and probe steps */
45051dfed1eSPierre-Louis Bossart 	struct sdw_intel_acpi_info info;
45151dfed1eSPierre-Louis Bossart 
45251dfed1eSPierre-Louis Bossart 	/* sdw context allocated by SoundWire driver */
45351dfed1eSPierre-Louis Bossart 	struct sdw_intel_ctx *sdw;
454edbaaadaSFred Oh 
455edbaaadaSFred Oh 	/* FW clock config, 0:HPRO, 1:LPRO */
456edbaaadaSFred Oh 	bool clk_config_lpro;
457dd96dacaSLiam Girdwood };
458dd96dacaSLiam Girdwood 
459dd96dacaSLiam Girdwood static inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s)
460dd96dacaSLiam Girdwood {
461dd96dacaSLiam Girdwood 	struct sof_intel_hda_dev *hda = s->pdata->hw_pdata;
462dd96dacaSLiam Girdwood 
463dd96dacaSLiam Girdwood 	return &hda->hbus.core;
464dd96dacaSLiam Girdwood }
465dd96dacaSLiam Girdwood 
466dd96dacaSLiam Girdwood static inline struct hda_bus *sof_to_hbus(struct snd_sof_dev *s)
467dd96dacaSLiam Girdwood {
468dd96dacaSLiam Girdwood 	struct sof_intel_hda_dev *hda = s->pdata->hw_pdata;
469dd96dacaSLiam Girdwood 
470dd96dacaSLiam Girdwood 	return &hda->hbus;
471dd96dacaSLiam Girdwood }
472dd96dacaSLiam Girdwood 
473dd96dacaSLiam Girdwood struct sof_intel_hda_stream {
4747623ae79SRanjani Sridharan 	struct snd_sof_dev *sdev;
475dd96dacaSLiam Girdwood 	struct hdac_ext_stream hda_stream;
476dd96dacaSLiam Girdwood 	struct sof_intel_stream stream;
4776b2239e3SRanjani Sridharan 	int host_reserved; /* reserve host DMA channel */
47889a400bdSRanjani Sridharan 	u32 flags;
479dd96dacaSLiam Girdwood };
480dd96dacaSLiam Girdwood 
481f5dbba9fSRanjani Sridharan #define hstream_to_sof_hda_stream(hstream) \
482f5dbba9fSRanjani Sridharan 	container_of(hstream, struct sof_intel_hda_stream, hda_stream)
483f5dbba9fSRanjani Sridharan 
484dd96dacaSLiam Girdwood #define bus_to_sof_hda(bus) \
485dd96dacaSLiam Girdwood 	container_of(bus, struct sof_intel_hda_dev, hbus.core)
486dd96dacaSLiam Girdwood 
487dd96dacaSLiam Girdwood #define SOF_STREAM_SD_OFFSET(s) \
488dd96dacaSLiam Girdwood 	(SOF_HDA_ADSP_SD_ENTRY_SIZE * ((s)->index) \
489dd96dacaSLiam Girdwood 	 + SOF_HDA_ADSP_LOADER_BASE)
490dd96dacaSLiam Girdwood 
491dd96dacaSLiam Girdwood /*
492dd96dacaSLiam Girdwood  * DSP Core services.
493dd96dacaSLiam Girdwood  */
494dd96dacaSLiam Girdwood int hda_dsp_probe(struct snd_sof_dev *sdev);
495dd96dacaSLiam Girdwood int hda_dsp_remove(struct snd_sof_dev *sdev);
496dd96dacaSLiam Girdwood int hda_dsp_core_reset_enter(struct snd_sof_dev *sdev,
497dd96dacaSLiam Girdwood 			     unsigned int core_mask);
498dd96dacaSLiam Girdwood int hda_dsp_core_reset_leave(struct snd_sof_dev *sdev,
499dd96dacaSLiam Girdwood 			     unsigned int core_mask);
500dd96dacaSLiam Girdwood int hda_dsp_core_stall_reset(struct snd_sof_dev *sdev, unsigned int core_mask);
501dd96dacaSLiam Girdwood int hda_dsp_core_run(struct snd_sof_dev *sdev, unsigned int core_mask);
502dd96dacaSLiam Girdwood int hda_dsp_core_power_up(struct snd_sof_dev *sdev, unsigned int core_mask);
503dd96dacaSLiam Girdwood int hda_dsp_enable_core(struct snd_sof_dev *sdev, unsigned int core_mask);
504dd96dacaSLiam Girdwood int hda_dsp_core_power_down(struct snd_sof_dev *sdev, unsigned int core_mask);
505dd96dacaSLiam Girdwood bool hda_dsp_core_is_enabled(struct snd_sof_dev *sdev,
506dd96dacaSLiam Girdwood 			     unsigned int core_mask);
507dd96dacaSLiam Girdwood int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev,
508dd96dacaSLiam Girdwood 				  unsigned int core_mask);
509dd96dacaSLiam Girdwood void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev);
510dd96dacaSLiam Girdwood void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev);
511dd96dacaSLiam Girdwood 
51262f8f766SKeyon Jie int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
51361e285caSRanjani Sridharan 			    const struct sof_dsp_power_state *target_state);
51462f8f766SKeyon Jie 
51561e285caSRanjani Sridharan int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state);
516dd96dacaSLiam Girdwood int hda_dsp_resume(struct snd_sof_dev *sdev);
5171c38c922SFred Oh int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev);
518dd96dacaSLiam Girdwood int hda_dsp_runtime_resume(struct snd_sof_dev *sdev);
51962fde977SKai Vehmanen int hda_dsp_runtime_idle(struct snd_sof_dev *sdev);
5207077a07aSRanjani Sridharan int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev);
521dd96dacaSLiam Girdwood void hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags);
522f3da49f0SPan Xiuli void hda_ipc_dump(struct snd_sof_dev *sdev);
523f1fd9d0eSKai Vehmanen void hda_ipc_irq_dump(struct snd_sof_dev *sdev);
52463e51fd3SRanjani Sridharan void hda_dsp_d0i3_work(struct work_struct *work);
525dd96dacaSLiam Girdwood 
526dd96dacaSLiam Girdwood /*
527dd96dacaSLiam Girdwood  * DSP PCM Operations.
528dd96dacaSLiam Girdwood  */
52949d7948eSCezary Rojewski u32 hda_dsp_get_mult_div(struct snd_sof_dev *sdev, int rate);
53049d7948eSCezary Rojewski u32 hda_dsp_get_bits(struct snd_sof_dev *sdev, int sample_bits);
531dd96dacaSLiam Girdwood int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
532dd96dacaSLiam Girdwood 		     struct snd_pcm_substream *substream);
533dd96dacaSLiam Girdwood int hda_dsp_pcm_close(struct snd_sof_dev *sdev,
534dd96dacaSLiam Girdwood 		      struct snd_pcm_substream *substream);
535dd96dacaSLiam Girdwood int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
536dd96dacaSLiam Girdwood 			  struct snd_pcm_substream *substream,
537dd96dacaSLiam Girdwood 			  struct snd_pcm_hw_params *params,
538dd96dacaSLiam Girdwood 			  struct sof_ipc_stream_params *ipc_params);
53993146bc2SRanjani Sridharan int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
54093146bc2SRanjani Sridharan 			   struct snd_pcm_substream *substream);
541dd96dacaSLiam Girdwood int hda_dsp_pcm_trigger(struct snd_sof_dev *sdev,
542dd96dacaSLiam Girdwood 			struct snd_pcm_substream *substream, int cmd);
543dd96dacaSLiam Girdwood snd_pcm_uframes_t hda_dsp_pcm_pointer(struct snd_sof_dev *sdev,
544dd96dacaSLiam Girdwood 				      struct snd_pcm_substream *substream);
545dd96dacaSLiam Girdwood 
546dd96dacaSLiam Girdwood /*
547dd96dacaSLiam Girdwood  * DSP Stream Operations.
548dd96dacaSLiam Girdwood  */
549dd96dacaSLiam Girdwood 
550dd96dacaSLiam Girdwood int hda_dsp_stream_init(struct snd_sof_dev *sdev);
551dd96dacaSLiam Girdwood void hda_dsp_stream_free(struct snd_sof_dev *sdev);
552dd96dacaSLiam Girdwood int hda_dsp_stream_hw_params(struct snd_sof_dev *sdev,
553dd96dacaSLiam Girdwood 			     struct hdac_ext_stream *stream,
554dd96dacaSLiam Girdwood 			     struct snd_dma_buffer *dmab,
555dd96dacaSLiam Girdwood 			     struct snd_pcm_hw_params *params);
556aca961f1SRanjani Sridharan int hda_dsp_iccmax_stream_hw_params(struct snd_sof_dev *sdev, struct hdac_ext_stream *stream,
557aca961f1SRanjani Sridharan 				    struct snd_dma_buffer *dmab,
558aca961f1SRanjani Sridharan 				    struct snd_pcm_hw_params *params);
559dd96dacaSLiam Girdwood int hda_dsp_stream_trigger(struct snd_sof_dev *sdev,
560dd96dacaSLiam Girdwood 			   struct hdac_ext_stream *stream, int cmd);
561dd96dacaSLiam Girdwood irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context);
562dd96dacaSLiam Girdwood int hda_dsp_stream_setup_bdl(struct snd_sof_dev *sdev,
563dd96dacaSLiam Girdwood 			     struct snd_dma_buffer *dmab,
564dd96dacaSLiam Girdwood 			     struct hdac_stream *stream);
5657c11af9fSBard Liao bool hda_dsp_check_ipc_irq(struct snd_sof_dev *sdev);
5667c11af9fSBard Liao bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev);
567dd96dacaSLiam Girdwood 
568dd96dacaSLiam Girdwood struct hdac_ext_stream *
56989a400bdSRanjani Sridharan 	hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags);
570dd96dacaSLiam Girdwood int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag);
571dd96dacaSLiam Girdwood int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev,
572dd96dacaSLiam Girdwood 			       struct hdac_ext_stream *stream,
573dd96dacaSLiam Girdwood 			       int enable, u32 size);
574dd96dacaSLiam Girdwood 
575dd96dacaSLiam Girdwood void hda_ipc_msg_data(struct snd_sof_dev *sdev,
576dd96dacaSLiam Girdwood 		      struct snd_pcm_substream *substream,
577dd96dacaSLiam Girdwood 		      void *p, size_t sz);
578dd96dacaSLiam Girdwood int hda_ipc_pcm_params(struct snd_sof_dev *sdev,
579dd96dacaSLiam Girdwood 		       struct snd_pcm_substream *substream,
580dd96dacaSLiam Girdwood 		       const struct sof_ipc_pcm_params_reply *reply);
581dd96dacaSLiam Girdwood 
5824c414da9SCezary Rojewski #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_PROBES)
5834c414da9SCezary Rojewski /*
5844c414da9SCezary Rojewski  * Probe Compress Operations.
5854c414da9SCezary Rojewski  */
5864c414da9SCezary Rojewski int hda_probe_compr_assign(struct snd_sof_dev *sdev,
5874c414da9SCezary Rojewski 			   struct snd_compr_stream *cstream,
5884c414da9SCezary Rojewski 			   struct snd_soc_dai *dai);
5894c414da9SCezary Rojewski int hda_probe_compr_free(struct snd_sof_dev *sdev,
5904c414da9SCezary Rojewski 			 struct snd_compr_stream *cstream,
5914c414da9SCezary Rojewski 			 struct snd_soc_dai *dai);
5924c414da9SCezary Rojewski int hda_probe_compr_set_params(struct snd_sof_dev *sdev,
5934c414da9SCezary Rojewski 			       struct snd_compr_stream *cstream,
5944c414da9SCezary Rojewski 			       struct snd_compr_params *params,
5954c414da9SCezary Rojewski 			       struct snd_soc_dai *dai);
5964c414da9SCezary Rojewski int hda_probe_compr_trigger(struct snd_sof_dev *sdev,
5974c414da9SCezary Rojewski 			    struct snd_compr_stream *cstream, int cmd,
5984c414da9SCezary Rojewski 			    struct snd_soc_dai *dai);
5994c414da9SCezary Rojewski int hda_probe_compr_pointer(struct snd_sof_dev *sdev,
6004c414da9SCezary Rojewski 			    struct snd_compr_stream *cstream,
6014c414da9SCezary Rojewski 			    struct snd_compr_tstamp *tstamp,
6024c414da9SCezary Rojewski 			    struct snd_soc_dai *dai);
6034c414da9SCezary Rojewski #endif
6044c414da9SCezary Rojewski 
605dd96dacaSLiam Girdwood /*
606dd96dacaSLiam Girdwood  * DSP IPC Operations.
607dd96dacaSLiam Girdwood  */
608dd96dacaSLiam Girdwood int hda_dsp_ipc_send_msg(struct snd_sof_dev *sdev,
609dd96dacaSLiam Girdwood 			 struct snd_sof_ipc_msg *msg);
610dd96dacaSLiam Girdwood void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev);
6116eebd390SDaniel Baluta int hda_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev);
6126eebd390SDaniel Baluta int hda_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id);
6136eebd390SDaniel Baluta 
614dd96dacaSLiam Girdwood irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context);
615dd96dacaSLiam Girdwood int hda_dsp_ipc_cmd_done(struct snd_sof_dev *sdev, int dir);
616dd96dacaSLiam Girdwood 
617dd96dacaSLiam Girdwood /*
618dd96dacaSLiam Girdwood  * DSP Code loader.
619dd96dacaSLiam Girdwood  */
620dd96dacaSLiam Girdwood int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev);
621acf705a4SRanjani Sridharan int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev);
6220cde3e9fSFred Oh int hda_dsp_cl_boot_firmware_iccmax_icl(struct snd_sof_dev *sdev);
623dd96dacaSLiam Girdwood int hda_dsp_cl_boot_firmware_skl(struct snd_sof_dev *sdev);
624dd96dacaSLiam Girdwood 
625dd96dacaSLiam Girdwood /* pre and post fw run ops */
626dd96dacaSLiam Girdwood int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev);
627dd96dacaSLiam Girdwood int hda_dsp_post_fw_run(struct snd_sof_dev *sdev);
6280cde3e9fSFred Oh int hda_dsp_post_fw_run_icl(struct snd_sof_dev *sdev);
6290cde3e9fSFred Oh int hda_dsp_core_stall_icl(struct snd_sof_dev *sdev, unsigned int core_mask);
630dd96dacaSLiam Girdwood 
631edbaaadaSFred Oh /* parse platform specific ext manifest ops */
632edbaaadaSFred Oh int hda_dsp_ext_man_get_cavs_config_data(struct snd_sof_dev *sdev,
633edbaaadaSFred Oh 					 const struct sof_ext_man_elem_header *hdr);
634edbaaadaSFred Oh 
635dd96dacaSLiam Girdwood /*
636dd96dacaSLiam Girdwood  * HDA Controller Operations.
637dd96dacaSLiam Girdwood  */
638dd96dacaSLiam Girdwood int hda_dsp_ctrl_get_caps(struct snd_sof_dev *sdev);
639dd96dacaSLiam Girdwood void hda_dsp_ctrl_ppcap_enable(struct snd_sof_dev *sdev, bool enable);
640dd96dacaSLiam Girdwood void hda_dsp_ctrl_ppcap_int_enable(struct snd_sof_dev *sdev, bool enable);
641dd96dacaSLiam Girdwood int hda_dsp_ctrl_link_reset(struct snd_sof_dev *sdev, bool reset);
642dd96dacaSLiam Girdwood void hda_dsp_ctrl_misc_clock_gating(struct snd_sof_dev *sdev, bool enable);
643dd96dacaSLiam Girdwood int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable);
644dd96dacaSLiam Girdwood int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev, bool full_reset);
64513063a2cSZhu Yingjiang void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev);
646dd96dacaSLiam Girdwood /*
647dd96dacaSLiam Girdwood  * HDA bus operations.
648dd96dacaSLiam Girdwood  */
649d4ff1b39STakashi Iwai void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev);
650dd96dacaSLiam Girdwood 
651dd96dacaSLiam Girdwood #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
652dd96dacaSLiam Girdwood /*
653dd96dacaSLiam Girdwood  * HDA Codec operations.
654dd96dacaSLiam Girdwood  */
65591dce767SKai Vehmanen void hda_codec_probe_bus(struct snd_sof_dev *sdev,
65680acdd4fSRanjani Sridharan 			 bool hda_codec_use_common_hdmi);
65731ba0c07SKai-Heng Feng void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable);
658fd15f2f5SRander Wang void hda_codec_jack_check(struct snd_sof_dev *sdev);
659dd96dacaSLiam Girdwood 
660dd96dacaSLiam Girdwood #endif /* CONFIG_SND_SOC_SOF_HDA */
661dd96dacaSLiam Girdwood 
662139c7febSKai Vehmanen #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) && \
663139c7febSKai Vehmanen 	(IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI) || \
664139c7febSKai Vehmanen 	 IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
665dd96dacaSLiam Girdwood 
66623ee0903SKai Vehmanen void hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable);
667dd96dacaSLiam Girdwood int hda_codec_i915_init(struct snd_sof_dev *sdev);
668dd96dacaSLiam Girdwood int hda_codec_i915_exit(struct snd_sof_dev *sdev);
669dd96dacaSLiam Girdwood 
670dd96dacaSLiam Girdwood #else
671dd96dacaSLiam Girdwood 
67223ee0903SKai Vehmanen static inline void hda_codec_i915_display_power(struct snd_sof_dev *sdev,
67323ee0903SKai Vehmanen 						bool enable) { }
674dd96dacaSLiam Girdwood static inline int hda_codec_i915_init(struct snd_sof_dev *sdev) { return 0; }
675dd96dacaSLiam Girdwood static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }
676dd96dacaSLiam Girdwood 
677139c7febSKai Vehmanen #endif
678dd96dacaSLiam Girdwood 
679dd96dacaSLiam Girdwood /*
680dd96dacaSLiam Girdwood  * Trace Control.
681dd96dacaSLiam Girdwood  */
682dd96dacaSLiam Girdwood int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag);
683dd96dacaSLiam Girdwood int hda_dsp_trace_release(struct snd_sof_dev *sdev);
684dd96dacaSLiam Girdwood int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd);
685dd96dacaSLiam Girdwood 
68651dfed1eSPierre-Louis Bossart /*
68751dfed1eSPierre-Louis Bossart  * SoundWire support
68851dfed1eSPierre-Louis Bossart  */
68951dfed1eSPierre-Louis Bossart #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
69051dfed1eSPierre-Louis Bossart 
69151dfed1eSPierre-Louis Bossart int hda_sdw_startup(struct snd_sof_dev *sdev);
69251dfed1eSPierre-Louis Bossart void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable);
693bbd19cdcSRander Wang void hda_sdw_process_wakeen(struct snd_sof_dev *sdev);
69451dfed1eSPierre-Louis Bossart 
69551dfed1eSPierre-Louis Bossart #else
69651dfed1eSPierre-Louis Bossart 
69751dfed1eSPierre-Louis Bossart static inline int hda_sdw_acpi_scan(struct snd_sof_dev *sdev)
69851dfed1eSPierre-Louis Bossart {
69951dfed1eSPierre-Louis Bossart 	return 0;
70051dfed1eSPierre-Louis Bossart }
70151dfed1eSPierre-Louis Bossart 
70251dfed1eSPierre-Louis Bossart static inline int hda_sdw_probe(struct snd_sof_dev *sdev)
70351dfed1eSPierre-Louis Bossart {
70451dfed1eSPierre-Louis Bossart 	return 0;
70551dfed1eSPierre-Louis Bossart }
70651dfed1eSPierre-Louis Bossart 
70751dfed1eSPierre-Louis Bossart static inline int hda_sdw_startup(struct snd_sof_dev *sdev)
70851dfed1eSPierre-Louis Bossart {
70951dfed1eSPierre-Louis Bossart 	return 0;
71051dfed1eSPierre-Louis Bossart }
71151dfed1eSPierre-Louis Bossart 
71251dfed1eSPierre-Louis Bossart static inline int hda_sdw_exit(struct snd_sof_dev *sdev)
71351dfed1eSPierre-Louis Bossart {
71451dfed1eSPierre-Louis Bossart 	return 0;
71551dfed1eSPierre-Louis Bossart }
71651dfed1eSPierre-Louis Bossart 
71751dfed1eSPierre-Louis Bossart static inline void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable)
71851dfed1eSPierre-Louis Bossart {
71951dfed1eSPierre-Louis Bossart }
72051dfed1eSPierre-Louis Bossart 
721722ba5f1SBard Liao static inline bool hda_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
722722ba5f1SBard Liao {
723722ba5f1SBard Liao 	return false;
724722ba5f1SBard Liao }
725722ba5f1SBard Liao 
726722ba5f1SBard Liao static inline irqreturn_t hda_dsp_sdw_thread(int irq, void *context)
727722ba5f1SBard Liao {
728722ba5f1SBard Liao 	return IRQ_HANDLED;
729722ba5f1SBard Liao }
730bbd19cdcSRander Wang 
73190de3281SRander Wang static inline bool hda_sdw_check_wakeen_irq(struct snd_sof_dev *sdev)
73290de3281SRander Wang {
73390de3281SRander Wang 	return false;
73490de3281SRander Wang }
73590de3281SRander Wang 
736bbd19cdcSRander Wang static inline void hda_sdw_process_wakeen(struct snd_sof_dev *sdev)
737bbd19cdcSRander Wang {
738bbd19cdcSRander Wang }
73951dfed1eSPierre-Louis Bossart #endif
74051dfed1eSPierre-Louis Bossart 
741dd96dacaSLiam Girdwood /* common dai driver */
742dd96dacaSLiam Girdwood extern struct snd_soc_dai_driver skl_dai[];
743dd96dacaSLiam Girdwood 
744dd96dacaSLiam Girdwood /*
745dd96dacaSLiam Girdwood  * Platform Specific HW abstraction Ops.
746dd96dacaSLiam Girdwood  */
747dd96dacaSLiam Girdwood extern const struct snd_sof_dsp_ops sof_apl_ops;
748dd96dacaSLiam Girdwood extern const struct snd_sof_dsp_ops sof_cnl_ops;
7498b98491aSRanjani Sridharan extern const struct snd_sof_dsp_ops sof_tgl_ops;
7500cde3e9fSFred Oh extern const struct snd_sof_dsp_ops sof_icl_ops;
751dd96dacaSLiam Girdwood 
752dd96dacaSLiam Girdwood extern const struct sof_intel_dsp_desc apl_chip_info;
753dd96dacaSLiam Girdwood extern const struct sof_intel_dsp_desc cnl_chip_info;
754dd96dacaSLiam Girdwood extern const struct sof_intel_dsp_desc skl_chip_info;
755630be964SZhu Yingjiang extern const struct sof_intel_dsp_desc icl_chip_info;
7561205c81eSPan Xiuli extern const struct sof_intel_dsp_desc tgl_chip_info;
75730ee3738SRander Wang extern const struct sof_intel_dsp_desc tglh_chip_info;
75861732690SPan Xiuli extern const struct sof_intel_dsp_desc ehl_chip_info;
7596fd99035SPan Xiuli extern const struct sof_intel_dsp_desc jsl_chip_info;
7606c2b6bb0SKai Vehmanen extern const struct sof_intel_dsp_desc adls_chip_info;
761dd96dacaSLiam Girdwood 
762285880a2SDaniel Baluta /* machine driver select */
763285880a2SDaniel Baluta void hda_machine_select(struct snd_sof_dev *sdev);
764285880a2SDaniel Baluta void hda_set_mach_params(const struct snd_soc_acpi_mach *mach,
765285880a2SDaniel Baluta 			 struct device *dev);
766285880a2SDaniel Baluta 
767*194fe0fcSPierre-Louis Bossart /* PCI driver selection and probe */
768*194fe0fcSPierre-Louis Bossart int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id);
769*194fe0fcSPierre-Louis Bossart 
770dd96dacaSLiam Girdwood #endif
771