mcbsp.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /*
  2. * linux/arch/arm/mach-omap2/mcbsp.c
  3. *
  4. * Copyright (C) 2008 Instituto Nokia de Tecnologia
  5. * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * Multichannel mode not supported.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/init.h>
  15. #include <linux/clk.h>
  16. #include <linux/err.h>
  17. #include <linux/io.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/slab.h>
  20. #include <mach/irqs.h>
  21. #include <plat/dma.h>
  22. #include <plat/mux.h>
  23. #include <plat/cpu.h>
  24. #include <plat/mcbsp.h>
  25. static void omap2_mcbsp2_mux_setup(void)
  26. {
  27. omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
  28. omap_cfg_reg(R14_24XX_MCBSP2_FSX);
  29. omap_cfg_reg(W15_24XX_MCBSP2_DR);
  30. omap_cfg_reg(V15_24XX_MCBSP2_DX);
  31. omap_cfg_reg(V14_24XX_GPIO117);
  32. /*
  33. * TODO: Need to add MUX settings for OMAP 2430 SDP
  34. */
  35. }
  36. static void omap2_mcbsp_request(unsigned int id)
  37. {
  38. if (cpu_is_omap2420() && (id == OMAP_MCBSP2))
  39. omap2_mcbsp2_mux_setup();
  40. }
  41. static struct omap_mcbsp_ops omap2_mcbsp_ops = {
  42. .request = omap2_mcbsp_request,
  43. };
  44. #ifdef CONFIG_ARCH_OMAP2420
  45. static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
  46. {
  47. .phys_base = OMAP24XX_MCBSP1_BASE,
  48. .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
  49. .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
  50. .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
  51. .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
  52. .ops = &omap2_mcbsp_ops,
  53. },
  54. {
  55. .phys_base = OMAP24XX_MCBSP2_BASE,
  56. .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
  57. .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
  58. .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
  59. .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
  60. .ops = &omap2_mcbsp_ops,
  61. },
  62. };
  63. #define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata)
  64. #define OMAP2420_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
  65. #else
  66. #define omap2420_mcbsp_pdata NULL
  67. #define OMAP2420_MCBSP_PDATA_SZ 0
  68. #define OMAP2420_MCBSP_REG_NUM 0
  69. #endif
  70. #ifdef CONFIG_ARCH_OMAP2430
  71. static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
  72. {
  73. .phys_base = OMAP24XX_MCBSP1_BASE,
  74. .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
  75. .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
  76. .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
  77. .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
  78. .ops = &omap2_mcbsp_ops,
  79. },
  80. {
  81. .phys_base = OMAP24XX_MCBSP2_BASE,
  82. .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
  83. .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
  84. .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
  85. .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
  86. .ops = &omap2_mcbsp_ops,
  87. },
  88. {
  89. .phys_base = OMAP2430_MCBSP3_BASE,
  90. .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX,
  91. .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX,
  92. .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
  93. .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
  94. .ops = &omap2_mcbsp_ops,
  95. },
  96. {
  97. .phys_base = OMAP2430_MCBSP4_BASE,
  98. .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX,
  99. .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
  100. .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
  101. .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
  102. .ops = &omap2_mcbsp_ops,
  103. },
  104. {
  105. .phys_base = OMAP2430_MCBSP5_BASE,
  106. .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX,
  107. .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
  108. .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
  109. .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
  110. .ops = &omap2_mcbsp_ops,
  111. },
  112. };
  113. #define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata)
  114. #define OMAP2430_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
  115. #else
  116. #define omap2430_mcbsp_pdata NULL
  117. #define OMAP2430_MCBSP_PDATA_SZ 0
  118. #define OMAP2430_MCBSP_REG_NUM 0
  119. #endif
  120. #ifdef CONFIG_ARCH_OMAP3
  121. static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
  122. {
  123. .phys_base = OMAP34XX_MCBSP1_BASE,
  124. .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
  125. .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
  126. .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
  127. .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
  128. .ops = &omap2_mcbsp_ops,
  129. .buffer_size = 0x6F,
  130. },
  131. {
  132. .phys_base = OMAP34XX_MCBSP2_BASE,
  133. .phys_base_st = OMAP34XX_MCBSP2_ST_BASE,
  134. .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
  135. .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
  136. .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
  137. .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
  138. .ops = &omap2_mcbsp_ops,
  139. .buffer_size = 0x3FF,
  140. },
  141. {
  142. .phys_base = OMAP34XX_MCBSP3_BASE,
  143. .phys_base_st = OMAP34XX_MCBSP3_ST_BASE,
  144. .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX,
  145. .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX,
  146. .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
  147. .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
  148. .ops = &omap2_mcbsp_ops,
  149. .buffer_size = 0x6F,
  150. },
  151. {
  152. .phys_base = OMAP34XX_MCBSP4_BASE,
  153. .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX,
  154. .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
  155. .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
  156. .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
  157. .ops = &omap2_mcbsp_ops,
  158. .buffer_size = 0x6F,
  159. },
  160. {
  161. .phys_base = OMAP34XX_MCBSP5_BASE,
  162. .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX,
  163. .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
  164. .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
  165. .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
  166. .ops = &omap2_mcbsp_ops,
  167. .buffer_size = 0x6F,
  168. },
  169. };
  170. #define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata)
  171. #define OMAP34XX_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
  172. #else
  173. #define omap34xx_mcbsp_pdata NULL
  174. #define OMAP34XX_MCBSP_PDATA_SZ 0
  175. #define OMAP34XX_MCBSP_REG_NUM 0
  176. #endif
  177. static struct omap_mcbsp_platform_data omap44xx_mcbsp_pdata[] = {
  178. {
  179. .phys_base = OMAP44XX_MCBSP1_BASE,
  180. .dma_rx_sync = OMAP44XX_DMA_MCBSP1_RX,
  181. .dma_tx_sync = OMAP44XX_DMA_MCBSP1_TX,
  182. .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
  183. .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
  184. .ops = &omap2_mcbsp_ops,
  185. },
  186. {
  187. .phys_base = OMAP44XX_MCBSP2_BASE,
  188. .dma_rx_sync = OMAP44XX_DMA_MCBSP2_RX,
  189. .dma_tx_sync = OMAP44XX_DMA_MCBSP2_TX,
  190. .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
  191. .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
  192. .ops = &omap2_mcbsp_ops,
  193. },
  194. {
  195. .phys_base = OMAP44XX_MCBSP3_BASE,
  196. .dma_rx_sync = OMAP44XX_DMA_MCBSP3_RX,
  197. .dma_tx_sync = OMAP44XX_DMA_MCBSP3_TX,
  198. .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
  199. .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
  200. .ops = &omap2_mcbsp_ops,
  201. },
  202. {
  203. .phys_base = OMAP44XX_MCBSP4_BASE,
  204. .dma_rx_sync = OMAP44XX_DMA_MCBSP4_RX,
  205. .dma_tx_sync = OMAP44XX_DMA_MCBSP4_TX,
  206. .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
  207. .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
  208. .ops = &omap2_mcbsp_ops,
  209. },
  210. };
  211. #define OMAP44XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap44xx_mcbsp_pdata)
  212. #define OMAP44XX_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
  213. static int __init omap2_mcbsp_init(void)
  214. {
  215. if (cpu_is_omap2420()) {
  216. omap_mcbsp_count = OMAP2420_MCBSP_PDATA_SZ;
  217. omap_mcbsp_cache_size = OMAP2420_MCBSP_REG_NUM * sizeof(u16);
  218. } else if (cpu_is_omap2430()) {
  219. omap_mcbsp_count = OMAP2430_MCBSP_PDATA_SZ;
  220. omap_mcbsp_cache_size = OMAP2430_MCBSP_REG_NUM * sizeof(u32);
  221. } else if (cpu_is_omap34xx()) {
  222. omap_mcbsp_count = OMAP34XX_MCBSP_PDATA_SZ;
  223. omap_mcbsp_cache_size = OMAP34XX_MCBSP_REG_NUM * sizeof(u32);
  224. } else if (cpu_is_omap44xx()) {
  225. omap_mcbsp_count = OMAP44XX_MCBSP_PDATA_SZ;
  226. omap_mcbsp_cache_size = OMAP44XX_MCBSP_REG_NUM * sizeof(u32);
  227. }
  228. mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *),
  229. GFP_KERNEL);
  230. if (!mcbsp_ptr)
  231. return -ENOMEM;
  232. if (cpu_is_omap2420())
  233. omap_mcbsp_register_board_cfg(omap2420_mcbsp_pdata,
  234. OMAP2420_MCBSP_PDATA_SZ);
  235. if (cpu_is_omap2430())
  236. omap_mcbsp_register_board_cfg(omap2430_mcbsp_pdata,
  237. OMAP2430_MCBSP_PDATA_SZ);
  238. if (cpu_is_omap34xx())
  239. omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata,
  240. OMAP34XX_MCBSP_PDATA_SZ);
  241. if (cpu_is_omap44xx())
  242. omap_mcbsp_register_board_cfg(omap44xx_mcbsp_pdata,
  243. OMAP44XX_MCBSP_PDATA_SZ);
  244. return omap_mcbsp_init();
  245. }
  246. arch_initcall(omap2_mcbsp_init);