shim.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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_SHIM_H
  11. #define __SOF_INTEL_SHIM_H
  12. enum sof_intel_hw_ip_version {
  13. SOF_INTEL_TANGIER,
  14. SOF_INTEL_BAYTRAIL,
  15. SOF_INTEL_BROADWELL,
  16. SOF_INTEL_CAVS_1_5, /* SkyLake, KabyLake, AmberLake */
  17. SOF_INTEL_CAVS_1_5_PLUS,/* ApolloLake, GeminiLake */
  18. SOF_INTEL_CAVS_1_8, /* CannonLake, CometLake, CoffeeLake */
  19. SOF_INTEL_CAVS_2_0, /* IceLake, JasperLake */
  20. SOF_INTEL_CAVS_2_5, /* TigerLake, AlderLake */
  21. SOF_INTEL_ACE_1_0, /* MeteorLake */
  22. SOF_INTEL_ACE_2_0, /* LunarLake */
  23. SOF_INTEL_ACE_3_0, /* PantherLake */
  24. };
  25. /*
  26. * SHIM registers for BYT, BSW, CHT, BDW
  27. */
  28. #define SHIM_CSR (SHIM_OFFSET + 0x00)
  29. #define SHIM_PISR (SHIM_OFFSET + 0x08)
  30. #define SHIM_PIMR (SHIM_OFFSET + 0x10)
  31. #define SHIM_ISRX (SHIM_OFFSET + 0x18)
  32. #define SHIM_ISRD (SHIM_OFFSET + 0x20)
  33. #define SHIM_IMRX (SHIM_OFFSET + 0x28)
  34. #define SHIM_IMRD (SHIM_OFFSET + 0x30)
  35. #define SHIM_IPCX (SHIM_OFFSET + 0x38)
  36. #define SHIM_IPCD (SHIM_OFFSET + 0x40)
  37. #define SHIM_ISRSC (SHIM_OFFSET + 0x48)
  38. #define SHIM_ISRLPESC (SHIM_OFFSET + 0x50)
  39. #define SHIM_IMRSC (SHIM_OFFSET + 0x58)
  40. #define SHIM_IMRLPESC (SHIM_OFFSET + 0x60)
  41. #define SHIM_IPCSC (SHIM_OFFSET + 0x68)
  42. #define SHIM_IPCLPESC (SHIM_OFFSET + 0x70)
  43. #define SHIM_CLKCTL (SHIM_OFFSET + 0x78)
  44. #define SHIM_CSR2 (SHIM_OFFSET + 0x80)
  45. #define SHIM_LTRC (SHIM_OFFSET + 0xE0)
  46. #define SHIM_HMDC (SHIM_OFFSET + 0xE8)
  47. #define SHIM_PWMCTRL 0x1000
  48. /*
  49. * SST SHIM register bits for BYT, BSW, CHT, BDW
  50. * Register bit naming and functionaility can differ between devices.
  51. */
  52. /* CSR / CS */
  53. #define SHIM_CSR_RST BIT(1)
  54. #define SHIM_CSR_SBCS0 BIT(2)
  55. #define SHIM_CSR_SBCS1 BIT(3)
  56. #define SHIM_CSR_DCS(x) ((x) << 4)
  57. #define SHIM_CSR_DCS_MASK (0x7 << 4)
  58. #define SHIM_CSR_STALL BIT(10)
  59. #define SHIM_CSR_S0IOCS BIT(21)
  60. #define SHIM_CSR_S1IOCS BIT(23)
  61. #define SHIM_CSR_LPCS BIT(31)
  62. #define SHIM_CSR_24MHZ_LPCS \
  63. (SHIM_CSR_SBCS0 | SHIM_CSR_SBCS1 | SHIM_CSR_LPCS)
  64. #define SHIM_CSR_24MHZ_NO_LPCS (SHIM_CSR_SBCS0 | SHIM_CSR_SBCS1)
  65. #define SHIM_BYT_CSR_RST BIT(0)
  66. #define SHIM_BYT_CSR_VECTOR_SEL BIT(1)
  67. #define SHIM_BYT_CSR_STALL BIT(2)
  68. #define SHIM_BYT_CSR_PWAITMODE BIT(3)
  69. /* ISRX / ISC */
  70. #define SHIM_ISRX_BUSY BIT(1)
  71. #define SHIM_ISRX_DONE BIT(0)
  72. #define SHIM_BYT_ISRX_REQUEST BIT(1)
  73. /* ISRD / ISD */
  74. #define SHIM_ISRD_BUSY BIT(1)
  75. #define SHIM_ISRD_DONE BIT(0)
  76. /* IMRX / IMC */
  77. #define SHIM_IMRX_BUSY BIT(1)
  78. #define SHIM_IMRX_DONE BIT(0)
  79. #define SHIM_BYT_IMRX_REQUEST BIT(1)
  80. /* IMRD / IMD */
  81. #define SHIM_IMRD_DONE BIT(0)
  82. #define SHIM_IMRD_BUSY BIT(1)
  83. #define SHIM_IMRD_SSP0 BIT(16)
  84. #define SHIM_IMRD_DMAC0 BIT(21)
  85. #define SHIM_IMRD_DMAC1 BIT(22)
  86. #define SHIM_IMRD_DMAC (SHIM_IMRD_DMAC0 | SHIM_IMRD_DMAC1)
  87. /* IPCX / IPCC */
  88. #define SHIM_IPCX_DONE BIT(30)
  89. #define SHIM_IPCX_BUSY BIT(31)
  90. #define SHIM_BYT_IPCX_DONE BIT_ULL(62)
  91. #define SHIM_BYT_IPCX_BUSY BIT_ULL(63)
  92. /* IPCD */
  93. #define SHIM_IPCD_DONE BIT(30)
  94. #define SHIM_IPCD_BUSY BIT(31)
  95. #define SHIM_BYT_IPCD_DONE BIT_ULL(62)
  96. #define SHIM_BYT_IPCD_BUSY BIT_ULL(63)
  97. /* CLKCTL */
  98. #define SHIM_CLKCTL_SMOS(x) ((x) << 24)
  99. #define SHIM_CLKCTL_MASK (3 << 24)
  100. #define SHIM_CLKCTL_DCPLCG BIT(18)
  101. #define SHIM_CLKCTL_SCOE1 BIT(17)
  102. #define SHIM_CLKCTL_SCOE0 BIT(16)
  103. /* CSR2 / CS2 */
  104. #define SHIM_CSR2_SDFD_SSP0 BIT(1)
  105. #define SHIM_CSR2_SDFD_SSP1 BIT(2)
  106. /* LTRC */
  107. #define SHIM_LTRC_VAL(x) ((x) << 0)
  108. /* HMDC */
  109. #define SHIM_HMDC_HDDA0(x) ((x) << 0)
  110. #define SHIM_HMDC_HDDA1(x) ((x) << 7)
  111. #define SHIM_HMDC_HDDA_E0_CH0 1
  112. #define SHIM_HMDC_HDDA_E0_CH1 2
  113. #define SHIM_HMDC_HDDA_E0_CH2 4
  114. #define SHIM_HMDC_HDDA_E0_CH3 8
  115. #define SHIM_HMDC_HDDA_E1_CH0 SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH0)
  116. #define SHIM_HMDC_HDDA_E1_CH1 SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH1)
  117. #define SHIM_HMDC_HDDA_E1_CH2 SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH2)
  118. #define SHIM_HMDC_HDDA_E1_CH3 SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH3)
  119. #define SHIM_HMDC_HDDA_E0_ALLCH \
  120. (SHIM_HMDC_HDDA_E0_CH0 | SHIM_HMDC_HDDA_E0_CH1 | \
  121. SHIM_HMDC_HDDA_E0_CH2 | SHIM_HMDC_HDDA_E0_CH3)
  122. #define SHIM_HMDC_HDDA_E1_ALLCH \
  123. (SHIM_HMDC_HDDA_E1_CH0 | SHIM_HMDC_HDDA_E1_CH1 | \
  124. SHIM_HMDC_HDDA_E1_CH2 | SHIM_HMDC_HDDA_E1_CH3)
  125. /* Audio DSP PCI registers */
  126. #define PCI_VDRTCTL0 0xa0
  127. #define PCI_VDRTCTL1 0xa4
  128. #define PCI_VDRTCTL2 0xa8
  129. #define PCI_VDRTCTL3 0xaC
  130. /* VDRTCTL0 */
  131. #define PCI_VDRTCL0_D3PGD BIT(0)
  132. #define PCI_VDRTCL0_D3SRAMPGD BIT(1)
  133. #define PCI_VDRTCL0_DSRAMPGE_SHIFT 12
  134. #define PCI_VDRTCL0_DSRAMPGE_MASK GENMASK(PCI_VDRTCL0_DSRAMPGE_SHIFT + 19,\
  135. PCI_VDRTCL0_DSRAMPGE_SHIFT)
  136. #define PCI_VDRTCL0_ISRAMPGE_SHIFT 2
  137. #define PCI_VDRTCL0_ISRAMPGE_MASK GENMASK(PCI_VDRTCL0_ISRAMPGE_SHIFT + 9,\
  138. PCI_VDRTCL0_ISRAMPGE_SHIFT)
  139. /* VDRTCTL2 */
  140. #define PCI_VDRTCL2_DCLCGE BIT(1)
  141. #define PCI_VDRTCL2_DTCGE BIT(10)
  142. #define PCI_VDRTCL2_APLLSE_MASK BIT(31)
  143. /* PMCS */
  144. #define PCI_PMCS 0x84
  145. #define PCI_PMCS_PS_MASK 0x3
  146. /* Intel quirks */
  147. #define SOF_INTEL_PROCEN_FMT_QUIRK BIT(0)
  148. /* DSP hardware descriptor */
  149. struct sof_intel_dsp_desc {
  150. int cores_num;
  151. int host_managed_cores_mask;
  152. int init_core_mask; /* cores available after fw boot */
  153. int ipc_req;
  154. int ipc_req_mask;
  155. int ipc_ack;
  156. int ipc_ack_mask;
  157. int ipc_ctl;
  158. int rom_status_reg;
  159. int rom_init_timeout;
  160. int ssp_count; /* ssp count of the platform */
  161. int ssp_base_offset; /* base address of the SSPs */
  162. u32 sdw_shim_base;
  163. u32 sdw_alh_base;
  164. u32 d0i3_offset;
  165. u32 quirks;
  166. enum sof_intel_hw_ip_version hw_ip_version;
  167. int (*read_sdw_lcount)(struct snd_sof_dev *sdev);
  168. void (*enable_sdw_irq)(struct snd_sof_dev *sdev, bool enable);
  169. bool (*check_sdw_irq)(struct snd_sof_dev *sdev);
  170. bool (*check_sdw_wakeen_irq)(struct snd_sof_dev *sdev);
  171. void (*sdw_process_wakeen)(struct snd_sof_dev *sdev);
  172. bool (*check_ipc_irq)(struct snd_sof_dev *sdev);
  173. int (*power_down_dsp)(struct snd_sof_dev *sdev);
  174. int (*disable_interrupts)(struct snd_sof_dev *sdev);
  175. int (*cl_init)(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot);
  176. };
  177. extern const struct snd_sof_dsp_ops sof_tng_ops;
  178. extern const struct sof_intel_dsp_desc tng_chip_info;
  179. struct sof_intel_stream {
  180. size_t posn_offset;
  181. };
  182. static inline const struct sof_intel_dsp_desc *get_chip_info(struct snd_sof_pdata *pdata)
  183. {
  184. const struct sof_dev_desc *desc = pdata->desc;
  185. return desc->chip_info;
  186. }
  187. #endif