blob: 0aa2524186fbbf31dbf1a68166caab4ad4a90dd5 [file] [log] [blame]
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001/*
2 * linux/arch/arm/plat-omap/mcbsp.c
3 *
4 * Copyright (C) 2004 Nokia Corporation
5 * Author: Samuel Ortiz <samuel.ortiz@nokia.com>
6 *
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * Multichannel mode not supported.
13 */
14
15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/device.h>
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +030018#include <linux/platform_device.h>
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010019#include <linux/wait.h>
20#include <linux/completion.h>
21#include <linux/interrupt.h>
22#include <linux/err.h>
Russell Kingf8ce2542006-01-07 16:15:52 +000023#include <linux/clk.h>
Tony Lindgren04fbf6a2007-02-12 10:50:53 -080024#include <linux/delay.h>
Eduardo Valentinfb78d802008-07-03 12:24:39 +030025#include <linux/io.h>
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010026
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/dma.h>
28#include <mach/mcbsp.h>
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010029
Chandra Shekharb4b58f52008-10-08 10:01:39 +030030struct omap_mcbsp **mcbsp_ptr;
31int omap_mcbsp_count;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +030032
Chandra Shekharb4b58f52008-10-08 10:01:39 +030033void omap_mcbsp_write(void __iomem *io_base, u16 reg, u32 val)
34{
35 if (cpu_class_is_omap1() || cpu_is_omap2420())
36 __raw_writew((u16)val, io_base + reg);
37 else
38 __raw_writel(val, io_base + reg);
39}
40
41int omap_mcbsp_read(void __iomem *io_base, u16 reg)
42{
43 if (cpu_class_is_omap1() || cpu_is_omap2420())
44 return __raw_readw(io_base + reg);
45 else
46 return __raw_readl(io_base + reg);
47}
48
49#define OMAP_MCBSP_READ(base, reg) \
50 omap_mcbsp_read(base, OMAP_MCBSP_REG_##reg)
51#define OMAP_MCBSP_WRITE(base, reg, val) \
52 omap_mcbsp_write(base, OMAP_MCBSP_REG_##reg, val)
53
54#define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
55#define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010056
57static void omap_mcbsp_dump_reg(u8 id)
58{
Chandra Shekharb4b58f52008-10-08 10:01:39 +030059 struct omap_mcbsp *mcbsp = id_to_mcbsp_ptr(id);
60
61 dev_dbg(mcbsp->dev, "**** McBSP%d regs ****\n", mcbsp->id);
62 dev_dbg(mcbsp->dev, "DRR2: 0x%04x\n",
63 OMAP_MCBSP_READ(mcbsp->io_base, DRR2));
64 dev_dbg(mcbsp->dev, "DRR1: 0x%04x\n",
65 OMAP_MCBSP_READ(mcbsp->io_base, DRR1));
66 dev_dbg(mcbsp->dev, "DXR2: 0x%04x\n",
67 OMAP_MCBSP_READ(mcbsp->io_base, DXR2));
68 dev_dbg(mcbsp->dev, "DXR1: 0x%04x\n",
69 OMAP_MCBSP_READ(mcbsp->io_base, DXR1));
70 dev_dbg(mcbsp->dev, "SPCR2: 0x%04x\n",
71 OMAP_MCBSP_READ(mcbsp->io_base, SPCR2));
72 dev_dbg(mcbsp->dev, "SPCR1: 0x%04x\n",
73 OMAP_MCBSP_READ(mcbsp->io_base, SPCR1));
74 dev_dbg(mcbsp->dev, "RCR2: 0x%04x\n",
75 OMAP_MCBSP_READ(mcbsp->io_base, RCR2));
76 dev_dbg(mcbsp->dev, "RCR1: 0x%04x\n",
77 OMAP_MCBSP_READ(mcbsp->io_base, RCR1));
78 dev_dbg(mcbsp->dev, "XCR2: 0x%04x\n",
79 OMAP_MCBSP_READ(mcbsp->io_base, XCR2));
80 dev_dbg(mcbsp->dev, "XCR1: 0x%04x\n",
81 OMAP_MCBSP_READ(mcbsp->io_base, XCR1));
82 dev_dbg(mcbsp->dev, "SRGR2: 0x%04x\n",
83 OMAP_MCBSP_READ(mcbsp->io_base, SRGR2));
84 dev_dbg(mcbsp->dev, "SRGR1: 0x%04x\n",
85 OMAP_MCBSP_READ(mcbsp->io_base, SRGR1));
86 dev_dbg(mcbsp->dev, "PCR0: 0x%04x\n",
87 OMAP_MCBSP_READ(mcbsp->io_base, PCR0));
88 dev_dbg(mcbsp->dev, "***********************\n");
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010089}
90
Linus Torvalds0cd61b62006-10-06 10:53:39 -070091static irqreturn_t omap_mcbsp_tx_irq_handler(int irq, void *dev_id)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010092{
Jeff Garzike8f2af12007-10-26 05:40:25 -040093 struct omap_mcbsp *mcbsp_tx = dev_id;
Eero Nurkkalad6d834b2009-05-25 11:08:42 -070094 u16 irqst_spcr2;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010095
Eero Nurkkalad6d834b2009-05-25 11:08:42 -070096 irqst_spcr2 = OMAP_MCBSP_READ(mcbsp_tx->io_base, SPCR2);
97 dev_dbg(mcbsp_tx->dev, "TX IRQ callback : 0x%x\n", irqst_spcr2);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010098
Eero Nurkkalad6d834b2009-05-25 11:08:42 -070099 if (irqst_spcr2 & XSYNC_ERR) {
100 dev_err(mcbsp_tx->dev, "TX Frame Sync Error! : 0x%x\n",
101 irqst_spcr2);
102 /* Writing zero to XSYNC_ERR clears the IRQ */
103 OMAP_MCBSP_WRITE(mcbsp_tx->io_base, SPCR2,
104 irqst_spcr2 & ~(XSYNC_ERR));
105 } else {
106 complete(&mcbsp_tx->tx_irq_completion);
107 }
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300108
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100109 return IRQ_HANDLED;
110}
111
Linus Torvalds0cd61b62006-10-06 10:53:39 -0700112static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100113{
Jeff Garzike8f2af12007-10-26 05:40:25 -0400114 struct omap_mcbsp *mcbsp_rx = dev_id;
Eero Nurkkalad6d834b2009-05-25 11:08:42 -0700115 u16 irqst_spcr1;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100116
Eero Nurkkalad6d834b2009-05-25 11:08:42 -0700117 irqst_spcr1 = OMAP_MCBSP_READ(mcbsp_rx->io_base, SPCR1);
118 dev_dbg(mcbsp_rx->dev, "RX IRQ callback : 0x%x\n", irqst_spcr1);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100119
Eero Nurkkalad6d834b2009-05-25 11:08:42 -0700120 if (irqst_spcr1 & RSYNC_ERR) {
121 dev_err(mcbsp_rx->dev, "RX Frame Sync Error! : 0x%x\n",
122 irqst_spcr1);
123 /* Writing zero to RSYNC_ERR clears the IRQ */
124 OMAP_MCBSP_WRITE(mcbsp_rx->io_base, SPCR1,
125 irqst_spcr1 & ~(RSYNC_ERR));
126 } else {
127 complete(&mcbsp_rx->tx_irq_completion);
128 }
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300129
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100130 return IRQ_HANDLED;
131}
132
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100133static void omap_mcbsp_tx_dma_callback(int lch, u16 ch_status, void *data)
134{
Jeff Garzike8f2af12007-10-26 05:40:25 -0400135 struct omap_mcbsp *mcbsp_dma_tx = data;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100136
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300137 dev_dbg(mcbsp_dma_tx->dev, "TX DMA callback : 0x%x\n",
138 OMAP_MCBSP_READ(mcbsp_dma_tx->io_base, SPCR2));
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100139
140 /* We can free the channels */
141 omap_free_dma(mcbsp_dma_tx->dma_tx_lch);
142 mcbsp_dma_tx->dma_tx_lch = -1;
143
144 complete(&mcbsp_dma_tx->tx_dma_completion);
145}
146
147static void omap_mcbsp_rx_dma_callback(int lch, u16 ch_status, void *data)
148{
Jeff Garzike8f2af12007-10-26 05:40:25 -0400149 struct omap_mcbsp *mcbsp_dma_rx = data;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100150
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300151 dev_dbg(mcbsp_dma_rx->dev, "RX DMA callback : 0x%x\n",
152 OMAP_MCBSP_READ(mcbsp_dma_rx->io_base, SPCR2));
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100153
154 /* We can free the channels */
155 omap_free_dma(mcbsp_dma_rx->dma_rx_lch);
156 mcbsp_dma_rx->dma_rx_lch = -1;
157
158 complete(&mcbsp_dma_rx->rx_dma_completion);
159}
160
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100161/*
162 * omap_mcbsp_config simply write a config to the
163 * appropriate McBSP.
164 * You either call this function or set the McBSP registers
165 * by yourself before calling omap_mcbsp_start().
166 */
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300167void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100168{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300169 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100170 void __iomem *io_base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100171
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300172 if (!omap_mcbsp_check_valid_id(id)) {
173 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
174 return;
175 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300176 mcbsp = id_to_mcbsp_ptr(id);
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300177
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300178 io_base = mcbsp->io_base;
179 dev_dbg(mcbsp->dev, "Configuring McBSP%d phys_base: 0x%08lx\n",
180 mcbsp->id, mcbsp->phys_base);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100181
182 /* We write the given config */
183 OMAP_MCBSP_WRITE(io_base, SPCR2, config->spcr2);
184 OMAP_MCBSP_WRITE(io_base, SPCR1, config->spcr1);
185 OMAP_MCBSP_WRITE(io_base, RCR2, config->rcr2);
186 OMAP_MCBSP_WRITE(io_base, RCR1, config->rcr1);
187 OMAP_MCBSP_WRITE(io_base, XCR2, config->xcr2);
188 OMAP_MCBSP_WRITE(io_base, XCR1, config->xcr1);
189 OMAP_MCBSP_WRITE(io_base, SRGR2, config->srgr2);
190 OMAP_MCBSP_WRITE(io_base, SRGR1, config->srgr1);
191 OMAP_MCBSP_WRITE(io_base, MCR2, config->mcr2);
192 OMAP_MCBSP_WRITE(io_base, MCR1, config->mcr1);
193 OMAP_MCBSP_WRITE(io_base, PCR0, config->pcr0);
Tony Lindgren3127f8f2009-01-15 13:09:54 +0200194 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
195 OMAP_MCBSP_WRITE(io_base, XCCR, config->xccr);
196 OMAP_MCBSP_WRITE(io_base, RCCR, config->rccr);
197 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100198}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300199EXPORT_SYMBOL(omap_mcbsp_config);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100200
Tony Lindgren120db2c2006-04-02 17:46:27 +0100201/*
202 * We can choose between IRQ based or polled IO.
203 * This needs to be called before omap_mcbsp_request().
204 */
205int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
206{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300207 struct omap_mcbsp *mcbsp;
208
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300209 if (!omap_mcbsp_check_valid_id(id)) {
210 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
211 return -ENODEV;
212 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300213 mcbsp = id_to_mcbsp_ptr(id);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100214
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300215 spin_lock(&mcbsp->lock);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100216
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300217 if (!mcbsp->free) {
218 dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
219 mcbsp->id);
220 spin_unlock(&mcbsp->lock);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100221 return -EINVAL;
222 }
223
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300224 mcbsp->io_type = io_type;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100225
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300226 spin_unlock(&mcbsp->lock);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100227
228 return 0;
229}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300230EXPORT_SYMBOL(omap_mcbsp_set_io_type);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100231
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100232int omap_mcbsp_request(unsigned int id)
233{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300234 struct omap_mcbsp *mcbsp;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100235 int err;
236
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300237 if (!omap_mcbsp_check_valid_id(id)) {
238 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
239 return -ENODEV;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100240 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300241 mcbsp = id_to_mcbsp_ptr(id);
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300242
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300243 spin_lock(&mcbsp->lock);
244 if (!mcbsp->free) {
245 dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
246 mcbsp->id);
247 spin_unlock(&mcbsp->lock);
Russell Kingb820ce42009-01-23 10:26:46 +0000248 return -EBUSY;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100249 }
250
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300251 mcbsp->free = 0;
252 spin_unlock(&mcbsp->lock);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100253
Russell Kingb820ce42009-01-23 10:26:46 +0000254 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request)
255 mcbsp->pdata->ops->request(id);
256
257 clk_enable(mcbsp->iclk);
258 clk_enable(mcbsp->fclk);
259
Jarkko Nikula5a070552008-10-08 10:01:41 +0300260 /*
261 * Make sure that transmitter, receiver and sample-rate generator are
262 * not running before activating IRQs.
263 */
264 OMAP_MCBSP_WRITE(mcbsp->io_base, SPCR1, 0);
265 OMAP_MCBSP_WRITE(mcbsp->io_base, SPCR2, 0);
266
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300267 if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
Tony Lindgren120db2c2006-04-02 17:46:27 +0100268 /* We need to get IRQs here */
Jarkko Nikula5a070552008-10-08 10:01:41 +0300269 init_completion(&mcbsp->tx_irq_completion);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300270 err = request_irq(mcbsp->tx_irq, omap_mcbsp_tx_irq_handler,
271 0, "McBSP", (void *)mcbsp);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100272 if (err != 0) {
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300273 dev_err(mcbsp->dev, "Unable to request TX IRQ %d "
274 "for McBSP%d\n", mcbsp->tx_irq,
275 mcbsp->id);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100276 return err;
277 }
278
Jarkko Nikula5a070552008-10-08 10:01:41 +0300279 init_completion(&mcbsp->rx_irq_completion);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300280 err = request_irq(mcbsp->rx_irq, omap_mcbsp_rx_irq_handler,
281 0, "McBSP", (void *)mcbsp);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100282 if (err != 0) {
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300283 dev_err(mcbsp->dev, "Unable to request RX IRQ %d "
284 "for McBSP%d\n", mcbsp->rx_irq,
285 mcbsp->id);
286 free_irq(mcbsp->tx_irq, (void *)mcbsp);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100287 return err;
288 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100289 }
290
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100291 return 0;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100292}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300293EXPORT_SYMBOL(omap_mcbsp_request);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100294
295void omap_mcbsp_free(unsigned int id)
296{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300297 struct omap_mcbsp *mcbsp;
298
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300299 if (!omap_mcbsp_check_valid_id(id)) {
300 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100301 return;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100302 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300303 mcbsp = id_to_mcbsp_ptr(id);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100304
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300305 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free)
306 mcbsp->pdata->ops->free(id);
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300307
Russell Kingb820ce42009-01-23 10:26:46 +0000308 clk_disable(mcbsp->fclk);
309 clk_disable(mcbsp->iclk);
310
311 if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
312 /* Free IRQs */
313 free_irq(mcbsp->rx_irq, (void *)mcbsp);
314 free_irq(mcbsp->tx_irq, (void *)mcbsp);
315 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100316
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300317 spin_lock(&mcbsp->lock);
318 if (mcbsp->free) {
319 dev_err(mcbsp->dev, "McBSP%d was not reserved\n",
320 mcbsp->id);
321 spin_unlock(&mcbsp->lock);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100322 return;
323 }
324
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300325 mcbsp->free = 1;
326 spin_unlock(&mcbsp->lock);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100327}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300328EXPORT_SYMBOL(omap_mcbsp_free);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100329
330/*
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300331 * Here we start the McBSP, by enabling transmitter, receiver or both.
332 * If no transmitter or receiver is active prior calling, then sample-rate
333 * generator and frame sync are started.
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100334 */
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300335void omap_mcbsp_start(unsigned int id, int tx, int rx)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100336{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300337 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100338 void __iomem *io_base;
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300339 int idle;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100340 u16 w;
341
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300342 if (!omap_mcbsp_check_valid_id(id)) {
343 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100344 return;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300345 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300346 mcbsp = id_to_mcbsp_ptr(id);
347 io_base = mcbsp->io_base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100348
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300349 mcbsp->rx_word_length = (OMAP_MCBSP_READ(io_base, RCR1) >> 5) & 0x7;
350 mcbsp->tx_word_length = (OMAP_MCBSP_READ(io_base, XCR1) >> 5) & 0x7;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100351
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300352 idle = !((OMAP_MCBSP_READ(io_base, SPCR2) |
353 OMAP_MCBSP_READ(io_base, SPCR1)) & 1);
354
355 if (idle) {
356 /* Start the sample generator */
357 w = OMAP_MCBSP_READ(io_base, SPCR2);
358 OMAP_MCBSP_WRITE(io_base, SPCR2, w | (1 << 6));
359 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100360
361 /* Enable transmitter and receiver */
362 w = OMAP_MCBSP_READ(io_base, SPCR2);
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300363 OMAP_MCBSP_WRITE(io_base, SPCR2, w | (tx & 1));
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100364
365 w = OMAP_MCBSP_READ(io_base, SPCR1);
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300366 OMAP_MCBSP_WRITE(io_base, SPCR1, w | (rx & 1));
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100367
368 udelay(100);
369
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300370 if (idle) {
371 /* Start frame sync */
372 w = OMAP_MCBSP_READ(io_base, SPCR2);
373 OMAP_MCBSP_WRITE(io_base, SPCR2, w | (1 << 7));
374 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100375
376 /* Dump McBSP Regs */
377 omap_mcbsp_dump_reg(id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100378}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300379EXPORT_SYMBOL(omap_mcbsp_start);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100380
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300381void omap_mcbsp_stop(unsigned int id, int tx, int rx)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100382{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300383 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100384 void __iomem *io_base;
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300385 int idle;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100386 u16 w;
387
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300388 if (!omap_mcbsp_check_valid_id(id)) {
389 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100390 return;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300391 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100392
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300393 mcbsp = id_to_mcbsp_ptr(id);
394 io_base = mcbsp->io_base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100395
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300396 /* Reset transmitter */
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100397 w = OMAP_MCBSP_READ(io_base, SPCR2);
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300398 OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(tx & 1));
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100399
400 /* Reset receiver */
401 w = OMAP_MCBSP_READ(io_base, SPCR1);
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300402 OMAP_MCBSP_WRITE(io_base, SPCR1, w & ~(rx & 1));
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100403
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300404 idle = !((OMAP_MCBSP_READ(io_base, SPCR2) |
405 OMAP_MCBSP_READ(io_base, SPCR1)) & 1);
406
407 if (idle) {
408 /* Reset the sample rate generator */
409 w = OMAP_MCBSP_READ(io_base, SPCR2);
410 OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(1 << 6));
411 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100412}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300413EXPORT_SYMBOL(omap_mcbsp_stop);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100414
Eero Nurkkala9abea082009-08-20 16:18:07 +0300415void omap_mcbsp_xmit_enable(unsigned int id, u8 enable)
416{
417 struct omap_mcbsp *mcbsp;
418 void __iomem *io_base;
419 u16 w;
420
421 if (!(cpu_is_omap2430() || cpu_is_omap34xx()))
422 return;
423
424 if (!omap_mcbsp_check_valid_id(id)) {
425 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
426 return;
427 }
428
429 mcbsp = id_to_mcbsp_ptr(id);
430 io_base = mcbsp->io_base;
431
432 w = OMAP_MCBSP_READ(io_base, XCCR);
433
434 if (enable)
435 OMAP_MCBSP_WRITE(io_base, XCCR, w & ~(XDISABLE));
436 else
437 OMAP_MCBSP_WRITE(io_base, XCCR, w | XDISABLE);
438}
439EXPORT_SYMBOL(omap_mcbsp_xmit_enable);
440
441void omap_mcbsp_recv_enable(unsigned int id, u8 enable)
442{
443 struct omap_mcbsp *mcbsp;
444 void __iomem *io_base;
445 u16 w;
446
447 if (!(cpu_is_omap2430() || cpu_is_omap34xx()))
448 return;
449
450 if (!omap_mcbsp_check_valid_id(id)) {
451 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
452 return;
453 }
454
455 mcbsp = id_to_mcbsp_ptr(id);
456 io_base = mcbsp->io_base;
457
458 w = OMAP_MCBSP_READ(io_base, RCCR);
459
460 if (enable)
461 OMAP_MCBSP_WRITE(io_base, RCCR, w & ~(RDISABLE));
462 else
463 OMAP_MCBSP_WRITE(io_base, RCCR, w | RDISABLE);
464}
465EXPORT_SYMBOL(omap_mcbsp_recv_enable);
466
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100467/* polled mcbsp i/o operations */
468int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
469{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300470 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100471 void __iomem *base;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300472
473 if (!omap_mcbsp_check_valid_id(id)) {
474 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
475 return -ENODEV;
476 }
477
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300478 mcbsp = id_to_mcbsp_ptr(id);
479 base = mcbsp->io_base;
480
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100481 writew(buf, base + OMAP_MCBSP_REG_DXR1);
482 /* if frame sync error - clear the error */
483 if (readw(base + OMAP_MCBSP_REG_SPCR2) & XSYNC_ERR) {
484 /* clear error */
485 writew(readw(base + OMAP_MCBSP_REG_SPCR2) & (~XSYNC_ERR),
486 base + OMAP_MCBSP_REG_SPCR2);
487 /* resend */
488 return -1;
489 } else {
490 /* wait for transmit confirmation */
491 int attemps = 0;
492 while (!(readw(base + OMAP_MCBSP_REG_SPCR2) & XRDY)) {
493 if (attemps++ > 1000) {
494 writew(readw(base + OMAP_MCBSP_REG_SPCR2) &
495 (~XRST),
496 base + OMAP_MCBSP_REG_SPCR2);
497 udelay(10);
498 writew(readw(base + OMAP_MCBSP_REG_SPCR2) |
499 (XRST),
500 base + OMAP_MCBSP_REG_SPCR2);
501 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300502 dev_err(mcbsp->dev, "Could not write to"
503 " McBSP%d Register\n", mcbsp->id);
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100504 return -2;
505 }
506 }
507 }
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300508
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100509 return 0;
510}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300511EXPORT_SYMBOL(omap_mcbsp_pollwrite);
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100512
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300513int omap_mcbsp_pollread(unsigned int id, u16 *buf)
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100514{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300515 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100516 void __iomem *base;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300517
518 if (!omap_mcbsp_check_valid_id(id)) {
519 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
520 return -ENODEV;
521 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300522 mcbsp = id_to_mcbsp_ptr(id);
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300523
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300524 base = mcbsp->io_base;
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100525 /* if frame sync error - clear the error */
526 if (readw(base + OMAP_MCBSP_REG_SPCR1) & RSYNC_ERR) {
527 /* clear error */
528 writew(readw(base + OMAP_MCBSP_REG_SPCR1) & (~RSYNC_ERR),
529 base + OMAP_MCBSP_REG_SPCR1);
530 /* resend */
531 return -1;
532 } else {
533 /* wait for recieve confirmation */
534 int attemps = 0;
535 while (!(readw(base + OMAP_MCBSP_REG_SPCR1) & RRDY)) {
536 if (attemps++ > 1000) {
537 writew(readw(base + OMAP_MCBSP_REG_SPCR1) &
538 (~RRST),
539 base + OMAP_MCBSP_REG_SPCR1);
540 udelay(10);
541 writew(readw(base + OMAP_MCBSP_REG_SPCR1) |
542 (RRST),
543 base + OMAP_MCBSP_REG_SPCR1);
544 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300545 dev_err(mcbsp->dev, "Could not read from"
546 " McBSP%d Register\n", mcbsp->id);
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100547 return -2;
548 }
549 }
550 }
551 *buf = readw(base + OMAP_MCBSP_REG_DRR1);
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300552
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100553 return 0;
554}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300555EXPORT_SYMBOL(omap_mcbsp_pollread);
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100556
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100557/*
558 * IRQ based word transmission.
559 */
560void omap_mcbsp_xmit_word(unsigned int id, u32 word)
561{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300562 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100563 void __iomem *io_base;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300564 omap_mcbsp_word_length word_length;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100565
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300566 if (!omap_mcbsp_check_valid_id(id)) {
567 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100568 return;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300569 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100570
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300571 mcbsp = id_to_mcbsp_ptr(id);
572 io_base = mcbsp->io_base;
573 word_length = mcbsp->tx_word_length;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100574
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300575 wait_for_completion(&mcbsp->tx_irq_completion);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100576
577 if (word_length > OMAP_MCBSP_WORD_16)
578 OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16);
579 OMAP_MCBSP_WRITE(io_base, DXR1, word & 0xffff);
580}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300581EXPORT_SYMBOL(omap_mcbsp_xmit_word);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100582
583u32 omap_mcbsp_recv_word(unsigned int id)
584{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300585 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100586 void __iomem *io_base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100587 u16 word_lsb, word_msb = 0;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300588 omap_mcbsp_word_length word_length;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100589
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300590 if (!omap_mcbsp_check_valid_id(id)) {
591 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
592 return -ENODEV;
593 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300594 mcbsp = id_to_mcbsp_ptr(id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100595
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300596 word_length = mcbsp->rx_word_length;
597 io_base = mcbsp->io_base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100598
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300599 wait_for_completion(&mcbsp->rx_irq_completion);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100600
601 if (word_length > OMAP_MCBSP_WORD_16)
602 word_msb = OMAP_MCBSP_READ(io_base, DRR2);
603 word_lsb = OMAP_MCBSP_READ(io_base, DRR1);
604
605 return (word_lsb | (word_msb << 16));
606}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300607EXPORT_SYMBOL(omap_mcbsp_recv_word);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100608
Tony Lindgren120db2c2006-04-02 17:46:27 +0100609int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
610{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300611 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100612 void __iomem *io_base;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300613 omap_mcbsp_word_length tx_word_length;
614 omap_mcbsp_word_length rx_word_length;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100615 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0;
616
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300617 if (!omap_mcbsp_check_valid_id(id)) {
618 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
619 return -ENODEV;
620 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300621 mcbsp = id_to_mcbsp_ptr(id);
622 io_base = mcbsp->io_base;
623 tx_word_length = mcbsp->tx_word_length;
624 rx_word_length = mcbsp->rx_word_length;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300625
Tony Lindgren120db2c2006-04-02 17:46:27 +0100626 if (tx_word_length != rx_word_length)
627 return -EINVAL;
628
629 /* First we wait for the transmitter to be ready */
630 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
631 while (!(spcr2 & XRDY)) {
632 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
633 if (attempts++ > 1000) {
634 /* We must reset the transmitter */
635 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 & (~XRST));
636 udelay(10);
637 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
638 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300639 dev_err(mcbsp->dev, "McBSP%d transmitter not "
640 "ready\n", mcbsp->id);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100641 return -EAGAIN;
642 }
643 }
644
645 /* Now we can push the data */
646 if (tx_word_length > OMAP_MCBSP_WORD_16)
647 OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16);
648 OMAP_MCBSP_WRITE(io_base, DXR1, word & 0xffff);
649
650 /* We wait for the receiver to be ready */
651 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
652 while (!(spcr1 & RRDY)) {
653 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
654 if (attempts++ > 1000) {
655 /* We must reset the receiver */
656 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 & (~RRST));
657 udelay(10);
658 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
659 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300660 dev_err(mcbsp->dev, "McBSP%d receiver not "
661 "ready\n", mcbsp->id);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100662 return -EAGAIN;
663 }
664 }
665
666 /* Receiver is ready, let's read the dummy data */
667 if (rx_word_length > OMAP_MCBSP_WORD_16)
668 word_msb = OMAP_MCBSP_READ(io_base, DRR2);
669 word_lsb = OMAP_MCBSP_READ(io_base, DRR1);
670
671 return 0;
672}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300673EXPORT_SYMBOL(omap_mcbsp_spi_master_xmit_word_poll);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100674
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300675int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
Tony Lindgren120db2c2006-04-02 17:46:27 +0100676{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300677 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100678 u32 clock_word = 0;
679 void __iomem *io_base;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300680 omap_mcbsp_word_length tx_word_length;
681 omap_mcbsp_word_length rx_word_length;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100682 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0;
683
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300684 if (!omap_mcbsp_check_valid_id(id)) {
685 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
686 return -ENODEV;
687 }
688
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300689 mcbsp = id_to_mcbsp_ptr(id);
690 io_base = mcbsp->io_base;
691
692 tx_word_length = mcbsp->tx_word_length;
693 rx_word_length = mcbsp->rx_word_length;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300694
Tony Lindgren120db2c2006-04-02 17:46:27 +0100695 if (tx_word_length != rx_word_length)
696 return -EINVAL;
697
698 /* First we wait for the transmitter to be ready */
699 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
700 while (!(spcr2 & XRDY)) {
701 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
702 if (attempts++ > 1000) {
703 /* We must reset the transmitter */
704 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 & (~XRST));
705 udelay(10);
706 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
707 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300708 dev_err(mcbsp->dev, "McBSP%d transmitter not "
709 "ready\n", mcbsp->id);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100710 return -EAGAIN;
711 }
712 }
713
714 /* We first need to enable the bus clock */
715 if (tx_word_length > OMAP_MCBSP_WORD_16)
716 OMAP_MCBSP_WRITE(io_base, DXR2, clock_word >> 16);
717 OMAP_MCBSP_WRITE(io_base, DXR1, clock_word & 0xffff);
718
719 /* We wait for the receiver to be ready */
720 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
721 while (!(spcr1 & RRDY)) {
722 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
723 if (attempts++ > 1000) {
724 /* We must reset the receiver */
725 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 & (~RRST));
726 udelay(10);
727 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
728 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300729 dev_err(mcbsp->dev, "McBSP%d receiver not "
730 "ready\n", mcbsp->id);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100731 return -EAGAIN;
732 }
733 }
734
735 /* Receiver is ready, there is something for us */
736 if (rx_word_length > OMAP_MCBSP_WORD_16)
737 word_msb = OMAP_MCBSP_READ(io_base, DRR2);
738 word_lsb = OMAP_MCBSP_READ(io_base, DRR1);
739
740 word[0] = (word_lsb | (word_msb << 16));
741
742 return 0;
743}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300744EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100745
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100746/*
747 * Simple DMA based buffer rx/tx routines.
748 * Nothing fancy, just a single buffer tx/rx through DMA.
749 * The DMA resources are released once the transfer is done.
750 * For anything fancier, you should use your own customized DMA
751 * routines and callbacks.
752 */
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300753int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
754 unsigned int length)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100755{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300756 struct omap_mcbsp *mcbsp;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100757 int dma_tx_ch;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100758 int src_port = 0;
759 int dest_port = 0;
760 int sync_dev = 0;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100761
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300762 if (!omap_mcbsp_check_valid_id(id)) {
763 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
764 return -ENODEV;
765 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300766 mcbsp = id_to_mcbsp_ptr(id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100767
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300768 if (omap_request_dma(mcbsp->dma_tx_sync, "McBSP TX",
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300769 omap_mcbsp_tx_dma_callback,
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300770 mcbsp,
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300771 &dma_tx_ch)) {
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300772 dev_err(mcbsp->dev, " Unable to request DMA channel for "
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300773 "McBSP%d TX. Trying IRQ based TX\n",
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300774 mcbsp->id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100775 return -EAGAIN;
776 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300777 mcbsp->dma_tx_lch = dma_tx_ch;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100778
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300779 dev_err(mcbsp->dev, "McBSP%d TX DMA on channel %d\n", mcbsp->id,
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300780 dma_tx_ch);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100781
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300782 init_completion(&mcbsp->tx_dma_completion);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100783
Tony Lindgren120db2c2006-04-02 17:46:27 +0100784 if (cpu_class_is_omap1()) {
785 src_port = OMAP_DMA_PORT_TIPB;
786 dest_port = OMAP_DMA_PORT_EMIFF;
787 }
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300788 if (cpu_class_is_omap2())
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300789 sync_dev = mcbsp->dma_tx_sync;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100790
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300791 omap_set_dma_transfer_params(mcbsp->dma_tx_lch,
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100792 OMAP_DMA_DATA_TYPE_S16,
793 length >> 1, 1,
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000794 OMAP_DMA_SYNC_ELEMENT,
Tony Lindgren120db2c2006-04-02 17:46:27 +0100795 sync_dev, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100796
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300797 omap_set_dma_dest_params(mcbsp->dma_tx_lch,
Tony Lindgren120db2c2006-04-02 17:46:27 +0100798 src_port,
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100799 OMAP_DMA_AMODE_CONSTANT,
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300800 mcbsp->phys_base + OMAP_MCBSP_REG_DXR1,
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000801 0, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100802
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300803 omap_set_dma_src_params(mcbsp->dma_tx_lch,
Tony Lindgren120db2c2006-04-02 17:46:27 +0100804 dest_port,
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100805 OMAP_DMA_AMODE_POST_INC,
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000806 buffer,
807 0, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100808
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300809 omap_start_dma(mcbsp->dma_tx_lch);
810 wait_for_completion(&mcbsp->tx_dma_completion);
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300811
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100812 return 0;
813}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300814EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100815
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300816int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
817 unsigned int length)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100818{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300819 struct omap_mcbsp *mcbsp;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100820 int dma_rx_ch;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100821 int src_port = 0;
822 int dest_port = 0;
823 int sync_dev = 0;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100824
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300825 if (!omap_mcbsp_check_valid_id(id)) {
826 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
827 return -ENODEV;
828 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300829 mcbsp = id_to_mcbsp_ptr(id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100830
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300831 if (omap_request_dma(mcbsp->dma_rx_sync, "McBSP RX",
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300832 omap_mcbsp_rx_dma_callback,
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300833 mcbsp,
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300834 &dma_rx_ch)) {
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300835 dev_err(mcbsp->dev, "Unable to request DMA channel for "
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300836 "McBSP%d RX. Trying IRQ based RX\n",
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300837 mcbsp->id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100838 return -EAGAIN;
839 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300840 mcbsp->dma_rx_lch = dma_rx_ch;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100841
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300842 dev_err(mcbsp->dev, "McBSP%d RX DMA on channel %d\n", mcbsp->id,
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300843 dma_rx_ch);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100844
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300845 init_completion(&mcbsp->rx_dma_completion);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100846
Tony Lindgren120db2c2006-04-02 17:46:27 +0100847 if (cpu_class_is_omap1()) {
848 src_port = OMAP_DMA_PORT_TIPB;
849 dest_port = OMAP_DMA_PORT_EMIFF;
850 }
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300851 if (cpu_class_is_omap2())
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300852 sync_dev = mcbsp->dma_rx_sync;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100853
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300854 omap_set_dma_transfer_params(mcbsp->dma_rx_lch,
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300855 OMAP_DMA_DATA_TYPE_S16,
856 length >> 1, 1,
857 OMAP_DMA_SYNC_ELEMENT,
858 sync_dev, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100859
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300860 omap_set_dma_src_params(mcbsp->dma_rx_lch,
Tony Lindgren120db2c2006-04-02 17:46:27 +0100861 src_port,
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100862 OMAP_DMA_AMODE_CONSTANT,
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300863 mcbsp->phys_base + OMAP_MCBSP_REG_DRR1,
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000864 0, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100865
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300866 omap_set_dma_dest_params(mcbsp->dma_rx_lch,
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300867 dest_port,
868 OMAP_DMA_AMODE_POST_INC,
869 buffer,
870 0, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100871
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300872 omap_start_dma(mcbsp->dma_rx_lch);
873 wait_for_completion(&mcbsp->rx_dma_completion);
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300874
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100875 return 0;
876}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300877EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100878
879/*
880 * SPI wrapper.
881 * Since SPI setup is much simpler than the generic McBSP one,
882 * this wrapper just need an omap_mcbsp_spi_cfg structure as an input.
883 * Once this is done, you can call omap_mcbsp_start().
884 */
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300885void omap_mcbsp_set_spi_mode(unsigned int id,
886 const struct omap_mcbsp_spi_cfg *spi_cfg)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100887{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300888 struct omap_mcbsp *mcbsp;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100889 struct omap_mcbsp_reg_cfg mcbsp_cfg;
890
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300891 if (!omap_mcbsp_check_valid_id(id)) {
892 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100893 return;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300894 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300895 mcbsp = id_to_mcbsp_ptr(id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100896
897 memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg));
898
899 /* SPI has only one frame */
900 mcbsp_cfg.rcr1 |= (RWDLEN1(spi_cfg->word_length) | RFRLEN1(0));
901 mcbsp_cfg.xcr1 |= (XWDLEN1(spi_cfg->word_length) | XFRLEN1(0));
902
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300903 /* Clock stop mode */
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100904 if (spi_cfg->clk_stp_mode == OMAP_MCBSP_CLK_STP_MODE_NO_DELAY)
905 mcbsp_cfg.spcr1 |= (1 << 12);
906 else
907 mcbsp_cfg.spcr1 |= (3 << 11);
908
909 /* Set clock parities */
910 if (spi_cfg->rx_clock_polarity == OMAP_MCBSP_CLK_RISING)
911 mcbsp_cfg.pcr0 |= CLKRP;
912 else
913 mcbsp_cfg.pcr0 &= ~CLKRP;
914
915 if (spi_cfg->tx_clock_polarity == OMAP_MCBSP_CLK_RISING)
916 mcbsp_cfg.pcr0 &= ~CLKXP;
917 else
918 mcbsp_cfg.pcr0 |= CLKXP;
919
920 /* Set SCLKME to 0 and CLKSM to 1 */
921 mcbsp_cfg.pcr0 &= ~SCLKME;
922 mcbsp_cfg.srgr2 |= CLKSM;
923
924 /* Set FSXP */
925 if (spi_cfg->fsx_polarity == OMAP_MCBSP_FS_ACTIVE_HIGH)
926 mcbsp_cfg.pcr0 &= ~FSXP;
927 else
928 mcbsp_cfg.pcr0 |= FSXP;
929
930 if (spi_cfg->spi_mode == OMAP_MCBSP_SPI_MASTER) {
931 mcbsp_cfg.pcr0 |= CLKXM;
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300932 mcbsp_cfg.srgr1 |= CLKGDV(spi_cfg->clk_div - 1);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100933 mcbsp_cfg.pcr0 |= FSXM;
934 mcbsp_cfg.srgr2 &= ~FSGM;
935 mcbsp_cfg.xcr2 |= XDATDLY(1);
936 mcbsp_cfg.rcr2 |= RDATDLY(1);
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300937 } else {
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100938 mcbsp_cfg.pcr0 &= ~CLKXM;
939 mcbsp_cfg.srgr1 |= CLKGDV(1);
940 mcbsp_cfg.pcr0 &= ~FSXM;
941 mcbsp_cfg.xcr2 &= ~XDATDLY(3);
942 mcbsp_cfg.rcr2 &= ~RDATDLY(3);
943 }
944
945 mcbsp_cfg.xcr2 &= ~XPHASE;
946 mcbsp_cfg.rcr2 &= ~RPHASE;
947
948 omap_mcbsp_config(id, &mcbsp_cfg);
949}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300950EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100951
952/*
953 * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
954 * 730 has only 2 McBSP, and both of them are MPU peripherals.
955 */
Uwe Kleine-König25cef222008-10-08 10:01:39 +0300956static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100957{
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300958 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data;
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300959 struct omap_mcbsp *mcbsp;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300960 int id = pdev->id - 1;
961 int ret = 0;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100962
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300963 if (!pdata) {
964 dev_err(&pdev->dev, "McBSP device initialized without"
965 "platform data\n");
966 ret = -EINVAL;
967 goto exit;
968 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100969
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300970 dev_dbg(&pdev->dev, "Initializing OMAP McBSP (%d).\n", pdev->id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100971
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300972 if (id >= omap_mcbsp_count) {
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300973 dev_err(&pdev->dev, "Invalid McBSP device id (%d)\n", id);
974 ret = -EINVAL;
975 goto exit;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100976 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100977
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300978 mcbsp = kzalloc(sizeof(struct omap_mcbsp), GFP_KERNEL);
979 if (!mcbsp) {
980 ret = -ENOMEM;
981 goto exit;
982 }
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300983
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300984 spin_lock_init(&mcbsp->lock);
985 mcbsp->id = id + 1;
986 mcbsp->free = 1;
987 mcbsp->dma_tx_lch = -1;
988 mcbsp->dma_rx_lch = -1;
989
990 mcbsp->phys_base = pdata->phys_base;
991 mcbsp->io_base = ioremap(pdata->phys_base, SZ_4K);
992 if (!mcbsp->io_base) {
Russell Kingd592dd12008-09-04 14:25:42 +0100993 ret = -ENOMEM;
994 goto err_ioremap;
995 }
996
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300997 /* Default I/O is IRQ based */
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300998 mcbsp->io_type = OMAP_MCBSP_IRQ_IO;
999 mcbsp->tx_irq = pdata->tx_irq;
1000 mcbsp->rx_irq = pdata->rx_irq;
1001 mcbsp->dma_rx_sync = pdata->dma_rx_sync;
1002 mcbsp->dma_tx_sync = pdata->dma_tx_sync;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001003
Russell Kingb820ce42009-01-23 10:26:46 +00001004 mcbsp->iclk = clk_get(&pdev->dev, "ick");
1005 if (IS_ERR(mcbsp->iclk)) {
1006 ret = PTR_ERR(mcbsp->iclk);
1007 dev_err(&pdev->dev, "unable to get ick: %d\n", ret);
1008 goto err_iclk;
1009 }
Stanley.Miao06151152009-01-29 08:57:12 -08001010
Russell Kingb820ce42009-01-23 10:26:46 +00001011 mcbsp->fclk = clk_get(&pdev->dev, "fck");
1012 if (IS_ERR(mcbsp->fclk)) {
1013 ret = PTR_ERR(mcbsp->fclk);
1014 dev_err(&pdev->dev, "unable to get fck: %d\n", ret);
1015 goto err_fclk;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001016 }
1017
Chandra Shekharb4b58f52008-10-08 10:01:39 +03001018 mcbsp->pdata = pdata;
1019 mcbsp->dev = &pdev->dev;
Russell Kingb820ce42009-01-23 10:26:46 +00001020 mcbsp_ptr[id] = mcbsp;
Chandra Shekharb4b58f52008-10-08 10:01:39 +03001021 platform_set_drvdata(pdev, mcbsp);
Russell Kingd592dd12008-09-04 14:25:42 +01001022 return 0;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001023
Russell Kingb820ce42009-01-23 10:26:46 +00001024err_fclk:
1025 clk_put(mcbsp->iclk);
1026err_iclk:
Chandra Shekharb4b58f52008-10-08 10:01:39 +03001027 iounmap(mcbsp->io_base);
Russell Kingd592dd12008-09-04 14:25:42 +01001028err_ioremap:
Russell Kingb820ce42009-01-23 10:26:46 +00001029 kfree(mcbsp);
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001030exit:
1031 return ret;
1032}
1033
Uwe Kleine-König25cef222008-10-08 10:01:39 +03001034static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001035{
1036 struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev);
1037
1038 platform_set_drvdata(pdev, NULL);
1039 if (mcbsp) {
1040
1041 if (mcbsp->pdata && mcbsp->pdata->ops &&
1042 mcbsp->pdata->ops->free)
1043 mcbsp->pdata->ops->free(mcbsp->id);
1044
Russell Kingb820ce42009-01-23 10:26:46 +00001045 clk_disable(mcbsp->fclk);
1046 clk_disable(mcbsp->iclk);
1047 clk_put(mcbsp->fclk);
1048 clk_put(mcbsp->iclk);
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001049
Russell Kingd592dd12008-09-04 14:25:42 +01001050 iounmap(mcbsp->io_base);
1051
Russell Kingb820ce42009-01-23 10:26:46 +00001052 mcbsp->fclk = NULL;
1053 mcbsp->iclk = NULL;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001054 mcbsp->free = 0;
1055 mcbsp->dev = NULL;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001056 }
1057
1058 return 0;
1059}
1060
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001061static struct platform_driver omap_mcbsp_driver = {
1062 .probe = omap_mcbsp_probe,
Uwe Kleine-König25cef222008-10-08 10:01:39 +03001063 .remove = __devexit_p(omap_mcbsp_remove),
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001064 .driver = {
1065 .name = "omap-mcbsp",
1066 },
1067};
1068
1069int __init omap_mcbsp_init(void)
1070{
1071 /* Register the McBSP driver */
1072 return platform_driver_register(&omap_mcbsp_driver);
1073}