aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/omap2_mcspi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/omap2_mcspi.c')
-rw-r--r--drivers/spi/omap2_mcspi.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index ba1a872b221e..e0de0d0eedea 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -32,11 +32,12 @@
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/clk.h> 33#include <linux/clk.h>
34#include <linux/io.h> 34#include <linux/io.h>
35#include <linux/slab.h>
35 36
36#include <linux/spi/spi.h> 37#include <linux/spi/spi.h>
37 38
38#include <mach/dma.h> 39#include <plat/dma.h>
39#include <mach/clock.h> 40#include <plat/clock.h>
40 41
41 42
42#define OMAP2_MCSPI_MAX_FREQ 48000000 43#define OMAP2_MCSPI_MAX_FREQ 48000000
@@ -203,6 +204,7 @@ static inline void mcspi_write_chconf0(const struct spi_device *spi, u32 val)
203 204
204 cs->chconf0 = val; 205 cs->chconf0 = val;
205 mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCONF0, val); 206 mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCONF0, val);
207 mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHCONF0);
206} 208}
207 209
208static void omap2_mcspi_set_dma_req(const struct spi_device *spi, 210static void omap2_mcspi_set_dma_req(const struct spi_device *spi,
@@ -531,7 +533,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
531 goto out; 533 goto out;
532 } 534 }
533#ifdef VERBOSE 535#ifdef VERBOSE
534 dev_dbg(&spi->dev, "write-%d %04x\n", 536 dev_dbg(&spi->dev, "write-%d %08x\n",
535 word_len, *tx); 537 word_len, *tx);
536#endif 538#endif
537 __raw_writel(*tx++, tx_reg); 539 __raw_writel(*tx++, tx_reg);
@@ -549,7 +551,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
549 mcspi_write_chconf0(spi, l); 551 mcspi_write_chconf0(spi, l);
550 *rx++ = __raw_readl(rx_reg); 552 *rx++ = __raw_readl(rx_reg);
551#ifdef VERBOSE 553#ifdef VERBOSE
552 dev_dbg(&spi->dev, "read-%d %04x\n", 554 dev_dbg(&spi->dev, "read-%d %08x\n",
553 word_len, *(rx - 1)); 555 word_len, *(rx - 1));
554#endif 556#endif
555 } 557 }
@@ -578,6 +580,7 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,
578 struct spi_master *spi_cntrl; 580 struct spi_master *spi_cntrl;
579 u32 l = 0, div = 0; 581 u32 l = 0, div = 0;
580 u8 word_len = spi->bits_per_word; 582 u8 word_len = spi->bits_per_word;
583 u32 speed_hz = spi->max_speed_hz;
581 584
582 mcspi = spi_master_get_devdata(spi->master); 585 mcspi = spi_master_get_devdata(spi->master);
583 spi_cntrl = mcspi->master; 586 spi_cntrl = mcspi->master;
@@ -587,9 +590,12 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,
587 590
588 cs->word_len = word_len; 591 cs->word_len = word_len;
589 592
590 if (spi->max_speed_hz) { 593 if (t && t->speed_hz)
594 speed_hz = t->speed_hz;
595
596 if (speed_hz) {
591 while (div <= 15 && (OMAP2_MCSPI_MAX_FREQ / (1 << div)) 597 while (div <= 15 && (OMAP2_MCSPI_MAX_FREQ / (1 << div))
592 > spi->max_speed_hz) 598 > speed_hz)
593 div++; 599 div++;
594 } else 600 } else
595 div = 15; 601 div = 15;
@@ -751,11 +757,13 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
751 mcspi = spi_master_get_devdata(spi->master); 757 mcspi = spi_master_get_devdata(spi->master);
752 mcspi_dma = &mcspi->dma_channels[spi->chip_select]; 758 mcspi_dma = &mcspi->dma_channels[spi->chip_select];
753 759
754 /* Unlink controller state from context save list */ 760 if (spi->controller_state) {
755 cs = spi->controller_state; 761 /* Unlink controller state from context save list */
756 list_del(&cs->node); 762 cs = spi->controller_state;
763 list_del(&cs->node);
757 764
758 kfree(spi->controller_state); 765 kfree(spi->controller_state);
766 }
759 767
760 if (mcspi_dma->dma_rx_channel != -1) { 768 if (mcspi_dma->dma_rx_channel != -1) {
761 omap_free_dma(mcspi_dma->dma_rx_channel); 769 omap_free_dma(mcspi_dma->dma_rx_channel);
@@ -1014,7 +1022,7 @@ static u8 __initdata spi2_txdma_id[] = {
1014 OMAP24XX_DMA_SPI2_TX1, 1022 OMAP24XX_DMA_SPI2_TX1,
1015}; 1023};
1016 1024
1017#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) \ 1025#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) \
1018 || defined(CONFIG_ARCH_OMAP4) 1026 || defined(CONFIG_ARCH_OMAP4)
1019static u8 __initdata spi3_rxdma_id[] = { 1027static u8 __initdata spi3_rxdma_id[] = {
1020 OMAP24XX_DMA_SPI3_RX0, 1028 OMAP24XX_DMA_SPI3_RX0,