0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef __SOF_INTEL_HDA_H
0012 #define __SOF_INTEL_HDA_H
0013
0014 #include <linux/soundwire/sdw.h>
0015 #include <linux/soundwire/sdw_intel.h>
0016 #include <sound/compress_driver.h>
0017 #include <sound/hda_codec.h>
0018 #include <sound/hdaudio_ext.h>
0019 #include "../sof-client-probes.h"
0020 #include "../sof-audio.h"
0021 #include "shim.h"
0022
0023
0024 #define PCI_TCSEL 0x44
0025 #define PCI_PGCTL PCI_TCSEL
0026 #define PCI_CGCTL 0x48
0027
0028
0029 #define PCI_PGCTL_ADSPPGD BIT(2)
0030 #define PCI_PGCTL_LSRMD_MASK BIT(4)
0031
0032
0033 #define PCI_CGCTL_MISCBDCGE_MASK BIT(6)
0034 #define PCI_CGCTL_ADSPDCGE BIT(1)
0035
0036
0037 #define SOF_HDA_GCAP 0x0
0038 #define SOF_HDA_GCTL 0x8
0039
0040 #define SOF_HDA_GCTL_UNSOL BIT(8)
0041 #define SOF_HDA_LLCH 0x14
0042 #define SOF_HDA_INTCTL 0x20
0043 #define SOF_HDA_INTSTS 0x24
0044 #define SOF_HDA_WAKESTS 0x0E
0045 #define SOF_HDA_WAKESTS_INT_MASK ((1 << 8) - 1)
0046 #define SOF_HDA_RIRBSTS 0x5d
0047
0048
0049 #define SOF_HDA_GCTL_RESET BIT(0)
0050
0051
0052 #define SOF_HDA_INT_GLOBAL_EN BIT(31)
0053 #define SOF_HDA_INT_CTRL_EN BIT(30)
0054 #define SOF_HDA_INT_ALL_STREAM 0xff
0055
0056
0057 #define SOF_HDA_INTSTS_GIS BIT(31)
0058
0059 #define SOF_HDA_MAX_CAPS 10
0060 #define SOF_HDA_CAP_ID_OFF 16
0061 #define SOF_HDA_CAP_ID_MASK GENMASK(SOF_HDA_CAP_ID_OFF + 11,\
0062 SOF_HDA_CAP_ID_OFF)
0063 #define SOF_HDA_CAP_NEXT_MASK 0xFFFF
0064
0065 #define SOF_HDA_GTS_CAP_ID 0x1
0066 #define SOF_HDA_ML_CAP_ID 0x2
0067
0068 #define SOF_HDA_PP_CAP_ID 0x3
0069 #define SOF_HDA_REG_PP_PPCH 0x10
0070 #define SOF_HDA_REG_PP_PPCTL 0x04
0071 #define SOF_HDA_REG_PP_PPSTS 0x08
0072 #define SOF_HDA_PPCTL_PIE BIT(31)
0073 #define SOF_HDA_PPCTL_GPROCEN BIT(30)
0074
0075
0076 #define SOF_HDA_VS_D0I3C 0x104A
0077
0078
0079 #define SOF_HDA_VS_D0I3C_CIP BIT(0)
0080 #define SOF_HDA_VS_D0I3C_I3 BIT(2)
0081
0082
0083 #define SOF_HDA_DPIB_ENTRY_SIZE 0x8
0084
0085 #define SOF_HDA_SPIB_CAP_ID 0x4
0086 #define SOF_HDA_DRSM_CAP_ID 0x5
0087
0088 #define SOF_HDA_SPIB_BASE 0x08
0089 #define SOF_HDA_SPIB_INTERVAL 0x08
0090 #define SOF_HDA_SPIB_SPIB 0x00
0091 #define SOF_HDA_SPIB_MAXFIFO 0x04
0092
0093 #define SOF_HDA_PPHC_BASE 0x10
0094 #define SOF_HDA_PPHC_INTERVAL 0x10
0095
0096 #define SOF_HDA_PPLC_BASE 0x10
0097 #define SOF_HDA_PPLC_MULTI 0x10
0098 #define SOF_HDA_PPLC_INTERVAL 0x10
0099
0100 #define SOF_HDA_DRSM_BASE 0x08
0101 #define SOF_HDA_DRSM_INTERVAL 0x08
0102
0103
0104 #define SOF_HDA_CL_DMA_SD_INT_DESC_ERR 0x10
0105
0106
0107 #define SOF_HDA_CL_DMA_SD_INT_FIFO_ERR 0x08
0108
0109
0110 #define SOF_HDA_CL_DMA_SD_INT_COMPLETE 0x04
0111
0112 #define SOF_HDA_CL_DMA_SD_INT_MASK \
0113 (SOF_HDA_CL_DMA_SD_INT_DESC_ERR | \
0114 SOF_HDA_CL_DMA_SD_INT_FIFO_ERR | \
0115 SOF_HDA_CL_DMA_SD_INT_COMPLETE)
0116 #define SOF_HDA_SD_CTL_DMA_START 0x02
0117
0118
0119 #define SOF_HDA_ADSP_LOADER_BASE 0x80
0120 #define SOF_HDA_ADSP_DPLBASE 0x70
0121 #define SOF_HDA_ADSP_DPUBASE 0x74
0122 #define SOF_HDA_ADSP_DPLBASE_ENABLE 0x01
0123
0124
0125 #define SOF_HDA_ADSP_REG_CL_SD_CTL 0x00
0126 #define SOF_HDA_ADSP_REG_CL_SD_STS 0x03
0127 #define SOF_HDA_ADSP_REG_CL_SD_LPIB 0x04
0128 #define SOF_HDA_ADSP_REG_CL_SD_CBL 0x08
0129 #define SOF_HDA_ADSP_REG_CL_SD_LVI 0x0C
0130 #define SOF_HDA_ADSP_REG_CL_SD_FIFOW 0x0E
0131 #define SOF_HDA_ADSP_REG_CL_SD_FIFOSIZE 0x10
0132 #define SOF_HDA_ADSP_REG_CL_SD_FORMAT 0x12
0133 #define SOF_HDA_ADSP_REG_CL_SD_FIFOL 0x14
0134 #define SOF_HDA_ADSP_REG_CL_SD_BDLPL 0x18
0135 #define SOF_HDA_ADSP_REG_CL_SD_BDLPU 0x1C
0136 #define SOF_HDA_ADSP_SD_ENTRY_SIZE 0x20
0137
0138
0139 #define SOF_DSP_REG_CL_SPBFIFO \
0140 (SOF_HDA_ADSP_LOADER_BASE + 0x20)
0141 #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCH 0x0
0142 #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCCTL 0x4
0143 #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPIB 0x8
0144 #define SOF_HDA_ADSP_REG_CL_SPBFIFO_MAXFIFOS 0xc
0145
0146
0147 #define SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT 20
0148 #define SOF_HDA_CL_SD_CTL_STREAM_TAG_MASK \
0149 GENMASK(SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT + 3,\
0150 SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT)
0151
0152 #define HDA_DSP_HDA_BAR 0
0153 #define HDA_DSP_PP_BAR 1
0154 #define HDA_DSP_SPIB_BAR 2
0155 #define HDA_DSP_DRSM_BAR 3
0156 #define HDA_DSP_BAR 4
0157
0158 #define SRAM_WINDOW_OFFSET(x) (0x80000 + (x) * 0x20000)
0159
0160 #define HDA_DSP_MBOX_OFFSET SRAM_WINDOW_OFFSET(0)
0161
0162 #define HDA_DSP_PANIC_OFFSET(x) \
0163 (((x) & 0xFFFFFF) + HDA_DSP_MBOX_OFFSET)
0164
0165
0166 #define HDA_DSP_SRAM_REG_ROM_STATUS (HDA_DSP_MBOX_OFFSET + 0x0)
0167 #define HDA_DSP_SRAM_REG_ROM_ERROR (HDA_DSP_MBOX_OFFSET + 0x4)
0168
0169 #define HDA_DSP_SRAM_REG_FW_STATUS (HDA_DSP_MBOX_OFFSET + 0x4)
0170 #define HDA_DSP_SRAM_REG_FW_TRACEP (HDA_DSP_MBOX_OFFSET + 0x8)
0171 #define HDA_DSP_SRAM_REG_FW_END (HDA_DSP_MBOX_OFFSET + 0xc)
0172
0173 #define HDA_DSP_MBOX_UPLINK_OFFSET 0x81000
0174
0175 #define HDA_DSP_STREAM_RESET_TIMEOUT 300
0176
0177
0178
0179
0180
0181 #define HDA_DSP_STREAM_RUN_TIMEOUT 300
0182
0183 #define HDA_DSP_SPIB_ENABLE 1
0184 #define HDA_DSP_SPIB_DISABLE 0
0185
0186 #define SOF_HDA_MAX_BUFFER_SIZE (32 * PAGE_SIZE)
0187
0188 #define HDA_DSP_STACK_DUMP_SIZE 32
0189
0190
0191 #define FSR_STATE_MASK GENMASK(23, 0)
0192 #define FSR_WAIT_STATE_MASK GENMASK(27, 24)
0193 #define FSR_MODULE_MASK GENMASK(30, 28)
0194 #define FSR_HALTED BIT(31)
0195 #define FSR_TO_STATE_CODE(x) ((x) & FSR_STATE_MASK)
0196 #define FSR_TO_WAIT_STATE_CODE(x) (((x) & FSR_WAIT_STATE_MASK) >> 24)
0197 #define FSR_TO_MODULE_CODE(x) (((x) & FSR_MODULE_MASK) >> 28)
0198
0199
0200 #define FSR_WAIT_FOR_IPC_BUSY 0x1
0201 #define FSR_WAIT_FOR_IPC_DONE 0x2
0202 #define FSR_WAIT_FOR_CACHE_INVALIDATION 0x3
0203 #define FSR_WAIT_FOR_LP_SRAM_OFF 0x4
0204 #define FSR_WAIT_FOR_DMA_BUFFER_FULL 0x5
0205 #define FSR_WAIT_FOR_CSE_CSR 0x6
0206
0207
0208 #define FSR_MOD_ROM 0x0
0209 #define FSR_MOD_ROM_BYP 0x1
0210 #define FSR_MOD_BASE_FW 0x2
0211 #define FSR_MOD_LP_BOOT 0x3
0212 #define FSR_MOD_BRNGUP 0x4
0213 #define FSR_MOD_ROM_EXT 0x5
0214
0215
0216
0217 #define FSR_STATE_INIT 0x0
0218 #define FSR_STATE_INIT_DONE 0x1
0219 #define FSR_STATE_FW_ENTERED 0x5
0220
0221
0222 #define FSR_STATE_ROM_INIT FSR_STATE_INIT
0223 #define FSR_STATE_ROM_INIT_DONE FSR_STATE_INIT_DONE
0224 #define FSR_STATE_ROM_CSE_MANIFEST_LOADED 0x2
0225 #define FSR_STATE_ROM_FW_MANIFEST_LOADED 0x3
0226 #define FSR_STATE_ROM_FW_FW_LOADED 0x4
0227 #define FSR_STATE_ROM_FW_ENTERED FSR_STATE_FW_ENTERED
0228 #define FSR_STATE_ROM_VERIFY_FEATURE_MASK 0x6
0229 #define FSR_STATE_ROM_GET_LOAD_OFFSET 0x7
0230 #define FSR_STATE_ROM_FETCH_ROM_EXT 0x8
0231 #define FSR_STATE_ROM_FETCH_ROM_EXT_DONE 0x9
0232
0233
0234 #define FSR_STATE_ROM_CSE_IMR_REQUEST 0x10
0235 #define FSR_STATE_ROM_CSE_IMR_GRANTED 0x11
0236 #define FSR_STATE_ROM_CSE_VALIDATE_IMAGE_REQUEST 0x12
0237 #define FSR_STATE_ROM_CSE_IMAGE_VALIDATED 0x13
0238
0239 #define FSR_STATE_ROM_CSE_IPC_IFACE_INIT 0x20
0240 #define FSR_STATE_ROM_CSE_IPC_RESET_PHASE_1 0x21
0241 #define FSR_STATE_ROM_CSE_IPC_OPERATIONAL_ENTRY 0x22
0242 #define FSR_STATE_ROM_CSE_IPC_OPERATIONAL 0x23
0243 #define FSR_STATE_ROM_CSE_IPC_DOWN 0x24
0244
0245
0246 #define FSR_STATE_BRINGUP_INIT FSR_STATE_INIT
0247 #define FSR_STATE_BRINGUP_INIT_DONE FSR_STATE_INIT_DONE
0248 #define FSR_STATE_BRINGUP_HPSRAM_LOAD 0x2
0249 #define FSR_STATE_BRINGUP_UNPACK_START 0X3
0250 #define FSR_STATE_BRINGUP_IMR_RESTORE 0x4
0251 #define FSR_STATE_BRINGUP_FW_ENTERED FSR_STATE_FW_ENTERED
0252
0253
0254 #define HDA_DSP_ROM_STS_MASK GENMASK(23, 0)
0255 #define HDA_DSP_ROM_INIT 0x1
0256 #define HDA_DSP_ROM_FW_MANIFEST_LOADED 0x3
0257 #define HDA_DSP_ROM_FW_FW_LOADED 0x4
0258 #define HDA_DSP_ROM_FW_ENTERED 0x5
0259 #define HDA_DSP_ROM_RFW_START 0xf
0260 #define HDA_DSP_ROM_CSE_ERROR 40
0261 #define HDA_DSP_ROM_CSE_WRONG_RESPONSE 41
0262 #define HDA_DSP_ROM_IMR_TO_SMALL 42
0263 #define HDA_DSP_ROM_BASE_FW_NOT_FOUND 43
0264 #define HDA_DSP_ROM_CSE_VALIDATION_FAILED 44
0265 #define HDA_DSP_ROM_IPC_FATAL_ERROR 45
0266 #define HDA_DSP_ROM_L2_CACHE_ERROR 46
0267 #define HDA_DSP_ROM_LOAD_OFFSET_TO_SMALL 47
0268 #define HDA_DSP_ROM_API_PTR_INVALID 50
0269 #define HDA_DSP_ROM_BASEFW_INCOMPAT 51
0270 #define HDA_DSP_ROM_UNHANDLED_INTERRUPT 0xBEE00000
0271 #define HDA_DSP_ROM_MEMORY_HOLE_ECC 0xECC00000
0272 #define HDA_DSP_ROM_KERNEL_EXCEPTION 0xCAFE0000
0273 #define HDA_DSP_ROM_USER_EXCEPTION 0xBEEF0000
0274 #define HDA_DSP_ROM_UNEXPECTED_RESET 0xDECAF000
0275 #define HDA_DSP_ROM_NULL_FW_ENTRY 0x4c4c4e55
0276
0277 #define HDA_DSP_ROM_IPC_CONTROL 0x01000000
0278 #define HDA_DSP_ROM_IPC_PURGE_FW 0x00004000
0279
0280
0281 #define HDA_DSP_PU_TIMEOUT 50
0282 #define HDA_DSP_PD_TIMEOUT 50
0283 #define HDA_DSP_RESET_TIMEOUT_US 50000
0284 #define HDA_DSP_BASEFW_TIMEOUT_US 3000000
0285 #define HDA_DSP_INIT_TIMEOUT_US 500000
0286 #define HDA_DSP_CTRL_RESET_TIMEOUT 100
0287 #define HDA_DSP_WAIT_TIMEOUT 500
0288 #define HDA_DSP_REG_POLL_INTERVAL_US 500
0289 #define HDA_DSP_REG_POLL_RETRY_COUNT 50
0290
0291 #define HDA_DSP_ADSPIC_IPC BIT(0)
0292 #define HDA_DSP_ADSPIS_IPC BIT(0)
0293
0294
0295 #define HDA_DSP_GEN_BASE 0x0
0296 #define HDA_DSP_REG_ADSPCS (HDA_DSP_GEN_BASE + 0x04)
0297 #define HDA_DSP_REG_ADSPIC (HDA_DSP_GEN_BASE + 0x08)
0298 #define HDA_DSP_REG_ADSPIS (HDA_DSP_GEN_BASE + 0x0C)
0299 #define HDA_DSP_REG_ADSPIC2 (HDA_DSP_GEN_BASE + 0x10)
0300 #define HDA_DSP_REG_ADSPIS2 (HDA_DSP_GEN_BASE + 0x14)
0301
0302 #define HDA_DSP_REG_ADSPIS2_SNDW BIT(5)
0303
0304
0305 #define HDA_DSP_IPC_BASE 0x40
0306 #define HDA_DSP_REG_HIPCT (HDA_DSP_IPC_BASE + 0x00)
0307 #define HDA_DSP_REG_HIPCTE (HDA_DSP_IPC_BASE + 0x04)
0308 #define HDA_DSP_REG_HIPCI (HDA_DSP_IPC_BASE + 0x08)
0309 #define HDA_DSP_REG_HIPCIE (HDA_DSP_IPC_BASE + 0x0C)
0310 #define HDA_DSP_REG_HIPCCTL (HDA_DSP_IPC_BASE + 0x10)
0311
0312
0313 #define HDA_VS_INTEL_EM2 0x1030
0314 #define HDA_VS_INTEL_EM2_L1SEN BIT(13)
0315 #define HDA_VS_INTEL_LTRP_GB_MASK 0x3F
0316
0317
0318 #define HDA_DSP_REG_HIPCI_BUSY BIT(31)
0319 #define HDA_DSP_REG_HIPCI_MSG_MASK 0x7FFFFFFF
0320
0321
0322 #define HDA_DSP_REG_HIPCIE_DONE BIT(30)
0323 #define HDA_DSP_REG_HIPCIE_MSG_MASK 0x3FFFFFFF
0324
0325
0326 #define HDA_DSP_REG_HIPCCTL_DONE BIT(1)
0327 #define HDA_DSP_REG_HIPCCTL_BUSY BIT(0)
0328
0329
0330 #define HDA_DSP_REG_HIPCT_BUSY BIT(31)
0331 #define HDA_DSP_REG_HIPCT_MSG_MASK 0x7FFFFFFF
0332
0333
0334 #define HDA_DSP_REG_HIPCTE_MSG_MASK 0x3FFFFFFF
0335
0336 #define HDA_DSP_ADSPIC_CL_DMA BIT(1)
0337 #define HDA_DSP_ADSPIS_CL_DMA BIT(1)
0338
0339
0340 #define BXT_D0I3_DELAY 5000
0341
0342 #define FW_CL_STREAM_NUMBER 0x1
0343 #define HDA_FW_BOOT_ATTEMPTS 3
0344
0345
0346
0347
0348
0349
0350
0351 #define HDA_DSP_ADSPCS_CRST_SHIFT 0
0352 #define HDA_DSP_ADSPCS_CRST_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CRST_SHIFT)
0353
0354
0355
0356
0357
0358 #define HDA_DSP_ADSPCS_CSTALL_SHIFT 8
0359 #define HDA_DSP_ADSPCS_CSTALL_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CSTALL_SHIFT)
0360
0361
0362
0363
0364
0365 #define HDA_DSP_ADSPCS_SPA_SHIFT 16
0366 #define HDA_DSP_ADSPCS_SPA_MASK(cm) ((cm) << HDA_DSP_ADSPCS_SPA_SHIFT)
0367
0368
0369
0370
0371
0372 #define HDA_DSP_ADSPCS_CPA_SHIFT 24
0373 #define HDA_DSP_ADSPCS_CPA_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CPA_SHIFT)
0374
0375
0376
0377
0378
0379 #define SOF_DSP_CORES_MASK(nc) GENMASK(((nc) - 1), 0)
0380
0381
0382 #define CNL_DSP_IPC_BASE 0xc0
0383 #define CNL_DSP_REG_HIPCTDR (CNL_DSP_IPC_BASE + 0x00)
0384 #define CNL_DSP_REG_HIPCTDA (CNL_DSP_IPC_BASE + 0x04)
0385 #define CNL_DSP_REG_HIPCTDD (CNL_DSP_IPC_BASE + 0x08)
0386 #define CNL_DSP_REG_HIPCIDR (CNL_DSP_IPC_BASE + 0x10)
0387 #define CNL_DSP_REG_HIPCIDA (CNL_DSP_IPC_BASE + 0x14)
0388 #define CNL_DSP_REG_HIPCIDD (CNL_DSP_IPC_BASE + 0x18)
0389 #define CNL_DSP_REG_HIPCCTL (CNL_DSP_IPC_BASE + 0x28)
0390
0391
0392 #define CNL_DSP_REG_HIPCIDR_BUSY BIT(31)
0393 #define CNL_DSP_REG_HIPCIDR_MSG_MASK 0x7FFFFFFF
0394
0395
0396 #define CNL_DSP_REG_HIPCIDA_DONE BIT(31)
0397 #define CNL_DSP_REG_HIPCIDA_MSG_MASK 0x7FFFFFFF
0398
0399
0400 #define CNL_DSP_REG_HIPCCTL_DONE BIT(1)
0401 #define CNL_DSP_REG_HIPCCTL_BUSY BIT(0)
0402
0403
0404 #define CNL_DSP_REG_HIPCTDR_BUSY BIT(31)
0405 #define CNL_DSP_REG_HIPCTDR_MSG_MASK 0x7FFFFFFF
0406
0407
0408 #define CNL_DSP_REG_HIPCTDA_DONE BIT(31)
0409 #define CNL_DSP_REG_HIPCTDA_MSG_MASK 0x7FFFFFFF
0410
0411
0412 #define CNL_DSP_REG_HIPCTDD_MSG_MASK 0x7FFFFFFF
0413
0414
0415 #define HDA_DSP_BDL_SIZE 4096
0416 #define HDA_DSP_MAX_BDL_ENTRIES \
0417 (HDA_DSP_BDL_SIZE / sizeof(struct sof_intel_dsp_bdl))
0418
0419
0420 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
0421 #define SOF_SKL_NUM_DAIS 15
0422 #else
0423 #define SOF_SKL_NUM_DAIS 8
0424 #endif
0425
0426
0427 #define HDA_ADSP_SRAM0_BASE_SKL 0x8000
0428
0429
0430 #define HDA_ADSP_FW_STATUS_SKL HDA_ADSP_SRAM0_BASE_SKL
0431 #define HDA_ADSP_ERROR_CODE_SKL (HDA_ADSP_FW_STATUS_SKL + 0x4)
0432
0433
0434 #define APL_SSP_BASE_OFFSET 0x2000
0435 #define CNL_SSP_BASE_OFFSET 0x10000
0436
0437
0438 #define SSP_DEV_MEM_SIZE 0x1000
0439
0440
0441 #define APL_SSP_COUNT 6
0442 #define CNL_SSP_COUNT 3
0443 #define ICL_SSP_COUNT 6
0444
0445
0446 #define SSP_SSC1_OFFSET 0x4
0447 #define SSP_SET_SCLK_CONSUMER BIT(25)
0448 #define SSP_SET_SFRM_CONSUMER BIT(24)
0449 #define SSP_SET_CBP_CFP (SSP_SET_SCLK_CONSUMER | SSP_SET_SFRM_CONSUMER)
0450
0451 #define HDA_IDISP_ADDR 2
0452 #define HDA_IDISP_CODEC(x) ((x) & BIT(HDA_IDISP_ADDR))
0453
0454 struct sof_intel_dsp_bdl {
0455 __le32 addr_l;
0456 __le32 addr_h;
0457 __le32 size;
0458 __le32 ioc;
0459 } __attribute((packed));
0460
0461 #define SOF_HDA_PLAYBACK_STREAMS 16
0462 #define SOF_HDA_CAPTURE_STREAMS 16
0463 #define SOF_HDA_PLAYBACK 0
0464 #define SOF_HDA_CAPTURE 1
0465
0466
0467 #define SOF_HDA_STREAM_DMI_L1_COMPATIBLE 1
0468
0469
0470
0471
0472
0473
0474 #define SOF_HDA_D0I3_WORK_DELAY_MS 5000
0475
0476
0477 enum sof_hda_D0_substate {
0478 SOF_HDA_DSP_PM_D0I0,
0479 SOF_HDA_DSP_PM_D0I3,
0480 };
0481
0482
0483 struct sof_intel_hda_dev {
0484 bool imrboot_supported;
0485 bool skip_imr_boot;
0486
0487 int boot_iteration;
0488
0489 struct hda_bus hbus;
0490
0491
0492 const struct sof_intel_dsp_desc *desc;
0493
0494
0495 struct hdac_ext_stream *dtrace_stream;
0496
0497
0498 u32 no_ipc_position;
0499
0500
0501 u32 stream_max;
0502
0503
0504 bool l1_support_changed;
0505
0506
0507 struct platform_device *dmic_dev;
0508
0509
0510 struct delayed_work d0i3_work;
0511
0512
0513 struct sdw_intel_acpi_info info;
0514
0515
0516 struct sdw_intel_ctx *sdw;
0517
0518
0519 bool clk_config_lpro;
0520
0521
0522 struct nhlt_acpi_table *nhlt;
0523 };
0524
0525 static inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s)
0526 {
0527 struct sof_intel_hda_dev *hda = s->pdata->hw_pdata;
0528
0529 return &hda->hbus.core;
0530 }
0531
0532 static inline struct hda_bus *sof_to_hbus(struct snd_sof_dev *s)
0533 {
0534 struct sof_intel_hda_dev *hda = s->pdata->hw_pdata;
0535
0536 return &hda->hbus;
0537 }
0538
0539 struct sof_intel_hda_stream {
0540 struct snd_sof_dev *sdev;
0541 struct hdac_ext_stream hext_stream;
0542 struct sof_intel_stream sof_intel_stream;
0543 int host_reserved;
0544 u32 flags;
0545 };
0546
0547 #define hstream_to_sof_hda_stream(hstream) \
0548 container_of(hstream, struct sof_intel_hda_stream, hext_stream)
0549
0550 #define bus_to_sof_hda(bus) \
0551 container_of(bus, struct sof_intel_hda_dev, hbus.core)
0552
0553 #define SOF_STREAM_SD_OFFSET(s) \
0554 (SOF_HDA_ADSP_SD_ENTRY_SIZE * ((s)->index) \
0555 + SOF_HDA_ADSP_LOADER_BASE)
0556
0557 #define SOF_STREAM_SD_OFFSET_CRST 0x1
0558
0559
0560
0561
0562 int hda_dsp_probe(struct snd_sof_dev *sdev);
0563 int hda_dsp_remove(struct snd_sof_dev *sdev);
0564 int hda_dsp_core_power_up(struct snd_sof_dev *sdev, unsigned int core_mask);
0565 int hda_dsp_core_run(struct snd_sof_dev *sdev, unsigned int core_mask);
0566 int hda_dsp_enable_core(struct snd_sof_dev *sdev, unsigned int core_mask);
0567 int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev,
0568 unsigned int core_mask);
0569 int hda_dsp_core_get(struct snd_sof_dev *sdev, int core);
0570 void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev);
0571 void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev);
0572
0573 int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
0574 const struct sof_dsp_power_state *target_state);
0575
0576 int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state);
0577 int hda_dsp_resume(struct snd_sof_dev *sdev);
0578 int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev);
0579 int hda_dsp_runtime_resume(struct snd_sof_dev *sdev);
0580 int hda_dsp_runtime_idle(struct snd_sof_dev *sdev);
0581 int hda_dsp_shutdown(struct snd_sof_dev *sdev);
0582 int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev);
0583 void hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags);
0584 void hda_ipc_dump(struct snd_sof_dev *sdev);
0585 void hda_ipc_irq_dump(struct snd_sof_dev *sdev);
0586 void hda_dsp_d0i3_work(struct work_struct *work);
0587
0588
0589
0590
0591 u32 hda_dsp_get_mult_div(struct snd_sof_dev *sdev, int rate);
0592 u32 hda_dsp_get_bits(struct snd_sof_dev *sdev, int sample_bits);
0593 int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
0594 struct snd_pcm_substream *substream);
0595 int hda_dsp_pcm_close(struct snd_sof_dev *sdev,
0596 struct snd_pcm_substream *substream);
0597 int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
0598 struct snd_pcm_substream *substream,
0599 struct snd_pcm_hw_params *params,
0600 struct snd_sof_platform_stream_params *platform_params);
0601 int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
0602 struct snd_pcm_substream *substream);
0603 int hda_dsp_pcm_trigger(struct snd_sof_dev *sdev,
0604 struct snd_pcm_substream *substream, int cmd);
0605 snd_pcm_uframes_t hda_dsp_pcm_pointer(struct snd_sof_dev *sdev,
0606 struct snd_pcm_substream *substream);
0607 int hda_dsp_pcm_ack(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream);
0608
0609
0610
0611
0612
0613 int hda_dsp_stream_init(struct snd_sof_dev *sdev);
0614 void hda_dsp_stream_free(struct snd_sof_dev *sdev);
0615 int hda_dsp_stream_hw_params(struct snd_sof_dev *sdev,
0616 struct hdac_ext_stream *hext_stream,
0617 struct snd_dma_buffer *dmab,
0618 struct snd_pcm_hw_params *params);
0619 int hda_dsp_iccmax_stream_hw_params(struct snd_sof_dev *sdev,
0620 struct hdac_ext_stream *hext_stream,
0621 struct snd_dma_buffer *dmab,
0622 struct snd_pcm_hw_params *params);
0623 int hda_dsp_stream_trigger(struct snd_sof_dev *sdev,
0624 struct hdac_ext_stream *hext_stream, int cmd);
0625 irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context);
0626 int hda_dsp_stream_setup_bdl(struct snd_sof_dev *sdev,
0627 struct snd_dma_buffer *dmab,
0628 struct hdac_stream *hstream);
0629 bool hda_dsp_check_ipc_irq(struct snd_sof_dev *sdev);
0630 bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev);
0631
0632 snd_pcm_uframes_t hda_dsp_stream_get_position(struct hdac_stream *hstream,
0633 int direction, bool can_sleep);
0634
0635 struct hdac_ext_stream *
0636 hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags);
0637 int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag);
0638 int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev,
0639 struct hdac_ext_stream *hext_stream,
0640 int enable, u32 size);
0641
0642 int hda_ipc_msg_data(struct snd_sof_dev *sdev,
0643 struct snd_pcm_substream *substream,
0644 void *p, size_t sz);
0645 int hda_set_stream_data_offset(struct snd_sof_dev *sdev,
0646 struct snd_pcm_substream *substream,
0647 size_t posn_offset);
0648
0649
0650
0651
0652 int hda_dsp_ipc_send_msg(struct snd_sof_dev *sdev,
0653 struct snd_sof_ipc_msg *msg);
0654 void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev);
0655 int hda_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev);
0656 int hda_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id);
0657
0658 irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context);
0659 int hda_dsp_ipc_cmd_done(struct snd_sof_dev *sdev, int dir);
0660
0661
0662
0663
0664 int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev);
0665 int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev);
0666 int hda_cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream);
0667 struct hdac_ext_stream *hda_cl_stream_prepare(struct snd_sof_dev *sdev, unsigned int format,
0668 unsigned int size, struct snd_dma_buffer *dmab,
0669 int direction);
0670 int hda_cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
0671 struct hdac_ext_stream *hext_stream);
0672 int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot);
0673 #define HDA_CL_STREAM_FORMAT 0x40
0674
0675
0676 int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev);
0677 int hda_dsp_post_fw_run(struct snd_sof_dev *sdev);
0678
0679
0680 int hda_dsp_ext_man_get_cavs_config_data(struct snd_sof_dev *sdev,
0681 const struct sof_ext_man_elem_header *hdr);
0682
0683
0684
0685
0686 int hda_dsp_ctrl_get_caps(struct snd_sof_dev *sdev);
0687 void hda_dsp_ctrl_ppcap_enable(struct snd_sof_dev *sdev, bool enable);
0688 void hda_dsp_ctrl_ppcap_int_enable(struct snd_sof_dev *sdev, bool enable);
0689 int hda_dsp_ctrl_link_reset(struct snd_sof_dev *sdev, bool reset);
0690 void hda_dsp_ctrl_misc_clock_gating(struct snd_sof_dev *sdev, bool enable);
0691 int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable);
0692 int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev, bool full_reset);
0693 void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev);
0694
0695
0696
0697 void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev);
0698
0699 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
0700
0701
0702
0703 void hda_codec_probe_bus(struct snd_sof_dev *sdev,
0704 bool hda_codec_use_common_hdmi);
0705 void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable);
0706 void hda_codec_jack_check(struct snd_sof_dev *sdev);
0707
0708 #endif
0709
0710 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) && \
0711 (IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI) || \
0712 IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI))
0713
0714 void hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable);
0715 int hda_codec_i915_init(struct snd_sof_dev *sdev);
0716 int hda_codec_i915_exit(struct snd_sof_dev *sdev);
0717
0718 #else
0719
0720 static inline void hda_codec_i915_display_power(struct snd_sof_dev *sdev,
0721 bool enable) { }
0722 static inline int hda_codec_i915_init(struct snd_sof_dev *sdev) { return 0; }
0723 static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }
0724
0725 #endif
0726
0727
0728
0729
0730 int hda_dsp_trace_init(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
0731 struct sof_ipc_dma_trace_params_ext *dtrace_params);
0732 int hda_dsp_trace_release(struct snd_sof_dev *sdev);
0733 int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd);
0734
0735
0736
0737
0738 #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
0739
0740 int hda_sdw_startup(struct snd_sof_dev *sdev);
0741 void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable);
0742 void hda_sdw_process_wakeen(struct snd_sof_dev *sdev);
0743 bool hda_common_check_sdw_irq(struct snd_sof_dev *sdev);
0744
0745 #else
0746
0747 static inline int hda_sdw_startup(struct snd_sof_dev *sdev)
0748 {
0749 return 0;
0750 }
0751
0752 static inline void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable)
0753 {
0754 }
0755
0756 static inline void hda_sdw_process_wakeen(struct snd_sof_dev *sdev)
0757 {
0758 }
0759
0760 static inline bool hda_common_check_sdw_irq(struct snd_sof_dev *sdev)
0761 {
0762 return false;
0763 }
0764
0765 #endif
0766
0767
0768 extern struct snd_soc_dai_driver skl_dai[];
0769 int hda_dsp_dais_suspend(struct snd_sof_dev *sdev);
0770
0771
0772
0773
0774 extern struct snd_sof_dsp_ops sof_hda_common_ops;
0775
0776 extern struct snd_sof_dsp_ops sof_apl_ops;
0777 int sof_apl_ops_init(struct snd_sof_dev *sdev);
0778 extern struct snd_sof_dsp_ops sof_cnl_ops;
0779 int sof_cnl_ops_init(struct snd_sof_dev *sdev);
0780 extern struct snd_sof_dsp_ops sof_tgl_ops;
0781 int sof_tgl_ops_init(struct snd_sof_dev *sdev);
0782 extern struct snd_sof_dsp_ops sof_icl_ops;
0783 int sof_icl_ops_init(struct snd_sof_dev *sdev);
0784 extern struct snd_sof_dsp_ops sof_mtl_ops;
0785 int sof_mtl_ops_init(struct snd_sof_dev *sdev);
0786
0787 extern const struct sof_intel_dsp_desc apl_chip_info;
0788 extern const struct sof_intel_dsp_desc cnl_chip_info;
0789 extern const struct sof_intel_dsp_desc icl_chip_info;
0790 extern const struct sof_intel_dsp_desc tgl_chip_info;
0791 extern const struct sof_intel_dsp_desc tglh_chip_info;
0792 extern const struct sof_intel_dsp_desc ehl_chip_info;
0793 extern const struct sof_intel_dsp_desc jsl_chip_info;
0794 extern const struct sof_intel_dsp_desc adls_chip_info;
0795 extern const struct sof_intel_dsp_desc mtl_chip_info;
0796
0797
0798 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_PROBES)
0799 int hda_probes_register(struct snd_sof_dev *sdev);
0800 void hda_probes_unregister(struct snd_sof_dev *sdev);
0801 #else
0802 static inline int hda_probes_register(struct snd_sof_dev *sdev)
0803 {
0804 return 0;
0805 }
0806
0807 static inline void hda_probes_unregister(struct snd_sof_dev *sdev)
0808 {
0809 }
0810 #endif
0811
0812
0813 int hda_register_clients(struct snd_sof_dev *sdev);
0814 void hda_unregister_clients(struct snd_sof_dev *sdev);
0815
0816
0817 struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev);
0818 void hda_set_mach_params(struct snd_soc_acpi_mach *mach,
0819 struct snd_sof_dev *sdev);
0820
0821
0822 int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id);
0823
0824 struct snd_sof_dai;
0825 struct sof_ipc_dai_config;
0826 int hda_ctrl_dai_widget_setup(struct snd_soc_dapm_widget *w, unsigned int quirk_flags,
0827 struct snd_sof_dai_config_data *data);
0828 int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w, unsigned int quirk_flags,
0829 struct snd_sof_dai_config_data *data);
0830
0831 #define SOF_HDA_POSITION_QUIRK_USE_SKYLAKE_LEGACY (0)
0832 #define SOF_HDA_POSITION_QUIRK_USE_DPIB_REGISTERS (1)
0833 #define SOF_HDA_POSITION_QUIRK_USE_DPIB_DDR_UPDATE (2)
0834
0835 extern int sof_hda_position_quirk;
0836
0837 void hda_set_dai_drv_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *ops);
0838 void hda_ops_free(struct snd_sof_dev *sdev);
0839
0840
0841 irqreturn_t cnl_ipc4_irq_thread(int irq, void *context);
0842 int cnl_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
0843 irqreturn_t hda_dsp_ipc4_irq_thread(int irq, void *context);
0844 int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
0845 extern struct sdw_intel_ops sdw_callback;
0846
0847 #endif