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>
193dc0d709SPeter Ujfalusi #include "../sof-client-probes.h"
20051744b1SRanjani Sridharan #include "../sof-audio.h"
21dd96dacaSLiam Girdwood #include "shim.h"
22dd96dacaSLiam Girdwood
23dd96dacaSLiam Girdwood /* PCI registers */
24dd96dacaSLiam Girdwood #define PCI_TCSEL 0x44
25dd96dacaSLiam Girdwood #define PCI_PGCTL PCI_TCSEL
26dd96dacaSLiam Girdwood #define PCI_CGCTL 0x48
27dd96dacaSLiam Girdwood
28dd96dacaSLiam Girdwood /* PCI_PGCTL bits */
29dd96dacaSLiam Girdwood #define PCI_PGCTL_ADSPPGD BIT(2)
30dd96dacaSLiam Girdwood #define PCI_PGCTL_LSRMD_MASK BIT(4)
31dd96dacaSLiam Girdwood
32dd96dacaSLiam Girdwood /* PCI_CGCTL bits */
33dd96dacaSLiam Girdwood #define PCI_CGCTL_MISCBDCGE_MASK BIT(6)
34dd96dacaSLiam Girdwood #define PCI_CGCTL_ADSPDCGE BIT(1)
35dd96dacaSLiam Girdwood
36dd96dacaSLiam Girdwood /* Legacy HDA registers and bits used - widths are variable */
37dd96dacaSLiam Girdwood #define SOF_HDA_GCAP 0x0
38dd96dacaSLiam Girdwood #define SOF_HDA_GCTL 0x8
39dd96dacaSLiam Girdwood /* accept unsol. response enable */
40dd96dacaSLiam Girdwood #define SOF_HDA_GCTL_UNSOL BIT(8)
41dd96dacaSLiam Girdwood #define SOF_HDA_LLCH 0x14
42dd96dacaSLiam Girdwood #define SOF_HDA_INTCTL 0x20
43dd96dacaSLiam Girdwood #define SOF_HDA_INTSTS 0x24
44dd96dacaSLiam Girdwood #define SOF_HDA_WAKESTS 0x0E
45dd96dacaSLiam Girdwood #define SOF_HDA_WAKESTS_INT_MASK ((1 << 8) - 1)
46dd96dacaSLiam Girdwood #define SOF_HDA_RIRBSTS 0x5d
47dd96dacaSLiam Girdwood
48dd96dacaSLiam Girdwood /* SOF_HDA_GCTL register bist */
49dd96dacaSLiam Girdwood #define SOF_HDA_GCTL_RESET BIT(0)
50dd96dacaSLiam Girdwood
517c11af9fSBard Liao /* SOF_HDA_INCTL regs */
52dd96dacaSLiam Girdwood #define SOF_HDA_INT_GLOBAL_EN BIT(31)
53dd96dacaSLiam Girdwood #define SOF_HDA_INT_CTRL_EN BIT(30)
54dd96dacaSLiam Girdwood #define SOF_HDA_INT_ALL_STREAM 0xff
55dd96dacaSLiam Girdwood
567c11af9fSBard Liao /* SOF_HDA_INTSTS regs */
577c11af9fSBard Liao #define SOF_HDA_INTSTS_GIS BIT(31)
587c11af9fSBard Liao
59dd96dacaSLiam Girdwood #define SOF_HDA_MAX_CAPS 10
60dd96dacaSLiam Girdwood #define SOF_HDA_CAP_ID_OFF 16
61dd96dacaSLiam Girdwood #define SOF_HDA_CAP_ID_MASK GENMASK(SOF_HDA_CAP_ID_OFF + 11,\
62dd96dacaSLiam Girdwood SOF_HDA_CAP_ID_OFF)
63dd96dacaSLiam Girdwood #define SOF_HDA_CAP_NEXT_MASK 0xFFFF
64dd96dacaSLiam Girdwood
65dd96dacaSLiam Girdwood #define SOF_HDA_GTS_CAP_ID 0x1
66dd96dacaSLiam Girdwood #define SOF_HDA_ML_CAP_ID 0x2
67dd96dacaSLiam Girdwood
68dd96dacaSLiam Girdwood #define SOF_HDA_PP_CAP_ID 0x3
69dd96dacaSLiam Girdwood #define SOF_HDA_REG_PP_PPCH 0x10
70dd96dacaSLiam Girdwood #define SOF_HDA_REG_PP_PPCTL 0x04
71f1fd9d0eSKai Vehmanen #define SOF_HDA_REG_PP_PPSTS 0x08
72dd96dacaSLiam Girdwood #define SOF_HDA_PPCTL_PIE BIT(31)
73dd96dacaSLiam Girdwood #define SOF_HDA_PPCTL_GPROCEN BIT(30)
74dd96dacaSLiam Girdwood
7562f8f766SKeyon Jie /*Vendor Specific Registers*/
7662f8f766SKeyon Jie #define SOF_HDA_VS_D0I3C 0x104A
7762f8f766SKeyon Jie
7862f8f766SKeyon Jie /* D0I3C Register fields */
7962f8f766SKeyon Jie #define SOF_HDA_VS_D0I3C_CIP BIT(0) /* Command-In-Progress */
8062f8f766SKeyon Jie #define SOF_HDA_VS_D0I3C_I3 BIT(2) /* D0i3 enable bit */
8162f8f766SKeyon Jie
82dd96dacaSLiam Girdwood /* DPIB entry size: 8 Bytes = 2 DWords */
83dd96dacaSLiam Girdwood #define SOF_HDA_DPIB_ENTRY_SIZE 0x8
84dd96dacaSLiam Girdwood
85dd96dacaSLiam Girdwood #define SOF_HDA_SPIB_CAP_ID 0x4
86dd96dacaSLiam Girdwood #define SOF_HDA_DRSM_CAP_ID 0x5
87dd96dacaSLiam Girdwood
88dd96dacaSLiam Girdwood #define SOF_HDA_SPIB_BASE 0x08
89dd96dacaSLiam Girdwood #define SOF_HDA_SPIB_INTERVAL 0x08
90dd96dacaSLiam Girdwood #define SOF_HDA_SPIB_SPIB 0x00
91dd96dacaSLiam Girdwood #define SOF_HDA_SPIB_MAXFIFO 0x04
92dd96dacaSLiam Girdwood
93dd96dacaSLiam Girdwood #define SOF_HDA_PPHC_BASE 0x10
94dd96dacaSLiam Girdwood #define SOF_HDA_PPHC_INTERVAL 0x10
95dd96dacaSLiam Girdwood
96dd96dacaSLiam Girdwood #define SOF_HDA_PPLC_BASE 0x10
97dd96dacaSLiam Girdwood #define SOF_HDA_PPLC_MULTI 0x10
98dd96dacaSLiam Girdwood #define SOF_HDA_PPLC_INTERVAL 0x10
99dd96dacaSLiam Girdwood
100dd96dacaSLiam Girdwood #define SOF_HDA_DRSM_BASE 0x08
101dd96dacaSLiam Girdwood #define SOF_HDA_DRSM_INTERVAL 0x08
102dd96dacaSLiam Girdwood
103dd96dacaSLiam Girdwood /* Descriptor error interrupt */
104dd96dacaSLiam Girdwood #define SOF_HDA_CL_DMA_SD_INT_DESC_ERR 0x10
105dd96dacaSLiam Girdwood
106dd96dacaSLiam Girdwood /* FIFO error interrupt */
107dd96dacaSLiam Girdwood #define SOF_HDA_CL_DMA_SD_INT_FIFO_ERR 0x08
108dd96dacaSLiam Girdwood
109dd96dacaSLiam Girdwood /* Buffer completion interrupt */
110dd96dacaSLiam Girdwood #define SOF_HDA_CL_DMA_SD_INT_COMPLETE 0x04
111dd96dacaSLiam Girdwood
112dd96dacaSLiam Girdwood #define SOF_HDA_CL_DMA_SD_INT_MASK \
113dd96dacaSLiam Girdwood (SOF_HDA_CL_DMA_SD_INT_DESC_ERR | \
114dd96dacaSLiam Girdwood SOF_HDA_CL_DMA_SD_INT_FIFO_ERR | \
115dd96dacaSLiam Girdwood SOF_HDA_CL_DMA_SD_INT_COMPLETE)
116dd96dacaSLiam Girdwood #define SOF_HDA_SD_CTL_DMA_START 0x02 /* Stream DMA start bit */
117dd96dacaSLiam Girdwood
118dd96dacaSLiam Girdwood /* Intel HD Audio Code Loader DMA Registers */
119dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_LOADER_BASE 0x80
120dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_DPLBASE 0x70
121dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_DPUBASE 0x74
122dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_DPLBASE_ENABLE 0x01
123dd96dacaSLiam Girdwood
124dd96dacaSLiam Girdwood /* Stream Registers */
12538bf0780SPierre-Louis Bossart #define SOF_HDA_ADSP_REG_SD_CTL 0x00
12638bf0780SPierre-Louis Bossart #define SOF_HDA_ADSP_REG_SD_STS 0x03
12738bf0780SPierre-Louis Bossart #define SOF_HDA_ADSP_REG_SD_LPIB 0x04
12838bf0780SPierre-Louis Bossart #define SOF_HDA_ADSP_REG_SD_CBL 0x08
12938bf0780SPierre-Louis Bossart #define SOF_HDA_ADSP_REG_SD_LVI 0x0C
13038bf0780SPierre-Louis Bossart #define SOF_HDA_ADSP_REG_SD_FIFOW 0x0E
13138bf0780SPierre-Louis Bossart #define SOF_HDA_ADSP_REG_SD_FIFOSIZE 0x10
13238bf0780SPierre-Louis Bossart #define SOF_HDA_ADSP_REG_SD_FORMAT 0x12
13338bf0780SPierre-Louis Bossart #define SOF_HDA_ADSP_REG_SD_FIFOL 0x14
13438bf0780SPierre-Louis Bossart #define SOF_HDA_ADSP_REG_SD_BDLPL 0x18
13538bf0780SPierre-Louis Bossart #define SOF_HDA_ADSP_REG_SD_BDLPU 0x1C
136dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_SD_ENTRY_SIZE 0x20
137dd96dacaSLiam Girdwood
138dd96dacaSLiam Girdwood /* CL: Software Position Based FIFO Capability Registers */
139dd96dacaSLiam Girdwood #define SOF_DSP_REG_CL_SPBFIFO \
140dd96dacaSLiam Girdwood (SOF_HDA_ADSP_LOADER_BASE + 0x20)
141dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCH 0x0
142dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCCTL 0x4
143dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPIB 0x8
144dd96dacaSLiam Girdwood #define SOF_HDA_ADSP_REG_CL_SPBFIFO_MAXFIFOS 0xc
145dd96dacaSLiam Girdwood
146dd96dacaSLiam Girdwood /* Stream Number */
147dd96dacaSLiam Girdwood #define SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT 20
148dd96dacaSLiam Girdwood #define SOF_HDA_CL_SD_CTL_STREAM_TAG_MASK \
149dd96dacaSLiam Girdwood GENMASK(SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT + 3,\
150dd96dacaSLiam Girdwood SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT)
151dd96dacaSLiam Girdwood
152dd96dacaSLiam Girdwood #define HDA_DSP_HDA_BAR 0
153dd96dacaSLiam Girdwood #define HDA_DSP_PP_BAR 1
154dd96dacaSLiam Girdwood #define HDA_DSP_SPIB_BAR 2
155dd96dacaSLiam Girdwood #define HDA_DSP_DRSM_BAR 3
156dd96dacaSLiam Girdwood #define HDA_DSP_BAR 4
157dd96dacaSLiam Girdwood
158dd96dacaSLiam Girdwood #define SRAM_WINDOW_OFFSET(x) (0x80000 + (x) * 0x20000)
159dd96dacaSLiam Girdwood
160dd96dacaSLiam Girdwood #define HDA_DSP_MBOX_OFFSET SRAM_WINDOW_OFFSET(0)
161dd96dacaSLiam Girdwood
162dd96dacaSLiam Girdwood #define HDA_DSP_PANIC_OFFSET(x) \
163dd96dacaSLiam Girdwood (((x) & 0xFFFFFF) + HDA_DSP_MBOX_OFFSET)
164dd96dacaSLiam Girdwood
165dd96dacaSLiam Girdwood /* SRAM window 0 FW "registers" */
166dd96dacaSLiam Girdwood #define HDA_DSP_SRAM_REG_ROM_STATUS (HDA_DSP_MBOX_OFFSET + 0x0)
167dd96dacaSLiam Girdwood #define HDA_DSP_SRAM_REG_ROM_ERROR (HDA_DSP_MBOX_OFFSET + 0x4)
168dd96dacaSLiam Girdwood /* FW and ROM share offset 4 */
169dd96dacaSLiam Girdwood #define HDA_DSP_SRAM_REG_FW_STATUS (HDA_DSP_MBOX_OFFSET + 0x4)
170dd96dacaSLiam Girdwood #define HDA_DSP_SRAM_REG_FW_TRACEP (HDA_DSP_MBOX_OFFSET + 0x8)
171dd96dacaSLiam Girdwood #define HDA_DSP_SRAM_REG_FW_END (HDA_DSP_MBOX_OFFSET + 0xc)
172dd96dacaSLiam Girdwood
173dd96dacaSLiam Girdwood #define HDA_DSP_MBOX_UPLINK_OFFSET 0x81000
174dd96dacaSLiam Girdwood
175dd96dacaSLiam Girdwood #define HDA_DSP_STREAM_RESET_TIMEOUT 300
1767bcaf0f2SZhu Yingjiang /*
1777bcaf0f2SZhu Yingjiang * Timeout in us, for setting the stream RUN bit, during
1787bcaf0f2SZhu Yingjiang * start/stop the stream. The timeout expires if new RUN bit
1797bcaf0f2SZhu Yingjiang * value cannot be read back within the specified time.
1807bcaf0f2SZhu Yingjiang */
1817bcaf0f2SZhu Yingjiang #define HDA_DSP_STREAM_RUN_TIMEOUT 300
182dd96dacaSLiam Girdwood
183dd96dacaSLiam Girdwood #define HDA_DSP_SPIB_ENABLE 1
184dd96dacaSLiam Girdwood #define HDA_DSP_SPIB_DISABLE 0
185dd96dacaSLiam Girdwood
186dd96dacaSLiam Girdwood #define SOF_HDA_MAX_BUFFER_SIZE (32 * PAGE_SIZE)
187dd96dacaSLiam Girdwood
188dd96dacaSLiam Girdwood #define HDA_DSP_STACK_DUMP_SIZE 32
189dd96dacaSLiam Girdwood
19015d8370cSPeter Ujfalusi /* ROM/FW status register */
19115d8370cSPeter Ujfalusi #define FSR_STATE_MASK GENMASK(23, 0)
19215d8370cSPeter Ujfalusi #define FSR_WAIT_STATE_MASK GENMASK(27, 24)
19315d8370cSPeter Ujfalusi #define FSR_MODULE_MASK GENMASK(30, 28)
19415d8370cSPeter Ujfalusi #define FSR_HALTED BIT(31)
19515d8370cSPeter Ujfalusi #define FSR_TO_STATE_CODE(x) ((x) & FSR_STATE_MASK)
19615d8370cSPeter Ujfalusi #define FSR_TO_WAIT_STATE_CODE(x) (((x) & FSR_WAIT_STATE_MASK) >> 24)
19715d8370cSPeter Ujfalusi #define FSR_TO_MODULE_CODE(x) (((x) & FSR_MODULE_MASK) >> 28)
19815d8370cSPeter Ujfalusi
19915d8370cSPeter Ujfalusi /* Wait states */
20015d8370cSPeter Ujfalusi #define FSR_WAIT_FOR_IPC_BUSY 0x1
20115d8370cSPeter Ujfalusi #define FSR_WAIT_FOR_IPC_DONE 0x2
20215d8370cSPeter Ujfalusi #define FSR_WAIT_FOR_CACHE_INVALIDATION 0x3
20315d8370cSPeter Ujfalusi #define FSR_WAIT_FOR_LP_SRAM_OFF 0x4
20415d8370cSPeter Ujfalusi #define FSR_WAIT_FOR_DMA_BUFFER_FULL 0x5
20515d8370cSPeter Ujfalusi #define FSR_WAIT_FOR_CSE_CSR 0x6
20615d8370cSPeter Ujfalusi
20715d8370cSPeter Ujfalusi /* Module codes */
20815d8370cSPeter Ujfalusi #define FSR_MOD_ROM 0x0
20915d8370cSPeter Ujfalusi #define FSR_MOD_ROM_BYP 0x1
21015d8370cSPeter Ujfalusi #define FSR_MOD_BASE_FW 0x2
21115d8370cSPeter Ujfalusi #define FSR_MOD_LP_BOOT 0x3
21215d8370cSPeter Ujfalusi #define FSR_MOD_BRNGUP 0x4
21315d8370cSPeter Ujfalusi #define FSR_MOD_ROM_EXT 0x5
21415d8370cSPeter Ujfalusi
21515d8370cSPeter Ujfalusi /* State codes (module dependent) */
21615d8370cSPeter Ujfalusi /* Module independent states */
21715d8370cSPeter Ujfalusi #define FSR_STATE_INIT 0x0
21815d8370cSPeter Ujfalusi #define FSR_STATE_INIT_DONE 0x1
21915d8370cSPeter Ujfalusi #define FSR_STATE_FW_ENTERED 0x5
22015d8370cSPeter Ujfalusi
22115d8370cSPeter Ujfalusi /* ROM states */
22215d8370cSPeter Ujfalusi #define FSR_STATE_ROM_INIT FSR_STATE_INIT
22315d8370cSPeter Ujfalusi #define FSR_STATE_ROM_INIT_DONE FSR_STATE_INIT_DONE
22415d8370cSPeter Ujfalusi #define FSR_STATE_ROM_CSE_MANIFEST_LOADED 0x2
22515d8370cSPeter Ujfalusi #define FSR_STATE_ROM_FW_MANIFEST_LOADED 0x3
22615d8370cSPeter Ujfalusi #define FSR_STATE_ROM_FW_FW_LOADED 0x4
22715d8370cSPeter Ujfalusi #define FSR_STATE_ROM_FW_ENTERED FSR_STATE_FW_ENTERED
22815d8370cSPeter Ujfalusi #define FSR_STATE_ROM_VERIFY_FEATURE_MASK 0x6
22915d8370cSPeter Ujfalusi #define FSR_STATE_ROM_GET_LOAD_OFFSET 0x7
23015d8370cSPeter Ujfalusi #define FSR_STATE_ROM_FETCH_ROM_EXT 0x8
23115d8370cSPeter Ujfalusi #define FSR_STATE_ROM_FETCH_ROM_EXT_DONE 0x9
232c712be34SPierre-Louis Bossart #define FSR_STATE_ROM_BASEFW_ENTERED 0xf /* SKL */
23315d8370cSPeter Ujfalusi
23415d8370cSPeter Ujfalusi /* (ROM) CSE states */
23515d8370cSPeter Ujfalusi #define FSR_STATE_ROM_CSE_IMR_REQUEST 0x10
23615d8370cSPeter Ujfalusi #define FSR_STATE_ROM_CSE_IMR_GRANTED 0x11
23715d8370cSPeter Ujfalusi #define FSR_STATE_ROM_CSE_VALIDATE_IMAGE_REQUEST 0x12
23815d8370cSPeter Ujfalusi #define FSR_STATE_ROM_CSE_IMAGE_VALIDATED 0x13
23915d8370cSPeter Ujfalusi
24015d8370cSPeter Ujfalusi #define FSR_STATE_ROM_CSE_IPC_IFACE_INIT 0x20
24115d8370cSPeter Ujfalusi #define FSR_STATE_ROM_CSE_IPC_RESET_PHASE_1 0x21
24215d8370cSPeter Ujfalusi #define FSR_STATE_ROM_CSE_IPC_OPERATIONAL_ENTRY 0x22
24315d8370cSPeter Ujfalusi #define FSR_STATE_ROM_CSE_IPC_OPERATIONAL 0x23
24415d8370cSPeter Ujfalusi #define FSR_STATE_ROM_CSE_IPC_DOWN 0x24
24515d8370cSPeter Ujfalusi
24615d8370cSPeter Ujfalusi /* BRINGUP (or BRNGUP) states */
24715d8370cSPeter Ujfalusi #define FSR_STATE_BRINGUP_INIT FSR_STATE_INIT
24815d8370cSPeter Ujfalusi #define FSR_STATE_BRINGUP_INIT_DONE FSR_STATE_INIT_DONE
24915d8370cSPeter Ujfalusi #define FSR_STATE_BRINGUP_HPSRAM_LOAD 0x2
25015d8370cSPeter Ujfalusi #define FSR_STATE_BRINGUP_UNPACK_START 0X3
25115d8370cSPeter Ujfalusi #define FSR_STATE_BRINGUP_IMR_RESTORE 0x4
25215d8370cSPeter Ujfalusi #define FSR_STATE_BRINGUP_FW_ENTERED FSR_STATE_FW_ENTERED
25315d8370cSPeter Ujfalusi
254dd96dacaSLiam Girdwood /* ROM status/error values */
255dd96dacaSLiam Girdwood #define HDA_DSP_ROM_CSE_ERROR 40
256dd96dacaSLiam Girdwood #define HDA_DSP_ROM_CSE_WRONG_RESPONSE 41
257dd96dacaSLiam Girdwood #define HDA_DSP_ROM_IMR_TO_SMALL 42
258dd96dacaSLiam Girdwood #define HDA_DSP_ROM_BASE_FW_NOT_FOUND 43
259dd96dacaSLiam Girdwood #define HDA_DSP_ROM_CSE_VALIDATION_FAILED 44
260dd96dacaSLiam Girdwood #define HDA_DSP_ROM_IPC_FATAL_ERROR 45
261dd96dacaSLiam Girdwood #define HDA_DSP_ROM_L2_CACHE_ERROR 46
262dd96dacaSLiam Girdwood #define HDA_DSP_ROM_LOAD_OFFSET_TO_SMALL 47
263dd96dacaSLiam Girdwood #define HDA_DSP_ROM_API_PTR_INVALID 50
264dd96dacaSLiam Girdwood #define HDA_DSP_ROM_BASEFW_INCOMPAT 51
265dd96dacaSLiam Girdwood #define HDA_DSP_ROM_UNHANDLED_INTERRUPT 0xBEE00000
266dd96dacaSLiam Girdwood #define HDA_DSP_ROM_MEMORY_HOLE_ECC 0xECC00000
267dd96dacaSLiam Girdwood #define HDA_DSP_ROM_KERNEL_EXCEPTION 0xCAFE0000
268dd96dacaSLiam Girdwood #define HDA_DSP_ROM_USER_EXCEPTION 0xBEEF0000
269dd96dacaSLiam Girdwood #define HDA_DSP_ROM_UNEXPECTED_RESET 0xDECAF000
270dd96dacaSLiam Girdwood #define HDA_DSP_ROM_NULL_FW_ENTRY 0x4c4c4e55
2712a68ff84SPeter Ujfalusi
2722a68ff84SPeter Ujfalusi #define HDA_DSP_ROM_IPC_CONTROL 0x01000000
2732a68ff84SPeter Ujfalusi #define HDA_DSP_ROM_IPC_PURGE_FW 0x00004000
274dd96dacaSLiam Girdwood
275dd96dacaSLiam Girdwood /* various timeout values */
276dd96dacaSLiam Girdwood #define HDA_DSP_PU_TIMEOUT 50
277dd96dacaSLiam Girdwood #define HDA_DSP_PD_TIMEOUT 50
278dd96dacaSLiam Girdwood #define HDA_DSP_RESET_TIMEOUT_US 50000
279dd96dacaSLiam Girdwood #define HDA_DSP_BASEFW_TIMEOUT_US 3000000
280dd96dacaSLiam Girdwood #define HDA_DSP_INIT_TIMEOUT_US 500000
281dd96dacaSLiam Girdwood #define HDA_DSP_CTRL_RESET_TIMEOUT 100
282dd96dacaSLiam Girdwood #define HDA_DSP_WAIT_TIMEOUT 500 /* 500 msec */
283dd96dacaSLiam Girdwood #define HDA_DSP_REG_POLL_INTERVAL_US 500 /* 0.5 msec */
28492f4beb7SKeyon Jie #define HDA_DSP_REG_POLL_RETRY_COUNT 50
285dd96dacaSLiam Girdwood
2869d201b69SPierre-Louis Bossart #define HDA_DSP_ADSPIC_IPC BIT(0)
2879d201b69SPierre-Louis Bossart #define HDA_DSP_ADSPIS_IPC BIT(0)
288dd96dacaSLiam Girdwood
289dd96dacaSLiam Girdwood /* Intel HD Audio General DSP Registers */
290dd96dacaSLiam Girdwood #define HDA_DSP_GEN_BASE 0x0
291dd96dacaSLiam Girdwood #define HDA_DSP_REG_ADSPCS (HDA_DSP_GEN_BASE + 0x04)
292dd96dacaSLiam Girdwood #define HDA_DSP_REG_ADSPIC (HDA_DSP_GEN_BASE + 0x08)
293dd96dacaSLiam Girdwood #define HDA_DSP_REG_ADSPIS (HDA_DSP_GEN_BASE + 0x0C)
294dd96dacaSLiam Girdwood #define HDA_DSP_REG_ADSPIC2 (HDA_DSP_GEN_BASE + 0x10)
295dd96dacaSLiam Girdwood #define HDA_DSP_REG_ADSPIS2 (HDA_DSP_GEN_BASE + 0x14)
296dd96dacaSLiam Girdwood
2978ebc9074SPierre-Louis Bossart #define HDA_DSP_REG_ADSPIC2_SNDW BIT(5)
298722ba5f1SBard Liao #define HDA_DSP_REG_ADSPIS2_SNDW BIT(5)
299722ba5f1SBard Liao
300dd96dacaSLiam Girdwood /* Intel HD Audio Inter-Processor Communication Registers */
301dd96dacaSLiam Girdwood #define HDA_DSP_IPC_BASE 0x40
302dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCT (HDA_DSP_IPC_BASE + 0x00)
303dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCTE (HDA_DSP_IPC_BASE + 0x04)
304dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCI (HDA_DSP_IPC_BASE + 0x08)
305dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCIE (HDA_DSP_IPC_BASE + 0x0C)
306dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCCTL (HDA_DSP_IPC_BASE + 0x10)
307dd96dacaSLiam Girdwood
30843b2ab90SRanjani Sridharan /* Intel Vendor Specific Registers */
30943b2ab90SRanjani Sridharan #define HDA_VS_INTEL_EM2 0x1030
31043b2ab90SRanjani Sridharan #define HDA_VS_INTEL_EM2_L1SEN BIT(13)
311847fd278SPierre-Louis Bossart #define HDA_VS_INTEL_LTRP 0x1048
312aca961f1SRanjani Sridharan #define HDA_VS_INTEL_LTRP_GB_MASK 0x3F
31343b2ab90SRanjani Sridharan
314dd96dacaSLiam Girdwood /* HIPCI */
315dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCI_BUSY BIT(31)
316dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCI_MSG_MASK 0x7FFFFFFF
317dd96dacaSLiam Girdwood
318dd96dacaSLiam Girdwood /* HIPCIE */
319dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCIE_DONE BIT(30)
320dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCIE_MSG_MASK 0x3FFFFFFF
321dd96dacaSLiam Girdwood
322dd96dacaSLiam Girdwood /* HIPCCTL */
323dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCCTL_DONE BIT(1)
324dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCCTL_BUSY BIT(0)
325dd96dacaSLiam Girdwood
326dd96dacaSLiam Girdwood /* HIPCT */
327dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCT_BUSY BIT(31)
328dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCT_MSG_MASK 0x7FFFFFFF
329dd96dacaSLiam Girdwood
330dd96dacaSLiam Girdwood /* HIPCTE */
331dd96dacaSLiam Girdwood #define HDA_DSP_REG_HIPCTE_MSG_MASK 0x3FFFFFFF
332dd96dacaSLiam Girdwood
3339d201b69SPierre-Louis Bossart #define HDA_DSP_ADSPIC_CL_DMA BIT(1)
3349d201b69SPierre-Louis Bossart #define HDA_DSP_ADSPIS_CL_DMA BIT(1)
335dd96dacaSLiam Girdwood
336dd96dacaSLiam Girdwood /* Delay before scheduling D0i3 entry */
337dd96dacaSLiam Girdwood #define BXT_D0I3_DELAY 5000
338dd96dacaSLiam Girdwood
339dd96dacaSLiam Girdwood #define FW_CL_STREAM_NUMBER 0x1
340776100a4SPierre-Louis Bossart #define HDA_FW_BOOT_ATTEMPTS 3
341dd96dacaSLiam Girdwood
342dd96dacaSLiam Girdwood /* ADSPCS - Audio DSP Control & Status */
343dd96dacaSLiam Girdwood
344dd96dacaSLiam Girdwood /*
345dd96dacaSLiam Girdwood * Core Reset - asserted high
346dd96dacaSLiam Girdwood * CRST Mask for a given core mask pattern, cm
347dd96dacaSLiam Girdwood */
348dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CRST_SHIFT 0
349dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CRST_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CRST_SHIFT)
350dd96dacaSLiam Girdwood
351dd96dacaSLiam Girdwood /*
352dd96dacaSLiam Girdwood * Core run/stall - when set to '1' core is stalled
353dd96dacaSLiam Girdwood * CSTALL Mask for a given core mask pattern, cm
354dd96dacaSLiam Girdwood */
355dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CSTALL_SHIFT 8
356dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CSTALL_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CSTALL_SHIFT)
357dd96dacaSLiam Girdwood
358dd96dacaSLiam Girdwood /*
359dd96dacaSLiam Girdwood * Set Power Active - when set to '1' turn cores on
360dd96dacaSLiam Girdwood * SPA Mask for a given core mask pattern, cm
361dd96dacaSLiam Girdwood */
362dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_SPA_SHIFT 16
363dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_SPA_MASK(cm) ((cm) << HDA_DSP_ADSPCS_SPA_SHIFT)
364dd96dacaSLiam Girdwood
365dd96dacaSLiam Girdwood /*
366dd96dacaSLiam Girdwood * Current Power Active - power status of cores, set by hardware
367dd96dacaSLiam Girdwood * CPA Mask for a given core mask pattern, cm
368dd96dacaSLiam Girdwood */
369dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CPA_SHIFT 24
370dd96dacaSLiam Girdwood #define HDA_DSP_ADSPCS_CPA_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CPA_SHIFT)
371dd96dacaSLiam Girdwood
372dd96dacaSLiam Girdwood /*
373dd96dacaSLiam Girdwood * Mask for a given number of cores
374dd96dacaSLiam Girdwood * nc = number of supported cores
375dd96dacaSLiam Girdwood */
376dd96dacaSLiam Girdwood #define SOF_DSP_CORES_MASK(nc) GENMASK(((nc) - 1), 0)
377dd96dacaSLiam Girdwood
378dd96dacaSLiam Girdwood /* Intel HD Audio Inter-Processor Communication Registers for Cannonlake*/
379dd96dacaSLiam Girdwood #define CNL_DSP_IPC_BASE 0xc0
380dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDR (CNL_DSP_IPC_BASE + 0x00)
381dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDA (CNL_DSP_IPC_BASE + 0x04)
382dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDD (CNL_DSP_IPC_BASE + 0x08)
383dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDR (CNL_DSP_IPC_BASE + 0x10)
384dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDA (CNL_DSP_IPC_BASE + 0x14)
3850267de58SKeyon Jie #define CNL_DSP_REG_HIPCIDD (CNL_DSP_IPC_BASE + 0x18)
386dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCCTL (CNL_DSP_IPC_BASE + 0x28)
387dd96dacaSLiam Girdwood
388dd96dacaSLiam Girdwood /* HIPCI */
389dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDR_BUSY BIT(31)
390dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDR_MSG_MASK 0x7FFFFFFF
391dd96dacaSLiam Girdwood
392dd96dacaSLiam Girdwood /* HIPCIE */
393dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDA_DONE BIT(31)
394dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCIDA_MSG_MASK 0x7FFFFFFF
395dd96dacaSLiam Girdwood
396dd96dacaSLiam Girdwood /* HIPCCTL */
397dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCCTL_DONE BIT(1)
398dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCCTL_BUSY BIT(0)
399dd96dacaSLiam Girdwood
400dd96dacaSLiam Girdwood /* HIPCT */
401dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDR_BUSY BIT(31)
402dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDR_MSG_MASK 0x7FFFFFFF
403dd96dacaSLiam Girdwood
404dd96dacaSLiam Girdwood /* HIPCTDA */
405dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDA_DONE BIT(31)
406dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDA_MSG_MASK 0x7FFFFFFF
407dd96dacaSLiam Girdwood
408dd96dacaSLiam Girdwood /* HIPCTDD */
409dd96dacaSLiam Girdwood #define CNL_DSP_REG_HIPCTDD_MSG_MASK 0x7FFFFFFF
410dd96dacaSLiam Girdwood
411dd96dacaSLiam Girdwood /* BDL */
412dd96dacaSLiam Girdwood #define HDA_DSP_BDL_SIZE 4096
413dd96dacaSLiam Girdwood #define HDA_DSP_MAX_BDL_ENTRIES \
414dd96dacaSLiam Girdwood (HDA_DSP_BDL_SIZE / sizeof(struct sof_intel_dsp_bdl))
415dd96dacaSLiam Girdwood
416dd96dacaSLiam Girdwood /* Number of DAIs */
4170f7b6a43SRanjani Sridharan #define SOF_SKL_NUM_DAIS_NOCODEC 8
4180f7b6a43SRanjani Sridharan
41945f3c2f8SPierre-Louis Bossart #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
420a6947c9dSCezary Rojewski #define SOF_SKL_NUM_DAIS 15
421dd96dacaSLiam Girdwood #else
4220f7b6a43SRanjani Sridharan #define SOF_SKL_NUM_DAIS SOF_SKL_NUM_DAIS_NOCODEC
423dd96dacaSLiam Girdwood #endif
424dd96dacaSLiam Girdwood
425dd96dacaSLiam Girdwood /* Intel HD Audio SRAM Window 0*/
426e2379d4aSPierre-Louis Bossart #define HDA_DSP_SRAM_REG_ROM_STATUS_SKL 0x8000
427dd96dacaSLiam Girdwood #define HDA_ADSP_SRAM0_BASE_SKL 0x8000
428dd96dacaSLiam Girdwood
429dd96dacaSLiam Girdwood /* Firmware status window */
430dd96dacaSLiam Girdwood #define HDA_ADSP_FW_STATUS_SKL HDA_ADSP_SRAM0_BASE_SKL
431dd96dacaSLiam Girdwood #define HDA_ADSP_ERROR_CODE_SKL (HDA_ADSP_FW_STATUS_SKL + 0x4)
432dd96dacaSLiam Girdwood
433df7e0de5SZhu Yingjiang /* Host Device Memory Space */
434df7e0de5SZhu Yingjiang #define APL_SSP_BASE_OFFSET 0x2000
435df7e0de5SZhu Yingjiang #define CNL_SSP_BASE_OFFSET 0x10000
436df7e0de5SZhu Yingjiang
437df7e0de5SZhu Yingjiang /* Host Device Memory Size of a Single SSP */
438df7e0de5SZhu Yingjiang #define SSP_DEV_MEM_SIZE 0x1000
439df7e0de5SZhu Yingjiang
440b095fe47SZhu Yingjiang /* SSP Count of the Platform */
441b095fe47SZhu Yingjiang #define APL_SSP_COUNT 6
442b095fe47SZhu Yingjiang #define CNL_SSP_COUNT 3
443ec836daaSZhu Yingjiang #define ICL_SSP_COUNT 6
4449ccbc2e1SPierre-Louis Bossart #define TGL_SSP_COUNT 3
4459ccbc2e1SPierre-Louis Bossart #define MTL_SSP_COUNT 3
446b095fe47SZhu Yingjiang
44774ed4097SZhu Yingjiang /* SSP Registers */
44874ed4097SZhu Yingjiang #define SSP_SSC1_OFFSET 0x4
449bd586a02SPierre-Louis Bossart #define SSP_SET_SCLK_CONSUMER BIT(25)
450bd586a02SPierre-Louis Bossart #define SSP_SET_SFRM_CONSUMER BIT(24)
451bd586a02SPierre-Louis Bossart #define SSP_SET_CBP_CFP (SSP_SET_SCLK_CONSUMER | SSP_SET_SFRM_CONSUMER)
45274ed4097SZhu Yingjiang
453c99fafdfSKai Vehmanen #define HDA_IDISP_ADDR 2
454c99fafdfSKai Vehmanen #define HDA_IDISP_CODEC(x) ((x) & BIT(HDA_IDISP_ADDR))
455dd96dacaSLiam Girdwood
456dd96dacaSLiam Girdwood struct sof_intel_dsp_bdl {
457dd96dacaSLiam Girdwood __le32 addr_l;
458dd96dacaSLiam Girdwood __le32 addr_h;
459dd96dacaSLiam Girdwood __le32 size;
460dd96dacaSLiam Girdwood __le32 ioc;
461dd96dacaSLiam Girdwood } __attribute((packed));
462dd96dacaSLiam Girdwood
463dd96dacaSLiam Girdwood #define SOF_HDA_PLAYBACK_STREAMS 16
464dd96dacaSLiam Girdwood #define SOF_HDA_CAPTURE_STREAMS 16
465dd96dacaSLiam Girdwood #define SOF_HDA_PLAYBACK 0
466dd96dacaSLiam Girdwood #define SOF_HDA_CAPTURE 1
467dd96dacaSLiam Girdwood
46889a400bdSRanjani Sridharan /* stream flags */
46989a400bdSRanjani Sridharan #define SOF_HDA_STREAM_DMI_L1_COMPATIBLE 1
47089a400bdSRanjani Sridharan
47163e51fd3SRanjani Sridharan /*
47263e51fd3SRanjani Sridharan * Time in ms for opportunistic D0I3 entry delay.
47363e51fd3SRanjani Sridharan * This has been deliberately chosen to be long to avoid race conditions.
47463e51fd3SRanjani Sridharan * Could be optimized in future.
47563e51fd3SRanjani Sridharan */
47663e51fd3SRanjani Sridharan #define SOF_HDA_D0I3_WORK_DELAY_MS 5000
47763e51fd3SRanjani Sridharan
47861e285caSRanjani Sridharan /* HDA DSP D0 substate */
47961e285caSRanjani Sridharan enum sof_hda_D0_substate {
48061e285caSRanjani Sridharan SOF_HDA_DSP_PM_D0I0, /* default D0 substate */
48161e285caSRanjani Sridharan SOF_HDA_DSP_PM_D0I3, /* low power D0 substate */
48261e285caSRanjani Sridharan };
48361e285caSRanjani Sridharan
484dd96dacaSLiam Girdwood /* represents DSP HDA controller frontend - i.e. host facing control */
485dd96dacaSLiam Girdwood struct sof_intel_hda_dev {
4862a68ff84SPeter Ujfalusi bool imrboot_supported;
48757724db1SPeter Ujfalusi bool skip_imr_boot;
4885d5d915bSPeter Ujfalusi bool booted_from_imr;
4892a68ff84SPeter Ujfalusi
490776100a4SPierre-Louis Bossart int boot_iteration;
491dd96dacaSLiam Girdwood
492dd96dacaSLiam Girdwood struct hda_bus hbus;
493dd96dacaSLiam Girdwood
494dd96dacaSLiam Girdwood /* hw config */
495dd96dacaSLiam Girdwood const struct sof_intel_dsp_desc *desc;
496dd96dacaSLiam Girdwood
497dd96dacaSLiam Girdwood /* trace */
498dd96dacaSLiam Girdwood struct hdac_ext_stream *dtrace_stream;
499dd96dacaSLiam Girdwood
500dd96dacaSLiam Girdwood /* if position update IPC needed */
501dd96dacaSLiam Girdwood u32 no_ipc_position;
502dd96dacaSLiam Girdwood
503e8e55dbeSKeyon Jie /* the maximum number of streams (playback + capture) supported */
504e8e55dbeSKeyon Jie u32 stream_max;
505e8e55dbeSKeyon Jie
50616299326SKeyon Jie /* PM related */
507ae9db908SRanjani Sridharan bool l1_disabled;/* is DMI link L1 disabled? */
50816299326SKeyon Jie
509dd96dacaSLiam Girdwood /* DMIC device */
510dd96dacaSLiam Girdwood struct platform_device *dmic_dev;
51163e51fd3SRanjani Sridharan
51263e51fd3SRanjani Sridharan /* delayed work to enter D0I3 opportunistically */
51363e51fd3SRanjani Sridharan struct delayed_work d0i3_work;
51451dfed1eSPierre-Louis Bossart
51551dfed1eSPierre-Louis Bossart /* ACPI information stored between scan and probe steps */
51651dfed1eSPierre-Louis Bossart struct sdw_intel_acpi_info info;
51751dfed1eSPierre-Louis Bossart
51851dfed1eSPierre-Louis Bossart /* sdw context allocated by SoundWire driver */
51951dfed1eSPierre-Louis Bossart struct sdw_intel_ctx *sdw;
520edbaaadaSFred Oh
521edbaaadaSFred Oh /* FW clock config, 0:HPRO, 1:LPRO */
522edbaaadaSFred Oh bool clk_config_lpro;
52395fa7a62SPierre-Louis Bossart
524c712be34SPierre-Louis Bossart wait_queue_head_t waitq;
525c712be34SPierre-Louis Bossart bool code_loading;
526c712be34SPierre-Louis Bossart
52795fa7a62SPierre-Louis Bossart /* Intel NHLT information */
52895fa7a62SPierre-Louis Bossart struct nhlt_acpi_table *nhlt;
529483e4cdfSPeter Ujfalusi
530483e4cdfSPeter Ujfalusi /*
531483e4cdfSPeter Ujfalusi * Pointing to the IPC message if immediate sending was not possible
532483e4cdfSPeter Ujfalusi * because the downlink communication channel was BUSY at the time.
533483e4cdfSPeter Ujfalusi * The message will be re-tried when the channel becomes free (the ACK
534483e4cdfSPeter Ujfalusi * is received from the DSP for the previous message)
535483e4cdfSPeter Ujfalusi */
536483e4cdfSPeter Ujfalusi struct snd_sof_ipc_msg *delayed_ipc_tx_msg;
537dd96dacaSLiam Girdwood };
538dd96dacaSLiam Girdwood
sof_to_bus(struct snd_sof_dev * s)539dd96dacaSLiam Girdwood static inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s)
540dd96dacaSLiam Girdwood {
541dd96dacaSLiam Girdwood struct sof_intel_hda_dev *hda = s->pdata->hw_pdata;
542dd96dacaSLiam Girdwood
543dd96dacaSLiam Girdwood return &hda->hbus.core;
544dd96dacaSLiam Girdwood }
545dd96dacaSLiam Girdwood
sof_to_hbus(struct snd_sof_dev * s)546dd96dacaSLiam Girdwood static inline struct hda_bus *sof_to_hbus(struct snd_sof_dev *s)
547dd96dacaSLiam Girdwood {
548dd96dacaSLiam Girdwood struct sof_intel_hda_dev *hda = s->pdata->hw_pdata;
549dd96dacaSLiam Girdwood
550dd96dacaSLiam Girdwood return &hda->hbus;
551dd96dacaSLiam Girdwood }
552dd96dacaSLiam Girdwood
553dd96dacaSLiam Girdwood struct sof_intel_hda_stream {
5547623ae79SRanjani Sridharan struct snd_sof_dev *sdev;
5557d88b960SPierre-Louis Bossart struct hdac_ext_stream hext_stream;
5567d88b960SPierre-Louis Bossart struct sof_intel_stream sof_intel_stream;
5576b2239e3SRanjani Sridharan int host_reserved; /* reserve host DMA channel */
55889a400bdSRanjani Sridharan u32 flags;
559dd96dacaSLiam Girdwood };
560dd96dacaSLiam Girdwood
561f5dbba9fSRanjani Sridharan #define hstream_to_sof_hda_stream(hstream) \
5627d88b960SPierre-Louis Bossart container_of(hstream, struct sof_intel_hda_stream, hext_stream)
563f5dbba9fSRanjani Sridharan
564dd96dacaSLiam Girdwood #define bus_to_sof_hda(bus) \
565dd96dacaSLiam Girdwood container_of(bus, struct sof_intel_hda_dev, hbus.core)
566dd96dacaSLiam Girdwood
567dd96dacaSLiam Girdwood #define SOF_STREAM_SD_OFFSET(s) \
568dd96dacaSLiam Girdwood (SOF_HDA_ADSP_SD_ENTRY_SIZE * ((s)->index) \
569dd96dacaSLiam Girdwood + SOF_HDA_ADSP_LOADER_BASE)
570dd96dacaSLiam Girdwood
5712b1acedcSRanjani Sridharan #define SOF_STREAM_SD_OFFSET_CRST 0x1
5722b1acedcSRanjani Sridharan
573dd96dacaSLiam Girdwood /*
574dd96dacaSLiam Girdwood * DSP Core services.
575dd96dacaSLiam Girdwood */
576dd96dacaSLiam Girdwood int hda_dsp_probe(struct snd_sof_dev *sdev);
577dd96dacaSLiam Girdwood int hda_dsp_remove(struct snd_sof_dev *sdev);
578537b4a0cSPeter Ujfalusi int hda_dsp_core_power_up(struct snd_sof_dev *sdev, unsigned int core_mask);
579dd96dacaSLiam Girdwood int hda_dsp_core_run(struct snd_sof_dev *sdev, unsigned int core_mask);
580dd96dacaSLiam Girdwood int hda_dsp_enable_core(struct snd_sof_dev *sdev, unsigned int core_mask);
581dd96dacaSLiam Girdwood int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev,
582dd96dacaSLiam Girdwood unsigned int core_mask);
583c714031fSFred Oh int hda_power_down_dsp(struct snd_sof_dev *sdev);
5849cdcbc9fSRanjani Sridharan int hda_dsp_core_get(struct snd_sof_dev *sdev, int core);
585dd96dacaSLiam Girdwood void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev);
586dd96dacaSLiam Girdwood void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev);
587556eb416SPierre-Louis Bossart bool hda_dsp_core_is_enabled(struct snd_sof_dev *sdev, unsigned int core_mask);
588dd96dacaSLiam Girdwood
589996b07efSRanjani Sridharan int hda_dsp_set_power_state_ipc3(struct snd_sof_dev *sdev,
590996b07efSRanjani Sridharan const struct sof_dsp_power_state *target_state);
591996b07efSRanjani Sridharan int hda_dsp_set_power_state_ipc4(struct snd_sof_dev *sdev,
59261e285caSRanjani Sridharan const struct sof_dsp_power_state *target_state);
59362f8f766SKeyon Jie
59461e285caSRanjani Sridharan int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state);
595dd96dacaSLiam Girdwood int hda_dsp_resume(struct snd_sof_dev *sdev);
5961c38c922SFred Oh int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev);
597dd96dacaSLiam Girdwood int hda_dsp_runtime_resume(struct snd_sof_dev *sdev);
59862fde977SKai Vehmanen int hda_dsp_runtime_idle(struct snd_sof_dev *sdev);
5992aa2a5eaSKai Vehmanen int hda_dsp_shutdown_dma_flush(struct snd_sof_dev *sdev);
60022aa9e02SLibin Yang int hda_dsp_shutdown(struct snd_sof_dev *sdev);
6017077a07aSRanjani Sridharan int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev);
602dd96dacaSLiam Girdwood void hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags);
603f3da49f0SPan Xiuli void hda_ipc_dump(struct snd_sof_dev *sdev);
604f1fd9d0eSKai Vehmanen void hda_ipc_irq_dump(struct snd_sof_dev *sdev);
60563e51fd3SRanjani Sridharan void hda_dsp_d0i3_work(struct work_struct *work);
606b2520dbcSRanjani Sridharan int hda_dsp_disable_interrupts(struct snd_sof_dev *sdev);
607dd96dacaSLiam Girdwood
608dd96dacaSLiam Girdwood /*
609dd96dacaSLiam Girdwood * DSP PCM Operations.
610dd96dacaSLiam Girdwood */
61149d7948eSCezary Rojewski u32 hda_dsp_get_mult_div(struct snd_sof_dev *sdev, int rate);
61249d7948eSCezary Rojewski u32 hda_dsp_get_bits(struct snd_sof_dev *sdev, int sample_bits);
613dd96dacaSLiam Girdwood int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
614dd96dacaSLiam Girdwood struct snd_pcm_substream *substream);
615dd96dacaSLiam Girdwood int hda_dsp_pcm_close(struct snd_sof_dev *sdev,
616dd96dacaSLiam Girdwood struct snd_pcm_substream *substream);
617dd96dacaSLiam Girdwood int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
618dd96dacaSLiam Girdwood struct snd_pcm_substream *substream,
619dd96dacaSLiam Girdwood struct snd_pcm_hw_params *params,
62031f60a0cSPeter Ujfalusi struct snd_sof_platform_stream_params *platform_params);
62193146bc2SRanjani Sridharan int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
62293146bc2SRanjani Sridharan struct snd_pcm_substream *substream);
623dd96dacaSLiam Girdwood int hda_dsp_pcm_trigger(struct snd_sof_dev *sdev,
624dd96dacaSLiam Girdwood struct snd_pcm_substream *substream, int cmd);
625dd96dacaSLiam Girdwood snd_pcm_uframes_t hda_dsp_pcm_pointer(struct snd_sof_dev *sdev,
626dd96dacaSLiam Girdwood struct snd_pcm_substream *substream);
6276c26b505SRanjani Sridharan int hda_dsp_pcm_ack(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream);
628dd96dacaSLiam Girdwood
629dd96dacaSLiam Girdwood /*
630dd96dacaSLiam Girdwood * DSP Stream Operations.
631dd96dacaSLiam Girdwood */
632dd96dacaSLiam Girdwood
633dd96dacaSLiam Girdwood int hda_dsp_stream_init(struct snd_sof_dev *sdev);
634dd96dacaSLiam Girdwood void hda_dsp_stream_free(struct snd_sof_dev *sdev);
635dd96dacaSLiam Girdwood int hda_dsp_stream_hw_params(struct snd_sof_dev *sdev,
6367d88b960SPierre-Louis Bossart struct hdac_ext_stream *hext_stream,
637dd96dacaSLiam Girdwood struct snd_dma_buffer *dmab,
638dd96dacaSLiam Girdwood struct snd_pcm_hw_params *params);
6397d88b960SPierre-Louis Bossart int hda_dsp_iccmax_stream_hw_params(struct snd_sof_dev *sdev,
6407d88b960SPierre-Louis Bossart struct hdac_ext_stream *hext_stream,
641aca961f1SRanjani Sridharan struct snd_dma_buffer *dmab,
642aca961f1SRanjani Sridharan struct snd_pcm_hw_params *params);
643dd96dacaSLiam Girdwood int hda_dsp_stream_trigger(struct snd_sof_dev *sdev,
6447d88b960SPierre-Louis Bossart struct hdac_ext_stream *hext_stream, int cmd);
645dd96dacaSLiam Girdwood irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context);
646dd96dacaSLiam Girdwood int hda_dsp_stream_setup_bdl(struct snd_sof_dev *sdev,
647dd96dacaSLiam Girdwood struct snd_dma_buffer *dmab,
6487d88b960SPierre-Louis Bossart struct hdac_stream *hstream);
6497c11af9fSBard Liao bool hda_dsp_check_ipc_irq(struct snd_sof_dev *sdev);
6507c11af9fSBard Liao bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev);
651dd96dacaSLiam Girdwood
652a37a9224SPeter Ujfalusi snd_pcm_uframes_t hda_dsp_stream_get_position(struct hdac_stream *hstream,
653a37a9224SPeter Ujfalusi int direction, bool can_sleep);
654a37a9224SPeter Ujfalusi
655dd96dacaSLiam Girdwood struct hdac_ext_stream *
65689a400bdSRanjani Sridharan hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags);
657dd96dacaSLiam Girdwood int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag);
658dd96dacaSLiam Girdwood int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev,
6597d88b960SPierre-Louis Bossart struct hdac_ext_stream *hext_stream,
660dd96dacaSLiam Girdwood int enable, u32 size);
661dd96dacaSLiam Girdwood
6626a0ba071SGuennadi Liakhovetski int hda_ipc_msg_data(struct snd_sof_dev *sdev,
6631b905942SDaniel Baluta struct snd_sof_pcm_stream *sps,
664dd96dacaSLiam Girdwood void *p, size_t sz);
66529e3aa0bSPeter Ujfalusi int hda_set_stream_data_offset(struct snd_sof_dev *sdev,
666249f186dSDaniel Baluta struct snd_sof_pcm_stream *sps,
66729e3aa0bSPeter Ujfalusi size_t posn_offset);
668dd96dacaSLiam Girdwood
669dd96dacaSLiam Girdwood /*
670dd96dacaSLiam Girdwood * DSP IPC Operations.
671dd96dacaSLiam Girdwood */
672dd96dacaSLiam Girdwood int hda_dsp_ipc_send_msg(struct snd_sof_dev *sdev,
673dd96dacaSLiam Girdwood struct snd_sof_ipc_msg *msg);
674dd96dacaSLiam Girdwood void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev);
6756eebd390SDaniel Baluta int hda_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev);
6766eebd390SDaniel Baluta int hda_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id);
6776eebd390SDaniel Baluta
678dd96dacaSLiam Girdwood irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context);
679dd96dacaSLiam Girdwood int hda_dsp_ipc_cmd_done(struct snd_sof_dev *sdev, int dir);
680dd96dacaSLiam Girdwood
681dd96dacaSLiam Girdwood /*
682dd96dacaSLiam Girdwood * DSP Code loader.
683dd96dacaSLiam Girdwood */
684dd96dacaSLiam Girdwood int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev);
685acf705a4SRanjani Sridharan int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev);
686b4e4c0b9SRanjani Sridharan int hda_cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream);
687b4e4c0b9SRanjani Sridharan struct hdac_ext_stream *hda_cl_stream_prepare(struct snd_sof_dev *sdev, unsigned int format,
688b4e4c0b9SRanjani Sridharan unsigned int size, struct snd_dma_buffer *dmab,
689b4e4c0b9SRanjani Sridharan int direction);
690b4e4c0b9SRanjani Sridharan int hda_cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
691b4e4c0b9SRanjani Sridharan struct hdac_ext_stream *hext_stream);
692ab222a4aSBard Liao int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot);
693406fed80SRanjani Sridharan #define HDA_CL_STREAM_FORMAT 0x40
694dd96dacaSLiam Girdwood
695dd96dacaSLiam Girdwood /* pre and post fw run ops */
696dd96dacaSLiam Girdwood int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev);
697dd96dacaSLiam Girdwood int hda_dsp_post_fw_run(struct snd_sof_dev *sdev);
698dd96dacaSLiam Girdwood
699edbaaadaSFred Oh /* parse platform specific ext manifest ops */
700edbaaadaSFred Oh int hda_dsp_ext_man_get_cavs_config_data(struct snd_sof_dev *sdev,
701edbaaadaSFred Oh const struct sof_ext_man_elem_header *hdr);
702edbaaadaSFred Oh
703dd96dacaSLiam Girdwood /*
704dd96dacaSLiam Girdwood * HDA Controller Operations.
705dd96dacaSLiam Girdwood */
706dd96dacaSLiam Girdwood int hda_dsp_ctrl_get_caps(struct snd_sof_dev *sdev);
707dd96dacaSLiam Girdwood void hda_dsp_ctrl_ppcap_enable(struct snd_sof_dev *sdev, bool enable);
708dd96dacaSLiam Girdwood void hda_dsp_ctrl_ppcap_int_enable(struct snd_sof_dev *sdev, bool enable);
709dd96dacaSLiam Girdwood int hda_dsp_ctrl_link_reset(struct snd_sof_dev *sdev, bool reset);
710dd96dacaSLiam Girdwood void hda_dsp_ctrl_misc_clock_gating(struct snd_sof_dev *sdev, bool enable);
711dd96dacaSLiam Girdwood int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable);
712b48b77d8SPierre-Louis Bossart int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev);
71313063a2cSZhu Yingjiang void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev);
714dd96dacaSLiam Girdwood /*
715dd96dacaSLiam Girdwood * HDA bus operations.
716dd96dacaSLiam Girdwood */
717afae0942SPierre-Louis Bossart void sof_hda_bus_init(struct snd_sof_dev *sdev, struct device *dev);
718afae0942SPierre-Louis Bossart void sof_hda_bus_exit(struct snd_sof_dev *sdev);
719dd96dacaSLiam Girdwood
720dc1d964aSPierre-Louis Bossart #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
721dd96dacaSLiam Girdwood /*
722dd96dacaSLiam Girdwood * HDA Codec operations.
723dd96dacaSLiam Girdwood */
724834c69d3SPierre-Louis Bossart void hda_codec_probe_bus(struct snd_sof_dev *sdev);
72531ba0c07SKai-Heng Feng void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable);
726fd15f2f5SRander Wang void hda_codec_jack_check(struct snd_sof_dev *sdev);
727580803a7SPierre-Louis Bossart void hda_codec_check_for_state_change(struct snd_sof_dev *sdev);
728ad09e446SPierre-Louis Bossart void hda_codec_init_cmd_io(struct snd_sof_dev *sdev);
7293400afcfSPierre-Louis Bossart void hda_codec_resume_cmd_io(struct snd_sof_dev *sdev);
730bf2d764bSPierre-Louis Bossart void hda_codec_stop_cmd_io(struct snd_sof_dev *sdev);
7313400afcfSPierre-Louis Bossart void hda_codec_suspend_cmd_io(struct snd_sof_dev *sdev);
732ad09e446SPierre-Louis Bossart void hda_codec_detect_mask(struct snd_sof_dev *sdev);
733ad09e446SPierre-Louis Bossart void hda_codec_rirb_status_clear(struct snd_sof_dev *sdev);
73487f42300SPierre-Louis Bossart bool hda_codec_check_rirb_status(struct snd_sof_dev *sdev);
7353246a6c9SPierre-Louis Bossart void hda_codec_set_codec_wakeup(struct snd_sof_dev *sdev, bool status);
736d4bfba1eSPierre-Louis Bossart void hda_codec_device_remove(struct snd_sof_dev *sdev);
737dd96dacaSLiam Girdwood
738dc1d964aSPierre-Louis Bossart #else
739dc1d964aSPierre-Louis Bossart
hda_codec_probe_bus(struct snd_sof_dev * sdev)740dc1d964aSPierre-Louis Bossart static inline void hda_codec_probe_bus(struct snd_sof_dev *sdev) { }
hda_codec_jack_wake_enable(struct snd_sof_dev * sdev,bool enable)741dc1d964aSPierre-Louis Bossart static inline void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable) { }
hda_codec_jack_check(struct snd_sof_dev * sdev)742dc1d964aSPierre-Louis Bossart static inline void hda_codec_jack_check(struct snd_sof_dev *sdev) { }
hda_codec_check_for_state_change(struct snd_sof_dev * sdev)743580803a7SPierre-Louis Bossart static inline void hda_codec_check_for_state_change(struct snd_sof_dev *sdev) { }
hda_codec_init_cmd_io(struct snd_sof_dev * sdev)744ad09e446SPierre-Louis Bossart static inline void hda_codec_init_cmd_io(struct snd_sof_dev *sdev) { }
hda_codec_resume_cmd_io(struct snd_sof_dev * sdev)7453400afcfSPierre-Louis Bossart static inline void hda_codec_resume_cmd_io(struct snd_sof_dev *sdev) { }
hda_codec_stop_cmd_io(struct snd_sof_dev * sdev)746bf2d764bSPierre-Louis Bossart static inline void hda_codec_stop_cmd_io(struct snd_sof_dev *sdev) { }
hda_codec_suspend_cmd_io(struct snd_sof_dev * sdev)7473400afcfSPierre-Louis Bossart static inline void hda_codec_suspend_cmd_io(struct snd_sof_dev *sdev) { }
hda_codec_detect_mask(struct snd_sof_dev * sdev)748ad09e446SPierre-Louis Bossart static inline void hda_codec_detect_mask(struct snd_sof_dev *sdev) { }
hda_codec_rirb_status_clear(struct snd_sof_dev * sdev)749ad09e446SPierre-Louis Bossart static inline void hda_codec_rirb_status_clear(struct snd_sof_dev *sdev) { }
hda_codec_check_rirb_status(struct snd_sof_dev * sdev)75087f42300SPierre-Louis Bossart static inline bool hda_codec_check_rirb_status(struct snd_sof_dev *sdev) { return false; }
hda_codec_set_codec_wakeup(struct snd_sof_dev * sdev,bool status)7513246a6c9SPierre-Louis Bossart static inline void hda_codec_set_codec_wakeup(struct snd_sof_dev *sdev, bool status) { }
hda_codec_device_remove(struct snd_sof_dev * sdev)752d4bfba1eSPierre-Louis Bossart static inline void hda_codec_device_remove(struct snd_sof_dev *sdev) { }
753dc1d964aSPierre-Louis Bossart
754dc1d964aSPierre-Louis Bossart #endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */
755dd96dacaSLiam Girdwood
7562c6c809cSPierre-Louis Bossart #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) && IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI)
757dd96dacaSLiam Girdwood
75823ee0903SKai Vehmanen void hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable);
759dd96dacaSLiam Girdwood int hda_codec_i915_init(struct snd_sof_dev *sdev);
760dd96dacaSLiam Girdwood int hda_codec_i915_exit(struct snd_sof_dev *sdev);
761dd96dacaSLiam Girdwood
762dd96dacaSLiam Girdwood #else
763dd96dacaSLiam Girdwood
hda_codec_i915_display_power(struct snd_sof_dev * sdev,bool enable)764834c69d3SPierre-Louis Bossart static inline void hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable) { }
hda_codec_i915_init(struct snd_sof_dev * sdev)765dd96dacaSLiam Girdwood static inline int hda_codec_i915_init(struct snd_sof_dev *sdev) { return 0; }
hda_codec_i915_exit(struct snd_sof_dev * sdev)766dd96dacaSLiam Girdwood static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }
767dd96dacaSLiam Girdwood
768139c7febSKai Vehmanen #endif
769dd96dacaSLiam Girdwood
770dd96dacaSLiam Girdwood /*
771dd96dacaSLiam Girdwood * Trace Control.
772dd96dacaSLiam Girdwood */
7734b49cbd1SPeter Ujfalusi int hda_dsp_trace_init(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
774bab05b50SPeter Ujfalusi struct sof_ipc_dma_trace_params_ext *dtrace_params);
775dd96dacaSLiam Girdwood int hda_dsp_trace_release(struct snd_sof_dev *sdev);
776dd96dacaSLiam Girdwood int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd);
777dd96dacaSLiam Girdwood
77851dfed1eSPierre-Louis Bossart /*
77951dfed1eSPierre-Louis Bossart * SoundWire support
78051dfed1eSPierre-Louis Bossart */
78151dfed1eSPierre-Louis Bossart #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
78251dfed1eSPierre-Louis Bossart
783625339caSPierre-Louis Bossart int hda_sdw_check_lcount_common(struct snd_sof_dev *sdev);
784d3e7c32bSPierre-Louis Bossart int hda_sdw_check_lcount_ext(struct snd_sof_dev *sdev);
78551dfed1eSPierre-Louis Bossart int hda_sdw_startup(struct snd_sof_dev *sdev);
7868ebc9074SPierre-Louis Bossart void hda_common_enable_sdw_irq(struct snd_sof_dev *sdev, bool enable);
78751dfed1eSPierre-Louis Bossart void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable);
7889362ab78SPierre-Louis Bossart bool hda_sdw_check_wakeen_irq_common(struct snd_sof_dev *sdev);
789bbd19cdcSRander Wang void hda_sdw_process_wakeen(struct snd_sof_dev *sdev);
790198fa4bcSBard Liao bool hda_common_check_sdw_irq(struct snd_sof_dev *sdev);
79151dfed1eSPierre-Louis Bossart
79251dfed1eSPierre-Louis Bossart #else
79351dfed1eSPierre-Louis Bossart
hda_sdw_check_lcount_common(struct snd_sof_dev * sdev)794625339caSPierre-Louis Bossart static inline int hda_sdw_check_lcount_common(struct snd_sof_dev *sdev)
795625339caSPierre-Louis Bossart {
796625339caSPierre-Louis Bossart return 0;
797625339caSPierre-Louis Bossart }
798625339caSPierre-Louis Bossart
hda_sdw_check_lcount_ext(struct snd_sof_dev * sdev)799d3e7c32bSPierre-Louis Bossart static inline int hda_sdw_check_lcount_ext(struct snd_sof_dev *sdev)
800d3e7c32bSPierre-Louis Bossart {
801d3e7c32bSPierre-Louis Bossart return 0;
802d3e7c32bSPierre-Louis Bossart }
803d3e7c32bSPierre-Louis Bossart
hda_sdw_startup(struct snd_sof_dev * sdev)80451dfed1eSPierre-Louis Bossart static inline int hda_sdw_startup(struct snd_sof_dev *sdev)
80551dfed1eSPierre-Louis Bossart {
80651dfed1eSPierre-Louis Bossart return 0;
80751dfed1eSPierre-Louis Bossart }
80851dfed1eSPierre-Louis Bossart
hda_common_enable_sdw_irq(struct snd_sof_dev * sdev,bool enable)8098ebc9074SPierre-Louis Bossart static inline void hda_common_enable_sdw_irq(struct snd_sof_dev *sdev, bool enable)
8108ebc9074SPierre-Louis Bossart {
8118ebc9074SPierre-Louis Bossart }
8128ebc9074SPierre-Louis Bossart
hda_sdw_int_enable(struct snd_sof_dev * sdev,bool enable)81351dfed1eSPierre-Louis Bossart static inline void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable)
81451dfed1eSPierre-Louis Bossart {
81551dfed1eSPierre-Louis Bossart }
81651dfed1eSPierre-Louis Bossart
hda_sdw_check_wakeen_irq_common(struct snd_sof_dev * sdev)8179362ab78SPierre-Louis Bossart static inline bool hda_sdw_check_wakeen_irq_common(struct snd_sof_dev *sdev)
8189362ab78SPierre-Louis Bossart {
8199362ab78SPierre-Louis Bossart return false;
8209362ab78SPierre-Louis Bossart }
8219362ab78SPierre-Louis Bossart
hda_sdw_process_wakeen(struct snd_sof_dev * sdev)822bbd19cdcSRander Wang static inline void hda_sdw_process_wakeen(struct snd_sof_dev *sdev)
823bbd19cdcSRander Wang {
824bbd19cdcSRander Wang }
825198fa4bcSBard Liao
hda_common_check_sdw_irq(struct snd_sof_dev * sdev)826198fa4bcSBard Liao static inline bool hda_common_check_sdw_irq(struct snd_sof_dev *sdev)
827198fa4bcSBard Liao {
828198fa4bcSBard Liao return false;
829198fa4bcSBard Liao }
830198fa4bcSBard Liao
83151dfed1eSPierre-Louis Bossart #endif
83251dfed1eSPierre-Louis Bossart
8332960ee5cSPierre-Louis Bossart int sdw_hda_dai_hw_params(struct snd_pcm_substream *substream,
8342960ee5cSPierre-Louis Bossart struct snd_pcm_hw_params *params,
8352960ee5cSPierre-Louis Bossart struct snd_soc_dai *cpu_dai,
8362960ee5cSPierre-Louis Bossart int link_id);
8372960ee5cSPierre-Louis Bossart
8382960ee5cSPierre-Louis Bossart int sdw_hda_dai_hw_free(struct snd_pcm_substream *substream,
8392960ee5cSPierre-Louis Bossart struct snd_soc_dai *cpu_dai,
8402960ee5cSPierre-Louis Bossart int link_id);
8412960ee5cSPierre-Louis Bossart
8422960ee5cSPierre-Louis Bossart int sdw_hda_dai_trigger(struct snd_pcm_substream *substream, int cmd,
8432960ee5cSPierre-Louis Bossart struct snd_soc_dai *cpu_dai);
8442960ee5cSPierre-Louis Bossart
845dd96dacaSLiam Girdwood /* common dai driver */
846dd96dacaSLiam Girdwood extern struct snd_soc_dai_driver skl_dai[];
847f09e9284SPierre-Louis Bossart int hda_dsp_dais_suspend(struct snd_sof_dev *sdev);
848dd96dacaSLiam Girdwood
849dd96dacaSLiam Girdwood /*
850dd96dacaSLiam Girdwood * Platform Specific HW abstraction Ops.
851dd96dacaSLiam Girdwood */
85237e809d5SPierre-Louis Bossart extern struct snd_sof_dsp_ops sof_hda_common_ops;
85337e809d5SPierre-Louis Bossart
854e2379d4aSPierre-Louis Bossart extern struct snd_sof_dsp_ops sof_skl_ops;
855e2379d4aSPierre-Louis Bossart int sof_skl_ops_init(struct snd_sof_dev *sdev);
856856601e5SPierre-Louis Bossart extern struct snd_sof_dsp_ops sof_apl_ops;
85737e809d5SPierre-Louis Bossart int sof_apl_ops_init(struct snd_sof_dev *sdev);
858856601e5SPierre-Louis Bossart extern struct snd_sof_dsp_ops sof_cnl_ops;
85937e809d5SPierre-Louis Bossart int sof_cnl_ops_init(struct snd_sof_dev *sdev);
860856601e5SPierre-Louis Bossart extern struct snd_sof_dsp_ops sof_tgl_ops;
86137e809d5SPierre-Louis Bossart int sof_tgl_ops_init(struct snd_sof_dev *sdev);
862856601e5SPierre-Louis Bossart extern struct snd_sof_dsp_ops sof_icl_ops;
86337e809d5SPierre-Louis Bossart int sof_icl_ops_init(struct snd_sof_dev *sdev);
864064520e8SBard Liao extern struct snd_sof_dsp_ops sof_mtl_ops;
865064520e8SBard Liao int sof_mtl_ops_init(struct snd_sof_dev *sdev);
866c22d5327SPierre-Louis Bossart extern struct snd_sof_dsp_ops sof_lnl_ops;
867c22d5327SPierre-Louis Bossart int sof_lnl_ops_init(struct snd_sof_dev *sdev);
868dd96dacaSLiam Girdwood
869e2379d4aSPierre-Louis Bossart extern const struct sof_intel_dsp_desc skl_chip_info;
870dd96dacaSLiam Girdwood extern const struct sof_intel_dsp_desc apl_chip_info;
871dd96dacaSLiam Girdwood extern const struct sof_intel_dsp_desc cnl_chip_info;
872630be964SZhu Yingjiang extern const struct sof_intel_dsp_desc icl_chip_info;
8731205c81eSPan Xiuli extern const struct sof_intel_dsp_desc tgl_chip_info;
87430ee3738SRander Wang extern const struct sof_intel_dsp_desc tglh_chip_info;
87561732690SPan Xiuli extern const struct sof_intel_dsp_desc ehl_chip_info;
8766fd99035SPan Xiuli extern const struct sof_intel_dsp_desc jsl_chip_info;
8776c2b6bb0SKai Vehmanen extern const struct sof_intel_dsp_desc adls_chip_info;
878064520e8SBard Liao extern const struct sof_intel_dsp_desc mtl_chip_info;
879*368017b1SPierre-Louis Bossart extern const struct sof_intel_dsp_desc arl_s_chip_info;
88064a63d99SRanjani Sridharan extern const struct sof_intel_dsp_desc lnl_chip_info;
881dd96dacaSLiam Girdwood
8823dc0d709SPeter Ujfalusi /* Probes support */
8833dc0d709SPeter Ujfalusi #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_PROBES)
8843dc0d709SPeter Ujfalusi int hda_probes_register(struct snd_sof_dev *sdev);
8853dc0d709SPeter Ujfalusi void hda_probes_unregister(struct snd_sof_dev *sdev);
8863dc0d709SPeter Ujfalusi #else
hda_probes_register(struct snd_sof_dev * sdev)8873dc0d709SPeter Ujfalusi static inline int hda_probes_register(struct snd_sof_dev *sdev)
8883dc0d709SPeter Ujfalusi {
8893dc0d709SPeter Ujfalusi return 0;
8903dc0d709SPeter Ujfalusi }
8913dc0d709SPeter Ujfalusi
hda_probes_unregister(struct snd_sof_dev * sdev)8923dc0d709SPeter Ujfalusi static inline void hda_probes_unregister(struct snd_sof_dev *sdev)
8933dc0d709SPeter Ujfalusi {
8943dc0d709SPeter Ujfalusi }
8953dc0d709SPeter Ujfalusi #endif /* CONFIG_SND_SOC_SOF_HDA_PROBES */
8963dc0d709SPeter Ujfalusi
8973dc0d709SPeter Ujfalusi /* SOF client registration for HDA platforms */
8983dc0d709SPeter Ujfalusi int hda_register_clients(struct snd_sof_dev *sdev);
8993dc0d709SPeter Ujfalusi void hda_unregister_clients(struct snd_sof_dev *sdev);
9003dc0d709SPeter Ujfalusi
901285880a2SDaniel Baluta /* machine driver select */
902cb515f10SGuennadi Liakhovetski struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev);
903cb515f10SGuennadi Liakhovetski void hda_set_mach_params(struct snd_soc_acpi_mach *mach,
90417e9d6b0SPierre-Louis Bossart struct snd_sof_dev *sdev);
905285880a2SDaniel Baluta
906194fe0fcSPierre-Louis Bossart /* PCI driver selection and probe */
907194fe0fcSPierre-Louis Bossart int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id);
908194fe0fcSPierre-Louis Bossart
9090acb48ddSRanjani Sridharan struct snd_sof_dai;
9100acb48ddSRanjani Sridharan struct sof_ipc_dai_config;
9110acb48ddSRanjani Sridharan
912288fad2fSPierre-Louis Bossart #define SOF_HDA_POSITION_QUIRK_USE_SKYLAKE_LEGACY (0) /* previous implementation */
913288fad2fSPierre-Louis Bossart #define SOF_HDA_POSITION_QUIRK_USE_DPIB_REGISTERS (1) /* recommended if VC0 only */
914288fad2fSPierre-Louis Bossart #define SOF_HDA_POSITION_QUIRK_USE_DPIB_DDR_UPDATE (2) /* recommended with VC0 or VC1 */
915288fad2fSPierre-Louis Bossart
916288fad2fSPierre-Louis Bossart extern int sof_hda_position_quirk;
917288fad2fSPierre-Louis Bossart
91851ec71dcSRanjani Sridharan void hda_set_dai_drv_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *ops);
9191da51943SRanjani Sridharan void hda_ops_free(struct snd_sof_dev *sdev);
92051ec71dcSRanjani Sridharan
921c712be34SPierre-Louis Bossart /* SKL/KBL */
922c712be34SPierre-Louis Bossart int hda_dsp_cl_boot_firmware_skl(struct snd_sof_dev *sdev);
923556eb416SPierre-Louis Bossart int hda_dsp_core_stall_reset(struct snd_sof_dev *sdev, unsigned int core_mask);
924556eb416SPierre-Louis Bossart
925e3105c0cSRanjani Sridharan /* IPC4 */
926e3105c0cSRanjani Sridharan irqreturn_t cnl_ipc4_irq_thread(int irq, void *context);
927e3105c0cSRanjani Sridharan int cnl_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
928e3105c0cSRanjani Sridharan irqreturn_t hda_dsp_ipc4_irq_thread(int irq, void *context);
929483e4cdfSPeter Ujfalusi bool hda_ipc4_tx_is_busy(struct snd_sof_dev *sdev);
9303e6b6ed3SRander Wang void hda_dsp_ipc4_schedule_d0i3_work(struct sof_intel_hda_dev *hdev,
9313e6b6ed3SRander Wang struct snd_sof_ipc_msg *msg);
932e3105c0cSRanjani Sridharan int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
93332b97c07SPeter Ujfalusi void hda_ipc4_dump(struct snd_sof_dev *sdev);
9342a1be12cSBard Liao extern struct sdw_intel_ops sdw_callback;
935e3105c0cSRanjani Sridharan
9363ab2c21eSPeter Ujfalusi struct sof_ipc4_fw_library;
9373ab2c21eSPeter Ujfalusi int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev,
9383ab2c21eSPeter Ujfalusi struct sof_ipc4_fw_library *fw_lib, bool reload);
9392ae49c6fSRanjani Sridharan
9402ae49c6fSRanjani Sridharan /**
9412ae49c6fSRanjani Sridharan * struct hda_dai_widget_dma_ops - DAI DMA ops optional by default unless specified otherwise
9422ae49c6fSRanjani Sridharan * @get_hext_stream: Mandatory function pointer to get the saved pointer to struct hdac_ext_stream
9432ae49c6fSRanjani Sridharan * @assign_hext_stream: Function pointer to assign a hdac_ext_stream
9442ae49c6fSRanjani Sridharan * @release_hext_stream: Function pointer to release the hdac_ext_stream
9452ae49c6fSRanjani Sridharan * @setup_hext_stream: Function pointer for hdac_ext_stream setup
9462ae49c6fSRanjani Sridharan * @reset_hext_stream: Function pointer for hdac_ext_stream reset
9472ae49c6fSRanjani Sridharan * @pre_trigger: Function pointer for DAI DMA pre-trigger actions
9482ae49c6fSRanjani Sridharan * @trigger: Function pointer for DAI DMA trigger actions
9492ae49c6fSRanjani Sridharan * @post_trigger: Function pointer for DAI DMA post-trigger actions
9502205c63dSPierre-Louis Bossart * @codec_dai_set_stream: Function pointer to set codec-side stream information
951767cda3fSPierre-Louis Bossart * @calc_stream_format: Function pointer to determine stream format from hw_params and
952767cda3fSPierre-Louis Bossart * for HDaudio codec DAI from the .sig bits
953d1bf5847SPierre-Louis Bossart * @get_hlink: Mandatory function pointer to retrieve hlink, mainly to program LOSIDV
954d1bf5847SPierre-Louis Bossart * for legacy HDaudio links or program HDaudio Extended Link registers.
9552ae49c6fSRanjani Sridharan */
9562ae49c6fSRanjani Sridharan struct hda_dai_widget_dma_ops {
9572ae49c6fSRanjani Sridharan struct hdac_ext_stream *(*get_hext_stream)(struct snd_sof_dev *sdev,
9582ae49c6fSRanjani Sridharan struct snd_soc_dai *cpu_dai,
9592ae49c6fSRanjani Sridharan struct snd_pcm_substream *substream);
9602ae49c6fSRanjani Sridharan struct hdac_ext_stream *(*assign_hext_stream)(struct snd_sof_dev *sdev,
9612ae49c6fSRanjani Sridharan struct snd_soc_dai *cpu_dai,
9622ae49c6fSRanjani Sridharan struct snd_pcm_substream *substream);
9632ae49c6fSRanjani Sridharan void (*release_hext_stream)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
9642ae49c6fSRanjani Sridharan struct snd_pcm_substream *substream);
9652ae49c6fSRanjani Sridharan void (*setup_hext_stream)(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream,
9662ae49c6fSRanjani Sridharan unsigned int format_val);
9672ae49c6fSRanjani Sridharan void (*reset_hext_stream)(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_sream);
9682ae49c6fSRanjani Sridharan int (*pre_trigger)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
9692ae49c6fSRanjani Sridharan struct snd_pcm_substream *substream, int cmd);
9702ae49c6fSRanjani Sridharan int (*trigger)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
9712ae49c6fSRanjani Sridharan struct snd_pcm_substream *substream, int cmd);
9722ae49c6fSRanjani Sridharan int (*post_trigger)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
9732ae49c6fSRanjani Sridharan struct snd_pcm_substream *substream, int cmd);
9742205c63dSPierre-Louis Bossart void (*codec_dai_set_stream)(struct snd_sof_dev *sdev,
9752205c63dSPierre-Louis Bossart struct snd_pcm_substream *substream,
9762205c63dSPierre-Louis Bossart struct hdac_stream *hstream);
977767cda3fSPierre-Louis Bossart unsigned int (*calc_stream_format)(struct snd_sof_dev *sdev,
978767cda3fSPierre-Louis Bossart struct snd_pcm_substream *substream,
979767cda3fSPierre-Louis Bossart struct snd_pcm_hw_params *params);
980d1bf5847SPierre-Louis Bossart struct hdac_ext_link * (*get_hlink)(struct snd_sof_dev *sdev,
981d1bf5847SPierre-Louis Bossart struct snd_pcm_substream *substream);
9822ae49c6fSRanjani Sridharan };
98380afde34SRanjani Sridharan
98480afde34SRanjani Sridharan const struct hda_dai_widget_dma_ops *
98580afde34SRanjani Sridharan hda_select_dai_widget_ops(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
9862b009fa0SRanjani Sridharan int hda_dai_config(struct snd_soc_dapm_widget *w, unsigned int flags,
9872b009fa0SRanjani Sridharan struct snd_sof_dai_config_data *data);
98890219f1bSRanjani Sridharan int hda_link_dma_cleanup(struct snd_pcm_substream *substream, struct hdac_ext_stream *hext_stream,
98990219f1bSRanjani Sridharan struct snd_soc_dai *cpu_dai);
99080afde34SRanjani Sridharan
991dd96dacaSLiam Girdwood #endif
992