mcbsp.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. #ifdef CONFIG_ARCH_OMAP2420
  25. static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
  26. {
  27. .phys_base = OMAP24XX_MCBSP1_BASE,
  28. .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
  29. .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
  30. .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
  31. .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
  32. },
  33. {
  34. .phys_base = OMAP24XX_MCBSP2_BASE,
  35. .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
  36. .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
  37. .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
  38. .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
  39. },
  40. };
  41. #define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata)
  42. #define OMAP2420_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
  43. #else
  44. #define omap2420_mcbsp_pdata NULL
  45. #define OMAP2420_MCBSP_PDATA_SZ 0
  46. #define OMAP2420_MCBSP_REG_NUM 0
  47. #endif
  48. #ifdef CONFIG_ARCH_OMAP2430
  49. static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
  50. {
  51. .phys_base = OMAP24XX_MCBSP1_BASE,
  52. .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
  53. .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
  54. .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
  55. .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
  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. },
  64. {
  65. .phys_base = OMAP2430_MCBSP3_BASE,
  66. .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX,
  67. .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX,
  68. .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
  69. .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
  70. },
  71. {
  72. .phys_base = OMAP2430_MCBSP4_BASE,
  73. .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX,
  74. .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
  75. .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
  76. .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
  77. },
  78. {
  79. .phys_base = OMAP2430_MCBSP5_BASE,
  80. .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX,
  81. .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
  82. .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
  83. .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
  84. },
  85. };
  86. #define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata)
  87. #define OMAP2430_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
  88. #else
  89. #define omap2430_mcbsp_pdata NULL
  90. #define OMAP2430_MCBSP_PDATA_SZ 0
  91. #define OMAP2430_MCBSP_REG_NUM 0
  92. #endif
  93. #ifdef CONFIG_ARCH_OMAP3
  94. static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
  95. {
  96. .phys_base = OMAP34XX_MCBSP1_BASE,
  97. .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
  98. .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
  99. .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
  100. .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
  101. .buffer_size = 0x80, /* The FIFO has 128 locations */
  102. },
  103. {
  104. .phys_base = OMAP34XX_MCBSP2_BASE,
  105. .phys_base_st = OMAP34XX_MCBSP2_ST_BASE,
  106. .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
  107. .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
  108. .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
  109. .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
  110. .buffer_size = 0x500, /* The FIFO has 1024 + 256 locations */
  111. },
  112. {
  113. .phys_base = OMAP34XX_MCBSP3_BASE,
  114. .phys_base_st = OMAP34XX_MCBSP3_ST_BASE,
  115. .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX,
  116. .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX,
  117. .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
  118. .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
  119. .buffer_size = 0x80, /* The FIFO has 128 locations */
  120. },
  121. {
  122. .phys_base = OMAP34XX_MCBSP4_BASE,
  123. .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX,
  124. .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
  125. .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
  126. .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
  127. .buffer_size = 0x80, /* The FIFO has 128 locations */
  128. },
  129. {
  130. .phys_base = OMAP34XX_MCBSP5_BASE,
  131. .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX,
  132. .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
  133. .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
  134. .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
  135. .buffer_size = 0x80, /* The FIFO has 128 locations */
  136. },
  137. };
  138. #define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata)
  139. #define OMAP34XX_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
  140. #else
  141. #define omap34xx_mcbsp_pdata NULL
  142. #define OMAP34XX_MCBSP_PDATA_SZ 0
  143. #define OMAP34XX_MCBSP_REG_NUM 0
  144. #endif
  145. static struct omap_mcbsp_platform_data omap44xx_mcbsp_pdata[] = {
  146. {
  147. .phys_base = OMAP44XX_MCBSP1_BASE,
  148. .dma_rx_sync = OMAP44XX_DMA_MCBSP1_RX,
  149. .dma_tx_sync = OMAP44XX_DMA_MCBSP1_TX,
  150. .tx_irq = OMAP44XX_IRQ_MCBSP1,
  151. },
  152. {
  153. .phys_base = OMAP44XX_MCBSP2_BASE,
  154. .dma_rx_sync = OMAP44XX_DMA_MCBSP2_RX,
  155. .dma_tx_sync = OMAP44XX_DMA_MCBSP2_TX,
  156. .tx_irq = OMAP44XX_IRQ_MCBSP2,
  157. },
  158. {
  159. .phys_base = OMAP44XX_MCBSP3_BASE,
  160. .dma_rx_sync = OMAP44XX_DMA_MCBSP3_RX,
  161. .dma_tx_sync = OMAP44XX_DMA_MCBSP3_TX,
  162. .tx_irq = OMAP44XX_IRQ_MCBSP3,
  163. },
  164. {
  165. .phys_base = OMAP44XX_MCBSP4_BASE,
  166. .dma_rx_sync = OMAP44XX_DMA_MCBSP4_RX,
  167. .dma_tx_sync = OMAP44XX_DMA_MCBSP4_TX,
  168. .tx_irq = OMAP44XX_IRQ_MCBSP4,
  169. },
  170. };
  171. #define OMAP44XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap44xx_mcbsp_pdata)
  172. #define OMAP44XX_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
  173. static int __init omap2_mcbsp_init(void)
  174. {
  175. if (cpu_is_omap2420()) {
  176. omap_mcbsp_count = OMAP2420_MCBSP_PDATA_SZ;
  177. omap_mcbsp_cache_size = OMAP2420_MCBSP_REG_NUM * sizeof(u16);
  178. } else if (cpu_is_omap2430()) {
  179. omap_mcbsp_count = OMAP2430_MCBSP_PDATA_SZ;
  180. omap_mcbsp_cache_size = OMAP2430_MCBSP_REG_NUM * sizeof(u32);
  181. } else if (cpu_is_omap34xx()) {
  182. omap_mcbsp_count = OMAP34XX_MCBSP_PDATA_SZ;
  183. omap_mcbsp_cache_size = OMAP34XX_MCBSP_REG_NUM * sizeof(u32);
  184. } else if (cpu_is_omap44xx()) {
  185. omap_mcbsp_count = OMAP44XX_MCBSP_PDATA_SZ;
  186. omap_mcbsp_cache_size = OMAP44XX_MCBSP_REG_NUM * sizeof(u32);
  187. }
  188. mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *),
  189. GFP_KERNEL);
  190. if (!mcbsp_ptr)
  191. return -ENOMEM;
  192. if (cpu_is_omap2420())
  193. omap_mcbsp_register_board_cfg(omap2420_mcbsp_pdata,
  194. OMAP2420_MCBSP_PDATA_SZ);
  195. if (cpu_is_omap2430())
  196. omap_mcbsp_register_board_cfg(omap2430_mcbsp_pdata,
  197. OMAP2430_MCBSP_PDATA_SZ);
  198. if (cpu_is_omap34xx())
  199. omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata,
  200. OMAP34XX_MCBSP_PDATA_SZ);
  201. if (cpu_is_omap44xx())
  202. omap_mcbsp_register_board_cfg(omap44xx_mcbsp_pdata,
  203. OMAP44XX_MCBSP_PDATA_SZ);
  204. return omap_mcbsp_init();
  205. }
  206. arch_initcall(omap2_mcbsp_init);