blob: 2f3cad6f940237680920acc62306344c3524ff62 [file] [log] [blame]
Eduardo Valentin78673bc2008-07-03 12:24:40 +03001/*
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>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090019#include <linux/slab.h>
Eduardo Valentin78673bc2008-07-03 12:24:40 +030020
Tony Lindgrendd7667a2009-01-15 13:09:51 +020021#include <mach/irqs.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070022#include <plat/dma.h>
23#include <plat/mux.h>
24#include <plat/cpu.h>
25#include <plat/mcbsp.h>
Eduardo Valentin78673bc2008-07-03 12:24:40 +030026
Eduardo Valentin78673bc2008-07-03 12:24:40 +030027static void omap2_mcbsp2_mux_setup(void)
28{
29 omap_cfg_reg(Y15_24XX_MCBSP2_CLKX);
30 omap_cfg_reg(R14_24XX_MCBSP2_FSX);
31 omap_cfg_reg(W15_24XX_MCBSP2_DR);
32 omap_cfg_reg(V15_24XX_MCBSP2_DX);
33 omap_cfg_reg(V14_24XX_GPIO117);
34 /*
35 * TODO: Need to add MUX settings for OMAP 2430 SDP
36 */
37}
38
39static void omap2_mcbsp_request(unsigned int id)
40{
41 if (cpu_is_omap2420() && (id == OMAP_MCBSP2))
42 omap2_mcbsp2_mux_setup();
43}
44
Eduardo Valentin78673bc2008-07-03 12:24:40 +030045static struct omap_mcbsp_ops omap2_mcbsp_ops = {
46 .request = omap2_mcbsp_request,
Eduardo Valentin78673bc2008-07-03 12:24:40 +030047};
48
Jarkko Nikula05228c32008-10-08 10:01:40 +030049#ifdef CONFIG_ARCH_OMAP2420
50static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
Eduardo Valentin78673bc2008-07-03 12:24:40 +030051 {
Russell King65846902008-09-03 23:46:18 +010052 .phys_base = OMAP24XX_MCBSP1_BASE,
Eduardo Valentin78673bc2008-07-03 12:24:40 +030053 .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
54 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
55 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
56 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
57 .ops = &omap2_mcbsp_ops,
Eduardo Valentin78673bc2008-07-03 12:24:40 +030058 },
59 {
Russell King65846902008-09-03 23:46:18 +010060 .phys_base = OMAP24XX_MCBSP2_BASE,
Eduardo Valentin78673bc2008-07-03 12:24:40 +030061 .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
62 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
63 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
64 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
65 .ops = &omap2_mcbsp_ops,
Eduardo Valentin78673bc2008-07-03 12:24:40 +030066 },
67};
Jarkko Nikula05228c32008-10-08 10:01:40 +030068#define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata)
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -080069#define OMAP2420_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
Eduardo Valentin78673bc2008-07-03 12:24:40 +030070#else
Jarkko Nikula05228c32008-10-08 10:01:40 +030071#define omap2420_mcbsp_pdata NULL
72#define OMAP2420_MCBSP_PDATA_SZ 0
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -080073#define OMAP2420_MCBSP_REG_NUM 0
Jarkko Nikula05228c32008-10-08 10:01:40 +030074#endif
75
76#ifdef CONFIG_ARCH_OMAP2430
77static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
78 {
79 .phys_base = OMAP24XX_MCBSP1_BASE,
80 .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
81 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
82 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
83 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
84 .ops = &omap2_mcbsp_ops,
Jarkko Nikula05228c32008-10-08 10:01:40 +030085 },
86 {
87 .phys_base = OMAP24XX_MCBSP2_BASE,
88 .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
89 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
90 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
91 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
92 .ops = &omap2_mcbsp_ops,
Jarkko Nikula05228c32008-10-08 10:01:40 +030093 },
94 {
95 .phys_base = OMAP2430_MCBSP3_BASE,
96 .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX,
97 .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX,
98 .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
99 .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
100 .ops = &omap2_mcbsp_ops,
Jarkko Nikula05228c32008-10-08 10:01:40 +0300101 },
102 {
103 .phys_base = OMAP2430_MCBSP4_BASE,
104 .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX,
105 .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
106 .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
107 .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
108 .ops = &omap2_mcbsp_ops,
Jarkko Nikula05228c32008-10-08 10:01:40 +0300109 },
110 {
111 .phys_base = OMAP2430_MCBSP5_BASE,
112 .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX,
113 .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
114 .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
115 .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
116 .ops = &omap2_mcbsp_ops,
Jarkko Nikula05228c32008-10-08 10:01:40 +0300117 },
118};
119#define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata)
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800120#define OMAP2430_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
Jarkko Nikula05228c32008-10-08 10:01:40 +0300121#else
122#define omap2430_mcbsp_pdata NULL
123#define OMAP2430_MCBSP_PDATA_SZ 0
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800124#define OMAP2430_MCBSP_REG_NUM 0
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300125#endif
126
Tony Lindgrena8eb7ca2010-02-12 12:26:48 -0800127#ifdef CONFIG_ARCH_OMAP3
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300128static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
129 {
Russell King65846902008-09-03 23:46:18 +0100130 .phys_base = OMAP34XX_MCBSP1_BASE,
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300131 .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
132 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
133 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
134 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
135 .ops = &omap2_mcbsp_ops,
Peter Ujfalusi7e4f9432009-08-20 16:18:12 +0300136 .buffer_size = 0x6F,
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300137 },
138 {
Russell King65846902008-09-03 23:46:18 +0100139 .phys_base = OMAP34XX_MCBSP2_BASE,
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000140 .phys_base_st = OMAP34XX_MCBSP2_ST_BASE,
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300141 .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
142 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
143 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
144 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
145 .ops = &omap2_mcbsp_ops,
Eduardo Valentina1a56f52009-08-20 16:18:11 +0300146 .buffer_size = 0x3FF,
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300147 },
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300148 {
149 .phys_base = OMAP34XX_MCBSP3_BASE,
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000150 .phys_base_st = OMAP34XX_MCBSP3_ST_BASE,
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300151 .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX,
152 .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX,
153 .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
154 .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
155 .ops = &omap2_mcbsp_ops,
Peter Ujfalusi7e4f9432009-08-20 16:18:12 +0300156 .buffer_size = 0x6F,
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300157 },
158 {
159 .phys_base = OMAP34XX_MCBSP4_BASE,
160 .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX,
161 .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
162 .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
163 .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
164 .ops = &omap2_mcbsp_ops,
Peter Ujfalusi7e4f9432009-08-20 16:18:12 +0300165 .buffer_size = 0x6F,
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300166 },
167 {
168 .phys_base = OMAP34XX_MCBSP5_BASE,
169 .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX,
170 .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
171 .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
172 .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
173 .ops = &omap2_mcbsp_ops,
Peter Ujfalusi7e4f9432009-08-20 16:18:12 +0300174 .buffer_size = 0x6F,
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300175 },
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300176};
177#define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata)
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800178#define OMAP34XX_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300179#else
180#define omap34xx_mcbsp_pdata NULL
181#define OMAP34XX_MCBSP_PDATA_SZ 0
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800182#define OMAP34XX_MCBSP_REG_NUM 0
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300183#endif
184
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530185static struct omap_mcbsp_platform_data omap44xx_mcbsp_pdata[] = {
186 {
187 .phys_base = OMAP44XX_MCBSP1_BASE,
188 .dma_rx_sync = OMAP44XX_DMA_MCBSP1_RX,
189 .dma_tx_sync = OMAP44XX_DMA_MCBSP1_TX,
190 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
191 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
192 .ops = &omap2_mcbsp_ops,
193 },
194 {
195 .phys_base = OMAP44XX_MCBSP2_BASE,
196 .dma_rx_sync = OMAP44XX_DMA_MCBSP2_RX,
197 .dma_tx_sync = OMAP44XX_DMA_MCBSP2_TX,
198 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
199 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
200 .ops = &omap2_mcbsp_ops,
201 },
202 {
203 .phys_base = OMAP44XX_MCBSP3_BASE,
204 .dma_rx_sync = OMAP44XX_DMA_MCBSP3_RX,
205 .dma_tx_sync = OMAP44XX_DMA_MCBSP3_TX,
206 .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
207 .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
208 .ops = &omap2_mcbsp_ops,
209 },
210 {
211 .phys_base = OMAP44XX_MCBSP4_BASE,
212 .dma_rx_sync = OMAP44XX_DMA_MCBSP4_RX,
213 .dma_tx_sync = OMAP44XX_DMA_MCBSP4_TX,
214 .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
215 .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
216 .ops = &omap2_mcbsp_ops,
217 },
218};
219#define OMAP44XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap44xx_mcbsp_pdata)
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800220#define OMAP44XX_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530221
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300222static int __init omap2_mcbsp_init(void)
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300223{
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800224 if (cpu_is_omap2420()) {
Jarkko Nikula05228c32008-10-08 10:01:40 +0300225 omap_mcbsp_count = OMAP2420_MCBSP_PDATA_SZ;
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800226 omap_mcbsp_cache_size = OMAP2420_MCBSP_REG_NUM * sizeof(u16);
227 } else if (cpu_is_omap2430()) {
Jarkko Nikula05228c32008-10-08 10:01:40 +0300228 omap_mcbsp_count = OMAP2430_MCBSP_PDATA_SZ;
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800229 omap_mcbsp_cache_size = OMAP2430_MCBSP_REG_NUM * sizeof(u32);
230 } else if (cpu_is_omap34xx()) {
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300231 omap_mcbsp_count = OMAP34XX_MCBSP_PDATA_SZ;
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800232 omap_mcbsp_cache_size = OMAP34XX_MCBSP_REG_NUM * sizeof(u32);
233 } else if (cpu_is_omap44xx()) {
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530234 omap_mcbsp_count = OMAP44XX_MCBSP_PDATA_SZ;
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800235 omap_mcbsp_cache_size = OMAP44XX_MCBSP_REG_NUM * sizeof(u32);
236 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300237
238 mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *),
239 GFP_KERNEL);
240 if (!mcbsp_ptr)
241 return -ENOMEM;
242
Jarkko Nikula05228c32008-10-08 10:01:40 +0300243 if (cpu_is_omap2420())
244 omap_mcbsp_register_board_cfg(omap2420_mcbsp_pdata,
245 OMAP2420_MCBSP_PDATA_SZ);
246 if (cpu_is_omap2430())
247 omap_mcbsp_register_board_cfg(omap2430_mcbsp_pdata,
248 OMAP2430_MCBSP_PDATA_SZ);
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300249 if (cpu_is_omap34xx())
250 omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata,
251 OMAP34XX_MCBSP_PDATA_SZ);
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530252 if (cpu_is_omap44xx())
253 omap_mcbsp_register_board_cfg(omap44xx_mcbsp_pdata,
254 OMAP44XX_MCBSP_PDATA_SZ);
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300255
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300256 return omap_mcbsp_init();
257}
258arch_initcall(omap2_mcbsp_init);