sst-dsp.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * Intel Smart Sound Technology (SST) Core
  3. *
  4. * Copyright (C) 2013, Intel Corporation. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License version
  8. * 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #ifndef __SOUND_SOC_SST_DSP_H
  17. #define __SOUND_SOC_SST_DSP_H
  18. #include <linux/kernel.h>
  19. #include <linux/types.h>
  20. #include <linux/interrupt.h>
  21. /* SST Device IDs */
  22. #define SST_DEV_ID_LYNX_POINT 0x33C8
  23. #define SST_DEV_ID_WILDCAT_POINT 0x3438
  24. #define SST_DEV_ID_BYT 0x0F28
  25. /* Supported SST DMA Devices */
  26. #define SST_DMA_TYPE_DW 1
  27. #define SST_DMA_TYPE_MID 2
  28. /* SST Shim register map
  29. * The register naming can differ between products. Some products also
  30. * contain extra functionality.
  31. */
  32. #define SST_CSR 0x00
  33. #define SST_PISR 0x08
  34. #define SST_PIMR 0x10
  35. #define SST_ISRX 0x18
  36. #define SST_ISRD 0x20
  37. #define SST_IMRX 0x28
  38. #define SST_IMRD 0x30
  39. #define SST_IPCX 0x38 /* IPC IA -> SST */
  40. #define SST_IPCD 0x40 /* IPC SST -> IA */
  41. #define SST_ISRSC 0x48
  42. #define SST_ISRLPESC 0x50
  43. #define SST_IMRSC 0x58
  44. #define SST_IMRLPESC 0x60
  45. #define SST_IPCSC 0x68
  46. #define SST_IPCLPESC 0x70
  47. #define SST_CLKCTL 0x78
  48. #define SST_CSR2 0x80
  49. #define SST_LTRC 0xE0
  50. #define SST_HDMC 0xE8
  51. #define SST_DBGO 0xF0
  52. #define SST_SHIM_SIZE 0x100
  53. #define SST_PWMCTRL 0x1000
  54. /* SST Shim Register bits
  55. * The register bit naming can differ between products. Some products also
  56. * contain extra functionality.
  57. */
  58. /* CSR / CS */
  59. #define SST_CSR_RST (0x1 << 1)
  60. #define SST_CSR_SBCS0 (0x1 << 2)
  61. #define SST_CSR_SBCS1 (0x1 << 3)
  62. #define SST_CSR_DCS(x) (x << 4)
  63. #define SST_CSR_DCS_MASK (0x7 << 4)
  64. #define SST_CSR_STALL (0x1 << 10)
  65. #define SST_CSR_S0IOCS (0x1 << 21)
  66. #define SST_CSR_S1IOCS (0x1 << 23)
  67. #define SST_CSR_LPCS (0x1 << 31)
  68. #define SST_BYT_CSR_RST (0x1 << 0)
  69. #define SST_BYT_CSR_VECTOR_SEL (0x1 << 1)
  70. #define SST_BYT_CSR_STALL (0x1 << 2)
  71. #define SST_BYT_CSR_PWAITMODE (0x1 << 3)
  72. /* ISRX / ISC */
  73. #define SST_ISRX_BUSY (0x1 << 1)
  74. #define SST_ISRX_DONE (0x1 << 0)
  75. #define SST_BYT_ISRX_REQUEST (0x1 << 1)
  76. /* ISRD / ISD */
  77. #define SST_ISRD_BUSY (0x1 << 1)
  78. #define SST_ISRD_DONE (0x1 << 0)
  79. /* IMRX / IMC */
  80. #define SST_IMRX_BUSY (0x1 << 1)
  81. #define SST_IMRX_DONE (0x1 << 0)
  82. #define SST_BYT_IMRX_REQUEST (0x1 << 1)
  83. /* IPCX / IPCC */
  84. #define SST_IPCX_DONE (0x1 << 30)
  85. #define SST_IPCX_BUSY (0x1 << 31)
  86. #define SST_BYT_IPCX_DONE ((u64)0x1 << 62)
  87. #define SST_BYT_IPCX_BUSY ((u64)0x1 << 63)
  88. /* IPCD */
  89. #define SST_IPCD_DONE (0x1 << 30)
  90. #define SST_IPCD_BUSY (0x1 << 31)
  91. #define SST_BYT_IPCD_DONE ((u64)0x1 << 62)
  92. #define SST_BYT_IPCD_BUSY ((u64)0x1 << 63)
  93. /* CLKCTL */
  94. #define SST_CLKCTL_SMOS(x) (x << 24)
  95. #define SST_CLKCTL_MASK (3 << 24)
  96. #define SST_CLKCTL_DCPLCG (1 << 18)
  97. #define SST_CLKCTL_SCOE1 (1 << 17)
  98. #define SST_CLKCTL_SCOE0 (1 << 16)
  99. /* CSR2 / CS2 */
  100. #define SST_CSR2_SDFD_SSP0 (1 << 1)
  101. #define SST_CSR2_SDFD_SSP1 (1 << 2)
  102. /* LTRC */
  103. #define SST_LTRC_VAL(x) (x << 0)
  104. /* HDMC */
  105. #define SST_HDMC_HDDA0(x) (x << 0)
  106. #define SST_HDMC_HDDA1(x) (x << 7)
  107. /* SST Vendor Defined Registers and bits */
  108. #define SST_VDRTCTL0 0xa0
  109. #define SST_VDRTCTL1 0xa4
  110. #define SST_VDRTCTL2 0xa8
  111. #define SST_VDRTCTL3 0xaC
  112. /* VDRTCTL0 */
  113. #define SST_VDRTCL0_DSRAMPGE_SHIFT 16
  114. #define SST_VDRTCL0_DSRAMPGE_MASK (0xffff << SST_VDRTCL0_DSRAMPGE_SHIFT)
  115. #define SST_VDRTCL0_ISRAMPGE_SHIFT 6
  116. #define SST_VDRTCL0_ISRAMPGE_MASK (0x3ff << SST_VDRTCL0_ISRAMPGE_SHIFT)
  117. struct sst_dsp;
  118. /*
  119. * SST Device.
  120. *
  121. * This structure is populated by the SST core driver.
  122. */
  123. struct sst_dsp_device {
  124. /* Mandatory fields */
  125. struct sst_ops *ops;
  126. irqreturn_t (*thread)(int irq, void *context);
  127. void *thread_context;
  128. };
  129. /*
  130. * SST Platform Data.
  131. */
  132. struct sst_pdata {
  133. /* ACPI data */
  134. u32 lpe_base;
  135. u32 lpe_size;
  136. u32 pcicfg_base;
  137. u32 pcicfg_size;
  138. u32 fw_base;
  139. u32 fw_size;
  140. int irq;
  141. /* Firmware */
  142. const struct firmware *fw;
  143. /* DMA */
  144. u32 dma_base;
  145. u32 dma_size;
  146. int dma_engine;
  147. struct device *dma_dev;
  148. /* DSP */
  149. u32 id;
  150. void *dsp;
  151. };
  152. /* Initialization */
  153. struct sst_dsp *sst_dsp_new(struct device *dev,
  154. struct sst_dsp_device *sst_dev, struct sst_pdata *pdata);
  155. void sst_dsp_free(struct sst_dsp *sst);
  156. /* SHIM Read / Write */
  157. void sst_dsp_shim_write(struct sst_dsp *sst, u32 offset, u32 value);
  158. u32 sst_dsp_shim_read(struct sst_dsp *sst, u32 offset);
  159. int sst_dsp_shim_update_bits(struct sst_dsp *sst, u32 offset,
  160. u32 mask, u32 value);
  161. void sst_dsp_shim_write64(struct sst_dsp *sst, u32 offset, u64 value);
  162. u64 sst_dsp_shim_read64(struct sst_dsp *sst, u32 offset);
  163. int sst_dsp_shim_update_bits64(struct sst_dsp *sst, u32 offset,
  164. u64 mask, u64 value);
  165. /* SHIM Read / Write Unlocked for callers already holding sst lock */
  166. void sst_dsp_shim_write_unlocked(struct sst_dsp *sst, u32 offset, u32 value);
  167. u32 sst_dsp_shim_read_unlocked(struct sst_dsp *sst, u32 offset);
  168. int sst_dsp_shim_update_bits_unlocked(struct sst_dsp *sst, u32 offset,
  169. u32 mask, u32 value);
  170. void sst_dsp_shim_write64_unlocked(struct sst_dsp *sst, u32 offset, u64 value);
  171. u64 sst_dsp_shim_read64_unlocked(struct sst_dsp *sst, u32 offset);
  172. int sst_dsp_shim_update_bits64_unlocked(struct sst_dsp *sst, u32 offset,
  173. u64 mask, u64 value);
  174. /* Internal generic low-level SST IO functions - can be overidden */
  175. void sst_shim32_write(void __iomem *addr, u32 offset, u32 value);
  176. u32 sst_shim32_read(void __iomem *addr, u32 offset);
  177. void sst_shim32_write64(void __iomem *addr, u32 offset, u64 value);
  178. u64 sst_shim32_read64(void __iomem *addr, u32 offset);
  179. void sst_memcpy_toio_32(struct sst_dsp *sst,
  180. void __iomem *dest, void *src, size_t bytes);
  181. void sst_memcpy_fromio_32(struct sst_dsp *sst,
  182. void *dest, void __iomem *src, size_t bytes);
  183. /* DSP reset & boot */
  184. void sst_dsp_reset(struct sst_dsp *sst);
  185. int sst_dsp_boot(struct sst_dsp *sst);
  186. /* Msg IO */
  187. void sst_dsp_ipc_msg_tx(struct sst_dsp *dsp, u32 msg);
  188. u32 sst_dsp_ipc_msg_rx(struct sst_dsp *dsp);
  189. /* Mailbox management */
  190. int sst_dsp_mailbox_init(struct sst_dsp *dsp, u32 inbox_offset,
  191. size_t inbox_size, u32 outbox_offset, size_t outbox_size);
  192. void sst_dsp_inbox_write(struct sst_dsp *dsp, void *message, size_t bytes);
  193. void sst_dsp_inbox_read(struct sst_dsp *dsp, void *message, size_t bytes);
  194. void sst_dsp_outbox_write(struct sst_dsp *dsp, void *message, size_t bytes);
  195. void sst_dsp_outbox_read(struct sst_dsp *dsp, void *message, size_t bytes);
  196. void sst_dsp_mailbox_dump(struct sst_dsp *dsp, size_t bytes);
  197. /* Debug */
  198. void sst_dsp_dump(struct sst_dsp *sst);
  199. #endif