2 * OMAP2 McSPI controller driver
4 * Copyright (C) 2005, 2006 Nokia Corporation
5 * Author: Samuel Ortiz <samuel.ortiz@nokia.com> and
6 * Juha Yrj�l� <juha.yrjola@nokia.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #include <linux/kernel.h>
20 #include <linux/interrupt.h>
21 #include <linux/module.h>
22 #include <linux/device.h>
23 #include <linux/delay.h>
24 #include <linux/dma-mapping.h>
25 #include <linux/dmaengine.h>
26 #include <linux/pinctrl/consumer.h>
27 #include <linux/platform_device.h>
28 #include <linux/err.h>
29 #include <linux/clk.h>
31 #include <linux/slab.h>
32 #include <linux/pm_runtime.h>
34 #include <linux/of_device.h>
35 #include <linux/gcd.h>
36 #include <linux/iopoll.h>
38 #include <linux/spi/spi.h>
39 #include <linux/gpio.h>
41 #include <linux/platform_data/spi-omap2-mcspi.h>
43 #define OMAP2_MCSPI_MAX_FREQ 48000000
44 #define OMAP2_MCSPI_MAX_DIVIDER 4096
45 #define OMAP2_MCSPI_MAX_FIFODEPTH 64
46 #define OMAP2_MCSPI_MAX_FIFOWCNT 0xFFFF
47 #define SPI_AUTOSUSPEND_TIMEOUT 2000
49 #define OMAP2_MCSPI_REVISION 0x00
50 #define OMAP2_MCSPI_SYSSTATUS 0x14
51 #define OMAP2_MCSPI_IRQSTATUS 0x18
52 #define OMAP2_MCSPI_IRQENABLE 0x1c
53 #define OMAP2_MCSPI_WAKEUPENABLE 0x20
54 #define OMAP2_MCSPI_SYST 0x24
55 #define OMAP2_MCSPI_MODULCTRL 0x28
56 #define OMAP2_MCSPI_XFERLEVEL 0x7c
58 /* per-channel banks, 0x14 bytes each, first is: */
59 #define OMAP2_MCSPI_CHCONF0 0x2c
60 #define OMAP2_MCSPI_CHSTAT0 0x30
61 #define OMAP2_MCSPI_CHCTRL0 0x34
62 #define OMAP2_MCSPI_TX0 0x38
63 #define OMAP2_MCSPI_RX0 0x3c
65 /* per-register bitmasks: */
66 #define OMAP2_MCSPI_IRQSTATUS_EOW BIT(17)
68 #define OMAP2_MCSPI_MODULCTRL_SINGLE BIT(0)
69 #define OMAP2_MCSPI_MODULCTRL_MS BIT(2)
70 #define OMAP2_MCSPI_MODULCTRL_STEST BIT(3)
72 #define OMAP2_MCSPI_CHCONF_PHA BIT(0)
73 #define OMAP2_MCSPI_CHCONF_POL BIT(1)
74 #define OMAP2_MCSPI_CHCONF_CLKD_MASK (0x0f << 2)
75 #define OMAP2_MCSPI_CHCONF_EPOL BIT(6)
76 #define OMAP2_MCSPI_CHCONF_WL_MASK (0x1f << 7)
77 #define OMAP2_MCSPI_CHCONF_TRM_RX_ONLY BIT(12)
78 #define OMAP2_MCSPI_CHCONF_TRM_TX_ONLY BIT(13)
79 #define OMAP2_MCSPI_CHCONF_TRM_MASK (0x03 << 12)
80 #define OMAP2_MCSPI_CHCONF_DMAW BIT(14)
81 #define OMAP2_MCSPI_CHCONF_DMAR BIT(15)
82 #define OMAP2_MCSPI_CHCONF_DPE0 BIT(16)
83 #define OMAP2_MCSPI_CHCONF_DPE1 BIT(17)
84 #define OMAP2_MCSPI_CHCONF_IS BIT(18)
85 #define OMAP2_MCSPI_CHCONF_TURBO BIT(19)
86 #define OMAP2_MCSPI_CHCONF_FORCE BIT(20)
87 #define OMAP2_MCSPI_CHCONF_FFET BIT(27)
88 #define OMAP2_MCSPI_CHCONF_FFER BIT(28)
89 #define OMAP2_MCSPI_CHCONF_CLKG BIT(29)
91 #define OMAP2_MCSPI_CHSTAT_RXS BIT(0)
92 #define OMAP2_MCSPI_CHSTAT_TXS BIT(1)
93 #define OMAP2_MCSPI_CHSTAT_EOT BIT(2)
94 #define OMAP2_MCSPI_CHSTAT_TXFFE BIT(3)
96 #define OMAP2_MCSPI_CHCTRL_EN BIT(0)
97 #define OMAP2_MCSPI_CHCTRL_EXTCLK_MASK (0xff << 8)
99 #define OMAP2_MCSPI_WAKEUPENABLE_WKEN BIT(0)
101 /* We have 2 DMA channels per CS, one for RX and one for TX */
102 struct omap2_mcspi_dma {
103 struct dma_chan *dma_tx;
104 struct dma_chan *dma_rx;
106 struct completion dma_tx_completion;
107 struct completion dma_rx_completion;
109 char dma_rx_ch_name[14];
110 char dma_tx_ch_name[14];
113 /* use PIO for small transfers, avoiding DMA setup/teardown overhead and
114 * cache operations; better heuristics consider wordsize and bitrate.
116 #define DMA_MIN_BYTES 160
120 * Used for context save and restore, structure members to be updated whenever
121 * corresponding registers are modified.
123 struct omap2_mcspi_regs {
130 struct spi_master *master;
131 /* Virtual base address of the controller */
134 /* SPI1 has 4 channels, while SPI2 has 2 */
135 struct omap2_mcspi_dma *dma_channels;
137 struct omap2_mcspi_regs ctx;
139 unsigned int pin_dir:1;
142 struct omap2_mcspi_cs {
147 struct list_head node;
148 /* Context save and restore shadow register */
149 u32 chconf0, chctrl0;
152 static inline void mcspi_write_reg(struct spi_master *master,
155 struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
157 writel_relaxed(val, mcspi->base + idx);
160 static inline u32 mcspi_read_reg(struct spi_master *master, int idx)
162 struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
164 return readl_relaxed(mcspi->base + idx);
167 static inline void mcspi_write_cs_reg(const struct spi_device *spi,
170 struct omap2_mcspi_cs *cs = spi->controller_state;
172 writel_relaxed(val, cs->base + idx);
175 static inline u32 mcspi_read_cs_reg(const struct spi_device *spi, int idx)
177 struct omap2_mcspi_cs *cs = spi->controller_state;
179 return readl_relaxed(cs->base + idx);
182 static inline u32 mcspi_cached_chconf0(const struct spi_device *spi)
184 struct omap2_mcspi_cs *cs = spi->controller_state;
189 static inline void mcspi_write_chconf0(const struct spi_device *spi, u32 val)
191 struct omap2_mcspi_cs *cs = spi->controller_state;
194 mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCONF0, val);
195 mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHCONF0);
198 static inline int mcspi_bytes_per_word(int word_len)
202 else if (word_len <= 16)
204 else /* word_len <= 32 */
208 static void omap2_mcspi_set_dma_req(const struct spi_device *spi,
209 int is_read, int enable)
213 l = mcspi_cached_chconf0(spi);
215 if (is_read) /* 1 is read, 0 write */
216 rw = OMAP2_MCSPI_CHCONF_DMAR;
218 rw = OMAP2_MCSPI_CHCONF_DMAW;
225 mcspi_write_chconf0(spi, l);
228 static void omap2_mcspi_set_enable(const struct spi_device *spi, int enable)
230 struct omap2_mcspi_cs *cs = spi->controller_state;
235 l |= OMAP2_MCSPI_CHCTRL_EN;
237 l &= ~OMAP2_MCSPI_CHCTRL_EN;
239 mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCTRL0, cs->chctrl0);
240 /* Flash post-writes */
241 mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHCTRL0);
244 static void omap2_mcspi_set_cs(struct spi_device *spi, bool enable)
246 struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
249 /* The controller handles the inverted chip selects
250 * using the OMAP2_MCSPI_CHCONF_EPOL bit so revert
251 * the inversion from the core spi_set_cs function.
253 if (spi->mode & SPI_CS_HIGH)
256 if (spi->controller_state) {
257 int err = pm_runtime_get_sync(mcspi->dev);
259 pm_runtime_put_noidle(mcspi->dev);
260 dev_err(mcspi->dev, "failed to get sync: %d\n", err);
264 l = mcspi_cached_chconf0(spi);
267 l &= ~OMAP2_MCSPI_CHCONF_FORCE;
269 l |= OMAP2_MCSPI_CHCONF_FORCE;
271 mcspi_write_chconf0(spi, l);
273 pm_runtime_mark_last_busy(mcspi->dev);
274 pm_runtime_put_autosuspend(mcspi->dev);
278 static void omap2_mcspi_set_master_mode(struct spi_master *master)
280 struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
281 struct omap2_mcspi_regs *ctx = &mcspi->ctx;
285 * Setup when switching from (reset default) slave mode
286 * to single-channel master mode
288 l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL);
289 l &= ~(OMAP2_MCSPI_MODULCTRL_STEST | OMAP2_MCSPI_MODULCTRL_MS);
290 l |= OMAP2_MCSPI_MODULCTRL_SINGLE;
291 mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l);
296 static void omap2_mcspi_set_fifo(const struct spi_device *spi,
297 struct spi_transfer *t, int enable)
299 struct spi_master *master = spi->master;
300 struct omap2_mcspi_cs *cs = spi->controller_state;
301 struct omap2_mcspi *mcspi;
303 int max_fifo_depth, bytes_per_word;
304 u32 chconf, xferlevel;
306 mcspi = spi_master_get_devdata(master);
308 chconf = mcspi_cached_chconf0(spi);
310 bytes_per_word = mcspi_bytes_per_word(cs->word_len);
311 if (t->len % bytes_per_word != 0)
314 if (t->rx_buf != NULL && t->tx_buf != NULL)
315 max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH / 2;
317 max_fifo_depth = OMAP2_MCSPI_MAX_FIFODEPTH;
319 wcnt = t->len / bytes_per_word;
320 if (wcnt > OMAP2_MCSPI_MAX_FIFOWCNT)
323 xferlevel = wcnt << 16;
324 if (t->rx_buf != NULL) {
325 chconf |= OMAP2_MCSPI_CHCONF_FFER;
326 xferlevel |= (bytes_per_word - 1) << 8;
329 if (t->tx_buf != NULL) {
330 chconf |= OMAP2_MCSPI_CHCONF_FFET;
331 xferlevel |= bytes_per_word - 1;
334 mcspi_write_reg(master, OMAP2_MCSPI_XFERLEVEL, xferlevel);
335 mcspi_write_chconf0(spi, chconf);
336 mcspi->fifo_depth = max_fifo_depth;
342 if (t->rx_buf != NULL)
343 chconf &= ~OMAP2_MCSPI_CHCONF_FFER;
345 if (t->tx_buf != NULL)
346 chconf &= ~OMAP2_MCSPI_CHCONF_FFET;
348 mcspi_write_chconf0(spi, chconf);
349 mcspi->fifo_depth = 0;
352 static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit)
356 return readl_poll_timeout(reg, val, val & bit, 1, MSEC_PER_SEC);
359 static void omap2_mcspi_rx_callback(void *data)
361 struct spi_device *spi = data;
362 struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
363 struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
365 /* We must disable the DMA RX request */
366 omap2_mcspi_set_dma_req(spi, 1, 0);
368 complete(&mcspi_dma->dma_rx_completion);
371 static void omap2_mcspi_tx_callback(void *data)
373 struct spi_device *spi = data;
374 struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
375 struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
377 /* We must disable the DMA TX request */
378 omap2_mcspi_set_dma_req(spi, 0, 0);
380 complete(&mcspi_dma->dma_tx_completion);
383 static void omap2_mcspi_tx_dma(struct spi_device *spi,
384 struct spi_transfer *xfer,
385 struct dma_slave_config cfg)
387 struct omap2_mcspi *mcspi;
388 struct omap2_mcspi_dma *mcspi_dma;
390 mcspi = spi_master_get_devdata(spi->master);
391 mcspi_dma = &mcspi->dma_channels[spi->chip_select];
393 if (mcspi_dma->dma_tx) {
394 struct dma_async_tx_descriptor *tx;
396 dmaengine_slave_config(mcspi_dma->dma_tx, &cfg);
398 tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, xfer->tx_sg.sgl,
401 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
403 tx->callback = omap2_mcspi_tx_callback;
404 tx->callback_param = spi;
405 dmaengine_submit(tx);
407 /* FIXME: fall back to PIO? */
410 dma_async_issue_pending(mcspi_dma->dma_tx);
411 omap2_mcspi_set_dma_req(spi, 0, 1);
416 omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
417 struct dma_slave_config cfg,
420 struct omap2_mcspi *mcspi;
421 struct omap2_mcspi_dma *mcspi_dma;
422 unsigned int count, transfer_reduction = 0;
423 struct scatterlist *sg_out[2];
424 int nb_sizes = 0, out_mapped_nents[2], ret, x;
428 int word_len, element_count;
429 struct omap2_mcspi_cs *cs = spi->controller_state;
430 void __iomem *chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
432 mcspi = spi_master_get_devdata(spi->master);
433 mcspi_dma = &mcspi->dma_channels[spi->chip_select];
437 * In the "End-of-Transfer Procedure" section for DMA RX in OMAP35x TRM
438 * it mentions reducing DMA transfer length by one element in master
441 if (mcspi->fifo_depth == 0)
442 transfer_reduction = es;
444 word_len = cs->word_len;
445 l = mcspi_cached_chconf0(spi);
448 element_count = count;
449 else if (word_len <= 16)
450 element_count = count >> 1;
451 else /* word_len <= 32 */
452 element_count = count >> 2;
454 if (mcspi_dma->dma_rx) {
455 struct dma_async_tx_descriptor *tx;
457 dmaengine_slave_config(mcspi_dma->dma_rx, &cfg);
460 * Reduce DMA transfer length by one more if McSPI is
461 * configured in turbo mode.
463 if ((l & OMAP2_MCSPI_CHCONF_TURBO) && mcspi->fifo_depth == 0)
464 transfer_reduction += es;
466 if (transfer_reduction) {
467 /* Split sgl into two. The second sgl won't be used. */
468 sizes[0] = count - transfer_reduction;
469 sizes[1] = transfer_reduction;
473 * Don't bother splitting the sgl. This essentially
474 * clones the original sgl.
480 ret = sg_split(xfer->rx_sg.sgl, xfer->rx_sg.nents,
483 sg_out, out_mapped_nents,
487 dev_err(&spi->dev, "sg_split failed\n");
491 tx = dmaengine_prep_slave_sg(mcspi_dma->dma_rx,
495 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
497 tx->callback = omap2_mcspi_rx_callback;
498 tx->callback_param = spi;
499 dmaengine_submit(tx);
501 /* FIXME: fall back to PIO? */
505 dma_async_issue_pending(mcspi_dma->dma_rx);
506 omap2_mcspi_set_dma_req(spi, 1, 1);
508 wait_for_completion(&mcspi_dma->dma_rx_completion);
510 for (x = 0; x < nb_sizes; x++)
513 if (mcspi->fifo_depth > 0)
517 * Due to the DMA transfer length reduction the missing bytes must
518 * be read manually to receive all of the expected data.
520 omap2_mcspi_set_enable(spi, 0);
522 elements = element_count - 1;
524 if (l & OMAP2_MCSPI_CHCONF_TURBO) {
527 if (!mcspi_wait_for_reg_bit(chstat_reg,
528 OMAP2_MCSPI_CHSTAT_RXS)) {
531 w = mcspi_read_cs_reg(spi, OMAP2_MCSPI_RX0);
533 ((u8 *)xfer->rx_buf)[elements++] = w;
534 else if (word_len <= 16)
535 ((u16 *)xfer->rx_buf)[elements++] = w;
536 else /* word_len <= 32 */
537 ((u32 *)xfer->rx_buf)[elements++] = w;
539 int bytes_per_word = mcspi_bytes_per_word(word_len);
540 dev_err(&spi->dev, "DMA RX penultimate word empty\n");
541 count -= (bytes_per_word << 1);
542 omap2_mcspi_set_enable(spi, 1);
546 if (!mcspi_wait_for_reg_bit(chstat_reg, OMAP2_MCSPI_CHSTAT_RXS)) {
549 w = mcspi_read_cs_reg(spi, OMAP2_MCSPI_RX0);
551 ((u8 *)xfer->rx_buf)[elements] = w;
552 else if (word_len <= 16)
553 ((u16 *)xfer->rx_buf)[elements] = w;
554 else /* word_len <= 32 */
555 ((u32 *)xfer->rx_buf)[elements] = w;
557 dev_err(&spi->dev, "DMA RX last word empty\n");
558 count -= mcspi_bytes_per_word(word_len);
560 omap2_mcspi_set_enable(spi, 1);
565 omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
567 struct omap2_mcspi *mcspi;
568 struct omap2_mcspi_cs *cs = spi->controller_state;
569 struct omap2_mcspi_dma *mcspi_dma;
573 struct dma_slave_config cfg;
574 enum dma_slave_buswidth width;
576 void __iomem *chstat_reg;
577 void __iomem *irqstat_reg;
580 mcspi = spi_master_get_devdata(spi->master);
581 mcspi_dma = &mcspi->dma_channels[spi->chip_select];
583 if (cs->word_len <= 8) {
584 width = DMA_SLAVE_BUSWIDTH_1_BYTE;
586 } else if (cs->word_len <= 16) {
587 width = DMA_SLAVE_BUSWIDTH_2_BYTES;
590 width = DMA_SLAVE_BUSWIDTH_4_BYTES;
596 memset(&cfg, 0, sizeof(cfg));
597 cfg.src_addr = cs->phys + OMAP2_MCSPI_RX0;
598 cfg.dst_addr = cs->phys + OMAP2_MCSPI_TX0;
599 cfg.src_addr_width = width;
600 cfg.dst_addr_width = width;
601 cfg.src_maxburst = es;
602 cfg.dst_maxburst = es;
608 omap2_mcspi_tx_dma(spi, xfer, cfg);
611 count = omap2_mcspi_rx_dma(spi, xfer, cfg, es);
614 wait_for_completion(&mcspi_dma->dma_tx_completion);
616 if (mcspi->fifo_depth > 0) {
617 irqstat_reg = mcspi->base + OMAP2_MCSPI_IRQSTATUS;
619 if (mcspi_wait_for_reg_bit(irqstat_reg,
620 OMAP2_MCSPI_IRQSTATUS_EOW) < 0)
621 dev_err(&spi->dev, "EOW timed out\n");
623 mcspi_write_reg(mcspi->master, OMAP2_MCSPI_IRQSTATUS,
624 OMAP2_MCSPI_IRQSTATUS_EOW);
627 /* for TX_ONLY mode, be sure all words have shifted out */
629 chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
630 if (mcspi->fifo_depth > 0) {
631 wait_res = mcspi_wait_for_reg_bit(chstat_reg,
632 OMAP2_MCSPI_CHSTAT_TXFFE);
634 dev_err(&spi->dev, "TXFFE timed out\n");
636 wait_res = mcspi_wait_for_reg_bit(chstat_reg,
637 OMAP2_MCSPI_CHSTAT_TXS);
639 dev_err(&spi->dev, "TXS timed out\n");
642 (mcspi_wait_for_reg_bit(chstat_reg,
643 OMAP2_MCSPI_CHSTAT_EOT) < 0))
644 dev_err(&spi->dev, "EOT timed out\n");
651 omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
653 struct omap2_mcspi_cs *cs = spi->controller_state;
654 unsigned int count, c;
656 void __iomem *base = cs->base;
657 void __iomem *tx_reg;
658 void __iomem *rx_reg;
659 void __iomem *chstat_reg;
664 word_len = cs->word_len;
666 l = mcspi_cached_chconf0(spi);
668 /* We store the pre-calculated register addresses on stack to speed
669 * up the transfer loop. */
670 tx_reg = base + OMAP2_MCSPI_TX0;
671 rx_reg = base + OMAP2_MCSPI_RX0;
672 chstat_reg = base + OMAP2_MCSPI_CHSTAT0;
674 if (c < (word_len>>3))
687 if (mcspi_wait_for_reg_bit(chstat_reg,
688 OMAP2_MCSPI_CHSTAT_TXS) < 0) {
689 dev_err(&spi->dev, "TXS timed out\n");
692 dev_vdbg(&spi->dev, "write-%d %02x\n",
694 writel_relaxed(*tx++, tx_reg);
697 if (mcspi_wait_for_reg_bit(chstat_reg,
698 OMAP2_MCSPI_CHSTAT_RXS) < 0) {
699 dev_err(&spi->dev, "RXS timed out\n");
703 if (c == 1 && tx == NULL &&
704 (l & OMAP2_MCSPI_CHCONF_TURBO)) {
705 omap2_mcspi_set_enable(spi, 0);
706 *rx++ = readl_relaxed(rx_reg);
707 dev_vdbg(&spi->dev, "read-%d %02x\n",
708 word_len, *(rx - 1));
709 if (mcspi_wait_for_reg_bit(chstat_reg,
710 OMAP2_MCSPI_CHSTAT_RXS) < 0) {
716 } else if (c == 0 && tx == NULL) {
717 omap2_mcspi_set_enable(spi, 0);
720 *rx++ = readl_relaxed(rx_reg);
721 dev_vdbg(&spi->dev, "read-%d %02x\n",
722 word_len, *(rx - 1));
725 } else if (word_len <= 16) {
734 if (mcspi_wait_for_reg_bit(chstat_reg,
735 OMAP2_MCSPI_CHSTAT_TXS) < 0) {
736 dev_err(&spi->dev, "TXS timed out\n");
739 dev_vdbg(&spi->dev, "write-%d %04x\n",
741 writel_relaxed(*tx++, tx_reg);
744 if (mcspi_wait_for_reg_bit(chstat_reg,
745 OMAP2_MCSPI_CHSTAT_RXS) < 0) {
746 dev_err(&spi->dev, "RXS timed out\n");
750 if (c == 2 && tx == NULL &&
751 (l & OMAP2_MCSPI_CHCONF_TURBO)) {
752 omap2_mcspi_set_enable(spi, 0);
753 *rx++ = readl_relaxed(rx_reg);
754 dev_vdbg(&spi->dev, "read-%d %04x\n",
755 word_len, *(rx - 1));
756 if (mcspi_wait_for_reg_bit(chstat_reg,
757 OMAP2_MCSPI_CHSTAT_RXS) < 0) {
763 } else if (c == 0 && tx == NULL) {
764 omap2_mcspi_set_enable(spi, 0);
767 *rx++ = readl_relaxed(rx_reg);
768 dev_vdbg(&spi->dev, "read-%d %04x\n",
769 word_len, *(rx - 1));
772 } else if (word_len <= 32) {
781 if (mcspi_wait_for_reg_bit(chstat_reg,
782 OMAP2_MCSPI_CHSTAT_TXS) < 0) {
783 dev_err(&spi->dev, "TXS timed out\n");
786 dev_vdbg(&spi->dev, "write-%d %08x\n",
788 writel_relaxed(*tx++, tx_reg);
791 if (mcspi_wait_for_reg_bit(chstat_reg,
792 OMAP2_MCSPI_CHSTAT_RXS) < 0) {
793 dev_err(&spi->dev, "RXS timed out\n");
797 if (c == 4 && tx == NULL &&
798 (l & OMAP2_MCSPI_CHCONF_TURBO)) {
799 omap2_mcspi_set_enable(spi, 0);
800 *rx++ = readl_relaxed(rx_reg);
801 dev_vdbg(&spi->dev, "read-%d %08x\n",
802 word_len, *(rx - 1));
803 if (mcspi_wait_for_reg_bit(chstat_reg,
804 OMAP2_MCSPI_CHSTAT_RXS) < 0) {
810 } else if (c == 0 && tx == NULL) {
811 omap2_mcspi_set_enable(spi, 0);
814 *rx++ = readl_relaxed(rx_reg);
815 dev_vdbg(&spi->dev, "read-%d %08x\n",
816 word_len, *(rx - 1));
821 /* for TX_ONLY mode, be sure all words have shifted out */
822 if (xfer->rx_buf == NULL) {
823 if (mcspi_wait_for_reg_bit(chstat_reg,
824 OMAP2_MCSPI_CHSTAT_TXS) < 0) {
825 dev_err(&spi->dev, "TXS timed out\n");
826 } else if (mcspi_wait_for_reg_bit(chstat_reg,
827 OMAP2_MCSPI_CHSTAT_EOT) < 0)
828 dev_err(&spi->dev, "EOT timed out\n");
830 /* disable chan to purge rx datas received in TX_ONLY transfer,
831 * otherwise these rx datas will affect the direct following
834 omap2_mcspi_set_enable(spi, 0);
837 omap2_mcspi_set_enable(spi, 1);
841 static u32 omap2_mcspi_calc_divisor(u32 speed_hz)
845 for (div = 0; div < 15; div++)
846 if (speed_hz >= (OMAP2_MCSPI_MAX_FREQ >> div))
852 /* called only when no transfer is active to this device */
853 static int omap2_mcspi_setup_transfer(struct spi_device *spi,
854 struct spi_transfer *t)
856 struct omap2_mcspi_cs *cs = spi->controller_state;
857 struct omap2_mcspi *mcspi;
858 u32 l = 0, clkd = 0, div, extclk = 0, clkg = 0;
859 u8 word_len = spi->bits_per_word;
860 u32 speed_hz = spi->max_speed_hz;
862 mcspi = spi_master_get_devdata(spi->master);
864 if (t != NULL && t->bits_per_word)
865 word_len = t->bits_per_word;
867 cs->word_len = word_len;
869 if (t && t->speed_hz)
870 speed_hz = t->speed_hz;
872 speed_hz = min_t(u32, speed_hz, OMAP2_MCSPI_MAX_FREQ);
873 if (speed_hz < (OMAP2_MCSPI_MAX_FREQ / OMAP2_MCSPI_MAX_DIVIDER)) {
874 clkd = omap2_mcspi_calc_divisor(speed_hz);
875 speed_hz = OMAP2_MCSPI_MAX_FREQ >> clkd;
878 div = (OMAP2_MCSPI_MAX_FREQ + speed_hz - 1) / speed_hz;
879 speed_hz = OMAP2_MCSPI_MAX_FREQ / div;
880 clkd = (div - 1) & 0xf;
881 extclk = (div - 1) >> 4;
882 clkg = OMAP2_MCSPI_CHCONF_CLKG;
885 l = mcspi_cached_chconf0(spi);
887 /* standard 4-wire master mode: SCK, MOSI/out, MISO/in, nCS
888 * REVISIT: this controller could support SPI_3WIRE mode.
890 if (mcspi->pin_dir == MCSPI_PINDIR_D0_IN_D1_OUT) {
891 l &= ~OMAP2_MCSPI_CHCONF_IS;
892 l &= ~OMAP2_MCSPI_CHCONF_DPE1;
893 l |= OMAP2_MCSPI_CHCONF_DPE0;
895 l |= OMAP2_MCSPI_CHCONF_IS;
896 l |= OMAP2_MCSPI_CHCONF_DPE1;
897 l &= ~OMAP2_MCSPI_CHCONF_DPE0;
901 l &= ~OMAP2_MCSPI_CHCONF_WL_MASK;
902 l |= (word_len - 1) << 7;
904 /* set chipselect polarity; manage with FORCE */
905 if (!(spi->mode & SPI_CS_HIGH))
906 l |= OMAP2_MCSPI_CHCONF_EPOL; /* active-low; normal */
908 l &= ~OMAP2_MCSPI_CHCONF_EPOL;
910 /* set clock divisor */
911 l &= ~OMAP2_MCSPI_CHCONF_CLKD_MASK;
914 /* set clock granularity */
915 l &= ~OMAP2_MCSPI_CHCONF_CLKG;
918 cs->chctrl0 &= ~OMAP2_MCSPI_CHCTRL_EXTCLK_MASK;
919 cs->chctrl0 |= extclk << 8;
920 mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCTRL0, cs->chctrl0);
923 /* set SPI mode 0..3 */
924 if (spi->mode & SPI_CPOL)
925 l |= OMAP2_MCSPI_CHCONF_POL;
927 l &= ~OMAP2_MCSPI_CHCONF_POL;
928 if (spi->mode & SPI_CPHA)
929 l |= OMAP2_MCSPI_CHCONF_PHA;
931 l &= ~OMAP2_MCSPI_CHCONF_PHA;
933 mcspi_write_chconf0(spi, l);
935 cs->mode = spi->mode;
937 dev_dbg(&spi->dev, "setup: speed %d, sample %s edge, clk %s\n",
939 (spi->mode & SPI_CPHA) ? "trailing" : "leading",
940 (spi->mode & SPI_CPOL) ? "inverted" : "normal");
946 * Note that we currently allow DMA only if we get a channel
947 * for both rx and tx. Otherwise we'll do PIO for both rx and tx.
949 static int omap2_mcspi_request_dma(struct spi_device *spi)
951 struct spi_master *master = spi->master;
952 struct omap2_mcspi *mcspi;
953 struct omap2_mcspi_dma *mcspi_dma;
956 mcspi = spi_master_get_devdata(master);
957 mcspi_dma = mcspi->dma_channels + spi->chip_select;
959 init_completion(&mcspi_dma->dma_rx_completion);
960 init_completion(&mcspi_dma->dma_tx_completion);
962 mcspi_dma->dma_rx = dma_request_chan(&master->dev,
963 mcspi_dma->dma_rx_ch_name);
964 if (IS_ERR(mcspi_dma->dma_rx)) {
965 ret = PTR_ERR(mcspi_dma->dma_rx);
966 mcspi_dma->dma_rx = NULL;
970 mcspi_dma->dma_tx = dma_request_chan(&master->dev,
971 mcspi_dma->dma_tx_ch_name);
972 if (IS_ERR(mcspi_dma->dma_tx)) {
973 ret = PTR_ERR(mcspi_dma->dma_tx);
974 mcspi_dma->dma_tx = NULL;
975 dma_release_channel(mcspi_dma->dma_rx);
976 mcspi_dma->dma_rx = NULL;
983 static int omap2_mcspi_setup(struct spi_device *spi)
986 struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
987 struct omap2_mcspi_regs *ctx = &mcspi->ctx;
988 struct omap2_mcspi_dma *mcspi_dma;
989 struct omap2_mcspi_cs *cs = spi->controller_state;
991 mcspi_dma = &mcspi->dma_channels[spi->chip_select];
994 cs = kzalloc(sizeof *cs, GFP_KERNEL);
997 cs->base = mcspi->base + spi->chip_select * 0x14;
998 cs->phys = mcspi->phys + spi->chip_select * 0x14;
1002 spi->controller_state = cs;
1003 /* Link this to context save list */
1004 list_add_tail(&cs->node, &ctx->cs);
1006 if (gpio_is_valid(spi->cs_gpio)) {
1007 ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
1009 dev_err(&spi->dev, "failed to request gpio\n");
1012 gpio_direction_output(spi->cs_gpio,
1013 !(spi->mode & SPI_CS_HIGH));
1017 if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) {
1018 ret = omap2_mcspi_request_dma(spi);
1020 dev_warn(&spi->dev, "not using DMA for McSPI (%d)\n",
1024 ret = pm_runtime_get_sync(mcspi->dev);
1026 pm_runtime_put_noidle(mcspi->dev);
1031 ret = omap2_mcspi_setup_transfer(spi, NULL);
1032 pm_runtime_mark_last_busy(mcspi->dev);
1033 pm_runtime_put_autosuspend(mcspi->dev);
1038 static void omap2_mcspi_cleanup(struct spi_device *spi)
1040 struct omap2_mcspi *mcspi;
1041 struct omap2_mcspi_dma *mcspi_dma;
1042 struct omap2_mcspi_cs *cs;
1044 mcspi = spi_master_get_devdata(spi->master);
1046 if (spi->controller_state) {
1047 /* Unlink controller state from context save list */
1048 cs = spi->controller_state;
1049 list_del(&cs->node);
1054 if (spi->chip_select < spi->master->num_chipselect) {
1055 mcspi_dma = &mcspi->dma_channels[spi->chip_select];
1057 if (mcspi_dma->dma_rx) {
1058 dma_release_channel(mcspi_dma->dma_rx);
1059 mcspi_dma->dma_rx = NULL;
1061 if (mcspi_dma->dma_tx) {
1062 dma_release_channel(mcspi_dma->dma_tx);
1063 mcspi_dma->dma_tx = NULL;
1067 if (gpio_is_valid(spi->cs_gpio))
1068 gpio_free(spi->cs_gpio);
1071 static int omap2_mcspi_transfer_one(struct spi_master *master,
1072 struct spi_device *spi,
1073 struct spi_transfer *t)
1076 /* We only enable one channel at a time -- the one whose message is
1077 * -- although this controller would gladly
1078 * arbitrate among multiple channels. This corresponds to "single
1079 * channel" master mode. As a side effect, we need to manage the
1080 * chipselect with the FORCE bit ... CS != channel enable.
1083 struct omap2_mcspi *mcspi;
1084 struct omap2_mcspi_dma *mcspi_dma;
1085 struct omap2_mcspi_cs *cs;
1086 struct omap2_mcspi_device_config *cd;
1087 int par_override = 0;
1091 mcspi = spi_master_get_devdata(master);
1092 mcspi_dma = mcspi->dma_channels + spi->chip_select;
1093 cs = spi->controller_state;
1094 cd = spi->controller_data;
1097 * The slave driver could have changed spi->mode in which case
1098 * it will be different from cs->mode (the current hardware setup).
1099 * If so, set par_override (even though its not a parity issue) so
1100 * omap2_mcspi_setup_transfer will be called to configure the hardware
1101 * with the correct mode on the first iteration of the loop below.
1103 if (spi->mode != cs->mode)
1106 omap2_mcspi_set_enable(spi, 0);
1108 if (gpio_is_valid(spi->cs_gpio))
1109 omap2_mcspi_set_cs(spi, spi->mode & SPI_CS_HIGH);
1112 (t->speed_hz != spi->max_speed_hz) ||
1113 (t->bits_per_word != spi->bits_per_word)) {
1115 status = omap2_mcspi_setup_transfer(spi, t);
1118 if (t->speed_hz == spi->max_speed_hz &&
1119 t->bits_per_word == spi->bits_per_word)
1122 if (cd && cd->cs_per_word) {
1123 chconf = mcspi->ctx.modulctrl;
1124 chconf &= ~OMAP2_MCSPI_MODULCTRL_SINGLE;
1125 mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf);
1126 mcspi->ctx.modulctrl =
1127 mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL);
1130 chconf = mcspi_cached_chconf0(spi);
1131 chconf &= ~OMAP2_MCSPI_CHCONF_TRM_MASK;
1132 chconf &= ~OMAP2_MCSPI_CHCONF_TURBO;
1134 if (t->tx_buf == NULL)
1135 chconf |= OMAP2_MCSPI_CHCONF_TRM_RX_ONLY;
1136 else if (t->rx_buf == NULL)
1137 chconf |= OMAP2_MCSPI_CHCONF_TRM_TX_ONLY;
1139 if (cd && cd->turbo_mode && t->tx_buf == NULL) {
1140 /* Turbo mode is for more than one word */
1141 if (t->len > ((cs->word_len + 7) >> 3))
1142 chconf |= OMAP2_MCSPI_CHCONF_TURBO;
1145 mcspi_write_chconf0(spi, chconf);
1150 if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) &&
1151 master->cur_msg_mapped &&
1152 master->can_dma(master, spi, t))
1153 omap2_mcspi_set_fifo(spi, t, 1);
1155 omap2_mcspi_set_enable(spi, 1);
1157 /* RX_ONLY mode needs dummy data in TX reg */
1158 if (t->tx_buf == NULL)
1159 writel_relaxed(0, cs->base
1162 if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) &&
1163 master->cur_msg_mapped &&
1164 master->can_dma(master, spi, t))
1165 count = omap2_mcspi_txrx_dma(spi, t);
1167 count = omap2_mcspi_txrx_pio(spi, t);
1169 if (count != t->len) {
1175 omap2_mcspi_set_enable(spi, 0);
1177 if (mcspi->fifo_depth > 0)
1178 omap2_mcspi_set_fifo(spi, t, 0);
1181 /* Restore defaults if they were overriden */
1184 status = omap2_mcspi_setup_transfer(spi, NULL);
1187 if (cd && cd->cs_per_word) {
1188 chconf = mcspi->ctx.modulctrl;
1189 chconf |= OMAP2_MCSPI_MODULCTRL_SINGLE;
1190 mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf);
1191 mcspi->ctx.modulctrl =
1192 mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL);
1195 omap2_mcspi_set_enable(spi, 0);
1197 if (gpio_is_valid(spi->cs_gpio))
1198 omap2_mcspi_set_cs(spi, !(spi->mode & SPI_CS_HIGH));
1200 if (mcspi->fifo_depth > 0 && t)
1201 omap2_mcspi_set_fifo(spi, t, 0);
1206 static int omap2_mcspi_prepare_message(struct spi_master *master,
1207 struct spi_message *msg)
1209 struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
1210 struct omap2_mcspi_regs *ctx = &mcspi->ctx;
1211 struct omap2_mcspi_cs *cs;
1213 /* Only a single channel can have the FORCE bit enabled
1214 * in its chconf0 register.
1215 * Scan all channels and disable them except the current one.
1216 * A FORCE can remain from a last transfer having cs_change enabled
1218 list_for_each_entry(cs, &ctx->cs, node) {
1219 if (msg->spi->controller_state == cs)
1222 if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE)) {
1223 cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE;
1224 writel_relaxed(cs->chconf0,
1225 cs->base + OMAP2_MCSPI_CHCONF0);
1226 readl_relaxed(cs->base + OMAP2_MCSPI_CHCONF0);
1233 static bool omap2_mcspi_can_dma(struct spi_master *master,
1234 struct spi_device *spi,
1235 struct spi_transfer *xfer)
1237 return (xfer->len >= DMA_MIN_BYTES);
1240 static int omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
1242 struct spi_master *master = mcspi->master;
1243 struct omap2_mcspi_regs *ctx = &mcspi->ctx;
1246 ret = pm_runtime_get_sync(mcspi->dev);
1248 pm_runtime_put_noidle(mcspi->dev);
1253 mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE,
1254 OMAP2_MCSPI_WAKEUPENABLE_WKEN);
1255 ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
1257 omap2_mcspi_set_master_mode(master);
1258 pm_runtime_mark_last_busy(mcspi->dev);
1259 pm_runtime_put_autosuspend(mcspi->dev);
1264 * When SPI wake up from off-mode, CS is in activate state. If it was in
1265 * inactive state when driver was suspend, then force it to inactive state at
1268 static int omap_mcspi_runtime_resume(struct device *dev)
1270 struct spi_master *master = dev_get_drvdata(dev);
1271 struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
1272 struct omap2_mcspi_regs *ctx = &mcspi->ctx;
1273 struct omap2_mcspi_cs *cs;
1275 /* McSPI: context restore */
1276 mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, ctx->modulctrl);
1277 mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable);
1279 list_for_each_entry(cs, &ctx->cs, node) {
1281 * We need to toggle CS state for OMAP take this
1282 * change in account.
1284 if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE) == 0) {
1285 cs->chconf0 |= OMAP2_MCSPI_CHCONF_FORCE;
1286 writel_relaxed(cs->chconf0,
1287 cs->base + OMAP2_MCSPI_CHCONF0);
1288 cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE;
1289 writel_relaxed(cs->chconf0,
1290 cs->base + OMAP2_MCSPI_CHCONF0);
1292 writel_relaxed(cs->chconf0,
1293 cs->base + OMAP2_MCSPI_CHCONF0);
1300 static struct omap2_mcspi_platform_config omap2_pdata = {
1304 static struct omap2_mcspi_platform_config omap4_pdata = {
1305 .regs_offset = OMAP4_MCSPI_REG_OFFSET,
1308 static const struct of_device_id omap_mcspi_of_match[] = {
1310 .compatible = "ti,omap2-mcspi",
1311 .data = &omap2_pdata,
1314 .compatible = "ti,omap4-mcspi",
1315 .data = &omap4_pdata,
1319 MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
1321 static int omap2_mcspi_probe(struct platform_device *pdev)
1323 struct spi_master *master;
1324 const struct omap2_mcspi_platform_config *pdata;
1325 struct omap2_mcspi *mcspi;
1328 u32 regs_offset = 0;
1329 struct device_node *node = pdev->dev.of_node;
1330 const struct of_device_id *match;
1332 master = spi_alloc_master(&pdev->dev, sizeof *mcspi);
1333 if (master == NULL) {
1334 dev_dbg(&pdev->dev, "master allocation failed\n");
1338 /* the spi->mode bits understood by this driver: */
1339 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
1340 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
1341 master->setup = omap2_mcspi_setup;
1342 master->auto_runtime_pm = true;
1343 master->prepare_message = omap2_mcspi_prepare_message;
1344 master->can_dma = omap2_mcspi_can_dma;
1345 master->transfer_one = omap2_mcspi_transfer_one;
1346 master->set_cs = omap2_mcspi_set_cs;
1347 master->cleanup = omap2_mcspi_cleanup;
1348 master->dev.of_node = node;
1349 master->max_speed_hz = OMAP2_MCSPI_MAX_FREQ;
1350 master->min_speed_hz = OMAP2_MCSPI_MAX_FREQ >> 15;
1352 platform_set_drvdata(pdev, master);
1354 mcspi = spi_master_get_devdata(master);
1355 mcspi->master = master;
1357 match = of_match_device(omap_mcspi_of_match, &pdev->dev);
1359 u32 num_cs = 1; /* default number of chipselect */
1360 pdata = match->data;
1362 of_property_read_u32(node, "ti,spi-num-cs", &num_cs);
1363 master->num_chipselect = num_cs;
1364 if (of_get_property(node, "ti,pindir-d0-out-d1-in", NULL))
1365 mcspi->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN;
1367 pdata = dev_get_platdata(&pdev->dev);
1368 master->num_chipselect = pdata->num_cs;
1369 mcspi->pin_dir = pdata->pin_dir;
1371 regs_offset = pdata->regs_offset;
1373 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1374 mcspi->base = devm_ioremap_resource(&pdev->dev, r);
1375 if (IS_ERR(mcspi->base)) {
1376 status = PTR_ERR(mcspi->base);
1379 mcspi->phys = r->start + regs_offset;
1380 mcspi->base += regs_offset;
1382 mcspi->dev = &pdev->dev;
1384 INIT_LIST_HEAD(&mcspi->ctx.cs);
1386 mcspi->dma_channels = devm_kcalloc(&pdev->dev, master->num_chipselect,
1387 sizeof(struct omap2_mcspi_dma),
1389 if (mcspi->dma_channels == NULL) {
1394 for (i = 0; i < master->num_chipselect; i++) {
1395 sprintf(mcspi->dma_channels[i].dma_rx_ch_name, "rx%d", i);
1396 sprintf(mcspi->dma_channels[i].dma_tx_ch_name, "tx%d", i);
1399 pm_runtime_use_autosuspend(&pdev->dev);
1400 pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
1401 pm_runtime_enable(&pdev->dev);
1403 status = omap2_mcspi_master_setup(mcspi);
1407 status = devm_spi_register_master(&pdev->dev, master);
1414 pm_runtime_dont_use_autosuspend(&pdev->dev);
1415 pm_runtime_put_sync(&pdev->dev);
1416 pm_runtime_disable(&pdev->dev);
1418 spi_master_put(master);
1422 static int omap2_mcspi_remove(struct platform_device *pdev)
1424 struct spi_master *master = platform_get_drvdata(pdev);
1425 struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
1427 pm_runtime_dont_use_autosuspend(mcspi->dev);
1428 pm_runtime_put_sync(mcspi->dev);
1429 pm_runtime_disable(&pdev->dev);
1434 /* work with hotplug and coldplug */
1435 MODULE_ALIAS("platform:omap2_mcspi");
1437 #ifdef CONFIG_SUSPEND
1438 static int omap2_mcspi_suspend_noirq(struct device *dev)
1440 return pinctrl_pm_select_sleep_state(dev);
1443 static int omap2_mcspi_resume_noirq(struct device *dev)
1445 struct spi_master *master = dev_get_drvdata(dev);
1446 struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
1449 error = pinctrl_pm_select_default_state(dev);
1451 dev_warn(mcspi->dev, "%s: failed to set pins: %i\n",
1458 #define omap2_mcspi_suspend_noirq NULL
1459 #define omap2_mcspi_resume_noirq NULL
1462 static const struct dev_pm_ops omap2_mcspi_pm_ops = {
1463 .suspend_noirq = omap2_mcspi_suspend_noirq,
1464 .resume_noirq = omap2_mcspi_resume_noirq,
1465 .runtime_resume = omap_mcspi_runtime_resume,
1468 static struct platform_driver omap2_mcspi_driver = {
1470 .name = "omap2_mcspi",
1471 .pm = &omap2_mcspi_pm_ops,
1472 .of_match_table = omap_mcspi_of_match,
1474 .probe = omap2_mcspi_probe,
1475 .remove = omap2_mcspi_remove,
1478 module_platform_driver(omap2_mcspi_driver);
1479 MODULE_LICENSE("GPL");