hda.h 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
  2. /*
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * Copyright(c) 2017 Intel Corporation
  7. *
  8. * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
  9. */
  10. #ifndef __SOF_INTEL_HDA_H
  11. #define __SOF_INTEL_HDA_H
  12. #include <linux/completion.h>
  13. #include <linux/soundwire/sdw.h>
  14. #include <linux/soundwire/sdw_intel.h>
  15. #include <sound/compress_driver.h>
  16. #include <sound/hda_codec.h>
  17. #include <sound/hdaudio_ext.h>
  18. #include "../sof-client-probes.h"
  19. #include "../sof-audio.h"
  20. #include "shim.h"
  21. /* PCI registers */
  22. #define PCI_TCSEL 0x44
  23. #define PCI_PGCTL PCI_TCSEL
  24. #define PCI_CGCTL 0x48
  25. /* PCI_PGCTL bits */
  26. #define PCI_PGCTL_ADSPPGD BIT(2)
  27. #define PCI_PGCTL_LSRMD_MASK BIT(4)
  28. /* PCI_CGCTL bits */
  29. #define PCI_CGCTL_MISCBDCGE_MASK BIT(6)
  30. #define PCI_CGCTL_ADSPDCGE BIT(1)
  31. /* Legacy HDA registers and bits used - widths are variable */
  32. #define SOF_HDA_GCAP 0x0
  33. #define SOF_HDA_GCTL 0x8
  34. /* accept unsol. response enable */
  35. #define SOF_HDA_GCTL_UNSOL BIT(8)
  36. #define SOF_HDA_LLCH 0x14
  37. #define SOF_HDA_INTCTL 0x20
  38. #define SOF_HDA_INTSTS 0x24
  39. #define SOF_HDA_WAKESTS 0x0E
  40. #define SOF_HDA_WAKESTS_INT_MASK ((1 << 8) - 1)
  41. #define SOF_HDA_RIRBSTS 0x5d
  42. /* SOF_HDA_GCTL register bist */
  43. #define SOF_HDA_GCTL_RESET BIT(0)
  44. /* SOF_HDA_INCTL regs */
  45. #define SOF_HDA_INT_GLOBAL_EN BIT(31)
  46. #define SOF_HDA_INT_CTRL_EN BIT(30)
  47. #define SOF_HDA_INT_ALL_STREAM 0xff
  48. /* SOF_HDA_INTSTS regs */
  49. #define SOF_HDA_INTSTS_GIS BIT(31)
  50. #define SOF_HDA_MAX_CAPS 10
  51. #define SOF_HDA_CAP_ID_OFF 16
  52. #define SOF_HDA_CAP_ID_MASK GENMASK(SOF_HDA_CAP_ID_OFF + 11,\
  53. SOF_HDA_CAP_ID_OFF)
  54. #define SOF_HDA_CAP_NEXT_MASK 0xFFFF
  55. #define SOF_HDA_GTS_CAP_ID 0x1
  56. #define SOF_HDA_ML_CAP_ID 0x2
  57. #define SOF_HDA_PP_CAP_ID 0x3
  58. #define SOF_HDA_REG_PP_PPCH 0x10
  59. #define SOF_HDA_REG_PP_PPCTL 0x04
  60. #define SOF_HDA_REG_PP_PPSTS 0x08
  61. #define SOF_HDA_PPCTL_PIE BIT(31)
  62. #define SOF_HDA_PPCTL_GPROCEN BIT(30)
  63. /*Vendor Specific Registers*/
  64. #define SOF_HDA_VS_D0I3C 0x104A
  65. /* D0I3C Register fields */
  66. #define SOF_HDA_VS_D0I3C_CIP BIT(0) /* Command-In-Progress */
  67. #define SOF_HDA_VS_D0I3C_I3 BIT(2) /* D0i3 enable bit */
  68. /* DPIB entry size: 8 Bytes = 2 DWords */
  69. #define SOF_HDA_DPIB_ENTRY_SIZE 0x8
  70. #define SOF_HDA_SPIB_CAP_ID 0x4
  71. #define SOF_HDA_DRSM_CAP_ID 0x5
  72. #define SOF_HDA_SPIB_BASE 0x08
  73. #define SOF_HDA_SPIB_INTERVAL 0x08
  74. #define SOF_HDA_SPIB_SPIB 0x00
  75. #define SOF_HDA_SPIB_MAXFIFO 0x04
  76. #define SOF_HDA_PPHC_BASE 0x10
  77. #define SOF_HDA_PPHC_INTERVAL 0x10
  78. #define SOF_HDA_PPLC_BASE 0x10
  79. #define SOF_HDA_PPLC_MULTI 0x10
  80. #define SOF_HDA_PPLC_INTERVAL 0x10
  81. #define SOF_HDA_DRSM_BASE 0x08
  82. #define SOF_HDA_DRSM_INTERVAL 0x08
  83. /* Descriptor error interrupt */
  84. #define SOF_HDA_CL_DMA_SD_INT_DESC_ERR 0x10
  85. /* FIFO error interrupt */
  86. #define SOF_HDA_CL_DMA_SD_INT_FIFO_ERR 0x08
  87. /* Buffer completion interrupt */
  88. #define SOF_HDA_CL_DMA_SD_INT_COMPLETE 0x04
  89. #define SOF_HDA_CL_DMA_SD_INT_MASK \
  90. (SOF_HDA_CL_DMA_SD_INT_DESC_ERR | \
  91. SOF_HDA_CL_DMA_SD_INT_FIFO_ERR | \
  92. SOF_HDA_CL_DMA_SD_INT_COMPLETE)
  93. #define SOF_HDA_SD_CTL_DMA_START 0x02 /* Stream DMA start bit */
  94. /* Intel HD Audio Code Loader DMA Registers */
  95. #define SOF_HDA_ADSP_LOADER_BASE 0x80
  96. #define SOF_HDA_ADSP_DPLBASE 0x70
  97. #define SOF_HDA_ADSP_DPUBASE 0x74
  98. #define SOF_HDA_ADSP_DPLBASE_ENABLE 0x01
  99. /* Stream Registers */
  100. #define SOF_HDA_ADSP_REG_SD_CTL 0x00
  101. #define SOF_HDA_ADSP_REG_SD_STS 0x03
  102. #define SOF_HDA_ADSP_REG_SD_LPIB 0x04
  103. #define SOF_HDA_ADSP_REG_SD_CBL 0x08
  104. #define SOF_HDA_ADSP_REG_SD_LVI 0x0C
  105. #define SOF_HDA_ADSP_REG_SD_FIFOW 0x0E
  106. #define SOF_HDA_ADSP_REG_SD_FIFOSIZE 0x10
  107. #define SOF_HDA_ADSP_REG_SD_FORMAT 0x12
  108. #define SOF_HDA_ADSP_REG_SD_FIFOL 0x14
  109. #define SOF_HDA_ADSP_REG_SD_BDLPL 0x18
  110. #define SOF_HDA_ADSP_REG_SD_BDLPU 0x1C
  111. #define SOF_HDA_ADSP_SD_ENTRY_SIZE 0x20
  112. /* SDxFIFOS FIFOS */
  113. #define SOF_HDA_SD_FIFOSIZE_FIFOS_MASK GENMASK(15, 0)
  114. /* CL: Software Position Based FIFO Capability Registers */
  115. #define SOF_DSP_REG_CL_SPBFIFO \
  116. (SOF_HDA_ADSP_LOADER_BASE + 0x20)
  117. #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCH 0x0
  118. #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCCTL 0x4
  119. #define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPIB 0x8
  120. #define SOF_HDA_ADSP_REG_CL_SPBFIFO_MAXFIFOS 0xc
  121. /* Stream Number */
  122. #define SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT 20
  123. #define SOF_HDA_CL_SD_CTL_STREAM_TAG_MASK \
  124. GENMASK(SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT + 3,\
  125. SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT)
  126. #define HDA_DSP_HDA_BAR 0
  127. #define HDA_DSP_PP_BAR 1
  128. #define HDA_DSP_SPIB_BAR 2
  129. #define HDA_DSP_DRSM_BAR 3
  130. #define HDA_DSP_BAR 4
  131. #define SRAM_WINDOW_OFFSET(x) (0x80000 + (x) * 0x20000)
  132. #define HDA_DSP_MBOX_OFFSET SRAM_WINDOW_OFFSET(0)
  133. #define HDA_DSP_PANIC_OFFSET(x) \
  134. (((x) & 0xFFFFFF) + HDA_DSP_MBOX_OFFSET)
  135. /* SRAM window 0 FW "registers" */
  136. #define HDA_DSP_SRAM_REG_ROM_STATUS (HDA_DSP_MBOX_OFFSET + 0x0)
  137. #define HDA_DSP_SRAM_REG_ROM_ERROR (HDA_DSP_MBOX_OFFSET + 0x4)
  138. /* FW and ROM share offset 4 */
  139. #define HDA_DSP_SRAM_REG_FW_STATUS (HDA_DSP_MBOX_OFFSET + 0x4)
  140. #define HDA_DSP_SRAM_REG_FW_TRACEP (HDA_DSP_MBOX_OFFSET + 0x8)
  141. #define HDA_DSP_SRAM_REG_FW_END (HDA_DSP_MBOX_OFFSET + 0xc)
  142. #define HDA_DSP_MBOX_UPLINK_OFFSET 0x81000
  143. #define HDA_DSP_STREAM_RESET_TIMEOUT 300
  144. /*
  145. * Timeout in us, for setting the stream RUN bit, during
  146. * start/stop the stream. The timeout expires if new RUN bit
  147. * value cannot be read back within the specified time.
  148. */
  149. #define HDA_DSP_STREAM_RUN_TIMEOUT 300
  150. #define HDA_DSP_SPIB_ENABLE 1
  151. #define HDA_DSP_SPIB_DISABLE 0
  152. #define SOF_HDA_MAX_BUFFER_SIZE (32 * PAGE_SIZE)
  153. #define HDA_DSP_STACK_DUMP_SIZE 32
  154. /* ROM/FW status register */
  155. #define FSR_STATE_MASK GENMASK(23, 0)
  156. #define FSR_WAIT_STATE_MASK GENMASK(27, 24)
  157. #define FSR_MODULE_MASK GENMASK(30, 28)
  158. #define FSR_HALTED BIT(31)
  159. #define FSR_TO_STATE_CODE(x) ((x) & FSR_STATE_MASK)
  160. #define FSR_TO_WAIT_STATE_CODE(x) (((x) & FSR_WAIT_STATE_MASK) >> 24)
  161. #define FSR_TO_MODULE_CODE(x) (((x) & FSR_MODULE_MASK) >> 28)
  162. /* Wait states */
  163. #define FSR_WAIT_FOR_IPC_BUSY 0x1
  164. #define FSR_WAIT_FOR_IPC_DONE 0x2
  165. #define FSR_WAIT_FOR_CACHE_INVALIDATION 0x3
  166. #define FSR_WAIT_FOR_LP_SRAM_OFF 0x4
  167. #define FSR_WAIT_FOR_DMA_BUFFER_FULL 0x5
  168. #define FSR_WAIT_FOR_CSE_CSR 0x6
  169. /* Module codes */
  170. #define FSR_MOD_ROM 0x0
  171. #define FSR_MOD_ROM_BYP 0x1
  172. #define FSR_MOD_BASE_FW 0x2
  173. #define FSR_MOD_LP_BOOT 0x3
  174. #define FSR_MOD_BRNGUP 0x4
  175. #define FSR_MOD_ROM_EXT 0x5
  176. /* State codes (module dependent) */
  177. /* Module independent states */
  178. #define FSR_STATE_INIT 0x0
  179. #define FSR_STATE_INIT_DONE 0x1
  180. #define FSR_STATE_FW_ENTERED 0x5
  181. /* ROM states */
  182. #define FSR_STATE_ROM_INIT FSR_STATE_INIT
  183. #define FSR_STATE_ROM_INIT_DONE FSR_STATE_INIT_DONE
  184. #define FSR_STATE_ROM_CSE_MANIFEST_LOADED 0x2
  185. #define FSR_STATE_ROM_FW_MANIFEST_LOADED 0x3
  186. #define FSR_STATE_ROM_FW_FW_LOADED 0x4
  187. #define FSR_STATE_ROM_FW_ENTERED FSR_STATE_FW_ENTERED
  188. #define FSR_STATE_ROM_VERIFY_FEATURE_MASK 0x6
  189. #define FSR_STATE_ROM_GET_LOAD_OFFSET 0x7
  190. #define FSR_STATE_ROM_FETCH_ROM_EXT 0x8
  191. #define FSR_STATE_ROM_FETCH_ROM_EXT_DONE 0x9
  192. #define FSR_STATE_ROM_BASEFW_ENTERED 0xf /* SKL */
  193. /* (ROM) CSE states */
  194. #define FSR_STATE_ROM_CSE_IMR_REQUEST 0x10
  195. #define FSR_STATE_ROM_CSE_IMR_GRANTED 0x11
  196. #define FSR_STATE_ROM_CSE_VALIDATE_IMAGE_REQUEST 0x12
  197. #define FSR_STATE_ROM_CSE_IMAGE_VALIDATED 0x13
  198. #define FSR_STATE_ROM_CSE_IPC_IFACE_INIT 0x20
  199. #define FSR_STATE_ROM_CSE_IPC_RESET_PHASE_1 0x21
  200. #define FSR_STATE_ROM_CSE_IPC_OPERATIONAL_ENTRY 0x22
  201. #define FSR_STATE_ROM_CSE_IPC_OPERATIONAL 0x23
  202. #define FSR_STATE_ROM_CSE_IPC_DOWN 0x24
  203. /* BRINGUP (or BRNGUP) states */
  204. #define FSR_STATE_BRINGUP_INIT FSR_STATE_INIT
  205. #define FSR_STATE_BRINGUP_INIT_DONE FSR_STATE_INIT_DONE
  206. #define FSR_STATE_BRINGUP_HPSRAM_LOAD 0x2
  207. #define FSR_STATE_BRINGUP_UNPACK_START 0X3
  208. #define FSR_STATE_BRINGUP_IMR_RESTORE 0x4
  209. #define FSR_STATE_BRINGUP_FW_ENTERED FSR_STATE_FW_ENTERED
  210. /* ROM status/error values */
  211. #define HDA_DSP_ROM_CSE_ERROR 40
  212. #define HDA_DSP_ROM_CSE_WRONG_RESPONSE 41
  213. #define HDA_DSP_ROM_IMR_TO_SMALL 42
  214. #define HDA_DSP_ROM_BASE_FW_NOT_FOUND 43
  215. #define HDA_DSP_ROM_CSE_VALIDATION_FAILED 44
  216. #define HDA_DSP_ROM_IPC_FATAL_ERROR 45
  217. #define HDA_DSP_ROM_L2_CACHE_ERROR 46
  218. #define HDA_DSP_ROM_LOAD_OFFSET_TO_SMALL 47
  219. #define HDA_DSP_ROM_API_PTR_INVALID 50
  220. #define HDA_DSP_ROM_BASEFW_INCOMPAT 51
  221. #define HDA_DSP_ROM_UNHANDLED_INTERRUPT 0xBEE00000
  222. #define HDA_DSP_ROM_MEMORY_HOLE_ECC 0xECC00000
  223. #define HDA_DSP_ROM_KERNEL_EXCEPTION 0xCAFE0000
  224. #define HDA_DSP_ROM_USER_EXCEPTION 0xBEEF0000
  225. #define HDA_DSP_ROM_UNEXPECTED_RESET 0xDECAF000
  226. #define HDA_DSP_ROM_NULL_FW_ENTRY 0x4c4c4e55
  227. #define HDA_DSP_ROM_IPC_CONTROL 0x01000000
  228. #define HDA_DSP_ROM_IPC_PURGE_FW 0x00004000
  229. /* various timeout values */
  230. #define HDA_DSP_PU_TIMEOUT 50
  231. #define HDA_DSP_PD_TIMEOUT 50
  232. #define HDA_DSP_RESET_TIMEOUT_US 50000
  233. #define HDA_DSP_BASEFW_TIMEOUT_US 3000000
  234. #define HDA_DSP_INIT_TIMEOUT_US 500000
  235. #define HDA_DSP_CTRL_RESET_TIMEOUT 100
  236. #define HDA_DSP_WAIT_TIMEOUT 500 /* 500 msec */
  237. #define HDA_DSP_REG_POLL_INTERVAL_US 500 /* 0.5 msec */
  238. #define HDA_DSP_REG_POLL_RETRY_COUNT 50
  239. #define HDA_DSP_ADSPIC_IPC BIT(0)
  240. #define HDA_DSP_ADSPIS_IPC BIT(0)
  241. /* Intel HD Audio General DSP Registers */
  242. #define HDA_DSP_GEN_BASE 0x0
  243. #define HDA_DSP_REG_ADSPCS (HDA_DSP_GEN_BASE + 0x04)
  244. #define HDA_DSP_REG_ADSPIC (HDA_DSP_GEN_BASE + 0x08)
  245. #define HDA_DSP_REG_ADSPIS (HDA_DSP_GEN_BASE + 0x0C)
  246. #define HDA_DSP_REG_ADSPIC2 (HDA_DSP_GEN_BASE + 0x10)
  247. #define HDA_DSP_REG_ADSPIS2 (HDA_DSP_GEN_BASE + 0x14)
  248. #define HDA_DSP_REG_ADSPIC2_SNDW BIT(5)
  249. #define HDA_DSP_REG_ADSPIS2_SNDW BIT(5)
  250. /* Intel HD Audio Inter-Processor Communication Registers */
  251. #define HDA_DSP_IPC_BASE 0x40
  252. #define HDA_DSP_REG_HIPCT (HDA_DSP_IPC_BASE + 0x00)
  253. #define HDA_DSP_REG_HIPCTE (HDA_DSP_IPC_BASE + 0x04)
  254. #define HDA_DSP_REG_HIPCI (HDA_DSP_IPC_BASE + 0x08)
  255. #define HDA_DSP_REG_HIPCIE (HDA_DSP_IPC_BASE + 0x0C)
  256. #define HDA_DSP_REG_HIPCCTL (HDA_DSP_IPC_BASE + 0x10)
  257. /* Intel Vendor Specific Registers */
  258. #define HDA_VS_INTEL_EM2 0x1030
  259. #define HDA_VS_INTEL_EM2_L1SEN BIT(13)
  260. #define HDA_VS_INTEL_LTRP 0x1048
  261. #define HDA_VS_INTEL_LTRP_GB_MASK 0x3F
  262. /* HIPCI */
  263. #define HDA_DSP_REG_HIPCI_BUSY BIT(31)
  264. #define HDA_DSP_REG_HIPCI_MSG_MASK 0x7FFFFFFF
  265. /* HIPCIE */
  266. #define HDA_DSP_REG_HIPCIE_DONE BIT(30)
  267. #define HDA_DSP_REG_HIPCIE_MSG_MASK 0x3FFFFFFF
  268. /* HIPCCTL */
  269. #define HDA_DSP_REG_HIPCCTL_DONE BIT(1)
  270. #define HDA_DSP_REG_HIPCCTL_BUSY BIT(0)
  271. /* HIPCT */
  272. #define HDA_DSP_REG_HIPCT_BUSY BIT(31)
  273. #define HDA_DSP_REG_HIPCT_MSG_MASK 0x7FFFFFFF
  274. /* HIPCTE */
  275. #define HDA_DSP_REG_HIPCTE_MSG_MASK 0x3FFFFFFF
  276. #define HDA_DSP_ADSPIC_CL_DMA BIT(1)
  277. #define HDA_DSP_ADSPIS_CL_DMA BIT(1)
  278. /* Delay before scheduling D0i3 entry */
  279. #define BXT_D0I3_DELAY 5000
  280. #define FW_CL_STREAM_NUMBER 0x1
  281. #define HDA_FW_BOOT_ATTEMPTS 3
  282. /* ADSPCS - Audio DSP Control & Status */
  283. /*
  284. * Core Reset - asserted high
  285. * CRST Mask for a given core mask pattern, cm
  286. */
  287. #define HDA_DSP_ADSPCS_CRST_SHIFT 0
  288. #define HDA_DSP_ADSPCS_CRST_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CRST_SHIFT)
  289. /*
  290. * Core run/stall - when set to '1' core is stalled
  291. * CSTALL Mask for a given core mask pattern, cm
  292. */
  293. #define HDA_DSP_ADSPCS_CSTALL_SHIFT 8
  294. #define HDA_DSP_ADSPCS_CSTALL_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CSTALL_SHIFT)
  295. /*
  296. * Set Power Active - when set to '1' turn cores on
  297. * SPA Mask for a given core mask pattern, cm
  298. */
  299. #define HDA_DSP_ADSPCS_SPA_SHIFT 16
  300. #define HDA_DSP_ADSPCS_SPA_MASK(cm) ((cm) << HDA_DSP_ADSPCS_SPA_SHIFT)
  301. /*
  302. * Current Power Active - power status of cores, set by hardware
  303. * CPA Mask for a given core mask pattern, cm
  304. */
  305. #define HDA_DSP_ADSPCS_CPA_SHIFT 24
  306. #define HDA_DSP_ADSPCS_CPA_MASK(cm) ((cm) << HDA_DSP_ADSPCS_CPA_SHIFT)
  307. /*
  308. * Mask for a given number of cores
  309. * nc = number of supported cores
  310. */
  311. #define SOF_DSP_CORES_MASK(nc) GENMASK(((nc) - 1), 0)
  312. /* Intel HD Audio Inter-Processor Communication Registers for Cannonlake*/
  313. #define CNL_DSP_IPC_BASE 0xc0
  314. #define CNL_DSP_REG_HIPCTDR (CNL_DSP_IPC_BASE + 0x00)
  315. #define CNL_DSP_REG_HIPCTDA (CNL_DSP_IPC_BASE + 0x04)
  316. #define CNL_DSP_REG_HIPCTDD (CNL_DSP_IPC_BASE + 0x08)
  317. #define CNL_DSP_REG_HIPCIDR (CNL_DSP_IPC_BASE + 0x10)
  318. #define CNL_DSP_REG_HIPCIDA (CNL_DSP_IPC_BASE + 0x14)
  319. #define CNL_DSP_REG_HIPCIDD (CNL_DSP_IPC_BASE + 0x18)
  320. #define CNL_DSP_REG_HIPCCTL (CNL_DSP_IPC_BASE + 0x28)
  321. /* HIPCI */
  322. #define CNL_DSP_REG_HIPCIDR_BUSY BIT(31)
  323. #define CNL_DSP_REG_HIPCIDR_MSG_MASK 0x7FFFFFFF
  324. /* HIPCIE */
  325. #define CNL_DSP_REG_HIPCIDA_DONE BIT(31)
  326. #define CNL_DSP_REG_HIPCIDA_MSG_MASK 0x7FFFFFFF
  327. /* HIPCCTL */
  328. #define CNL_DSP_REG_HIPCCTL_DONE BIT(1)
  329. #define CNL_DSP_REG_HIPCCTL_BUSY BIT(0)
  330. /* HIPCT */
  331. #define CNL_DSP_REG_HIPCTDR_BUSY BIT(31)
  332. #define CNL_DSP_REG_HIPCTDR_MSG_MASK 0x7FFFFFFF
  333. /* HIPCTDA */
  334. #define CNL_DSP_REG_HIPCTDA_DONE BIT(31)
  335. #define CNL_DSP_REG_HIPCTDA_MSG_MASK 0x7FFFFFFF
  336. /* HIPCTDD */
  337. #define CNL_DSP_REG_HIPCTDD_MSG_MASK 0x7FFFFFFF
  338. /* BDL */
  339. #define HDA_DSP_BDL_SIZE 4096
  340. #define HDA_DSP_MAX_BDL_ENTRIES \
  341. (HDA_DSP_BDL_SIZE / sizeof(struct sof_intel_dsp_bdl))
  342. /* Number of DAIs */
  343. #define SOF_SKL_NUM_DAIS_NOCODEC 8
  344. #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
  345. #define SOF_SKL_NUM_DAIS 15
  346. #else
  347. #define SOF_SKL_NUM_DAIS SOF_SKL_NUM_DAIS_NOCODEC
  348. #endif
  349. /* Intel HD Audio SRAM Window 0*/
  350. #define HDA_DSP_SRAM_REG_ROM_STATUS_SKL 0x8000
  351. #define HDA_ADSP_SRAM0_BASE_SKL 0x8000
  352. /* Firmware status window */
  353. #define HDA_ADSP_FW_STATUS_SKL HDA_ADSP_SRAM0_BASE_SKL
  354. #define HDA_ADSP_ERROR_CODE_SKL (HDA_ADSP_FW_STATUS_SKL + 0x4)
  355. /* Host Device Memory Space */
  356. #define APL_SSP_BASE_OFFSET 0x2000
  357. #define CNL_SSP_BASE_OFFSET 0x10000
  358. /* Host Device Memory Size of a Single SSP */
  359. #define SSP_DEV_MEM_SIZE 0x1000
  360. /* SSP Count of the Platform */
  361. #define APL_SSP_COUNT 6
  362. #define CNL_SSP_COUNT 3
  363. #define ICL_SSP_COUNT 6
  364. #define TGL_SSP_COUNT 3
  365. #define MTL_SSP_COUNT 3
  366. /* SSP Registers */
  367. #define SSP_SSC1_OFFSET 0x4
  368. #define SSP_SET_SCLK_CONSUMER BIT(25)
  369. #define SSP_SET_SFRM_CONSUMER BIT(24)
  370. #define SSP_SET_CBP_CFP (SSP_SET_SCLK_CONSUMER | SSP_SET_SFRM_CONSUMER)
  371. #define HDA_EXT_ADDR 0
  372. #define HDA_EXT_CODEC(x) ((x) & BIT(HDA_EXT_ADDR))
  373. #define HDA_IDISP_ADDR 2
  374. #define HDA_IDISP_CODEC(x) ((x) & BIT(HDA_IDISP_ADDR))
  375. struct sof_intel_dsp_bdl {
  376. __le32 addr_l;
  377. __le32 addr_h;
  378. __le32 size;
  379. __le32 ioc;
  380. } __attribute((packed));
  381. #define SOF_HDA_PLAYBACK_STREAMS 16
  382. #define SOF_HDA_CAPTURE_STREAMS 16
  383. #define SOF_HDA_PLAYBACK 0
  384. #define SOF_HDA_CAPTURE 1
  385. /* stream flags */
  386. #define SOF_HDA_STREAM_DMI_L1_COMPATIBLE 1
  387. /*
  388. * Time in ms for opportunistic D0I3 entry delay.
  389. * This has been deliberately chosen to be long to avoid race conditions.
  390. * Could be optimized in future.
  391. */
  392. #define SOF_HDA_D0I3_WORK_DELAY_MS 5000
  393. /* HDA DSP D0 substate */
  394. enum sof_hda_D0_substate {
  395. SOF_HDA_DSP_PM_D0I0, /* default D0 substate */
  396. SOF_HDA_DSP_PM_D0I3, /* low power D0 substate */
  397. };
  398. /* represents DSP HDA controller frontend - i.e. host facing control */
  399. struct sof_intel_hda_dev {
  400. bool imrboot_supported;
  401. bool skip_imr_boot;
  402. bool booted_from_imr;
  403. int boot_iteration;
  404. struct hda_bus hbus;
  405. /* hw config */
  406. const struct sof_intel_dsp_desc *desc;
  407. /* trace */
  408. struct hdac_ext_stream *dtrace_stream;
  409. /* if position update IPC needed */
  410. u32 no_ipc_position;
  411. /* the maximum number of streams (playback + capture) supported */
  412. u32 stream_max;
  413. /* PM related */
  414. bool l1_disabled;/* is DMI link L1 disabled? */
  415. /* DMIC device */
  416. struct platform_device *dmic_dev;
  417. /* delayed work to enter D0I3 opportunistically */
  418. struct delayed_work d0i3_work;
  419. /* ACPI information stored between scan and probe steps */
  420. struct sdw_intel_acpi_info info;
  421. /* sdw context allocated by SoundWire driver */
  422. struct sdw_intel_ctx *sdw;
  423. /* FW clock config, 0:HPRO, 1:LPRO */
  424. bool clk_config_lpro;
  425. wait_queue_head_t waitq;
  426. bool code_loading;
  427. /* Intel NHLT information */
  428. struct nhlt_acpi_table *nhlt;
  429. /*
  430. * Pointing to the IPC message if immediate sending was not possible
  431. * because the downlink communication channel was BUSY at the time.
  432. * The message will be re-tried when the channel becomes free (the ACK
  433. * is received from the DSP for the previous message)
  434. */
  435. struct snd_sof_ipc_msg *delayed_ipc_tx_msg;
  436. };
  437. static inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s)
  438. {
  439. struct sof_intel_hda_dev *hda = s->pdata->hw_pdata;
  440. return &hda->hbus.core;
  441. }
  442. static inline struct hda_bus *sof_to_hbus(struct snd_sof_dev *s)
  443. {
  444. struct sof_intel_hda_dev *hda = s->pdata->hw_pdata;
  445. return &hda->hbus;
  446. }
  447. struct sof_intel_hda_stream {
  448. struct snd_sof_dev *sdev;
  449. struct hdac_ext_stream hext_stream;
  450. struct sof_intel_stream sof_intel_stream;
  451. int host_reserved; /* reserve host DMA channel */
  452. u32 flags;
  453. struct completion ioc;
  454. };
  455. #define hstream_to_sof_hda_stream(hstream) \
  456. container_of(hstream, struct sof_intel_hda_stream, hext_stream)
  457. #define bus_to_sof_hda(bus) \
  458. container_of(bus, struct sof_intel_hda_dev, hbus.core)
  459. #define SOF_STREAM_SD_OFFSET(s) \
  460. (SOF_HDA_ADSP_SD_ENTRY_SIZE * ((s)->index) \
  461. + SOF_HDA_ADSP_LOADER_BASE)
  462. #define SOF_STREAM_SD_OFFSET_CRST 0x1
  463. /*
  464. * DAI support
  465. */
  466. bool hda_is_chain_dma_supported(struct snd_sof_dev *sdev, u32 dai_type);
  467. /*
  468. * DSP Core services.
  469. */
  470. int hda_dsp_probe_early(struct snd_sof_dev *sdev);
  471. int hda_dsp_probe(struct snd_sof_dev *sdev);
  472. void hda_dsp_remove(struct snd_sof_dev *sdev);
  473. void hda_dsp_remove_late(struct snd_sof_dev *sdev);
  474. int hda_dsp_core_power_up(struct snd_sof_dev *sdev, unsigned int core_mask);
  475. int hda_dsp_core_run(struct snd_sof_dev *sdev, unsigned int core_mask);
  476. int hda_dsp_enable_core(struct snd_sof_dev *sdev, unsigned int core_mask);
  477. int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev,
  478. unsigned int core_mask);
  479. int hda_power_down_dsp(struct snd_sof_dev *sdev);
  480. int hda_dsp_core_get(struct snd_sof_dev *sdev, int core);
  481. void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev);
  482. void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev);
  483. bool hda_dsp_core_is_enabled(struct snd_sof_dev *sdev, unsigned int core_mask);
  484. int hda_dsp_set_power_state_ipc3(struct snd_sof_dev *sdev,
  485. const struct sof_dsp_power_state *target_state);
  486. int hda_dsp_set_power_state_ipc4(struct snd_sof_dev *sdev,
  487. const struct sof_dsp_power_state *target_state);
  488. int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state);
  489. int hda_dsp_resume(struct snd_sof_dev *sdev);
  490. int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev);
  491. int hda_dsp_runtime_resume(struct snd_sof_dev *sdev);
  492. int hda_dsp_runtime_idle(struct snd_sof_dev *sdev);
  493. int hda_dsp_shutdown_dma_flush(struct snd_sof_dev *sdev);
  494. int hda_dsp_shutdown(struct snd_sof_dev *sdev);
  495. int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev);
  496. void hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags);
  497. void hda_ipc4_dsp_dump(struct snd_sof_dev *sdev, u32 flags);
  498. void hda_ipc_dump(struct snd_sof_dev *sdev);
  499. void hda_ipc_irq_dump(struct snd_sof_dev *sdev);
  500. void hda_dsp_d0i3_work(struct work_struct *work);
  501. int hda_dsp_disable_interrupts(struct snd_sof_dev *sdev);
  502. bool hda_check_ipc_irq(struct snd_sof_dev *sdev);
  503. u32 hda_get_interface_mask(struct snd_sof_dev *sdev);
  504. /*
  505. * DSP PCM Operations.
  506. */
  507. u32 hda_dsp_get_mult_div(struct snd_sof_dev *sdev, int rate);
  508. u32 hda_dsp_get_bits(struct snd_sof_dev *sdev, int sample_bits);
  509. int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
  510. struct snd_pcm_substream *substream);
  511. int hda_dsp_pcm_close(struct snd_sof_dev *sdev,
  512. struct snd_pcm_substream *substream);
  513. int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
  514. struct snd_pcm_substream *substream,
  515. struct snd_pcm_hw_params *params,
  516. struct snd_sof_platform_stream_params *platform_params);
  517. int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
  518. struct snd_pcm_substream *substream);
  519. int hda_dsp_pcm_trigger(struct snd_sof_dev *sdev,
  520. struct snd_pcm_substream *substream, int cmd);
  521. snd_pcm_uframes_t hda_dsp_pcm_pointer(struct snd_sof_dev *sdev,
  522. struct snd_pcm_substream *substream);
  523. int hda_dsp_pcm_ack(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream);
  524. /*
  525. * DSP Stream Operations.
  526. */
  527. int hda_dsp_stream_init(struct snd_sof_dev *sdev);
  528. void hda_dsp_stream_free(struct snd_sof_dev *sdev);
  529. int hda_dsp_stream_hw_params(struct snd_sof_dev *sdev,
  530. struct hdac_ext_stream *hext_stream,
  531. struct snd_dma_buffer *dmab,
  532. struct snd_pcm_hw_params *params);
  533. int hda_dsp_iccmax_stream_hw_params(struct snd_sof_dev *sdev,
  534. struct hdac_ext_stream *hext_stream,
  535. struct snd_dma_buffer *dmab,
  536. struct snd_pcm_hw_params *params);
  537. int hda_dsp_stream_trigger(struct snd_sof_dev *sdev,
  538. struct hdac_ext_stream *hext_stream, int cmd);
  539. irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context);
  540. int hda_dsp_stream_setup_bdl(struct snd_sof_dev *sdev,
  541. struct snd_dma_buffer *dmab,
  542. struct hdac_stream *hstream);
  543. bool hda_dsp_check_ipc_irq(struct snd_sof_dev *sdev);
  544. bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev);
  545. snd_pcm_uframes_t hda_dsp_stream_get_position(struct hdac_stream *hstream,
  546. int direction, bool can_sleep);
  547. u64 hda_dsp_get_stream_llp(struct snd_sof_dev *sdev,
  548. struct snd_soc_component *component,
  549. struct snd_pcm_substream *substream);
  550. u64 hda_dsp_get_stream_ldp(struct snd_sof_dev *sdev,
  551. struct snd_soc_component *component,
  552. struct snd_pcm_substream *substream);
  553. struct hdac_ext_stream *
  554. hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags);
  555. int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag);
  556. int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev,
  557. struct hdac_ext_stream *hext_stream,
  558. int enable, u32 size);
  559. int hda_ipc_msg_data(struct snd_sof_dev *sdev,
  560. struct snd_sof_pcm_stream *sps,
  561. void *p, size_t sz);
  562. int hda_set_stream_data_offset(struct snd_sof_dev *sdev,
  563. struct snd_sof_pcm_stream *sps,
  564. size_t posn_offset);
  565. /*
  566. * DSP IPC Operations.
  567. */
  568. int hda_dsp_ipc_send_msg(struct snd_sof_dev *sdev,
  569. struct snd_sof_ipc_msg *msg);
  570. void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev);
  571. int hda_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev);
  572. int hda_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id);
  573. irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context);
  574. int hda_dsp_ipc_cmd_done(struct snd_sof_dev *sdev, int dir);
  575. void hda_dsp_get_state(struct snd_sof_dev *sdev, const char *level);
  576. void hda_dsp_dump_ext_rom_status(struct snd_sof_dev *sdev, const char *level,
  577. u32 flags);
  578. /*
  579. * DSP Code loader.
  580. */
  581. int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev);
  582. int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev);
  583. int hda_cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream);
  584. struct hdac_ext_stream *hda_cl_prepare(struct device *dev, unsigned int format,
  585. unsigned int size, struct snd_dma_buffer *dmab,
  586. int direction, bool is_iccmax);
  587. int hda_cl_trigger(struct device *dev, struct hdac_ext_stream *hext_stream, int cmd);
  588. int hda_cl_cleanup(struct device *dev, struct snd_dma_buffer *dmab,
  589. struct hdac_ext_stream *hext_stream);
  590. int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot);
  591. #define HDA_CL_STREAM_FORMAT 0x40
  592. /* pre and post fw run ops */
  593. int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev);
  594. int hda_dsp_post_fw_run(struct snd_sof_dev *sdev);
  595. /* parse platform specific ext manifest ops */
  596. int hda_dsp_ext_man_get_cavs_config_data(struct snd_sof_dev *sdev,
  597. const struct sof_ext_man_elem_header *hdr);
  598. /*
  599. * HDA Controller Operations.
  600. */
  601. int hda_dsp_ctrl_get_caps(struct snd_sof_dev *sdev);
  602. void hda_dsp_ctrl_ppcap_enable(struct snd_sof_dev *sdev, bool enable);
  603. void hda_dsp_ctrl_ppcap_int_enable(struct snd_sof_dev *sdev, bool enable);
  604. int hda_dsp_ctrl_link_reset(struct snd_sof_dev *sdev, bool reset);
  605. void hda_dsp_ctrl_misc_clock_gating(struct snd_sof_dev *sdev, bool enable);
  606. int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable);
  607. int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev);
  608. void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev);
  609. /*
  610. * HDA bus operations.
  611. */
  612. void sof_hda_bus_init(struct snd_sof_dev *sdev, struct device *dev);
  613. void sof_hda_bus_exit(struct snd_sof_dev *sdev);
  614. #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
  615. /*
  616. * HDA Codec operations.
  617. */
  618. void hda_codec_probe_bus(struct snd_sof_dev *sdev);
  619. void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable);
  620. void hda_codec_jack_check(struct snd_sof_dev *sdev);
  621. void hda_codec_check_for_state_change(struct snd_sof_dev *sdev);
  622. void hda_codec_init_cmd_io(struct snd_sof_dev *sdev);
  623. void hda_codec_resume_cmd_io(struct snd_sof_dev *sdev);
  624. void hda_codec_stop_cmd_io(struct snd_sof_dev *sdev);
  625. void hda_codec_suspend_cmd_io(struct snd_sof_dev *sdev);
  626. void hda_codec_detect_mask(struct snd_sof_dev *sdev);
  627. void hda_codec_rirb_status_clear(struct snd_sof_dev *sdev);
  628. bool hda_codec_check_rirb_status(struct snd_sof_dev *sdev);
  629. void hda_codec_set_codec_wakeup(struct snd_sof_dev *sdev, bool status);
  630. void hda_codec_device_remove(struct snd_sof_dev *sdev);
  631. #else
  632. static inline void hda_codec_probe_bus(struct snd_sof_dev *sdev) { }
  633. static inline void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable) { }
  634. static inline void hda_codec_jack_check(struct snd_sof_dev *sdev) { }
  635. static inline void hda_codec_check_for_state_change(struct snd_sof_dev *sdev) { }
  636. static inline void hda_codec_init_cmd_io(struct snd_sof_dev *sdev) { }
  637. static inline void hda_codec_resume_cmd_io(struct snd_sof_dev *sdev) { }
  638. static inline void hda_codec_stop_cmd_io(struct snd_sof_dev *sdev) { }
  639. static inline void hda_codec_suspend_cmd_io(struct snd_sof_dev *sdev) { }
  640. static inline void hda_codec_detect_mask(struct snd_sof_dev *sdev) { }
  641. static inline void hda_codec_rirb_status_clear(struct snd_sof_dev *sdev) { }
  642. static inline bool hda_codec_check_rirb_status(struct snd_sof_dev *sdev) { return false; }
  643. static inline void hda_codec_set_codec_wakeup(struct snd_sof_dev *sdev, bool status) { }
  644. static inline void hda_codec_device_remove(struct snd_sof_dev *sdev) { }
  645. #endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */
  646. #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) && IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI)
  647. void hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable);
  648. int hda_codec_i915_init(struct snd_sof_dev *sdev);
  649. int hda_codec_i915_exit(struct snd_sof_dev *sdev);
  650. #else
  651. static inline void hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable) { }
  652. static inline int hda_codec_i915_init(struct snd_sof_dev *sdev) { return 0; }
  653. static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }
  654. #endif
  655. /*
  656. * Trace Control.
  657. */
  658. int hda_dsp_trace_init(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
  659. struct sof_ipc_dma_trace_params_ext *dtrace_params);
  660. int hda_dsp_trace_release(struct snd_sof_dev *sdev);
  661. int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd);
  662. /*
  663. * SoundWire support
  664. */
  665. #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
  666. int hda_sdw_check_lcount_common(struct snd_sof_dev *sdev);
  667. int hda_sdw_check_lcount_ext(struct snd_sof_dev *sdev);
  668. int hda_sdw_check_lcount(struct snd_sof_dev *sdev);
  669. int hda_sdw_startup(struct snd_sof_dev *sdev);
  670. void hda_common_enable_sdw_irq(struct snd_sof_dev *sdev, bool enable);
  671. void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable);
  672. bool hda_sdw_check_wakeen_irq_common(struct snd_sof_dev *sdev);
  673. void hda_sdw_process_wakeen_common(struct snd_sof_dev *sdev);
  674. void hda_sdw_process_wakeen(struct snd_sof_dev *sdev);
  675. bool hda_common_check_sdw_irq(struct snd_sof_dev *sdev);
  676. #else
  677. static inline int hda_sdw_check_lcount_common(struct snd_sof_dev *sdev)
  678. {
  679. return 0;
  680. }
  681. static inline int hda_sdw_check_lcount_ext(struct snd_sof_dev *sdev)
  682. {
  683. return 0;
  684. }
  685. static inline int hda_sdw_check_lcount(struct snd_sof_dev *sdev)
  686. {
  687. return 0;
  688. }
  689. static inline int hda_sdw_startup(struct snd_sof_dev *sdev)
  690. {
  691. return 0;
  692. }
  693. static inline void hda_common_enable_sdw_irq(struct snd_sof_dev *sdev, bool enable)
  694. {
  695. }
  696. static inline void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable)
  697. {
  698. }
  699. static inline bool hda_sdw_check_wakeen_irq_common(struct snd_sof_dev *sdev)
  700. {
  701. return false;
  702. }
  703. static inline void hda_sdw_process_wakeen_common(struct snd_sof_dev *sdev)
  704. {
  705. }
  706. static inline void hda_sdw_process_wakeen(struct snd_sof_dev *sdev)
  707. {
  708. }
  709. static inline bool hda_common_check_sdw_irq(struct snd_sof_dev *sdev)
  710. {
  711. return false;
  712. }
  713. #endif
  714. int sdw_hda_dai_hw_params(struct snd_pcm_substream *substream,
  715. struct snd_pcm_hw_params *params,
  716. struct snd_soc_dai *cpu_dai,
  717. int link_id,
  718. int intel_alh_id);
  719. int sdw_hda_dai_hw_free(struct snd_pcm_substream *substream,
  720. struct snd_soc_dai *cpu_dai,
  721. int link_id);
  722. int sdw_hda_dai_trigger(struct snd_pcm_substream *substream, int cmd,
  723. struct snd_soc_dai *cpu_dai);
  724. /* common dai driver */
  725. extern struct snd_soc_dai_driver skl_dai[];
  726. int hda_dsp_dais_suspend(struct snd_sof_dev *sdev);
  727. /*
  728. * Platform Specific HW abstraction Ops.
  729. */
  730. extern const struct snd_sof_dsp_ops sof_hda_common_ops;
  731. extern struct snd_sof_dsp_ops sof_skl_ops;
  732. int sof_skl_ops_init(struct snd_sof_dev *sdev);
  733. extern struct snd_sof_dsp_ops sof_apl_ops;
  734. int sof_apl_ops_init(struct snd_sof_dev *sdev);
  735. extern struct snd_sof_dsp_ops sof_cnl_ops;
  736. int sof_cnl_ops_init(struct snd_sof_dev *sdev);
  737. extern struct snd_sof_dsp_ops sof_tgl_ops;
  738. int sof_tgl_ops_init(struct snd_sof_dev *sdev);
  739. extern struct snd_sof_dsp_ops sof_icl_ops;
  740. int sof_icl_ops_init(struct snd_sof_dev *sdev);
  741. extern struct snd_sof_dsp_ops sof_mtl_ops;
  742. int sof_mtl_ops_init(struct snd_sof_dev *sdev);
  743. extern struct snd_sof_dsp_ops sof_lnl_ops;
  744. int sof_lnl_ops_init(struct snd_sof_dev *sdev);
  745. extern const struct sof_intel_dsp_desc skl_chip_info;
  746. extern const struct sof_intel_dsp_desc apl_chip_info;
  747. extern const struct sof_intel_dsp_desc cnl_chip_info;
  748. extern const struct sof_intel_dsp_desc icl_chip_info;
  749. extern const struct sof_intel_dsp_desc tgl_chip_info;
  750. extern const struct sof_intel_dsp_desc tglh_chip_info;
  751. extern const struct sof_intel_dsp_desc ehl_chip_info;
  752. extern const struct sof_intel_dsp_desc jsl_chip_info;
  753. extern const struct sof_intel_dsp_desc adls_chip_info;
  754. extern const struct sof_intel_dsp_desc mtl_chip_info;
  755. extern const struct sof_intel_dsp_desc arl_s_chip_info;
  756. extern const struct sof_intel_dsp_desc lnl_chip_info;
  757. extern const struct sof_intel_dsp_desc ptl_chip_info;
  758. /* Probes support */
  759. #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_PROBES)
  760. int hda_probes_register(struct snd_sof_dev *sdev);
  761. void hda_probes_unregister(struct snd_sof_dev *sdev);
  762. #else
  763. static inline int hda_probes_register(struct snd_sof_dev *sdev)
  764. {
  765. return 0;
  766. }
  767. static inline void hda_probes_unregister(struct snd_sof_dev *sdev)
  768. {
  769. }
  770. #endif /* CONFIG_SND_SOC_SOF_HDA_PROBES */
  771. /* SOF client registration for HDA platforms */
  772. int hda_register_clients(struct snd_sof_dev *sdev);
  773. void hda_unregister_clients(struct snd_sof_dev *sdev);
  774. /* machine driver select */
  775. struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev);
  776. void hda_set_mach_params(struct snd_soc_acpi_mach *mach,
  777. struct snd_sof_dev *sdev);
  778. /* PCI driver selection and probe */
  779. int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id);
  780. struct snd_sof_dai;
  781. struct sof_ipc_dai_config;
  782. #define SOF_HDA_POSITION_QUIRK_USE_SKYLAKE_LEGACY (0) /* previous implementation */
  783. #define SOF_HDA_POSITION_QUIRK_USE_DPIB_REGISTERS (1) /* recommended if VC0 only */
  784. #define SOF_HDA_POSITION_QUIRK_USE_DPIB_DDR_UPDATE (2) /* recommended with VC0 or VC1 */
  785. extern int sof_hda_position_quirk;
  786. void hda_set_dai_drv_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *ops);
  787. void hda_ops_free(struct snd_sof_dev *sdev);
  788. /* SKL/KBL */
  789. int hda_dsp_cl_boot_firmware_skl(struct snd_sof_dev *sdev);
  790. int hda_dsp_core_stall_reset(struct snd_sof_dev *sdev, unsigned int core_mask);
  791. /* IPC4 */
  792. irqreturn_t cnl_ipc4_irq_thread(int irq, void *context);
  793. int cnl_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
  794. irqreturn_t hda_dsp_ipc4_irq_thread(int irq, void *context);
  795. bool hda_ipc4_tx_is_busy(struct snd_sof_dev *sdev);
  796. void hda_dsp_ipc4_schedule_d0i3_work(struct sof_intel_hda_dev *hdev,
  797. struct snd_sof_ipc_msg *msg);
  798. int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
  799. void hda_ipc4_dump(struct snd_sof_dev *sdev);
  800. extern struct sdw_intel_ops sdw_callback;
  801. struct sof_ipc4_fw_library;
  802. int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev,
  803. struct sof_ipc4_fw_library *fw_lib, bool reload);
  804. /**
  805. * struct hda_dai_widget_dma_ops - DAI DMA ops optional by default unless specified otherwise
  806. * @get_hext_stream: Mandatory function pointer to get the saved pointer to struct hdac_ext_stream
  807. * @assign_hext_stream: Function pointer to assign a hdac_ext_stream
  808. * @release_hext_stream: Function pointer to release the hdac_ext_stream
  809. * @setup_hext_stream: Function pointer for hdac_ext_stream setup
  810. * @reset_hext_stream: Function pointer for hdac_ext_stream reset
  811. * @pre_trigger: Function pointer for DAI DMA pre-trigger actions
  812. * @trigger: Function pointer for DAI DMA trigger actions
  813. * @post_trigger: Function pointer for DAI DMA post-trigger actions
  814. * @codec_dai_set_stream: Function pointer to set codec-side stream information
  815. * @calc_stream_format: Function pointer to determine stream format from hw_params and
  816. * for HDaudio codec DAI from the .sig bits
  817. * @get_hlink: Mandatory function pointer to retrieve hlink, mainly to program LOSIDV
  818. * for legacy HDaudio links or program HDaudio Extended Link registers.
  819. */
  820. struct hda_dai_widget_dma_ops {
  821. struct hdac_ext_stream *(*get_hext_stream)(struct snd_sof_dev *sdev,
  822. struct snd_soc_dai *cpu_dai,
  823. struct snd_pcm_substream *substream);
  824. struct hdac_ext_stream *(*assign_hext_stream)(struct snd_sof_dev *sdev,
  825. struct snd_soc_dai *cpu_dai,
  826. struct snd_pcm_substream *substream);
  827. void (*release_hext_stream)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
  828. struct snd_pcm_substream *substream);
  829. void (*setup_hext_stream)(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream,
  830. unsigned int format_val);
  831. void (*reset_hext_stream)(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_sream);
  832. int (*pre_trigger)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
  833. struct snd_pcm_substream *substream, int cmd);
  834. int (*trigger)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
  835. struct snd_pcm_substream *substream, int cmd);
  836. int (*post_trigger)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
  837. struct snd_pcm_substream *substream, int cmd);
  838. void (*codec_dai_set_stream)(struct snd_sof_dev *sdev,
  839. struct snd_pcm_substream *substream,
  840. struct hdac_stream *hstream);
  841. unsigned int (*calc_stream_format)(struct snd_sof_dev *sdev,
  842. struct snd_pcm_substream *substream,
  843. struct snd_pcm_hw_params *params);
  844. struct hdac_ext_link * (*get_hlink)(struct snd_sof_dev *sdev,
  845. struct snd_pcm_substream *substream);
  846. };
  847. const struct hda_dai_widget_dma_ops *
  848. hda_select_dai_widget_ops(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
  849. int hda_dai_config(struct snd_soc_dapm_widget *w, unsigned int flags,
  850. struct snd_sof_dai_config_data *data);
  851. static inline struct snd_sof_dev *widget_to_sdev(struct snd_soc_dapm_widget *w)
  852. {
  853. struct snd_sof_widget *swidget = w->dobj.private;
  854. struct snd_soc_component *component = swidget->scomp;
  855. return snd_soc_component_get_drvdata(component);
  856. }
  857. #endif