mcbsp.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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/cpu.h>
  23. #include <plat/mcbsp.h>
  24. #include "mux.h"
  25. static void omap2_mcbsp2_mux_setup(void)
  26. {
  27. omap_mux_init_signal("eac_ac_sclk.mcbsp2_clkx", OMAP_PULL_ENA);
  28. omap_mux_init_signal("eac_ac_fs.mcbsp2_fsx", OMAP_PULL_ENA);
  29. omap_mux_init_signal("eac_ac_din.mcbsp2_dr", OMAP_PULL_ENA);
  30. omap_mux_init_signal("eac_ac_dout.mcbsp2_dx", OMAP_PULL_ENA);
  31. omap_mux_init_gpio(117, OMAP_PULL_ENA);
  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 = 0x80, /* The FIFO has 128 locations */
  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 = 0x500, /* The FIFO has 1024 + 256 locations */
  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 = 0x80, /* The FIFO has 128 locations */
  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 = 0x80, /* The FIFO has 128 locations */
  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 = 0x80, /* The FIFO has 128 locations */
  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. .tx_irq = OMAP44XX_IRQ_MCBSP1,
  183. .ops = &omap2_mcbsp_ops,
  184. },
  185. {
  186. .phys_base = OMAP44XX_MCBSP2_BASE,
  187. .dma_rx_sync = OMAP44XX_DMA_MCBSP2_RX,
  188. .dma_tx_sync = OMAP44XX_DMA_MCBSP2_TX,
  189. .tx_irq = OMAP44XX_IRQ_MCBSP2,
  190. .ops = &omap2_mcbsp_ops,
  191. },
  192. {
  193. .phys_base = OMAP44XX_MCBSP3_BASE,
  194. .dma_rx_sync = OMAP44XX_DMA_MCBSP3_RX,
  195. .dma_tx_sync = OMAP44XX_DMA_MCBSP3_TX,
  196. .tx_irq = OMAP44XX_IRQ_MCBSP3,
  197. .ops = &omap2_mcbsp_ops,
  198. },
  199. {
  200. .phys_base = OMAP44XX_MCBSP4_BASE,
  201. .dma_rx_sync = OMAP44XX_DMA_MCBSP4_RX,
  202. .dma_tx_sync = OMAP44XX_DMA_MCBSP4_TX,
  203. .tx_irq = OMAP44XX_IRQ_MCBSP4,
  204. .ops = &omap2_mcbsp_ops,
  205. },
  206. };
  207. #define OMAP44XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap44xx_mcbsp_pdata)
  208. #define OMAP44XX_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
  209. static int __init omap2_mcbsp_init(void)
  210. {
  211. if (cpu_is_omap2420()) {
  212. omap_mcbsp_count = OMAP2420_MCBSP_PDATA_SZ;
  213. omap_mcbsp_cache_size = OMAP2420_MCBSP_REG_NUM * sizeof(u16);
  214. } else if (cpu_is_omap2430()) {
  215. omap_mcbsp_count = OMAP2430_MCBSP_PDATA_SZ;
  216. omap_mcbsp_cache_size = OMAP2430_MCBSP_REG_NUM * sizeof(u32);
  217. } else if (cpu_is_omap34xx()) {
  218. omap_mcbsp_count = OMAP34XX_MCBSP_PDATA_SZ;
  219. omap_mcbsp_cache_size = OMAP34XX_MCBSP_REG_NUM * sizeof(u32);
  220. } else if (cpu_is_omap44xx()) {
  221. omap_mcbsp_count = OMAP44XX_MCBSP_PDATA_SZ;
  222. omap_mcbsp_cache_size = OMAP44XX_MCBSP_REG_NUM * sizeof(u32);
  223. }
  224. mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *),
  225. GFP_KERNEL);
  226. if (!mcbsp_ptr)
  227. return -ENOMEM;
  228. if (cpu_is_omap2420())
  229. omap_mcbsp_register_board_cfg(omap2420_mcbsp_pdata,
  230. OMAP2420_MCBSP_PDATA_SZ);
  231. if (cpu_is_omap2430())
  232. omap_mcbsp_register_board_cfg(omap2430_mcbsp_pdata,
  233. OMAP2430_MCBSP_PDATA_SZ);
  234. if (cpu_is_omap34xx())
  235. omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata,
  236. OMAP34XX_MCBSP_PDATA_SZ);
  237. if (cpu_is_omap44xx())
  238. omap_mcbsp_register_board_cfg(omap44xx_mcbsp_pdata,
  239. OMAP44XX_MCBSP_PDATA_SZ);
  240. return omap_mcbsp_init();
  241. }
  242. arch_initcall(omap2_mcbsp_init);