blob: 467aae245781c91c6ac4535a5d7d7295e5251ec6 [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>
Tony Lindgrence491cf2009-10-20 09:40:47 -070023#include <plat/cpu.h>
24#include <plat/mcbsp.h>
Eduardo Valentin78673bc2008-07-03 12:24:40 +030025
Tony Lindgrenf99bf162010-07-05 16:31:40 +030026#include "mux.h"
27
Eduardo Valentin78673bc2008-07-03 12:24:40 +030028static void omap2_mcbsp2_mux_setup(void)
29{
Tony Lindgrenf99bf162010-07-05 16:31:40 +030030 omap_mux_init_signal("eac_ac_sclk.mcbsp2_clkx", OMAP_PULL_ENA);
31 omap_mux_init_signal("eac_ac_fs.mcbsp2_fsx", OMAP_PULL_ENA);
32 omap_mux_init_signal("eac_ac_din.mcbsp2_dr", OMAP_PULL_ENA);
33 omap_mux_init_signal("eac_ac_dout.mcbsp2_dx", OMAP_PULL_ENA);
34 omap_mux_init_gpio(117, OMAP_PULL_ENA);
Eduardo Valentin78673bc2008-07-03 12:24:40 +030035 /*
36 * TODO: Need to add MUX settings for OMAP 2430 SDP
37 */
38}
39
40static void omap2_mcbsp_request(unsigned int id)
41{
42 if (cpu_is_omap2420() && (id == OMAP_MCBSP2))
43 omap2_mcbsp2_mux_setup();
44}
45
Eduardo Valentin78673bc2008-07-03 12:24:40 +030046static struct omap_mcbsp_ops omap2_mcbsp_ops = {
47 .request = omap2_mcbsp_request,
Eduardo Valentin78673bc2008-07-03 12:24:40 +030048};
49
Jarkko Nikula05228c32008-10-08 10:01:40 +030050#ifdef CONFIG_ARCH_OMAP2420
51static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
Eduardo Valentin78673bc2008-07-03 12:24:40 +030052 {
Russell King65846902008-09-03 23:46:18 +010053 .phys_base = OMAP24XX_MCBSP1_BASE,
Eduardo Valentin78673bc2008-07-03 12:24:40 +030054 .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
55 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
56 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
57 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
58 .ops = &omap2_mcbsp_ops,
Eduardo Valentin78673bc2008-07-03 12:24:40 +030059 },
60 {
Russell King65846902008-09-03 23:46:18 +010061 .phys_base = OMAP24XX_MCBSP2_BASE,
Eduardo Valentin78673bc2008-07-03 12:24:40 +030062 .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
63 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
64 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
65 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
66 .ops = &omap2_mcbsp_ops,
Eduardo Valentin78673bc2008-07-03 12:24:40 +030067 },
68};
Jarkko Nikula05228c32008-10-08 10:01:40 +030069#define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata)
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -080070#define OMAP2420_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
Eduardo Valentin78673bc2008-07-03 12:24:40 +030071#else
Jarkko Nikula05228c32008-10-08 10:01:40 +030072#define omap2420_mcbsp_pdata NULL
73#define OMAP2420_MCBSP_PDATA_SZ 0
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -080074#define OMAP2420_MCBSP_REG_NUM 0
Jarkko Nikula05228c32008-10-08 10:01:40 +030075#endif
76
77#ifdef CONFIG_ARCH_OMAP2430
78static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
79 {
80 .phys_base = OMAP24XX_MCBSP1_BASE,
81 .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
82 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
83 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
84 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
85 .ops = &omap2_mcbsp_ops,
Jarkko Nikula05228c32008-10-08 10:01:40 +030086 },
87 {
88 .phys_base = OMAP24XX_MCBSP2_BASE,
89 .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
90 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
91 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
92 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
93 .ops = &omap2_mcbsp_ops,
Jarkko Nikula05228c32008-10-08 10:01:40 +030094 },
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,
Jarkko Nikula05228c32008-10-08 10:01:40 +0300102 },
103 {
104 .phys_base = OMAP2430_MCBSP4_BASE,
105 .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX,
106 .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
107 .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
108 .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
109 .ops = &omap2_mcbsp_ops,
Jarkko Nikula05228c32008-10-08 10:01:40 +0300110 },
111 {
112 .phys_base = OMAP2430_MCBSP5_BASE,
113 .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX,
114 .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
115 .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
116 .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
117 .ops = &omap2_mcbsp_ops,
Jarkko Nikula05228c32008-10-08 10:01:40 +0300118 },
119};
120#define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata)
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800121#define OMAP2430_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
Jarkko Nikula05228c32008-10-08 10:01:40 +0300122#else
123#define omap2430_mcbsp_pdata NULL
124#define OMAP2430_MCBSP_PDATA_SZ 0
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800125#define OMAP2430_MCBSP_REG_NUM 0
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300126#endif
127
Tony Lindgrena8eb7ca2010-02-12 12:26:48 -0800128#ifdef CONFIG_ARCH_OMAP3
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300129static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
130 {
Russell King65846902008-09-03 23:46:18 +0100131 .phys_base = OMAP34XX_MCBSP1_BASE,
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300132 .dma_rx_sync = OMAP24XX_DMA_MCBSP1_RX,
133 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
134 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
135 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
136 .ops = &omap2_mcbsp_ops,
Peter Ujfalusi451fd822010-06-03 07:39:33 +0300137 .buffer_size = 0x80, /* The FIFO has 128 locations */
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300138 },
139 {
Russell King65846902008-09-03 23:46:18 +0100140 .phys_base = OMAP34XX_MCBSP2_BASE,
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000141 .phys_base_st = OMAP34XX_MCBSP2_ST_BASE,
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300142 .dma_rx_sync = OMAP24XX_DMA_MCBSP2_RX,
143 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
144 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
145 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
146 .ops = &omap2_mcbsp_ops,
Peter Ujfalusi451fd822010-06-03 07:39:33 +0300147 .buffer_size = 0x500, /* The FIFO has 1024 + 256 locations */
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300148 },
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300149 {
150 .phys_base = OMAP34XX_MCBSP3_BASE,
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000151 .phys_base_st = OMAP34XX_MCBSP3_ST_BASE,
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300152 .dma_rx_sync = OMAP24XX_DMA_MCBSP3_RX,
153 .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX,
154 .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
155 .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
156 .ops = &omap2_mcbsp_ops,
Peter Ujfalusi451fd822010-06-03 07:39:33 +0300157 .buffer_size = 0x80, /* The FIFO has 128 locations */
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300158 },
159 {
160 .phys_base = OMAP34XX_MCBSP4_BASE,
161 .dma_rx_sync = OMAP24XX_DMA_MCBSP4_RX,
162 .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
163 .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
164 .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
165 .ops = &omap2_mcbsp_ops,
Peter Ujfalusi451fd822010-06-03 07:39:33 +0300166 .buffer_size = 0x80, /* The FIFO has 128 locations */
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300167 },
168 {
169 .phys_base = OMAP34XX_MCBSP5_BASE,
170 .dma_rx_sync = OMAP24XX_DMA_MCBSP5_RX,
171 .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
172 .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
173 .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
174 .ops = &omap2_mcbsp_ops,
Peter Ujfalusi451fd822010-06-03 07:39:33 +0300175 .buffer_size = 0x80, /* The FIFO has 128 locations */
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300176 },
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300177};
178#define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata)
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800179#define OMAP34XX_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300180#else
181#define omap34xx_mcbsp_pdata NULL
182#define OMAP34XX_MCBSP_PDATA_SZ 0
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800183#define OMAP34XX_MCBSP_REG_NUM 0
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300184#endif
185
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530186static struct omap_mcbsp_platform_data omap44xx_mcbsp_pdata[] = {
187 {
188 .phys_base = OMAP44XX_MCBSP1_BASE,
189 .dma_rx_sync = OMAP44XX_DMA_MCBSP1_RX,
190 .dma_tx_sync = OMAP44XX_DMA_MCBSP1_TX,
Jorge Eduardo Candelaria9319b9d2010-05-12 12:18:39 -0500191 .tx_irq = OMAP44XX_IRQ_MCBSP1,
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530192 .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,
Jorge Eduardo Candelaria9319b9d2010-05-12 12:18:39 -0500198 .tx_irq = OMAP44XX_IRQ_MCBSP2,
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530199 .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,
Jorge Eduardo Candelaria9319b9d2010-05-12 12:18:39 -0500205 .tx_irq = OMAP44XX_IRQ_MCBSP3,
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530206 .ops = &omap2_mcbsp_ops,
207 },
208 {
209 .phys_base = OMAP44XX_MCBSP4_BASE,
210 .dma_rx_sync = OMAP44XX_DMA_MCBSP4_RX,
211 .dma_tx_sync = OMAP44XX_DMA_MCBSP4_TX,
Jorge Eduardo Candelaria9319b9d2010-05-12 12:18:39 -0500212 .tx_irq = OMAP44XX_IRQ_MCBSP4,
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530213 .ops = &omap2_mcbsp_ops,
214 },
215};
216#define OMAP44XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap44xx_mcbsp_pdata)
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800217#define OMAP44XX_MCBSP_REG_NUM (OMAP_MCBSP_REG_RCCR / sizeof(u32) + 1)
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530218
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300219static int __init omap2_mcbsp_init(void)
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300220{
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800221 if (cpu_is_omap2420()) {
Jarkko Nikula05228c32008-10-08 10:01:40 +0300222 omap_mcbsp_count = OMAP2420_MCBSP_PDATA_SZ;
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800223 omap_mcbsp_cache_size = OMAP2420_MCBSP_REG_NUM * sizeof(u16);
224 } else if (cpu_is_omap2430()) {
Jarkko Nikula05228c32008-10-08 10:01:40 +0300225 omap_mcbsp_count = OMAP2430_MCBSP_PDATA_SZ;
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800226 omap_mcbsp_cache_size = OMAP2430_MCBSP_REG_NUM * sizeof(u32);
227 } else if (cpu_is_omap34xx()) {
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300228 omap_mcbsp_count = OMAP34XX_MCBSP_PDATA_SZ;
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800229 omap_mcbsp_cache_size = OMAP34XX_MCBSP_REG_NUM * sizeof(u32);
230 } else if (cpu_is_omap44xx()) {
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530231 omap_mcbsp_count = OMAP44XX_MCBSP_PDATA_SZ;
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800232 omap_mcbsp_cache_size = OMAP44XX_MCBSP_REG_NUM * sizeof(u32);
233 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300234
235 mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *),
236 GFP_KERNEL);
237 if (!mcbsp_ptr)
238 return -ENOMEM;
239
Jarkko Nikula05228c32008-10-08 10:01:40 +0300240 if (cpu_is_omap2420())
241 omap_mcbsp_register_board_cfg(omap2420_mcbsp_pdata,
242 OMAP2420_MCBSP_PDATA_SZ);
243 if (cpu_is_omap2430())
244 omap_mcbsp_register_board_cfg(omap2430_mcbsp_pdata,
245 OMAP2430_MCBSP_PDATA_SZ);
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300246 if (cpu_is_omap34xx())
247 omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata,
248 OMAP34XX_MCBSP_PDATA_SZ);
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +0530249 if (cpu_is_omap44xx())
250 omap_mcbsp_register_board_cfg(omap44xx_mcbsp_pdata,
251 OMAP44XX_MCBSP_PDATA_SZ);
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300252
Eduardo Valentin78673bc2008-07-03 12:24:40 +0300253 return omap_mcbsp_init();
254}
255arch_initcall(omap2_mcbsp_init);