2 * linux/arch/arm/mach-omap1/mcbsp.c
4 * Copyright (C) 2008 Instituto Nokia de Tecnologia
5 * Contact: Eduardo Valentin <eduardo.valentin@indt.org.br>
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.
11 * Multichannel mode not supported.
13 #include <linux/ioport.h>
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/clk.h>
17 #include <linux/err.h>
19 #include <linux/platform_device.h>
20 #include <linux/slab.h>
22 #include <mach/irqs.h>
26 #include <plat/mcbsp.h>
28 #define DPS_RSTCT2_PER_EN (1 << 0)
29 #define DSP_RSTCT2_WD_PER_EN (1 << 1)
32 static struct clk *api_clk;
33 static struct clk *dsp_clk;
35 static void omap1_mcbsp_request(unsigned int id)
38 * On 1510, 1610 and 1710, McBSP1 and McBSP3
39 * are DSP public peripherals.
41 if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3) {
43 api_clk = clk_get(NULL, "api_ck");
44 dsp_clk = clk_get(NULL, "dsp_ck");
45 if (!IS_ERR(api_clk) && !IS_ERR(dsp_clk)) {
50 * DSP external peripheral reset
51 * FIXME: This should be moved to dsp code
53 __raw_writew(__raw_readw(DSP_RSTCT2) | DPS_RSTCT2_PER_EN |
54 DSP_RSTCT2_WD_PER_EN, DSP_RSTCT2);
60 static void omap1_mcbsp_free(unsigned int id)
62 if (id == OMAP_MCBSP1 || id == OMAP_MCBSP3) {
64 if (!IS_ERR(api_clk)) {
68 if (!IS_ERR(dsp_clk)) {
76 static struct omap_mcbsp_ops omap1_mcbsp_ops = {
77 .request = omap1_mcbsp_request,
78 .free = omap1_mcbsp_free,
81 #if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
82 struct resource omap7xx_mcbsp_res[][6] = {
85 .start = OMAP7XX_MCBSP1_BASE,
86 .end = OMAP7XX_MCBSP1_BASE + SZ_256,
87 .flags = IORESOURCE_MEM,
91 .start = INT_7XX_McBSP1RX,
92 .flags = IORESOURCE_IRQ,
96 .start = INT_7XX_McBSP1TX,
97 .flags = IORESOURCE_IRQ,
101 .start = OMAP_DMA_MCBSP1_RX,
102 .flags = IORESOURCE_DMA,
106 .start = OMAP_DMA_MCBSP1_TX,
107 .flags = IORESOURCE_DMA,
112 .start = OMAP7XX_MCBSP2_BASE,
113 .end = OMAP7XX_MCBSP2_BASE + SZ_256,
114 .flags = IORESOURCE_MEM,
118 .start = INT_7XX_McBSP2RX,
119 .flags = IORESOURCE_IRQ,
123 .start = INT_7XX_McBSP2TX,
124 .flags = IORESOURCE_IRQ,
128 .start = OMAP_DMA_MCBSP3_RX,
129 .flags = IORESOURCE_DMA,
133 .start = OMAP_DMA_MCBSP3_TX,
134 .flags = IORESOURCE_DMA,
139 static struct omap_mcbsp_platform_data omap7xx_mcbsp_pdata[] = {
141 .ops = &omap1_mcbsp_ops,
144 .ops = &omap1_mcbsp_ops,
147 #define OMAP7XX_MCBSP_RES_SZ ARRAY_SIZE(omap7xx_mcbsp_res[1])
148 #define OMAP7XX_MCBSP_COUNT ARRAY_SIZE(omap7xx_mcbsp_res)
150 #define omap7xx_mcbsp_res NULL
151 #define omap7xx_mcbsp_pdata NULL
152 #define OMAP7XX_MCBSP_RES_SZ 0
153 #define OMAP7XX_MCBSP_COUNT 0
156 #ifdef CONFIG_ARCH_OMAP15XX
157 struct resource omap15xx_mcbsp_res[][6] = {
160 .start = OMAP1510_MCBSP1_BASE,
161 .end = OMAP1510_MCBSP1_BASE + SZ_256,
162 .flags = IORESOURCE_MEM,
166 .start = INT_McBSP1RX,
167 .flags = IORESOURCE_IRQ,
171 .start = INT_McBSP1TX,
172 .flags = IORESOURCE_IRQ,
176 .start = OMAP_DMA_MCBSP1_RX,
177 .flags = IORESOURCE_DMA,
181 .start = OMAP_DMA_MCBSP1_TX,
182 .flags = IORESOURCE_DMA,
187 .start = OMAP1510_MCBSP2_BASE,
188 .end = OMAP1510_MCBSP2_BASE + SZ_256,
189 .flags = IORESOURCE_MEM,
193 .start = INT_1510_SPI_RX,
194 .flags = IORESOURCE_IRQ,
198 .start = INT_1510_SPI_TX,
199 .flags = IORESOURCE_IRQ,
203 .start = OMAP_DMA_MCBSP2_RX,
204 .flags = IORESOURCE_DMA,
208 .start = OMAP_DMA_MCBSP2_TX,
209 .flags = IORESOURCE_DMA,
214 .start = OMAP1510_MCBSP3_BASE,
215 .end = OMAP1510_MCBSP3_BASE + SZ_256,
216 .flags = IORESOURCE_MEM,
220 .start = INT_McBSP3RX,
221 .flags = IORESOURCE_IRQ,
225 .start = INT_McBSP3TX,
226 .flags = IORESOURCE_IRQ,
230 .start = OMAP_DMA_MCBSP3_RX,
231 .flags = IORESOURCE_DMA,
235 .start = OMAP_DMA_MCBSP3_TX,
236 .flags = IORESOURCE_DMA,
241 static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = {
243 .ops = &omap1_mcbsp_ops,
246 .ops = &omap1_mcbsp_ops,
249 .ops = &omap1_mcbsp_ops,
252 #define OMAP15XX_MCBSP_RES_SZ ARRAY_SIZE(omap15xx_mcbsp_res[1])
253 #define OMAP15XX_MCBSP_COUNT ARRAY_SIZE(omap15xx_mcbsp_res)
255 #define omap15xx_mcbsp_res NULL
256 #define omap15xx_mcbsp_pdata NULL
257 #define OMAP15XX_MCBSP_RES_SZ 0
258 #define OMAP15XX_MCBSP_COUNT 0
261 #ifdef CONFIG_ARCH_OMAP16XX
262 struct resource omap16xx_mcbsp_res[][6] = {
265 .start = OMAP1610_MCBSP1_BASE,
266 .end = OMAP1610_MCBSP1_BASE + SZ_256,
267 .flags = IORESOURCE_MEM,
271 .start = INT_McBSP1RX,
272 .flags = IORESOURCE_IRQ,
276 .start = INT_McBSP1TX,
277 .flags = IORESOURCE_IRQ,
281 .start = OMAP_DMA_MCBSP1_RX,
282 .flags = IORESOURCE_DMA,
286 .start = OMAP_DMA_MCBSP1_TX,
287 .flags = IORESOURCE_DMA,
292 .start = OMAP1610_MCBSP2_BASE,
293 .end = OMAP1610_MCBSP2_BASE + SZ_256,
294 .flags = IORESOURCE_MEM,
298 .start = INT_1610_McBSP2_RX,
299 .flags = IORESOURCE_IRQ,
303 .start = INT_1610_McBSP2_TX,
304 .flags = IORESOURCE_IRQ,
308 .start = OMAP_DMA_MCBSP2_RX,
309 .flags = IORESOURCE_DMA,
313 .start = OMAP_DMA_MCBSP2_TX,
314 .flags = IORESOURCE_DMA,
319 .start = OMAP1610_MCBSP3_BASE,
320 .end = OMAP1610_MCBSP3_BASE + SZ_256,
321 .flags = IORESOURCE_MEM,
325 .start = INT_McBSP3RX,
326 .flags = IORESOURCE_IRQ,
330 .start = INT_McBSP3TX,
331 .flags = IORESOURCE_IRQ,
335 .start = OMAP_DMA_MCBSP3_RX,
336 .flags = IORESOURCE_DMA,
340 .start = OMAP_DMA_MCBSP3_TX,
341 .flags = IORESOURCE_DMA,
346 static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {
348 .ops = &omap1_mcbsp_ops,
351 .ops = &omap1_mcbsp_ops,
354 .ops = &omap1_mcbsp_ops,
357 #define OMAP16XX_MCBSP_RES_SZ ARRAY_SIZE(omap16xx_mcbsp_res[1])
358 #define OMAP16XX_MCBSP_COUNT ARRAY_SIZE(omap16xx_mcbsp_res)
360 #define omap16xx_mcbsp_res NULL
361 #define omap16xx_mcbsp_pdata NULL
362 #define OMAP16XX_MCBSP_RES_SZ 0
363 #define OMAP16XX_MCBSP_COUNT 0
366 static int __init omap1_mcbsp_init(void)
368 if (!cpu_class_is_omap1())
371 if (cpu_is_omap7xx())
372 omap_mcbsp_count = OMAP7XX_MCBSP_COUNT;
373 else if (cpu_is_omap15xx())
374 omap_mcbsp_count = OMAP15XX_MCBSP_COUNT;
375 else if (cpu_is_omap16xx())
376 omap_mcbsp_count = OMAP16XX_MCBSP_COUNT;
378 mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *),
383 if (cpu_is_omap7xx())
384 omap_mcbsp_register_board_cfg(omap7xx_mcbsp_res[0],
385 OMAP7XX_MCBSP_RES_SZ,
387 OMAP7XX_MCBSP_COUNT);
389 if (cpu_is_omap15xx())
390 omap_mcbsp_register_board_cfg(omap15xx_mcbsp_res[0],
391 OMAP15XX_MCBSP_RES_SZ,
392 omap15xx_mcbsp_pdata,
393 OMAP15XX_MCBSP_COUNT);
395 if (cpu_is_omap16xx())
396 omap_mcbsp_register_board_cfg(omap16xx_mcbsp_res[0],
397 OMAP16XX_MCBSP_RES_SZ,
398 omap16xx_mcbsp_pdata,
399 OMAP16XX_MCBSP_COUNT);
401 return omap_mcbsp_init();
404 arch_initcall(omap1_mcbsp_init);