fsl_ssi.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. * fsl_ssi.h - ALSA SSI interface for the Freescale MPC8610 SoC
  3. *
  4. * Author: Timur Tabi <timur@freescale.com>
  5. *
  6. * Copyright 2007-2008 Freescale Semiconductor, Inc. This file is licensed
  7. * under the terms of the GNU General Public License version 2. This
  8. * program is licensed "as is" without any warranty of any kind, whether
  9. * express or implied.
  10. */
  11. #ifndef _MPC8610_I2S_H
  12. #define _MPC8610_I2S_H
  13. /* SSI registers */
  14. #define CCSR_SSI_STX0 0x00
  15. #define CCSR_SSI_STX1 0x04
  16. #define CCSR_SSI_SRX0 0x08
  17. #define CCSR_SSI_SRX1 0x0c
  18. #define CCSR_SSI_SCR 0x10
  19. #define CCSR_SSI_SISR 0x14
  20. #define CCSR_SSI_SIER 0x18
  21. #define CCSR_SSI_STCR 0x1c
  22. #define CCSR_SSI_SRCR 0x20
  23. #define CCSR_SSI_STCCR 0x24
  24. #define CCSR_SSI_SRCCR 0x28
  25. #define CCSR_SSI_SFCSR 0x2c
  26. #define CCSR_SSI_STR 0x30
  27. #define CCSR_SSI_SOR 0x34
  28. #define CCSR_SSI_SACNT 0x38
  29. #define CCSR_SSI_SACADD 0x3c
  30. #define CCSR_SSI_SACDAT 0x40
  31. #define CCSR_SSI_SATAG 0x44
  32. #define CCSR_SSI_STMSK 0x48
  33. #define CCSR_SSI_SRMSK 0x4c
  34. #define CCSR_SSI_SACCST 0x50
  35. #define CCSR_SSI_SACCEN 0x54
  36. #define CCSR_SSI_SACCDIS 0x58
  37. #define CCSR_SSI_SCR_SYNC_TX_FS 0x00001000
  38. #define CCSR_SSI_SCR_RFR_CLK_DIS 0x00000800
  39. #define CCSR_SSI_SCR_TFR_CLK_DIS 0x00000400
  40. #define CCSR_SSI_SCR_TCH_EN 0x00000100
  41. #define CCSR_SSI_SCR_SYS_CLK_EN 0x00000080
  42. #define CCSR_SSI_SCR_I2S_MODE_MASK 0x00000060
  43. #define CCSR_SSI_SCR_I2S_MODE_NORMAL 0x00000000
  44. #define CCSR_SSI_SCR_I2S_MODE_MASTER 0x00000020
  45. #define CCSR_SSI_SCR_I2S_MODE_SLAVE 0x00000040
  46. #define CCSR_SSI_SCR_SYN 0x00000010
  47. #define CCSR_SSI_SCR_NET 0x00000008
  48. #define CCSR_SSI_SCR_RE 0x00000004
  49. #define CCSR_SSI_SCR_TE 0x00000002
  50. #define CCSR_SSI_SCR_SSIEN 0x00000001
  51. #define CCSR_SSI_SISR_RFRC 0x01000000
  52. #define CCSR_SSI_SISR_TFRC 0x00800000
  53. #define CCSR_SSI_SISR_CMDAU 0x00040000
  54. #define CCSR_SSI_SISR_CMDDU 0x00020000
  55. #define CCSR_SSI_SISR_RXT 0x00010000
  56. #define CCSR_SSI_SISR_RDR1 0x00008000
  57. #define CCSR_SSI_SISR_RDR0 0x00004000
  58. #define CCSR_SSI_SISR_TDE1 0x00002000
  59. #define CCSR_SSI_SISR_TDE0 0x00001000
  60. #define CCSR_SSI_SISR_ROE1 0x00000800
  61. #define CCSR_SSI_SISR_ROE0 0x00000400
  62. #define CCSR_SSI_SISR_TUE1 0x00000200
  63. #define CCSR_SSI_SISR_TUE0 0x00000100
  64. #define CCSR_SSI_SISR_TFS 0x00000080
  65. #define CCSR_SSI_SISR_RFS 0x00000040
  66. #define CCSR_SSI_SISR_TLS 0x00000020
  67. #define CCSR_SSI_SISR_RLS 0x00000010
  68. #define CCSR_SSI_SISR_RFF1 0x00000008
  69. #define CCSR_SSI_SISR_RFF0 0x00000004
  70. #define CCSR_SSI_SISR_TFE1 0x00000002
  71. #define CCSR_SSI_SISR_TFE0 0x00000001
  72. #define CCSR_SSI_SIER_RFRC_EN 0x01000000
  73. #define CCSR_SSI_SIER_TFRC_EN 0x00800000
  74. #define CCSR_SSI_SIER_RDMAE 0x00400000
  75. #define CCSR_SSI_SIER_RIE 0x00200000
  76. #define CCSR_SSI_SIER_TDMAE 0x00100000
  77. #define CCSR_SSI_SIER_TIE 0x00080000
  78. #define CCSR_SSI_SIER_CMDAU_EN 0x00040000
  79. #define CCSR_SSI_SIER_CMDDU_EN 0x00020000
  80. #define CCSR_SSI_SIER_RXT_EN 0x00010000
  81. #define CCSR_SSI_SIER_RDR1_EN 0x00008000
  82. #define CCSR_SSI_SIER_RDR0_EN 0x00004000
  83. #define CCSR_SSI_SIER_TDE1_EN 0x00002000
  84. #define CCSR_SSI_SIER_TDE0_EN 0x00001000
  85. #define CCSR_SSI_SIER_ROE1_EN 0x00000800
  86. #define CCSR_SSI_SIER_ROE0_EN 0x00000400
  87. #define CCSR_SSI_SIER_TUE1_EN 0x00000200
  88. #define CCSR_SSI_SIER_TUE0_EN 0x00000100
  89. #define CCSR_SSI_SIER_TFS_EN 0x00000080
  90. #define CCSR_SSI_SIER_RFS_EN 0x00000040
  91. #define CCSR_SSI_SIER_TLS_EN 0x00000020
  92. #define CCSR_SSI_SIER_RLS_EN 0x00000010
  93. #define CCSR_SSI_SIER_RFF1_EN 0x00000008
  94. #define CCSR_SSI_SIER_RFF0_EN 0x00000004
  95. #define CCSR_SSI_SIER_TFE1_EN 0x00000002
  96. #define CCSR_SSI_SIER_TFE0_EN 0x00000001
  97. #define CCSR_SSI_STCR_TXBIT0 0x00000200
  98. #define CCSR_SSI_STCR_TFEN1 0x00000100
  99. #define CCSR_SSI_STCR_TFEN0 0x00000080
  100. #define CCSR_SSI_STCR_TFDIR 0x00000040
  101. #define CCSR_SSI_STCR_TXDIR 0x00000020
  102. #define CCSR_SSI_STCR_TSHFD 0x00000010
  103. #define CCSR_SSI_STCR_TSCKP 0x00000008
  104. #define CCSR_SSI_STCR_TFSI 0x00000004
  105. #define CCSR_SSI_STCR_TFSL 0x00000002
  106. #define CCSR_SSI_STCR_TEFS 0x00000001
  107. #define CCSR_SSI_SRCR_RXEXT 0x00000400
  108. #define CCSR_SSI_SRCR_RXBIT0 0x00000200
  109. #define CCSR_SSI_SRCR_RFEN1 0x00000100
  110. #define CCSR_SSI_SRCR_RFEN0 0x00000080
  111. #define CCSR_SSI_SRCR_RFDIR 0x00000040
  112. #define CCSR_SSI_SRCR_RXDIR 0x00000020
  113. #define CCSR_SSI_SRCR_RSHFD 0x00000010
  114. #define CCSR_SSI_SRCR_RSCKP 0x00000008
  115. #define CCSR_SSI_SRCR_RFSI 0x00000004
  116. #define CCSR_SSI_SRCR_RFSL 0x00000002
  117. #define CCSR_SSI_SRCR_REFS 0x00000001
  118. /* STCCR and SRCCR */
  119. #define CCSR_SSI_SxCCR_DIV2_SHIFT 18
  120. #define CCSR_SSI_SxCCR_DIV2 0x00040000
  121. #define CCSR_SSI_SxCCR_PSR_SHIFT 17
  122. #define CCSR_SSI_SxCCR_PSR 0x00020000
  123. #define CCSR_SSI_SxCCR_WL_SHIFT 13
  124. #define CCSR_SSI_SxCCR_WL_MASK 0x0001E000
  125. #define CCSR_SSI_SxCCR_WL(x) \
  126. (((((x) / 2) - 1) << CCSR_SSI_SxCCR_WL_SHIFT) & CCSR_SSI_SxCCR_WL_MASK)
  127. #define CCSR_SSI_SxCCR_DC_SHIFT 8
  128. #define CCSR_SSI_SxCCR_DC_MASK 0x00001F00
  129. #define CCSR_SSI_SxCCR_DC(x) \
  130. ((((x) - 1) << CCSR_SSI_SxCCR_DC_SHIFT) & CCSR_SSI_SxCCR_DC_MASK)
  131. #define CCSR_SSI_SxCCR_PM_SHIFT 0
  132. #define CCSR_SSI_SxCCR_PM_MASK 0x000000FF
  133. #define CCSR_SSI_SxCCR_PM(x) \
  134. ((((x) - 1) << CCSR_SSI_SxCCR_PM_SHIFT) & CCSR_SSI_SxCCR_PM_MASK)
  135. /*
  136. * The xFCNT bits are read-only, and the xFWM bits are read/write. Use the
  137. * CCSR_SSI_SFCSR_xFCNTy() macros to read the FIFO counters, and use the
  138. * CCSR_SSI_SFCSR_xFWMy() macros to set the watermarks.
  139. */
  140. #define CCSR_SSI_SFCSR_RFCNT1_SHIFT 28
  141. #define CCSR_SSI_SFCSR_RFCNT1_MASK 0xF0000000
  142. #define CCSR_SSI_SFCSR_RFCNT1(x) \
  143. (((x) & CCSR_SSI_SFCSR_RFCNT1_MASK) >> CCSR_SSI_SFCSR_RFCNT1_SHIFT)
  144. #define CCSR_SSI_SFCSR_TFCNT1_SHIFT 24
  145. #define CCSR_SSI_SFCSR_TFCNT1_MASK 0x0F000000
  146. #define CCSR_SSI_SFCSR_TFCNT1(x) \
  147. (((x) & CCSR_SSI_SFCSR_TFCNT1_MASK) >> CCSR_SSI_SFCSR_TFCNT1_SHIFT)
  148. #define CCSR_SSI_SFCSR_RFWM1_SHIFT 20
  149. #define CCSR_SSI_SFCSR_RFWM1_MASK 0x00F00000
  150. #define CCSR_SSI_SFCSR_RFWM1(x) \
  151. (((x) << CCSR_SSI_SFCSR_RFWM1_SHIFT) & CCSR_SSI_SFCSR_RFWM1_MASK)
  152. #define CCSR_SSI_SFCSR_TFWM1_SHIFT 16
  153. #define CCSR_SSI_SFCSR_TFWM1_MASK 0x000F0000
  154. #define CCSR_SSI_SFCSR_TFWM1(x) \
  155. (((x) << CCSR_SSI_SFCSR_TFWM1_SHIFT) & CCSR_SSI_SFCSR_TFWM1_MASK)
  156. #define CCSR_SSI_SFCSR_RFCNT0_SHIFT 12
  157. #define CCSR_SSI_SFCSR_RFCNT0_MASK 0x0000F000
  158. #define CCSR_SSI_SFCSR_RFCNT0(x) \
  159. (((x) & CCSR_SSI_SFCSR_RFCNT0_MASK) >> CCSR_SSI_SFCSR_RFCNT0_SHIFT)
  160. #define CCSR_SSI_SFCSR_TFCNT0_SHIFT 8
  161. #define CCSR_SSI_SFCSR_TFCNT0_MASK 0x00000F00
  162. #define CCSR_SSI_SFCSR_TFCNT0(x) \
  163. (((x) & CCSR_SSI_SFCSR_TFCNT0_MASK) >> CCSR_SSI_SFCSR_TFCNT0_SHIFT)
  164. #define CCSR_SSI_SFCSR_RFWM0_SHIFT 4
  165. #define CCSR_SSI_SFCSR_RFWM0_MASK 0x000000F0
  166. #define CCSR_SSI_SFCSR_RFWM0(x) \
  167. (((x) << CCSR_SSI_SFCSR_RFWM0_SHIFT) & CCSR_SSI_SFCSR_RFWM0_MASK)
  168. #define CCSR_SSI_SFCSR_TFWM0_SHIFT 0
  169. #define CCSR_SSI_SFCSR_TFWM0_MASK 0x0000000F
  170. #define CCSR_SSI_SFCSR_TFWM0(x) \
  171. (((x) << CCSR_SSI_SFCSR_TFWM0_SHIFT) & CCSR_SSI_SFCSR_TFWM0_MASK)
  172. #define CCSR_SSI_STR_TEST 0x00008000
  173. #define CCSR_SSI_STR_RCK2TCK 0x00004000
  174. #define CCSR_SSI_STR_RFS2TFS 0x00002000
  175. #define CCSR_SSI_STR_RXSTATE(x) (((x) >> 8) & 0x1F)
  176. #define CCSR_SSI_STR_TXD2RXD 0x00000080
  177. #define CCSR_SSI_STR_TCK2RCK 0x00000040
  178. #define CCSR_SSI_STR_TFS2RFS 0x00000020
  179. #define CCSR_SSI_STR_TXSTATE(x) ((x) & 0x1F)
  180. #define CCSR_SSI_SOR_CLKOFF 0x00000040
  181. #define CCSR_SSI_SOR_RX_CLR 0x00000020
  182. #define CCSR_SSI_SOR_TX_CLR 0x00000010
  183. #define CCSR_SSI_SOR_INIT 0x00000008
  184. #define CCSR_SSI_SOR_WAIT_SHIFT 1
  185. #define CCSR_SSI_SOR_WAIT_MASK 0x00000006
  186. #define CCSR_SSI_SOR_WAIT(x) (((x) & 3) << CCSR_SSI_SOR_WAIT_SHIFT)
  187. #define CCSR_SSI_SOR_SYNRST 0x00000001
  188. #define CCSR_SSI_SACNT_FRDIV(x) (((x) & 0x3f) << 5)
  189. #define CCSR_SSI_SACNT_WR 0x00000010
  190. #define CCSR_SSI_SACNT_RD 0x00000008
  191. #define CCSR_SSI_SACNT_RDWR_MASK 0x00000018
  192. #define CCSR_SSI_SACNT_TIF 0x00000004
  193. #define CCSR_SSI_SACNT_FV 0x00000002
  194. #define CCSR_SSI_SACNT_AC97EN 0x00000001
  195. struct device;
  196. #if IS_ENABLED(CONFIG_DEBUG_FS)
  197. struct fsl_ssi_dbg {
  198. struct dentry *dbg_dir;
  199. struct dentry *dbg_stats;
  200. struct {
  201. unsigned int rfrc;
  202. unsigned int tfrc;
  203. unsigned int cmdau;
  204. unsigned int cmddu;
  205. unsigned int rxt;
  206. unsigned int rdr1;
  207. unsigned int rdr0;
  208. unsigned int tde1;
  209. unsigned int tde0;
  210. unsigned int roe1;
  211. unsigned int roe0;
  212. unsigned int tue1;
  213. unsigned int tue0;
  214. unsigned int tfs;
  215. unsigned int rfs;
  216. unsigned int tls;
  217. unsigned int rls;
  218. unsigned int rff1;
  219. unsigned int rff0;
  220. unsigned int tfe1;
  221. unsigned int tfe0;
  222. } stats;
  223. };
  224. void fsl_ssi_dbg_isr(struct fsl_ssi_dbg *ssi_dbg, u32 sisr);
  225. int fsl_ssi_debugfs_create(struct fsl_ssi_dbg *ssi_dbg, struct device *dev);
  226. void fsl_ssi_debugfs_remove(struct fsl_ssi_dbg *ssi_dbg);
  227. #else
  228. struct fsl_ssi_dbg {
  229. };
  230. static inline void fsl_ssi_dbg_isr(struct fsl_ssi_dbg *stats, u32 sisr)
  231. {
  232. }
  233. static inline int fsl_ssi_debugfs_create(struct fsl_ssi_dbg *ssi_dbg,
  234. struct device *dev)
  235. {
  236. return 0;
  237. }
  238. static inline void fsl_ssi_debugfs_remove(struct fsl_ssi_dbg *ssi_dbg)
  239. {
  240. }
  241. #endif /* ! IS_ENABLED(CONFIG_DEBUG_FS) */
  242. #endif