mcbsp.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * linux/arch/arm/mach-omap1/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. #include <mach/dsp_common.h>
  26. #define DPS_RSTCT2_PER_EN (1 << 0)
  27. #define DSP_RSTCT2_WD_PER_EN (1 << 1)
  28. #if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX)
  29. const char *clk_names[] = { "dsp_ck", "api_ck", "dspxor_ck" };
  30. #endif
  31. static void omap1_mcbsp_request(unsigned int id)
  32. {
  33. /*
  34. * On 1510, 1610 and 1710, McBSP1 and McBSP3
  35. * are DSP public peripherals.
  36. */
  37. if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3) {
  38. omap_dsp_request_mem();
  39. /*
  40. * DSP external peripheral reset
  41. * FIXME: This should be moved to dsp code
  42. */
  43. __raw_writew(__raw_readw(DSP_RSTCT2) | DPS_RSTCT2_PER_EN |
  44. DSP_RSTCT2_WD_PER_EN, DSP_RSTCT2);
  45. }
  46. }
  47. static void omap1_mcbsp_free(unsigned int id)
  48. {
  49. if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3)
  50. omap_dsp_release_mem();
  51. }
  52. static struct omap_mcbsp_ops omap1_mcbsp_ops = {
  53. .request = omap1_mcbsp_request,
  54. .free = omap1_mcbsp_free,
  55. };
  56. #ifdef CONFIG_ARCH_OMAP730
  57. static struct omap_mcbsp_platform_data omap730_mcbsp_pdata[] = {
  58. {
  59. .phys_base = OMAP730_MCBSP1_BASE,
  60. .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
  61. .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
  62. .rx_irq = INT_730_McBSP1RX,
  63. .tx_irq = INT_730_McBSP1TX,
  64. .ops = &omap1_mcbsp_ops,
  65. },
  66. {
  67. .phys_base = OMAP730_MCBSP2_BASE,
  68. .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
  69. .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
  70. .rx_irq = INT_730_McBSP2RX,
  71. .tx_irq = INT_730_McBSP2TX,
  72. .ops = &omap1_mcbsp_ops,
  73. },
  74. };
  75. #define OMAP730_MCBSP_PDATA_SZ ARRAY_SIZE(omap730_mcbsp_pdata)
  76. #else
  77. #define omap730_mcbsp_pdata NULL
  78. #define OMAP730_MCBSP_PDATA_SZ 0
  79. #endif
  80. #ifdef CONFIG_ARCH_OMAP15XX
  81. static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = {
  82. {
  83. .phys_base = OMAP1510_MCBSP1_BASE,
  84. .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
  85. .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
  86. .rx_irq = INT_McBSP1RX,
  87. .tx_irq = INT_McBSP1TX,
  88. .ops = &omap1_mcbsp_ops,
  89. .clk_names = clk_names,
  90. .num_clks = 3,
  91. },
  92. {
  93. .phys_base = OMAP1510_MCBSP2_BASE,
  94. .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
  95. .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
  96. .rx_irq = INT_1510_SPI_RX,
  97. .tx_irq = INT_1510_SPI_TX,
  98. .ops = &omap1_mcbsp_ops,
  99. },
  100. {
  101. .phys_base = OMAP1510_MCBSP3_BASE,
  102. .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
  103. .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
  104. .rx_irq = INT_McBSP3RX,
  105. .tx_irq = INT_McBSP3TX,
  106. .ops = &omap1_mcbsp_ops,
  107. .clk_names = clk_names,
  108. .num_clks = 3,
  109. },
  110. };
  111. #define OMAP15XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap15xx_mcbsp_pdata)
  112. #else
  113. #define omap15xx_mcbsp_pdata NULL
  114. #define OMAP15XX_MCBSP_PDATA_SZ 0
  115. #endif
  116. #ifdef CONFIG_ARCH_OMAP16XX
  117. static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {
  118. {
  119. .phys_base = OMAP1610_MCBSP1_BASE,
  120. .dma_rx_sync = OMAP_DMA_MCBSP1_RX,
  121. .dma_tx_sync = OMAP_DMA_MCBSP1_TX,
  122. .rx_irq = INT_McBSP1RX,
  123. .tx_irq = INT_McBSP1TX,
  124. .ops = &omap1_mcbsp_ops,
  125. .clk_names = clk_names,
  126. .num_clks = 3,
  127. },
  128. {
  129. .phys_base = OMAP1610_MCBSP2_BASE,
  130. .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
  131. .dma_tx_sync = OMAP_DMA_MCBSP2_TX,
  132. .rx_irq = INT_1610_McBSP2_RX,
  133. .tx_irq = INT_1610_McBSP2_TX,
  134. .ops = &omap1_mcbsp_ops,
  135. },
  136. {
  137. .phys_base = OMAP1610_MCBSP3_BASE,
  138. .dma_rx_sync = OMAP_DMA_MCBSP3_RX,
  139. .dma_tx_sync = OMAP_DMA_MCBSP3_TX,
  140. .rx_irq = INT_McBSP3RX,
  141. .tx_irq = INT_McBSP3TX,
  142. .ops = &omap1_mcbsp_ops,
  143. .clk_names = clk_names,
  144. .num_clks = 3,
  145. },
  146. };
  147. #define OMAP16XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap16xx_mcbsp_pdata)
  148. #else
  149. #define omap16xx_mcbsp_pdata NULL
  150. #define OMAP16XX_MCBSP_PDATA_SZ 0
  151. #endif
  152. int __init omap1_mcbsp_init(void)
  153. {
  154. if (cpu_is_omap730())
  155. omap_mcbsp_count = OMAP730_MCBSP_PDATA_SZ;
  156. if (cpu_is_omap15xx())
  157. omap_mcbsp_count = OMAP15XX_MCBSP_PDATA_SZ;
  158. if (cpu_is_omap16xx())
  159. omap_mcbsp_count = OMAP16XX_MCBSP_PDATA_SZ;
  160. mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *),
  161. GFP_KERNEL);
  162. if (!mcbsp_ptr)
  163. return -ENOMEM;
  164. if (cpu_is_omap730())
  165. omap_mcbsp_register_board_cfg(omap730_mcbsp_pdata,
  166. OMAP730_MCBSP_PDATA_SZ);
  167. if (cpu_is_omap15xx())
  168. omap_mcbsp_register_board_cfg(omap15xx_mcbsp_pdata,
  169. OMAP15XX_MCBSP_PDATA_SZ);
  170. if (cpu_is_omap16xx())
  171. omap_mcbsp_register_board_cfg(omap16xx_mcbsp_pdata,
  172. OMAP16XX_MCBSP_PDATA_SZ);
  173. return omap_mcbsp_init();
  174. }
  175. arch_initcall(omap1_mcbsp_init);