mcbsp.c 7.3 KB

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