Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 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 | |
Tony Lindgren | dd7667a | 2009-01-15 13:09:51 +0200 | [diff] [blame] | 20 | #include <mach/irqs.h> |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 21 | #include <plat/dma.h> |
| 22 | #include <plat/mux.h> |
| 23 | #include <plat/cpu.h> |
| 24 | #include <plat/mcbsp.h> |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 25 | |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 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 | |
| 38 | static void omap2_mcbsp_request(unsigned int id) |
| 39 | { |
| 40 | if (cpu_is_omap2420() && (id == OMAP_MCBSP2)) |
| 41 | omap2_mcbsp2_mux_setup(); |
| 42 | } |
| 43 | |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 44 | static struct omap_mcbsp_ops omap2_mcbsp_ops = { |
| 45 | .request = omap2_mcbsp_request, |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 46 | }; |
| 47 | |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 48 | #ifdef CONFIG_ARCH_OMAP2420 |
| 49 | static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = { |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 50 | { |
Russell King | 6584690 | 2008-09-03 23:46:18 +0100 | [diff] [blame] | 51 | .phys_base = OMAP24XX_MCBSP1_BASE, |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 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 | .ops = &omap2_mcbsp_ops, |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 57 | }, |
| 58 | { |
Russell King | 6584690 | 2008-09-03 23:46:18 +0100 | [diff] [blame] | 59 | .phys_base = OMAP24XX_MCBSP2_BASE, |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 60 | .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX, |
| 61 | .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX, |
| 62 | .rx_irq = INT_24XX_MCBSP2_IRQ_RX, |
| 63 | .tx_irq = INT_24XX_MCBSP2_IRQ_TX, |
| 64 | .ops = &omap2_mcbsp_ops, |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 65 | }, |
| 66 | }; |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 67 | #define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata) |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 68 | #define OMAP2420_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1) |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 69 | #else |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 70 | #define omap2420_mcbsp_pdata NULL |
| 71 | #define OMAP2420_MCBSP_PDATA_SZ 0 |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 72 | #define OMAP2420_MCBSP_REG_NUM 0 |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 73 | #endif |
| 74 | |
| 75 | #ifdef CONFIG_ARCH_OMAP2430 |
| 76 | static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = { |
| 77 | { |
| 78 | .phys_base = OMAP24XX_MCBSP1_BASE, |
| 79 | .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX, |
| 80 | .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX, |
| 81 | .rx_irq = INT_24XX_MCBSP1_IRQ_RX, |
| 82 | .tx_irq = INT_24XX_MCBSP1_IRQ_TX, |
| 83 | .ops = &omap2_mcbsp_ops, |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 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, |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 92 | }, |
| 93 | { |
| 94 | .phys_base = OMAP2430_MCBSP3_BASE, |
| 95 | .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX, |
| 96 | .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX, |
| 97 | .rx_irq = INT_24XX_MCBSP3_IRQ_RX, |
| 98 | .tx_irq = INT_24XX_MCBSP3_IRQ_TX, |
| 99 | .ops = &omap2_mcbsp_ops, |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 100 | }, |
| 101 | { |
| 102 | .phys_base = OMAP2430_MCBSP4_BASE, |
| 103 | .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX, |
| 104 | .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX, |
| 105 | .rx_irq = INT_24XX_MCBSP4_IRQ_RX, |
| 106 | .tx_irq = INT_24XX_MCBSP4_IRQ_TX, |
| 107 | .ops = &omap2_mcbsp_ops, |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 108 | }, |
| 109 | { |
| 110 | .phys_base = OMAP2430_MCBSP5_BASE, |
| 111 | .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX, |
| 112 | .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX, |
| 113 | .rx_irq = INT_24XX_MCBSP5_IRQ_RX, |
| 114 | .tx_irq = INT_24XX_MCBSP5_IRQ_TX, |
| 115 | .ops = &omap2_mcbsp_ops, |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 116 | }, |
| 117 | }; |
| 118 | #define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata) |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 119 | #define OMAP2430_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1) |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 120 | #else |
| 121 | #define omap2430_mcbsp_pdata NULL |
| 122 | #define OMAP2430_MCBSP_PDATA_SZ 0 |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 123 | #define OMAP2430_MCBSP_REG_NUM 0 |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 124 | #endif |
| 125 | |
Tony Lindgren | a8eb7ca | 2010-02-12 12:26:48 -0800 | [diff] [blame] | 126 | #ifdef CONFIG_ARCH_OMAP3 |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 127 | static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = { |
| 128 | { |
Russell King | 6584690 | 2008-09-03 23:46:18 +0100 | [diff] [blame] | 129 | .phys_base = OMAP34XX_MCBSP1_BASE, |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 130 | .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX, |
| 131 | .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX, |
| 132 | .rx_irq = INT_24XX_MCBSP1_IRQ_RX, |
| 133 | .tx_irq = INT_24XX_MCBSP1_IRQ_TX, |
| 134 | .ops = &omap2_mcbsp_ops, |
Peter Ujfalusi | 7e4f943 | 2009-08-20 16:18:12 +0300 | [diff] [blame] | 135 | .buffer_size = 0x6F, |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 136 | }, |
| 137 | { |
Russell King | 6584690 | 2008-09-03 23:46:18 +0100 | [diff] [blame] | 138 | .phys_base = OMAP34XX_MCBSP2_BASE, |
Eero Nurkkala | d912fa9 | 2010-02-22 12:21:11 +0000 | [diff] [blame^] | 139 | .phys_base_st = OMAP34XX_MCBSP2_ST_BASE, |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 140 | .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX, |
| 141 | .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX, |
| 142 | .rx_irq = INT_24XX_MCBSP2_IRQ_RX, |
| 143 | .tx_irq = INT_24XX_MCBSP2_IRQ_TX, |
| 144 | .ops = &omap2_mcbsp_ops, |
Eduardo Valentin | a1a56f5f | 2009-08-20 16:18:11 +0300 | [diff] [blame] | 145 | .buffer_size = 0x3FF, |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 146 | }, |
Chandra Shekhar | 9c8e3a0 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 147 | { |
| 148 | .phys_base = OMAP34XX_MCBSP3_BASE, |
Eero Nurkkala | d912fa9 | 2010-02-22 12:21:11 +0000 | [diff] [blame^] | 149 | .phys_base_st = OMAP34XX_MCBSP3_ST_BASE, |
Chandra Shekhar | 9c8e3a0 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 150 | .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX, |
| 151 | .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX, |
| 152 | .rx_irq = INT_24XX_MCBSP3_IRQ_RX, |
| 153 | .tx_irq = INT_24XX_MCBSP3_IRQ_TX, |
| 154 | .ops = &omap2_mcbsp_ops, |
Peter Ujfalusi | 7e4f943 | 2009-08-20 16:18:12 +0300 | [diff] [blame] | 155 | .buffer_size = 0x6F, |
Chandra Shekhar | 9c8e3a0 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 156 | }, |
| 157 | { |
| 158 | .phys_base = OMAP34XX_MCBSP4_BASE, |
| 159 | .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX, |
| 160 | .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX, |
| 161 | .rx_irq = INT_24XX_MCBSP4_IRQ_RX, |
| 162 | .tx_irq = INT_24XX_MCBSP4_IRQ_TX, |
| 163 | .ops = &omap2_mcbsp_ops, |
Peter Ujfalusi | 7e4f943 | 2009-08-20 16:18:12 +0300 | [diff] [blame] | 164 | .buffer_size = 0x6F, |
Chandra Shekhar | 9c8e3a0 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 165 | }, |
| 166 | { |
| 167 | .phys_base = OMAP34XX_MCBSP5_BASE, |
| 168 | .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX, |
| 169 | .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX, |
| 170 | .rx_irq = INT_24XX_MCBSP5_IRQ_RX, |
| 171 | .tx_irq = INT_24XX_MCBSP5_IRQ_TX, |
| 172 | .ops = &omap2_mcbsp_ops, |
Peter Ujfalusi | 7e4f943 | 2009-08-20 16:18:12 +0300 | [diff] [blame] | 173 | .buffer_size = 0x6F, |
Chandra Shekhar | 9c8e3a0 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 174 | }, |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 175 | }; |
| 176 | #define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata) |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 177 | #define OMAP34XX_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1) |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 178 | #else |
| 179 | #define omap34xx_mcbsp_pdata NULL |
| 180 | #define OMAP34XX_MCBSP_PDATA_SZ 0 |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 181 | #define OMAP34XX_MCBSP_REG_NUM 0 |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 182 | #endif |
| 183 | |
Syed Rafiuddin | a5b92cc | 2009-07-28 18:57:10 +0530 | [diff] [blame] | 184 | static struct omap_mcbsp_platform_data omap44xx_mcbsp_pdata[] = { |
| 185 | { |
| 186 | .phys_base = OMAP44XX_MCBSP1_BASE, |
| 187 | .dma_rx_sync = OMAP44XX_DMA_MCBSP1_RX, |
| 188 | .dma_tx_sync = OMAP44XX_DMA_MCBSP1_TX, |
| 189 | .rx_irq = INT_24XX_MCBSP1_IRQ_RX, |
| 190 | .tx_irq = INT_24XX_MCBSP1_IRQ_TX, |
| 191 | .ops = &omap2_mcbsp_ops, |
| 192 | }, |
| 193 | { |
| 194 | .phys_base = OMAP44XX_MCBSP2_BASE, |
| 195 | .dma_rx_sync = OMAP44XX_DMA_MCBSP2_RX, |
| 196 | .dma_tx_sync = OMAP44XX_DMA_MCBSP2_TX, |
| 197 | .rx_irq = INT_24XX_MCBSP2_IRQ_RX, |
| 198 | .tx_irq = INT_24XX_MCBSP2_IRQ_TX, |
| 199 | .ops = &omap2_mcbsp_ops, |
| 200 | }, |
| 201 | { |
| 202 | .phys_base = OMAP44XX_MCBSP3_BASE, |
| 203 | .dma_rx_sync = OMAP44XX_DMA_MCBSP3_RX, |
| 204 | .dma_tx_sync = OMAP44XX_DMA_MCBSP3_TX, |
| 205 | .rx_irq = INT_24XX_MCBSP3_IRQ_RX, |
| 206 | .tx_irq = INT_24XX_MCBSP3_IRQ_TX, |
| 207 | .ops = &omap2_mcbsp_ops, |
| 208 | }, |
| 209 | { |
| 210 | .phys_base = OMAP44XX_MCBSP4_BASE, |
| 211 | .dma_rx_sync = OMAP44XX_DMA_MCBSP4_RX, |
| 212 | .dma_tx_sync = OMAP44XX_DMA_MCBSP4_TX, |
| 213 | .rx_irq = INT_24XX_MCBSP4_IRQ_RX, |
| 214 | .tx_irq = INT_24XX_MCBSP4_IRQ_TX, |
| 215 | .ops = &omap2_mcbsp_ops, |
| 216 | }, |
| 217 | }; |
| 218 | #define OMAP44XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap44xx_mcbsp_pdata) |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 219 | #define OMAP44XX_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1) |
Syed Rafiuddin | a5b92cc | 2009-07-28 18:57:10 +0530 | [diff] [blame] | 220 | |
Chandra Shekhar | b4b58f5 | 2008-10-08 10:01:39 +0300 | [diff] [blame] | 221 | static int __init omap2_mcbsp_init(void) |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 222 | { |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 223 | if (cpu_is_omap2420()) { |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 224 | omap_mcbsp_count = OMAP2420_MCBSP_PDATA_SZ; |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 225 | omap_mcbsp_cache_size = OMAP2420_MCBSP_REG_NUM * sizeof(u16); |
| 226 | } else if (cpu_is_omap2430()) { |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 227 | omap_mcbsp_count = OMAP2430_MCBSP_PDATA_SZ; |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 228 | omap_mcbsp_cache_size = OMAP2430_MCBSP_REG_NUM * sizeof(u32); |
| 229 | } else if (cpu_is_omap34xx()) { |
Chandra Shekhar | b4b58f5 | 2008-10-08 10:01:39 +0300 | [diff] [blame] | 230 | omap_mcbsp_count = OMAP34XX_MCBSP_PDATA_SZ; |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 231 | omap_mcbsp_cache_size = OMAP34XX_MCBSP_REG_NUM * sizeof(u32); |
| 232 | } else if (cpu_is_omap44xx()) { |
Syed Rafiuddin | a5b92cc | 2009-07-28 18:57:10 +0530 | [diff] [blame] | 233 | omap_mcbsp_count = OMAP44XX_MCBSP_PDATA_SZ; |
Janusz Krzysztofik | c8c9969 | 2010-02-15 10:03:33 -0800 | [diff] [blame] | 234 | omap_mcbsp_cache_size = OMAP44XX_MCBSP_REG_NUM * sizeof(u32); |
| 235 | } |
Chandra Shekhar | b4b58f5 | 2008-10-08 10:01:39 +0300 | [diff] [blame] | 236 | |
| 237 | mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *), |
| 238 | GFP_KERNEL); |
| 239 | if (!mcbsp_ptr) |
| 240 | return -ENOMEM; |
| 241 | |
Jarkko Nikula | 05228c3 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 242 | if (cpu_is_omap2420()) |
| 243 | omap_mcbsp_register_board_cfg(omap2420_mcbsp_pdata, |
| 244 | OMAP2420_MCBSP_PDATA_SZ); |
| 245 | if (cpu_is_omap2430()) |
| 246 | omap_mcbsp_register_board_cfg(omap2430_mcbsp_pdata, |
| 247 | OMAP2430_MCBSP_PDATA_SZ); |
Chandra Shekhar | 9c8e3a0 | 2008-10-08 10:01:40 +0300 | [diff] [blame] | 248 | if (cpu_is_omap34xx()) |
| 249 | omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata, |
| 250 | OMAP34XX_MCBSP_PDATA_SZ); |
Syed Rafiuddin | a5b92cc | 2009-07-28 18:57:10 +0530 | [diff] [blame] | 251 | if (cpu_is_omap44xx()) |
| 252 | omap_mcbsp_register_board_cfg(omap44xx_mcbsp_pdata, |
| 253 | OMAP44XX_MCBSP_PDATA_SZ); |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 254 | |
Eduardo Valentin | 78673bc | 2008-07-03 12:24:40 +0300 | [diff] [blame] | 255 | return omap_mcbsp_init(); |
| 256 | } |
| 257 | arch_initcall(omap2_mcbsp_init); |