mcbsp.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. /*
  2. * arch/arm/plat-omap/include/mach/mcbsp.h
  3. *
  4. * Defines for Multi-Channel Buffered Serial Port
  5. *
  6. * Copyright (C) 2002 RidgeRun, Inc.
  7. * Author: Steve Johnson
  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 __ASM_ARCH_OMAP_MCBSP_H
  25. #define __ASM_ARCH_OMAP_MCBSP_H
  26. #include <linux/completion.h>
  27. #include <linux/spinlock.h>
  28. #include <mach/hardware.h>
  29. #include <plat/clock.h>
  30. /* macro for building platform_device for McBSP ports */
  31. #define OMAP_MCBSP_PLATFORM_DEVICE(port_nr) \
  32. static struct platform_device omap_mcbsp##port_nr = { \
  33. .name = "omap-mcbsp-dai", \
  34. .id = OMAP_MCBSP##port_nr, \
  35. }
  36. #define OMAP7XX_MCBSP1_BASE 0xfffb1000
  37. #define OMAP7XX_MCBSP2_BASE 0xfffb1800
  38. #define OMAP1510_MCBSP1_BASE 0xe1011800
  39. #define OMAP1510_MCBSP2_BASE 0xfffb1000
  40. #define OMAP1510_MCBSP3_BASE 0xe1017000
  41. #define OMAP1610_MCBSP1_BASE 0xe1011800
  42. #define OMAP1610_MCBSP2_BASE 0xfffb1000
  43. #define OMAP1610_MCBSP3_BASE 0xe1017000
  44. #define OMAP24XX_MCBSP1_BASE 0x48074000
  45. #define OMAP24XX_MCBSP2_BASE 0x48076000
  46. #define OMAP2430_MCBSP3_BASE 0x4808c000
  47. #define OMAP2430_MCBSP4_BASE 0x4808e000
  48. #define OMAP2430_MCBSP5_BASE 0x48096000
  49. #define OMAP34XX_MCBSP1_BASE 0x48074000
  50. #define OMAP34XX_MCBSP2_BASE 0x49022000
  51. #define OMAP34XX_MCBSP2_ST_BASE 0x49028000
  52. #define OMAP34XX_MCBSP3_BASE 0x49024000
  53. #define OMAP34XX_MCBSP3_ST_BASE 0x4902A000
  54. #define OMAP34XX_MCBSP3_BASE 0x49024000
  55. #define OMAP34XX_MCBSP4_BASE 0x49026000
  56. #define OMAP34XX_MCBSP5_BASE 0x48096000
  57. #define OMAP44XX_MCBSP1_BASE 0x49022000
  58. #define OMAP44XX_MCBSP2_BASE 0x49024000
  59. #define OMAP44XX_MCBSP3_BASE 0x49026000
  60. #define OMAP44XX_MCBSP4_BASE 0x48096000
  61. #if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
  62. #define OMAP_MCBSP_REG_DRR2 0x00
  63. #define OMAP_MCBSP_REG_DRR1 0x02
  64. #define OMAP_MCBSP_REG_DXR2 0x04
  65. #define OMAP_MCBSP_REG_DXR1 0x06
  66. #define OMAP_MCBSP_REG_SPCR2 0x08
  67. #define OMAP_MCBSP_REG_SPCR1 0x0a
  68. #define OMAP_MCBSP_REG_RCR2 0x0c
  69. #define OMAP_MCBSP_REG_RCR1 0x0e
  70. #define OMAP_MCBSP_REG_XCR2 0x10
  71. #define OMAP_MCBSP_REG_XCR1 0x12
  72. #define OMAP_MCBSP_REG_SRGR2 0x14
  73. #define OMAP_MCBSP_REG_SRGR1 0x16
  74. #define OMAP_MCBSP_REG_MCR2 0x18
  75. #define OMAP_MCBSP_REG_MCR1 0x1a
  76. #define OMAP_MCBSP_REG_RCERA 0x1c
  77. #define OMAP_MCBSP_REG_RCERB 0x1e
  78. #define OMAP_MCBSP_REG_XCERA 0x20
  79. #define OMAP_MCBSP_REG_XCERB 0x22
  80. #define OMAP_MCBSP_REG_PCR0 0x24
  81. #define OMAP_MCBSP_REG_RCERC 0x26
  82. #define OMAP_MCBSP_REG_RCERD 0x28
  83. #define OMAP_MCBSP_REG_XCERC 0x2A
  84. #define OMAP_MCBSP_REG_XCERD 0x2C
  85. #define OMAP_MCBSP_REG_RCERE 0x2E
  86. #define OMAP_MCBSP_REG_RCERF 0x30
  87. #define OMAP_MCBSP_REG_XCERE 0x32
  88. #define OMAP_MCBSP_REG_XCERF 0x34
  89. #define OMAP_MCBSP_REG_RCERG 0x36
  90. #define OMAP_MCBSP_REG_RCERH 0x38
  91. #define OMAP_MCBSP_REG_XCERG 0x3A
  92. #define OMAP_MCBSP_REG_XCERH 0x3C
  93. /* Dummy defines, these are not available on omap1 */
  94. #define OMAP_MCBSP_REG_XCCR 0x00
  95. #define OMAP_MCBSP_REG_RCCR 0x00
  96. #define AUDIO_MCBSP_DATAWRITE (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1)
  97. #define AUDIO_MCBSP_DATAREAD (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1)
  98. #define AUDIO_MCBSP OMAP_MCBSP1
  99. #define AUDIO_DMA_TX OMAP_DMA_MCBSP1_TX
  100. #define AUDIO_DMA_RX OMAP_DMA_MCBSP1_RX
  101. #else
  102. #define OMAP_MCBSP_REG_DRR2 0x00
  103. #define OMAP_MCBSP_REG_DRR1 0x04
  104. #define OMAP_MCBSP_REG_DXR2 0x08
  105. #define OMAP_MCBSP_REG_DXR1 0x0C
  106. #define OMAP_MCBSP_REG_DRR 0x00
  107. #define OMAP_MCBSP_REG_DXR 0x08
  108. #define OMAP_MCBSP_REG_SPCR2 0x10
  109. #define OMAP_MCBSP_REG_SPCR1 0x14
  110. #define OMAP_MCBSP_REG_RCR2 0x18
  111. #define OMAP_MCBSP_REG_RCR1 0x1C
  112. #define OMAP_MCBSP_REG_XCR2 0x20
  113. #define OMAP_MCBSP_REG_XCR1 0x24
  114. #define OMAP_MCBSP_REG_SRGR2 0x28
  115. #define OMAP_MCBSP_REG_SRGR1 0x2C
  116. #define OMAP_MCBSP_REG_MCR2 0x30
  117. #define OMAP_MCBSP_REG_MCR1 0x34
  118. #define OMAP_MCBSP_REG_RCERA 0x38
  119. #define OMAP_MCBSP_REG_RCERB 0x3C
  120. #define OMAP_MCBSP_REG_XCERA 0x40
  121. #define OMAP_MCBSP_REG_XCERB 0x44
  122. #define OMAP_MCBSP_REG_PCR0 0x48
  123. #define OMAP_MCBSP_REG_RCERC 0x4C
  124. #define OMAP_MCBSP_REG_RCERD 0x50
  125. #define OMAP_MCBSP_REG_XCERC 0x54
  126. #define OMAP_MCBSP_REG_XCERD 0x58
  127. #define OMAP_MCBSP_REG_RCERE 0x5C
  128. #define OMAP_MCBSP_REG_RCERF 0x60
  129. #define OMAP_MCBSP_REG_XCERE 0x64
  130. #define OMAP_MCBSP_REG_XCERF 0x68
  131. #define OMAP_MCBSP_REG_RCERG 0x6C
  132. #define OMAP_MCBSP_REG_RCERH 0x70
  133. #define OMAP_MCBSP_REG_XCERG 0x74
  134. #define OMAP_MCBSP_REG_XCERH 0x78
  135. #define OMAP_MCBSP_REG_SYSCON 0x8C
  136. #define OMAP_MCBSP_REG_THRSH2 0x90
  137. #define OMAP_MCBSP_REG_THRSH1 0x94
  138. #define OMAP_MCBSP_REG_IRQST 0xA0
  139. #define OMAP_MCBSP_REG_IRQEN 0xA4
  140. #define OMAP_MCBSP_REG_WAKEUPEN 0xA8
  141. #define OMAP_MCBSP_REG_XCCR 0xAC
  142. #define OMAP_MCBSP_REG_RCCR 0xB0
  143. #define OMAP_MCBSP_REG_XBUFFSTAT 0xB4
  144. #define OMAP_MCBSP_REG_RBUFFSTAT 0xB8
  145. #define OMAP_MCBSP_REG_SSELCR 0xBC
  146. #define OMAP_ST_REG_REV 0x00
  147. #define OMAP_ST_REG_SYSCONFIG 0x10
  148. #define OMAP_ST_REG_IRQSTATUS 0x18
  149. #define OMAP_ST_REG_IRQENABLE 0x1C
  150. #define OMAP_ST_REG_SGAINCR 0x24
  151. #define OMAP_ST_REG_SFIRCR 0x28
  152. #define OMAP_ST_REG_SSELCR 0x2C
  153. #define AUDIO_MCBSP_DATAWRITE (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1)
  154. #define AUDIO_MCBSP_DATAREAD (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1)
  155. #define AUDIO_MCBSP OMAP_MCBSP2
  156. #define AUDIO_DMA_TX OMAP24XX_DMA_MCBSP2_TX
  157. #define AUDIO_DMA_RX OMAP24XX_DMA_MCBSP2_RX
  158. #endif
  159. /************************** McBSP SPCR1 bit definitions ***********************/
  160. #define RRST 0x0001
  161. #define RRDY 0x0002
  162. #define RFULL 0x0004
  163. #define RSYNC_ERR 0x0008
  164. #define RINTM(value) ((value)<<4) /* bits 4:5 */
  165. #define ABIS 0x0040
  166. #define DXENA 0x0080
  167. #define CLKSTP(value) ((value)<<11) /* bits 11:12 */
  168. #define RJUST(value) ((value)<<13) /* bits 13:14 */
  169. #define ALB 0x8000
  170. #define DLB 0x8000
  171. /************************** McBSP SPCR2 bit definitions ***********************/
  172. #define XRST 0x0001
  173. #define XRDY 0x0002
  174. #define XEMPTY 0x0004
  175. #define XSYNC_ERR 0x0008
  176. #define XINTM(value) ((value)<<4) /* bits 4:5 */
  177. #define GRST 0x0040
  178. #define FRST 0x0080
  179. #define SOFT 0x0100
  180. #define FREE 0x0200
  181. /************************** McBSP PCR bit definitions *************************/
  182. #define CLKRP 0x0001
  183. #define CLKXP 0x0002
  184. #define FSRP 0x0004
  185. #define FSXP 0x0008
  186. #define DR_STAT 0x0010
  187. #define DX_STAT 0x0020
  188. #define CLKS_STAT 0x0040
  189. #define SCLKME 0x0080
  190. #define CLKRM 0x0100
  191. #define CLKXM 0x0200
  192. #define FSRM 0x0400
  193. #define FSXM 0x0800
  194. #define RIOEN 0x1000
  195. #define XIOEN 0x2000
  196. #define IDLE_EN 0x4000
  197. /************************** McBSP RCR1 bit definitions ************************/
  198. #define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */
  199. #define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */
  200. /************************** McBSP XCR1 bit definitions ************************/
  201. #define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */
  202. #define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */
  203. /*************************** McBSP RCR2 bit definitions ***********************/
  204. #define RDATDLY(value) (value) /* Bits 0:1 */
  205. #define RFIG 0x0004
  206. #define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */
  207. #define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */
  208. #define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */
  209. #define RPHASE 0x8000
  210. /*************************** McBSP XCR2 bit definitions ***********************/
  211. #define XDATDLY(value) (value) /* Bits 0:1 */
  212. #define XFIG 0x0004
  213. #define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */
  214. #define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */
  215. #define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */
  216. #define XPHASE 0x8000
  217. /************************* McBSP SRGR1 bit definitions ************************/
  218. #define CLKGDV(value) (value) /* Bits 0:7 */
  219. #define FWID(value) ((value)<<8) /* Bits 8:15 */
  220. /************************* McBSP SRGR2 bit definitions ************************/
  221. #define FPER(value) (value) /* Bits 0:11 */
  222. #define FSGM 0x1000
  223. #define CLKSM 0x2000
  224. #define CLKSP 0x4000
  225. #define GSYNC 0x8000
  226. /************************* McBSP MCR1 bit definitions *************************/
  227. #define RMCM 0x0001
  228. #define RCBLK(value) ((value)<<2) /* Bits 2:4 */
  229. #define RPABLK(value) ((value)<<5) /* Bits 5:6 */
  230. #define RPBBLK(value) ((value)<<7) /* Bits 7:8 */
  231. /************************* McBSP MCR2 bit definitions *************************/
  232. #define XMCM(value) (value) /* Bits 0:1 */
  233. #define XCBLK(value) ((value)<<2) /* Bits 2:4 */
  234. #define XPABLK(value) ((value)<<5) /* Bits 5:6 */
  235. #define XPBBLK(value) ((value)<<7) /* Bits 7:8 */
  236. /*********************** McBSP XCCR bit definitions *************************/
  237. #define EXTCLKGATE 0x8000
  238. #define PPCONNECT 0x4000
  239. #define DXENDLY(value) ((value)<<12) /* Bits 12:13 */
  240. #define XFULL_CYCLE 0x0800
  241. #define DILB 0x0020
  242. #define XDMAEN 0x0008
  243. #define XDISABLE 0x0001
  244. /********************** McBSP RCCR bit definitions *************************/
  245. #define RFULL_CYCLE 0x0800
  246. #define RDMAEN 0x0008
  247. #define RDISABLE 0x0001
  248. /********************** McBSP SYSCONFIG bit definitions ********************/
  249. #define CLOCKACTIVITY(value) ((value)<<8)
  250. #define SIDLEMODE(value) ((value)<<3)
  251. #define ENAWAKEUP 0x0004
  252. #define SOFTRST 0x0002
  253. /********************** McBSP SSELCR bit definitions ***********************/
  254. #define SIDETONEEN 0x0400
  255. /********************** McBSP Sidetone SYSCONFIG bit definitions ***********/
  256. #define ST_AUTOIDLE 0x0001
  257. /********************** McBSP Sidetone SGAINCR bit definitions *************/
  258. #define ST_CH1GAIN(value) ((value<<16)) /* Bits 16:31 */
  259. #define ST_CH0GAIN(value) (value) /* Bits 0:15 */
  260. /********************** McBSP Sidetone SFIRCR bit definitions **************/
  261. #define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
  262. /********************** McBSP Sidetone SSELCR bit definitions **************/
  263. #define ST_COEFFWRDONE 0x0004
  264. #define ST_COEFFWREN 0x0002
  265. #define ST_SIDETONEEN 0x0001
  266. /********************** McBSP DMA operating modes **************************/
  267. #define MCBSP_DMA_MODE_ELEMENT 0
  268. #define MCBSP_DMA_MODE_THRESHOLD 1
  269. #define MCBSP_DMA_MODE_FRAME 2
  270. /********************** McBSP WAKEUPEN bit definitions *********************/
  271. #define XEMPTYEOFEN 0x4000
  272. #define XRDYEN 0x0400
  273. #define XEOFEN 0x0200
  274. #define XFSXEN 0x0100
  275. #define XSYNCERREN 0x0080
  276. #define RRDYEN 0x0008
  277. #define REOFEN 0x0004
  278. #define RFSREN 0x0002
  279. #define RSYNCERREN 0x0001
  280. /* CLKR signal muxing options */
  281. #define CLKR_SRC_CLKR 0
  282. #define CLKR_SRC_CLKX 1
  283. /* FSR signal muxing options */
  284. #define FSR_SRC_FSR 0
  285. #define FSR_SRC_FSX 1
  286. /* McBSP functional clock sources */
  287. #define MCBSP_CLKS_PRCM_SRC 0
  288. #define MCBSP_CLKS_PAD_SRC 1
  289. /* we don't do multichannel for now */
  290. struct omap_mcbsp_reg_cfg {
  291. u16 spcr2;
  292. u16 spcr1;
  293. u16 rcr2;
  294. u16 rcr1;
  295. u16 xcr2;
  296. u16 xcr1;
  297. u16 srgr2;
  298. u16 srgr1;
  299. u16 mcr2;
  300. u16 mcr1;
  301. u16 pcr0;
  302. u16 rcerc;
  303. u16 rcerd;
  304. u16 xcerc;
  305. u16 xcerd;
  306. u16 rcere;
  307. u16 rcerf;
  308. u16 xcere;
  309. u16 xcerf;
  310. u16 rcerg;
  311. u16 rcerh;
  312. u16 xcerg;
  313. u16 xcerh;
  314. u16 xccr;
  315. u16 rccr;
  316. };
  317. typedef enum {
  318. OMAP_MCBSP1 = 0,
  319. OMAP_MCBSP2,
  320. OMAP_MCBSP3,
  321. OMAP_MCBSP4,
  322. OMAP_MCBSP5
  323. } omap_mcbsp_id;
  324. typedef int __bitwise omap_mcbsp_io_type_t;
  325. #define OMAP_MCBSP_IRQ_IO ((__force omap_mcbsp_io_type_t) 1)
  326. #define OMAP_MCBSP_POLL_IO ((__force omap_mcbsp_io_type_t) 2)
  327. typedef enum {
  328. OMAP_MCBSP_WORD_8 = 0,
  329. OMAP_MCBSP_WORD_12,
  330. OMAP_MCBSP_WORD_16,
  331. OMAP_MCBSP_WORD_20,
  332. OMAP_MCBSP_WORD_24,
  333. OMAP_MCBSP_WORD_32,
  334. } omap_mcbsp_word_length;
  335. typedef enum {
  336. OMAP_MCBSP_CLK_RISING = 0,
  337. OMAP_MCBSP_CLK_FALLING,
  338. } omap_mcbsp_clk_polarity;
  339. typedef enum {
  340. OMAP_MCBSP_FS_ACTIVE_HIGH = 0,
  341. OMAP_MCBSP_FS_ACTIVE_LOW,
  342. } omap_mcbsp_fs_polarity;
  343. typedef enum {
  344. OMAP_MCBSP_CLK_STP_MODE_NO_DELAY = 0,
  345. OMAP_MCBSP_CLK_STP_MODE_DELAY,
  346. } omap_mcbsp_clk_stp_mode;
  347. /******* SPI specific mode **********/
  348. typedef enum {
  349. OMAP_MCBSP_SPI_MASTER = 0,
  350. OMAP_MCBSP_SPI_SLAVE,
  351. } omap_mcbsp_spi_mode;
  352. struct omap_mcbsp_spi_cfg {
  353. omap_mcbsp_spi_mode spi_mode;
  354. omap_mcbsp_clk_polarity rx_clock_polarity;
  355. omap_mcbsp_clk_polarity tx_clock_polarity;
  356. omap_mcbsp_fs_polarity fsx_polarity;
  357. u8 clk_div;
  358. omap_mcbsp_clk_stp_mode clk_stp_mode;
  359. omap_mcbsp_word_length word_length;
  360. };
  361. /* Platform specific configuration */
  362. struct omap_mcbsp_ops {
  363. void (*request)(unsigned int);
  364. void (*free)(unsigned int);
  365. int (*set_clks_src)(u8, u8);
  366. };
  367. struct omap_mcbsp_platform_data {
  368. unsigned long phys_base;
  369. u8 dma_rx_sync, dma_tx_sync;
  370. u16 rx_irq, tx_irq;
  371. struct omap_mcbsp_ops *ops;
  372. #ifdef CONFIG_ARCH_OMAP3
  373. /* Sidetone block for McBSP 2 and 3 */
  374. unsigned long phys_base_st;
  375. u16 buffer_size;
  376. #endif
  377. };
  378. struct omap_mcbsp_st_data {
  379. void __iomem *io_base_st;
  380. bool running;
  381. bool enabled;
  382. s16 taps[128]; /* Sidetone filter coefficients */
  383. int nr_taps; /* Number of filter coefficients in use */
  384. s16 ch0gain;
  385. s16 ch1gain;
  386. };
  387. struct omap_mcbsp {
  388. struct device *dev;
  389. unsigned long phys_base;
  390. void __iomem *io_base;
  391. u8 id;
  392. u8 free;
  393. omap_mcbsp_word_length rx_word_length;
  394. omap_mcbsp_word_length tx_word_length;
  395. omap_mcbsp_io_type_t io_type; /* IRQ or poll */
  396. /* IRQ based TX/RX */
  397. int rx_irq;
  398. int tx_irq;
  399. /* DMA stuff */
  400. u8 dma_rx_sync;
  401. short dma_rx_lch;
  402. u8 dma_tx_sync;
  403. short dma_tx_lch;
  404. /* Completion queues */
  405. struct completion tx_irq_completion;
  406. struct completion rx_irq_completion;
  407. struct completion tx_dma_completion;
  408. struct completion rx_dma_completion;
  409. /* Protect the field .free, while checking if the mcbsp is in use */
  410. spinlock_t lock;
  411. struct omap_mcbsp_platform_data *pdata;
  412. struct clk *iclk;
  413. struct clk *fclk;
  414. #ifdef CONFIG_ARCH_OMAP3
  415. struct omap_mcbsp_st_data *st_data;
  416. int dma_op_mode;
  417. u16 max_tx_thres;
  418. u16 max_rx_thres;
  419. #endif
  420. void *reg_cache;
  421. };
  422. extern struct omap_mcbsp **mcbsp_ptr;
  423. extern int omap_mcbsp_count, omap_mcbsp_cache_size;
  424. #define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
  425. #define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
  426. int omap_mcbsp_init(void);
  427. void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
  428. int size);
  429. void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config);
  430. #ifdef CONFIG_ARCH_OMAP3
  431. void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold);
  432. void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold);
  433. u16 omap_mcbsp_get_max_tx_threshold(unsigned int id);
  434. u16 omap_mcbsp_get_max_rx_threshold(unsigned int id);
  435. u16 omap_mcbsp_get_fifo_size(unsigned int id);
  436. u16 omap_mcbsp_get_tx_delay(unsigned int id);
  437. u16 omap_mcbsp_get_rx_delay(unsigned int id);
  438. int omap_mcbsp_get_dma_op_mode(unsigned int id);
  439. #else
  440. static inline void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold)
  441. { }
  442. static inline void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold)
  443. { }
  444. static inline u16 omap_mcbsp_get_max_tx_threshold(unsigned int id) { return 0; }
  445. static inline u16 omap_mcbsp_get_max_rx_threshold(unsigned int id) { return 0; }
  446. static inline u16 omap_mcbsp_get_fifo_size(unsigned int id) { return 0; }
  447. static inline u16 omap_mcbsp_get_tx_delay(unsigned int id) { return 0; }
  448. static inline u16 omap_mcbsp_get_rx_delay(unsigned int id) { return 0; }
  449. static inline int omap_mcbsp_get_dma_op_mode(unsigned int id) { return 0; }
  450. #endif
  451. int omap_mcbsp_request(unsigned int id);
  452. void omap_mcbsp_free(unsigned int id);
  453. void omap_mcbsp_start(unsigned int id, int tx, int rx);
  454. void omap_mcbsp_stop(unsigned int id, int tx, int rx);
  455. void omap_mcbsp_xmit_word(unsigned int id, u32 word);
  456. u32 omap_mcbsp_recv_word(unsigned int id);
  457. int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int length);
  458. int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int length);
  459. int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word);
  460. int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word);
  461. /* McBSP functional clock source changing function */
  462. extern int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id);
  463. /* SPI specific API */
  464. void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg);
  465. /* Polled read/write functions */
  466. int omap_mcbsp_pollread(unsigned int id, u16 * buf);
  467. int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
  468. int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
  469. /* McBSP signal muxing API */
  470. void omap2_mcbsp1_mux_clkr_src(u8 mux);
  471. void omap2_mcbsp1_mux_fsr_src(u8 mux);
  472. #ifdef CONFIG_ARCH_OMAP3
  473. /* Sidetone specific API */
  474. int omap_st_set_chgain(unsigned int id, int channel, s16 chgain);
  475. int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain);
  476. int omap_st_enable(unsigned int id);
  477. int omap_st_disable(unsigned int id);
  478. int omap_st_is_enabled(unsigned int id);
  479. #else
  480. static inline int omap_st_set_chgain(unsigned int id, int channel,
  481. s16 chgain) { return 0; }
  482. static inline int omap_st_get_chgain(unsigned int id, int channel,
  483. s16 *chgain) { return 0; }
  484. static inline int omap_st_enable(unsigned int id) { return 0; }
  485. static inline int omap_st_disable(unsigned int id) { return 0; }
  486. static inline int omap_st_is_enabled(unsigned int id) { return 0; }
  487. #endif
  488. #endif