mcbsp.c 5.9 KB

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