mcbsp.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /*
  2. * sound/soc/omap/mcbsp.h
  3. *
  4. * OMAP Multi-Channel Buffered Serial Port
  5. *
  6. * Contact: Jarkko Nikula <jarkko.nikula@bitmer.com>
  7. * Peter Ujfalusi <peter.ujfalusi@ti.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #ifndef __ASOC_MCBSP_H
  25. #define __ASOC_MCBSP_H
  26. /* McBSP register numbers. Register address offset = num * reg_step */
  27. enum {
  28. /* Common registers */
  29. OMAP_MCBSP_REG_SPCR2 = 4,
  30. OMAP_MCBSP_REG_SPCR1,
  31. OMAP_MCBSP_REG_RCR2,
  32. OMAP_MCBSP_REG_RCR1,
  33. OMAP_MCBSP_REG_XCR2,
  34. OMAP_MCBSP_REG_XCR1,
  35. OMAP_MCBSP_REG_SRGR2,
  36. OMAP_MCBSP_REG_SRGR1,
  37. OMAP_MCBSP_REG_MCR2,
  38. OMAP_MCBSP_REG_MCR1,
  39. OMAP_MCBSP_REG_RCERA,
  40. OMAP_MCBSP_REG_RCERB,
  41. OMAP_MCBSP_REG_XCERA,
  42. OMAP_MCBSP_REG_XCERB,
  43. OMAP_MCBSP_REG_PCR0,
  44. OMAP_MCBSP_REG_RCERC,
  45. OMAP_MCBSP_REG_RCERD,
  46. OMAP_MCBSP_REG_XCERC,
  47. OMAP_MCBSP_REG_XCERD,
  48. OMAP_MCBSP_REG_RCERE,
  49. OMAP_MCBSP_REG_RCERF,
  50. OMAP_MCBSP_REG_XCERE,
  51. OMAP_MCBSP_REG_XCERF,
  52. OMAP_MCBSP_REG_RCERG,
  53. OMAP_MCBSP_REG_RCERH,
  54. OMAP_MCBSP_REG_XCERG,
  55. OMAP_MCBSP_REG_XCERH,
  56. /* OMAP1-OMAP2420 registers */
  57. OMAP_MCBSP_REG_DRR2 = 0,
  58. OMAP_MCBSP_REG_DRR1,
  59. OMAP_MCBSP_REG_DXR2,
  60. OMAP_MCBSP_REG_DXR1,
  61. /* OMAP2430 and onwards */
  62. OMAP_MCBSP_REG_DRR = 0,
  63. OMAP_MCBSP_REG_DXR = 2,
  64. OMAP_MCBSP_REG_SYSCON = 35,
  65. OMAP_MCBSP_REG_THRSH2,
  66. OMAP_MCBSP_REG_THRSH1,
  67. OMAP_MCBSP_REG_IRQST = 40,
  68. OMAP_MCBSP_REG_IRQEN,
  69. OMAP_MCBSP_REG_WAKEUPEN,
  70. OMAP_MCBSP_REG_XCCR,
  71. OMAP_MCBSP_REG_RCCR,
  72. OMAP_MCBSP_REG_XBUFFSTAT,
  73. OMAP_MCBSP_REG_RBUFFSTAT,
  74. OMAP_MCBSP_REG_SSELCR,
  75. };
  76. /* OMAP3 sidetone control registers */
  77. #define OMAP_ST_REG_REV 0x00
  78. #define OMAP_ST_REG_SYSCONFIG 0x10
  79. #define OMAP_ST_REG_IRQSTATUS 0x18
  80. #define OMAP_ST_REG_IRQENABLE 0x1C
  81. #define OMAP_ST_REG_SGAINCR 0x24
  82. #define OMAP_ST_REG_SFIRCR 0x28
  83. #define OMAP_ST_REG_SSELCR 0x2C
  84. /************************** McBSP SPCR1 bit definitions ***********************/
  85. #define RRST 0x0001
  86. #define RRDY 0x0002
  87. #define RFULL 0x0004
  88. #define RSYNC_ERR 0x0008
  89. #define RINTM(value) ((value)<<4) /* bits 4:5 */
  90. #define ABIS 0x0040
  91. #define DXENA 0x0080
  92. #define CLKSTP(value) ((value)<<11) /* bits 11:12 */
  93. #define RJUST(value) ((value)<<13) /* bits 13:14 */
  94. #define ALB 0x8000
  95. #define DLB 0x8000
  96. /************************** McBSP SPCR2 bit definitions ***********************/
  97. #define XRST 0x0001
  98. #define XRDY 0x0002
  99. #define XEMPTY 0x0004
  100. #define XSYNC_ERR 0x0008
  101. #define XINTM(value) ((value)<<4) /* bits 4:5 */
  102. #define GRST 0x0040
  103. #define FRST 0x0080
  104. #define SOFT 0x0100
  105. #define FREE 0x0200
  106. /************************** McBSP PCR bit definitions *************************/
  107. #define CLKRP 0x0001
  108. #define CLKXP 0x0002
  109. #define FSRP 0x0004
  110. #define FSXP 0x0008
  111. #define DR_STAT 0x0010
  112. #define DX_STAT 0x0020
  113. #define CLKS_STAT 0x0040
  114. #define SCLKME 0x0080
  115. #define CLKRM 0x0100
  116. #define CLKXM 0x0200
  117. #define FSRM 0x0400
  118. #define FSXM 0x0800
  119. #define RIOEN 0x1000
  120. #define XIOEN 0x2000
  121. #define IDLE_EN 0x4000
  122. /************************** McBSP RCR1 bit definitions ************************/
  123. #define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */
  124. #define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */
  125. /************************** McBSP XCR1 bit definitions ************************/
  126. #define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */
  127. #define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */
  128. /*************************** McBSP RCR2 bit definitions ***********************/
  129. #define RDATDLY(value) (value) /* Bits 0:1 */
  130. #define RFIG 0x0004
  131. #define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */
  132. #define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */
  133. #define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */
  134. #define RPHASE 0x8000
  135. /*************************** McBSP XCR2 bit definitions ***********************/
  136. #define XDATDLY(value) (value) /* Bits 0:1 */
  137. #define XFIG 0x0004
  138. #define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */
  139. #define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */
  140. #define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */
  141. #define XPHASE 0x8000
  142. /************************* McBSP SRGR1 bit definitions ************************/
  143. #define CLKGDV(value) (value) /* Bits 0:7 */
  144. #define FWID(value) ((value)<<8) /* Bits 8:15 */
  145. /************************* McBSP SRGR2 bit definitions ************************/
  146. #define FPER(value) (value) /* Bits 0:11 */
  147. #define FSGM 0x1000
  148. #define CLKSM 0x2000
  149. #define CLKSP 0x4000
  150. #define GSYNC 0x8000
  151. /************************* McBSP MCR1 bit definitions *************************/
  152. #define RMCM 0x0001
  153. #define RCBLK(value) ((value)<<2) /* Bits 2:4 */
  154. #define RPABLK(value) ((value)<<5) /* Bits 5:6 */
  155. #define RPBBLK(value) ((value)<<7) /* Bits 7:8 */
  156. /************************* McBSP MCR2 bit definitions *************************/
  157. #define XMCM(value) (value) /* Bits 0:1 */
  158. #define XCBLK(value) ((value)<<2) /* Bits 2:4 */
  159. #define XPABLK(value) ((value)<<5) /* Bits 5:6 */
  160. #define XPBBLK(value) ((value)<<7) /* Bits 7:8 */
  161. /*********************** McBSP XCCR bit definitions *************************/
  162. #define EXTCLKGATE 0x8000
  163. #define PPCONNECT 0x4000
  164. #define DXENDLY(value) ((value)<<12) /* Bits 12:13 */
  165. #define XFULL_CYCLE 0x0800
  166. #define DILB 0x0020
  167. #define XDMAEN 0x0008
  168. #define XDISABLE 0x0001
  169. /********************** McBSP RCCR bit definitions *************************/
  170. #define RFULL_CYCLE 0x0800
  171. #define RDMAEN 0x0008
  172. #define RDISABLE 0x0001
  173. /********************** McBSP SYSCONFIG bit definitions ********************/
  174. #define CLOCKACTIVITY(value) ((value)<<8)
  175. #define SIDLEMODE(value) ((value)<<3)
  176. #define ENAWAKEUP 0x0004
  177. #define SOFTRST 0x0002
  178. /********************** McBSP SSELCR bit definitions ***********************/
  179. #define SIDETONEEN 0x0400
  180. /********************** McBSP Sidetone SYSCONFIG bit definitions ***********/
  181. #define ST_AUTOIDLE 0x0001
  182. /********************** McBSP Sidetone SGAINCR bit definitions *************/
  183. #define ST_CH1GAIN(value) ((value<<16)) /* Bits 16:31 */
  184. #define ST_CH0GAIN(value) (value) /* Bits 0:15 */
  185. /********************** McBSP Sidetone SFIRCR bit definitions **************/
  186. #define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
  187. /********************** McBSP Sidetone SSELCR bit definitions **************/
  188. #define ST_COEFFWRDONE 0x0004
  189. #define ST_COEFFWREN 0x0002
  190. #define ST_SIDETONEEN 0x0001
  191. /********************** McBSP DMA operating modes **************************/
  192. #define MCBSP_DMA_MODE_ELEMENT 0
  193. #define MCBSP_DMA_MODE_THRESHOLD 1
  194. #define MCBSP_DMA_MODE_FRAME 2
  195. /********************** McBSP WAKEUPEN bit definitions *********************/
  196. #define XEMPTYEOFEN 0x4000
  197. #define XRDYEN 0x0400
  198. #define XEOFEN 0x0200
  199. #define XFSXEN 0x0100
  200. #define XSYNCERREN 0x0080
  201. #define RRDYEN 0x0008
  202. #define REOFEN 0x0004
  203. #define RFSREN 0x0002
  204. #define RSYNCERREN 0x0001
  205. /* we don't do multichannel for now */
  206. struct omap_mcbsp_reg_cfg {
  207. u16 spcr2;
  208. u16 spcr1;
  209. u16 rcr2;
  210. u16 rcr1;
  211. u16 xcr2;
  212. u16 xcr1;
  213. u16 srgr2;
  214. u16 srgr1;
  215. u16 mcr2;
  216. u16 mcr1;
  217. u16 pcr0;
  218. u16 rcerc;
  219. u16 rcerd;
  220. u16 xcerc;
  221. u16 xcerd;
  222. u16 rcere;
  223. u16 rcerf;
  224. u16 xcere;
  225. u16 xcerf;
  226. u16 rcerg;
  227. u16 rcerh;
  228. u16 xcerg;
  229. u16 xcerh;
  230. u16 xccr;
  231. u16 rccr;
  232. };
  233. void omap_mcbsp_config(unsigned int id,
  234. const struct omap_mcbsp_reg_cfg *config);
  235. void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold);
  236. void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold);
  237. u16 omap_mcbsp_get_max_tx_threshold(unsigned int id);
  238. u16 omap_mcbsp_get_max_rx_threshold(unsigned int id);
  239. u16 omap_mcbsp_get_fifo_size(unsigned int id);
  240. u16 omap_mcbsp_get_tx_delay(unsigned int id);
  241. u16 omap_mcbsp_get_rx_delay(unsigned int id);
  242. int omap_mcbsp_get_dma_op_mode(unsigned int id);
  243. int omap_mcbsp_request(unsigned int id);
  244. void omap_mcbsp_free(unsigned int id);
  245. void omap_mcbsp_start(unsigned int id, int tx, int rx);
  246. void omap_mcbsp_stop(unsigned int id, int tx, int rx);
  247. /* McBSP functional clock source changing function */
  248. int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id);
  249. /* McBSP signal muxing API */
  250. void omap2_mcbsp1_mux_clkr_src(u8 mux);
  251. void omap2_mcbsp1_mux_fsr_src(u8 mux);
  252. int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream);
  253. int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream);
  254. /* Sidetone specific API */
  255. int omap_st_set_chgain(unsigned int id, int channel, s16 chgain);
  256. int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain);
  257. int omap_st_enable(unsigned int id);
  258. int omap_st_disable(unsigned int id);
  259. int omap_st_is_enabled(unsigned int id);
  260. #endif /* __ASOC_MCBSP_H */