blob: e9dd70320f7d9564fee7fd870b0db7c1de4bbc62 [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
Eduardo Valentin44a63112009-08-20 16:18:09 +0300368 /*
369 * Worst case: CLKSRG*2 = 8000khz: (1/8000) * 2 * 2 usec
370 * REVISIT: 100us may give enough time for two CLKSRG, however
371 * due to some unknown PM related, clock gating etc. reason it
372 * is now at 500us.
373 */
374 udelay(500);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100375
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300376 if (idle) {
377 /* Start frame sync */
378 w = OMAP_MCBSP_READ(io_base, SPCR2);
379 OMAP_MCBSP_WRITE(io_base, SPCR2, w | (1 << 7));
380 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100381
382 /* Dump McBSP Regs */
383 omap_mcbsp_dump_reg(id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100384}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300385EXPORT_SYMBOL(omap_mcbsp_start);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100386
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300387void omap_mcbsp_stop(unsigned int id, int tx, int rx)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100388{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300389 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100390 void __iomem *io_base;
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300391 int idle;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100392 u16 w;
393
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300394 if (!omap_mcbsp_check_valid_id(id)) {
395 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100396 return;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300397 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100398
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300399 mcbsp = id_to_mcbsp_ptr(id);
400 io_base = mcbsp->io_base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100401
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300402 /* Reset transmitter */
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100403 w = OMAP_MCBSP_READ(io_base, SPCR2);
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300404 OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(tx & 1));
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100405
406 /* Reset receiver */
407 w = OMAP_MCBSP_READ(io_base, SPCR1);
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300408 OMAP_MCBSP_WRITE(io_base, SPCR1, w & ~(rx & 1));
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100409
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300410 idle = !((OMAP_MCBSP_READ(io_base, SPCR2) |
411 OMAP_MCBSP_READ(io_base, SPCR1)) & 1);
412
413 if (idle) {
414 /* Reset the sample rate generator */
415 w = OMAP_MCBSP_READ(io_base, SPCR2);
416 OMAP_MCBSP_WRITE(io_base, SPCR2, w & ~(1 << 6));
417 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100418}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300419EXPORT_SYMBOL(omap_mcbsp_stop);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100420
Eero Nurkkala9abea082009-08-20 16:18:07 +0300421void omap_mcbsp_xmit_enable(unsigned int id, u8 enable)
422{
423 struct omap_mcbsp *mcbsp;
424 void __iomem *io_base;
425 u16 w;
426
427 if (!(cpu_is_omap2430() || cpu_is_omap34xx()))
428 return;
429
430 if (!omap_mcbsp_check_valid_id(id)) {
431 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
432 return;
433 }
434
435 mcbsp = id_to_mcbsp_ptr(id);
436 io_base = mcbsp->io_base;
437
438 w = OMAP_MCBSP_READ(io_base, XCCR);
439
440 if (enable)
441 OMAP_MCBSP_WRITE(io_base, XCCR, w & ~(XDISABLE));
442 else
443 OMAP_MCBSP_WRITE(io_base, XCCR, w | XDISABLE);
444}
445EXPORT_SYMBOL(omap_mcbsp_xmit_enable);
446
447void omap_mcbsp_recv_enable(unsigned int id, u8 enable)
448{
449 struct omap_mcbsp *mcbsp;
450 void __iomem *io_base;
451 u16 w;
452
453 if (!(cpu_is_omap2430() || cpu_is_omap34xx()))
454 return;
455
456 if (!omap_mcbsp_check_valid_id(id)) {
457 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
458 return;
459 }
460
461 mcbsp = id_to_mcbsp_ptr(id);
462 io_base = mcbsp->io_base;
463
464 w = OMAP_MCBSP_READ(io_base, RCCR);
465
466 if (enable)
467 OMAP_MCBSP_WRITE(io_base, RCCR, w & ~(RDISABLE));
468 else
469 OMAP_MCBSP_WRITE(io_base, RCCR, w | RDISABLE);
470}
471EXPORT_SYMBOL(omap_mcbsp_recv_enable);
472
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100473/* polled mcbsp i/o operations */
474int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
475{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300476 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100477 void __iomem *base;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300478
479 if (!omap_mcbsp_check_valid_id(id)) {
480 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
481 return -ENODEV;
482 }
483
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300484 mcbsp = id_to_mcbsp_ptr(id);
485 base = mcbsp->io_base;
486
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100487 writew(buf, base + OMAP_MCBSP_REG_DXR1);
488 /* if frame sync error - clear the error */
489 if (readw(base + OMAP_MCBSP_REG_SPCR2) & XSYNC_ERR) {
490 /* clear error */
491 writew(readw(base + OMAP_MCBSP_REG_SPCR2) & (~XSYNC_ERR),
492 base + OMAP_MCBSP_REG_SPCR2);
493 /* resend */
494 return -1;
495 } else {
496 /* wait for transmit confirmation */
497 int attemps = 0;
498 while (!(readw(base + OMAP_MCBSP_REG_SPCR2) & XRDY)) {
499 if (attemps++ > 1000) {
500 writew(readw(base + OMAP_MCBSP_REG_SPCR2) &
501 (~XRST),
502 base + OMAP_MCBSP_REG_SPCR2);
503 udelay(10);
504 writew(readw(base + OMAP_MCBSP_REG_SPCR2) |
505 (XRST),
506 base + OMAP_MCBSP_REG_SPCR2);
507 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300508 dev_err(mcbsp->dev, "Could not write to"
509 " McBSP%d Register\n", mcbsp->id);
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100510 return -2;
511 }
512 }
513 }
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300514
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100515 return 0;
516}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300517EXPORT_SYMBOL(omap_mcbsp_pollwrite);
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100518
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300519int omap_mcbsp_pollread(unsigned int id, u16 *buf)
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100520{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300521 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100522 void __iomem *base;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300523
524 if (!omap_mcbsp_check_valid_id(id)) {
525 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
526 return -ENODEV;
527 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300528 mcbsp = id_to_mcbsp_ptr(id);
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300529
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300530 base = mcbsp->io_base;
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100531 /* if frame sync error - clear the error */
532 if (readw(base + OMAP_MCBSP_REG_SPCR1) & RSYNC_ERR) {
533 /* clear error */
534 writew(readw(base + OMAP_MCBSP_REG_SPCR1) & (~RSYNC_ERR),
535 base + OMAP_MCBSP_REG_SPCR1);
536 /* resend */
537 return -1;
538 } else {
539 /* wait for recieve confirmation */
540 int attemps = 0;
541 while (!(readw(base + OMAP_MCBSP_REG_SPCR1) & RRDY)) {
542 if (attemps++ > 1000) {
543 writew(readw(base + OMAP_MCBSP_REG_SPCR1) &
544 (~RRST),
545 base + OMAP_MCBSP_REG_SPCR1);
546 udelay(10);
547 writew(readw(base + OMAP_MCBSP_REG_SPCR1) |
548 (RRST),
549 base + OMAP_MCBSP_REG_SPCR1);
550 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300551 dev_err(mcbsp->dev, "Could not read from"
552 " McBSP%d Register\n", mcbsp->id);
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100553 return -2;
554 }
555 }
556 }
557 *buf = readw(base + OMAP_MCBSP_REG_DRR1);
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300558
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100559 return 0;
560}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300561EXPORT_SYMBOL(omap_mcbsp_pollread);
Tony Lindgrenbb13b5f2005-07-10 19:58:18 +0100562
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100563/*
564 * IRQ based word transmission.
565 */
566void omap_mcbsp_xmit_word(unsigned int id, u32 word)
567{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300568 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100569 void __iomem *io_base;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300570 omap_mcbsp_word_length word_length;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100571
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300572 if (!omap_mcbsp_check_valid_id(id)) {
573 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100574 return;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300575 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100576
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300577 mcbsp = id_to_mcbsp_ptr(id);
578 io_base = mcbsp->io_base;
579 word_length = mcbsp->tx_word_length;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100580
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300581 wait_for_completion(&mcbsp->tx_irq_completion);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100582
583 if (word_length > OMAP_MCBSP_WORD_16)
584 OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16);
585 OMAP_MCBSP_WRITE(io_base, DXR1, word & 0xffff);
586}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300587EXPORT_SYMBOL(omap_mcbsp_xmit_word);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100588
589u32 omap_mcbsp_recv_word(unsigned int id)
590{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300591 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100592 void __iomem *io_base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100593 u16 word_lsb, word_msb = 0;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300594 omap_mcbsp_word_length word_length;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100595
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300596 if (!omap_mcbsp_check_valid_id(id)) {
597 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
598 return -ENODEV;
599 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300600 mcbsp = id_to_mcbsp_ptr(id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100601
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300602 word_length = mcbsp->rx_word_length;
603 io_base = mcbsp->io_base;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100604
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300605 wait_for_completion(&mcbsp->rx_irq_completion);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100606
607 if (word_length > OMAP_MCBSP_WORD_16)
608 word_msb = OMAP_MCBSP_READ(io_base, DRR2);
609 word_lsb = OMAP_MCBSP_READ(io_base, DRR1);
610
611 return (word_lsb | (word_msb << 16));
612}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300613EXPORT_SYMBOL(omap_mcbsp_recv_word);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100614
Tony Lindgren120db2c2006-04-02 17:46:27 +0100615int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word)
616{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300617 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100618 void __iomem *io_base;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300619 omap_mcbsp_word_length tx_word_length;
620 omap_mcbsp_word_length rx_word_length;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100621 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0;
622
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300623 if (!omap_mcbsp_check_valid_id(id)) {
624 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
625 return -ENODEV;
626 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300627 mcbsp = id_to_mcbsp_ptr(id);
628 io_base = mcbsp->io_base;
629 tx_word_length = mcbsp->tx_word_length;
630 rx_word_length = mcbsp->rx_word_length;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300631
Tony Lindgren120db2c2006-04-02 17:46:27 +0100632 if (tx_word_length != rx_word_length)
633 return -EINVAL;
634
635 /* First we wait for the transmitter to be ready */
636 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
637 while (!(spcr2 & XRDY)) {
638 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
639 if (attempts++ > 1000) {
640 /* We must reset the transmitter */
641 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 & (~XRST));
642 udelay(10);
643 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
644 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300645 dev_err(mcbsp->dev, "McBSP%d transmitter not "
646 "ready\n", mcbsp->id);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100647 return -EAGAIN;
648 }
649 }
650
651 /* Now we can push the data */
652 if (tx_word_length > OMAP_MCBSP_WORD_16)
653 OMAP_MCBSP_WRITE(io_base, DXR2, word >> 16);
654 OMAP_MCBSP_WRITE(io_base, DXR1, word & 0xffff);
655
656 /* We wait for the receiver to be ready */
657 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
658 while (!(spcr1 & RRDY)) {
659 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
660 if (attempts++ > 1000) {
661 /* We must reset the receiver */
662 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 & (~RRST));
663 udelay(10);
664 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
665 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300666 dev_err(mcbsp->dev, "McBSP%d receiver not "
667 "ready\n", mcbsp->id);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100668 return -EAGAIN;
669 }
670 }
671
672 /* Receiver is ready, let's read the dummy data */
673 if (rx_word_length > OMAP_MCBSP_WORD_16)
674 word_msb = OMAP_MCBSP_READ(io_base, DRR2);
675 word_lsb = OMAP_MCBSP_READ(io_base, DRR1);
676
677 return 0;
678}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300679EXPORT_SYMBOL(omap_mcbsp_spi_master_xmit_word_poll);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100680
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300681int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 *word)
Tony Lindgren120db2c2006-04-02 17:46:27 +0100682{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300683 struct omap_mcbsp *mcbsp;
Russell Kingd592dd12008-09-04 14:25:42 +0100684 u32 clock_word = 0;
685 void __iomem *io_base;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300686 omap_mcbsp_word_length tx_word_length;
687 omap_mcbsp_word_length rx_word_length;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100688 u16 spcr2, spcr1, attempts = 0, word_lsb, word_msb = 0;
689
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300690 if (!omap_mcbsp_check_valid_id(id)) {
691 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
692 return -ENODEV;
693 }
694
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300695 mcbsp = id_to_mcbsp_ptr(id);
696 io_base = mcbsp->io_base;
697
698 tx_word_length = mcbsp->tx_word_length;
699 rx_word_length = mcbsp->rx_word_length;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300700
Tony Lindgren120db2c2006-04-02 17:46:27 +0100701 if (tx_word_length != rx_word_length)
702 return -EINVAL;
703
704 /* First we wait for the transmitter to be ready */
705 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
706 while (!(spcr2 & XRDY)) {
707 spcr2 = OMAP_MCBSP_READ(io_base, SPCR2);
708 if (attempts++ > 1000) {
709 /* We must reset the transmitter */
710 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 & (~XRST));
711 udelay(10);
712 OMAP_MCBSP_WRITE(io_base, SPCR2, spcr2 | XRST);
713 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300714 dev_err(mcbsp->dev, "McBSP%d transmitter not "
715 "ready\n", mcbsp->id);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100716 return -EAGAIN;
717 }
718 }
719
720 /* We first need to enable the bus clock */
721 if (tx_word_length > OMAP_MCBSP_WORD_16)
722 OMAP_MCBSP_WRITE(io_base, DXR2, clock_word >> 16);
723 OMAP_MCBSP_WRITE(io_base, DXR1, clock_word & 0xffff);
724
725 /* We wait for the receiver to be ready */
726 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
727 while (!(spcr1 & RRDY)) {
728 spcr1 = OMAP_MCBSP_READ(io_base, SPCR1);
729 if (attempts++ > 1000) {
730 /* We must reset the receiver */
731 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 & (~RRST));
732 udelay(10);
733 OMAP_MCBSP_WRITE(io_base, SPCR1, spcr1 | RRST);
734 udelay(10);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300735 dev_err(mcbsp->dev, "McBSP%d receiver not "
736 "ready\n", mcbsp->id);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100737 return -EAGAIN;
738 }
739 }
740
741 /* Receiver is ready, there is something for us */
742 if (rx_word_length > OMAP_MCBSP_WORD_16)
743 word_msb = OMAP_MCBSP_READ(io_base, DRR2);
744 word_lsb = OMAP_MCBSP_READ(io_base, DRR1);
745
746 word[0] = (word_lsb | (word_msb << 16));
747
748 return 0;
749}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300750EXPORT_SYMBOL(omap_mcbsp_spi_master_recv_word_poll);
Tony Lindgren120db2c2006-04-02 17:46:27 +0100751
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100752/*
753 * Simple DMA based buffer rx/tx routines.
754 * Nothing fancy, just a single buffer tx/rx through DMA.
755 * The DMA resources are released once the transfer is done.
756 * For anything fancier, you should use your own customized DMA
757 * routines and callbacks.
758 */
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300759int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
760 unsigned int length)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100761{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300762 struct omap_mcbsp *mcbsp;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100763 int dma_tx_ch;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100764 int src_port = 0;
765 int dest_port = 0;
766 int sync_dev = 0;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100767
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300768 if (!omap_mcbsp_check_valid_id(id)) {
769 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
770 return -ENODEV;
771 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300772 mcbsp = id_to_mcbsp_ptr(id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100773
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300774 if (omap_request_dma(mcbsp->dma_tx_sync, "McBSP TX",
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300775 omap_mcbsp_tx_dma_callback,
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300776 mcbsp,
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300777 &dma_tx_ch)) {
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300778 dev_err(mcbsp->dev, " Unable to request DMA channel for "
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300779 "McBSP%d TX. Trying IRQ based TX\n",
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300780 mcbsp->id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100781 return -EAGAIN;
782 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300783 mcbsp->dma_tx_lch = dma_tx_ch;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100784
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300785 dev_err(mcbsp->dev, "McBSP%d TX DMA on channel %d\n", mcbsp->id,
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300786 dma_tx_ch);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100787
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300788 init_completion(&mcbsp->tx_dma_completion);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100789
Tony Lindgren120db2c2006-04-02 17:46:27 +0100790 if (cpu_class_is_omap1()) {
791 src_port = OMAP_DMA_PORT_TIPB;
792 dest_port = OMAP_DMA_PORT_EMIFF;
793 }
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300794 if (cpu_class_is_omap2())
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300795 sync_dev = mcbsp->dma_tx_sync;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100796
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300797 omap_set_dma_transfer_params(mcbsp->dma_tx_lch,
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100798 OMAP_DMA_DATA_TYPE_S16,
799 length >> 1, 1,
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000800 OMAP_DMA_SYNC_ELEMENT,
Tony Lindgren120db2c2006-04-02 17:46:27 +0100801 sync_dev, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100802
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300803 omap_set_dma_dest_params(mcbsp->dma_tx_lch,
Tony Lindgren120db2c2006-04-02 17:46:27 +0100804 src_port,
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100805 OMAP_DMA_AMODE_CONSTANT,
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300806 mcbsp->phys_base + OMAP_MCBSP_REG_DXR1,
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000807 0, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100808
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300809 omap_set_dma_src_params(mcbsp->dma_tx_lch,
Tony Lindgren120db2c2006-04-02 17:46:27 +0100810 dest_port,
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100811 OMAP_DMA_AMODE_POST_INC,
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000812 buffer,
813 0, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100814
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300815 omap_start_dma(mcbsp->dma_tx_lch);
816 wait_for_completion(&mcbsp->tx_dma_completion);
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300817
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100818 return 0;
819}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300820EXPORT_SYMBOL(omap_mcbsp_xmit_buffer);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100821
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300822int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
823 unsigned int length)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100824{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300825 struct omap_mcbsp *mcbsp;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100826 int dma_rx_ch;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100827 int src_port = 0;
828 int dest_port = 0;
829 int sync_dev = 0;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100830
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300831 if (!omap_mcbsp_check_valid_id(id)) {
832 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
833 return -ENODEV;
834 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300835 mcbsp = id_to_mcbsp_ptr(id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100836
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300837 if (omap_request_dma(mcbsp->dma_rx_sync, "McBSP RX",
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300838 omap_mcbsp_rx_dma_callback,
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300839 mcbsp,
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300840 &dma_rx_ch)) {
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300841 dev_err(mcbsp->dev, "Unable to request DMA channel for "
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300842 "McBSP%d RX. Trying IRQ based RX\n",
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300843 mcbsp->id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100844 return -EAGAIN;
845 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300846 mcbsp->dma_rx_lch = dma_rx_ch;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100847
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300848 dev_err(mcbsp->dev, "McBSP%d RX DMA on channel %d\n", mcbsp->id,
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300849 dma_rx_ch);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100850
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300851 init_completion(&mcbsp->rx_dma_completion);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100852
Tony Lindgren120db2c2006-04-02 17:46:27 +0100853 if (cpu_class_is_omap1()) {
854 src_port = OMAP_DMA_PORT_TIPB;
855 dest_port = OMAP_DMA_PORT_EMIFF;
856 }
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300857 if (cpu_class_is_omap2())
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300858 sync_dev = mcbsp->dma_rx_sync;
Tony Lindgren120db2c2006-04-02 17:46:27 +0100859
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300860 omap_set_dma_transfer_params(mcbsp->dma_rx_lch,
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300861 OMAP_DMA_DATA_TYPE_S16,
862 length >> 1, 1,
863 OMAP_DMA_SYNC_ELEMENT,
864 sync_dev, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100865
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300866 omap_set_dma_src_params(mcbsp->dma_rx_lch,
Tony Lindgren120db2c2006-04-02 17:46:27 +0100867 src_port,
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100868 OMAP_DMA_AMODE_CONSTANT,
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300869 mcbsp->phys_base + OMAP_MCBSP_REG_DRR1,
Tony Lindgren1a8bfa12005-11-10 14:26:50 +0000870 0, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100871
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300872 omap_set_dma_dest_params(mcbsp->dma_rx_lch,
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300873 dest_port,
874 OMAP_DMA_AMODE_POST_INC,
875 buffer,
876 0, 0);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100877
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300878 omap_start_dma(mcbsp->dma_rx_lch);
879 wait_for_completion(&mcbsp->rx_dma_completion);
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300880
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100881 return 0;
882}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300883EXPORT_SYMBOL(omap_mcbsp_recv_buffer);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100884
885/*
886 * SPI wrapper.
887 * Since SPI setup is much simpler than the generic McBSP one,
888 * this wrapper just need an omap_mcbsp_spi_cfg structure as an input.
889 * Once this is done, you can call omap_mcbsp_start().
890 */
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300891void omap_mcbsp_set_spi_mode(unsigned int id,
892 const struct omap_mcbsp_spi_cfg *spi_cfg)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100893{
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300894 struct omap_mcbsp *mcbsp;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100895 struct omap_mcbsp_reg_cfg mcbsp_cfg;
896
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300897 if (!omap_mcbsp_check_valid_id(id)) {
898 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100899 return;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300900 }
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300901 mcbsp = id_to_mcbsp_ptr(id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100902
903 memset(&mcbsp_cfg, 0, sizeof(struct omap_mcbsp_reg_cfg));
904
905 /* SPI has only one frame */
906 mcbsp_cfg.rcr1 |= (RWDLEN1(spi_cfg->word_length) | RFRLEN1(0));
907 mcbsp_cfg.xcr1 |= (XWDLEN1(spi_cfg->word_length) | XFRLEN1(0));
908
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300909 /* Clock stop mode */
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100910 if (spi_cfg->clk_stp_mode == OMAP_MCBSP_CLK_STP_MODE_NO_DELAY)
911 mcbsp_cfg.spcr1 |= (1 << 12);
912 else
913 mcbsp_cfg.spcr1 |= (3 << 11);
914
915 /* Set clock parities */
916 if (spi_cfg->rx_clock_polarity == OMAP_MCBSP_CLK_RISING)
917 mcbsp_cfg.pcr0 |= CLKRP;
918 else
919 mcbsp_cfg.pcr0 &= ~CLKRP;
920
921 if (spi_cfg->tx_clock_polarity == OMAP_MCBSP_CLK_RISING)
922 mcbsp_cfg.pcr0 &= ~CLKXP;
923 else
924 mcbsp_cfg.pcr0 |= CLKXP;
925
926 /* Set SCLKME to 0 and CLKSM to 1 */
927 mcbsp_cfg.pcr0 &= ~SCLKME;
928 mcbsp_cfg.srgr2 |= CLKSM;
929
930 /* Set FSXP */
931 if (spi_cfg->fsx_polarity == OMAP_MCBSP_FS_ACTIVE_HIGH)
932 mcbsp_cfg.pcr0 &= ~FSXP;
933 else
934 mcbsp_cfg.pcr0 |= FSXP;
935
936 if (spi_cfg->spi_mode == OMAP_MCBSP_SPI_MASTER) {
937 mcbsp_cfg.pcr0 |= CLKXM;
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300938 mcbsp_cfg.srgr1 |= CLKGDV(spi_cfg->clk_div - 1);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100939 mcbsp_cfg.pcr0 |= FSXM;
940 mcbsp_cfg.srgr2 &= ~FSGM;
941 mcbsp_cfg.xcr2 |= XDATDLY(1);
942 mcbsp_cfg.rcr2 |= RDATDLY(1);
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300943 } else {
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100944 mcbsp_cfg.pcr0 &= ~CLKXM;
945 mcbsp_cfg.srgr1 |= CLKGDV(1);
946 mcbsp_cfg.pcr0 &= ~FSXM;
947 mcbsp_cfg.xcr2 &= ~XDATDLY(3);
948 mcbsp_cfg.rcr2 &= ~RDATDLY(3);
949 }
950
951 mcbsp_cfg.xcr2 &= ~XPHASE;
952 mcbsp_cfg.rcr2 &= ~RPHASE;
953
954 omap_mcbsp_config(id, &mcbsp_cfg);
955}
Eduardo Valentinfb78d802008-07-03 12:24:39 +0300956EXPORT_SYMBOL(omap_mcbsp_set_spi_mode);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100957
958/*
959 * McBSP1 and McBSP3 are directly mapped on 1610 and 1510.
960 * 730 has only 2 McBSP, and both of them are MPU peripherals.
961 */
Uwe Kleine-König25cef222008-10-08 10:01:39 +0300962static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100963{
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300964 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data;
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300965 struct omap_mcbsp *mcbsp;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300966 int id = pdev->id - 1;
967 int ret = 0;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100968
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300969 if (!pdata) {
970 dev_err(&pdev->dev, "McBSP device initialized without"
971 "platform data\n");
972 ret = -EINVAL;
973 goto exit;
974 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100975
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300976 dev_dbg(&pdev->dev, "Initializing OMAP McBSP (%d).\n", pdev->id);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100977
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300978 if (id >= omap_mcbsp_count) {
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300979 dev_err(&pdev->dev, "Invalid McBSP device id (%d)\n", id);
980 ret = -EINVAL;
981 goto exit;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100982 }
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100983
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300984 mcbsp = kzalloc(sizeof(struct omap_mcbsp), GFP_KERNEL);
985 if (!mcbsp) {
986 ret = -ENOMEM;
987 goto exit;
988 }
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +0300989
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300990 spin_lock_init(&mcbsp->lock);
991 mcbsp->id = id + 1;
992 mcbsp->free = 1;
993 mcbsp->dma_tx_lch = -1;
994 mcbsp->dma_rx_lch = -1;
995
996 mcbsp->phys_base = pdata->phys_base;
997 mcbsp->io_base = ioremap(pdata->phys_base, SZ_4K);
998 if (!mcbsp->io_base) {
Russell Kingd592dd12008-09-04 14:25:42 +0100999 ret = -ENOMEM;
1000 goto err_ioremap;
1001 }
1002
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001003 /* Default I/O is IRQ based */
Chandra Shekharb4b58f52008-10-08 10:01:39 +03001004 mcbsp->io_type = OMAP_MCBSP_IRQ_IO;
1005 mcbsp->tx_irq = pdata->tx_irq;
1006 mcbsp->rx_irq = pdata->rx_irq;
1007 mcbsp->dma_rx_sync = pdata->dma_rx_sync;
1008 mcbsp->dma_tx_sync = pdata->dma_tx_sync;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001009
Russell Kingb820ce42009-01-23 10:26:46 +00001010 mcbsp->iclk = clk_get(&pdev->dev, "ick");
1011 if (IS_ERR(mcbsp->iclk)) {
1012 ret = PTR_ERR(mcbsp->iclk);
1013 dev_err(&pdev->dev, "unable to get ick: %d\n", ret);
1014 goto err_iclk;
1015 }
Stanley.Miao06151152009-01-29 08:57:12 -08001016
Russell Kingb820ce42009-01-23 10:26:46 +00001017 mcbsp->fclk = clk_get(&pdev->dev, "fck");
1018 if (IS_ERR(mcbsp->fclk)) {
1019 ret = PTR_ERR(mcbsp->fclk);
1020 dev_err(&pdev->dev, "unable to get fck: %d\n", ret);
1021 goto err_fclk;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001022 }
1023
Chandra Shekharb4b58f52008-10-08 10:01:39 +03001024 mcbsp->pdata = pdata;
1025 mcbsp->dev = &pdev->dev;
Russell Kingb820ce42009-01-23 10:26:46 +00001026 mcbsp_ptr[id] = mcbsp;
Chandra Shekharb4b58f52008-10-08 10:01:39 +03001027 platform_set_drvdata(pdev, mcbsp);
Russell Kingd592dd12008-09-04 14:25:42 +01001028 return 0;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001029
Russell Kingb820ce42009-01-23 10:26:46 +00001030err_fclk:
1031 clk_put(mcbsp->iclk);
1032err_iclk:
Chandra Shekharb4b58f52008-10-08 10:01:39 +03001033 iounmap(mcbsp->io_base);
Russell Kingd592dd12008-09-04 14:25:42 +01001034err_ioremap:
Russell Kingb820ce42009-01-23 10:26:46 +00001035 kfree(mcbsp);
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001036exit:
1037 return ret;
1038}
1039
Uwe Kleine-König25cef222008-10-08 10:01:39 +03001040static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001041{
1042 struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev);
1043
1044 platform_set_drvdata(pdev, NULL);
1045 if (mcbsp) {
1046
1047 if (mcbsp->pdata && mcbsp->pdata->ops &&
1048 mcbsp->pdata->ops->free)
1049 mcbsp->pdata->ops->free(mcbsp->id);
1050
Russell Kingb820ce42009-01-23 10:26:46 +00001051 clk_disable(mcbsp->fclk);
1052 clk_disable(mcbsp->iclk);
1053 clk_put(mcbsp->fclk);
1054 clk_put(mcbsp->iclk);
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001055
Russell Kingd592dd12008-09-04 14:25:42 +01001056 iounmap(mcbsp->io_base);
1057
Russell Kingb820ce42009-01-23 10:26:46 +00001058 mcbsp->fclk = NULL;
1059 mcbsp->iclk = NULL;
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001060 mcbsp->free = 0;
1061 mcbsp->dev = NULL;
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001062 }
1063
1064 return 0;
1065}
1066
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001067static struct platform_driver omap_mcbsp_driver = {
1068 .probe = omap_mcbsp_probe,
Uwe Kleine-König25cef222008-10-08 10:01:39 +03001069 .remove = __devexit_p(omap_mcbsp_remove),
Eduardo Valentinbc5d0c82008-07-03 12:24:39 +03001070 .driver = {
1071 .name = "omap-mcbsp",
1072 },
1073};
1074
1075int __init omap_mcbsp_init(void)
1076{
1077 /* Register the McBSP driver */
1078 return platform_driver_register(&omap_mcbsp_driver);
1079}