diff options
author | Aisheng.Dong <b29396@freescale.com> | 2010-09-02 14:39:02 +0800 |
---|---|---|
committer | Alan Tull <r80115@freescale.com> | 2010-09-25 09:53:33 -0500 |
commit | 5a5920c53db8eb10cc8c3d07a9097f6daac3dbf5 (patch) | |
tree | 3111cd721abb4f4fa065e4866131b16b1fbd0d61 /drivers/spi | |
parent | 77c68716bb375856027de43eb0443e729dab158c (diff) |
ENGR00131466-1 mxs spi: add version 4.x support
Version 4.x will be used for mx28 platform.
Signed-off-by: Aisheng.Dong <b29396@freescale.com>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi_mxs.c | 42 | ||||
-rw-r--r-- | drivers/spi/spi_mxs.h | 2 |
2 files changed, 37 insertions, 7 deletions
diff --git a/drivers/spi/spi_mxs.c b/drivers/spi/spi_mxs.c index 744be68d9433..ca518916ea23 100644 --- a/drivers/spi/spi_mxs.c +++ b/drivers/spi/spi_mxs.c @@ -41,6 +41,21 @@ #include "spi_mxs.h" +#ifndef BF_SSP_CTRL0_XFER_COUNT +#define BF_SSP_CTRL0_XFER_COUNT(len) HW_SSP_VERSION +#endif +#ifndef BM_SSP_CTRL0_XFER_COUNT +#define BM_SSP_CTRL0_XFER_COUNT HW_SSP_VERSION +#endif + +#ifndef BF_SSP_XFER_SIZE_XFER_COUNT +#define BF_SSP_XFER_SIZE_XFER_COUNT(len) HW_SSP_VERSION +#endif +#ifndef BM_SSP_XFER_SIZE_XFER_COUNT +#define BM_SSP_XFER_SIZE_XFER_COUNT HW_SSP_VERSION +#endif + + /* 0 means DMA modei(recommended, default), !0 - PIO mode */ static int pio /* = 0 */ ; static int debug; @@ -206,7 +221,7 @@ static int mxs_spi_txrx_dma(struct mxs_spi *ss, int cs, unsigned char *buf, dma_addr_t dma_buf, int len, int *first, int *last, int write) { - u32 c0 = 0; + u32 c0 = 0, xfer_size = 0; dma_addr_t spi_buf_dma = dma_buf; int count, status = 0; enum dma_data_direction dir = write ? DMA_TO_DEVICE : DMA_FROM_DEVICE; @@ -218,7 +233,12 @@ static int mxs_spi_txrx_dma(struct mxs_spi *ss, int cs, c0 |= mxs_spi_cs(cs); - c0 |= BF_SSP_CTRL0_XFER_COUNT(len); + if (ss->ver_major > 3) { + xfer_size = BF_SSP_XFER_SIZE_XFER_COUNT(len); + __raw_writel(xfer_size, ss->regs + HW_SSP_XFER_SIZE); + } else { + c0 |= BF_SSP_CTRL0_XFER_COUNT(len); + } if (!dma_buf) spi_buf_dma = dma_map_single(ss->master_dev, buf, len, dir); @@ -285,9 +305,15 @@ static int mxs_spi_txrx_pio(struct mxs_spi *ss, int cs, mxs_spi_disable(ss); *last = 0; } - __raw_writel(BM_SSP_CTRL0_XFER_COUNT, - ss->regs + HW_SSP_CTRL0_CLR); - __raw_writel(1, ss->regs + HW_SSP_CTRL0_SET); /* byte-by-byte */ + + /* byte-by-byte */ + if (ss->ver_major > 3) { + __raw_writel(1, ss->regs + HW_SSP_XFER_SIZE); + } else { + __raw_writel(BM_SSP_CTRL0_XFER_COUNT, + ss->regs + HW_SSP_CTRL0_CLR); + __raw_writel(1, ss->regs + HW_SSP_CTRL0_SET); + } if (write) __raw_writel(BM_SSP_CTRL0_READ, @@ -580,6 +606,8 @@ static int __init mxs_spi_probe(struct platform_device *dev) dev_info(&dev->dev, "Max possible speed %d = %ld/%d kHz\n", ss->speed_khz, clk_get_rate(ss->clk), ss->divider); + ss->ver_major = __raw_readl(ss->regs + HW_SSP_VERSION) >> 24; + /* Register for SPI Interrupt */ err = request_irq(ss->irq_dma, mxs_spi_irq_dma, 0, dev_name(&dev->dev), ss); @@ -599,9 +627,9 @@ static int __init mxs_spi_probe(struct platform_device *dev) dev_dbg(&dev->dev, "cannot register spi master, %d\n", err); goto out_free_irq_2; } - dev_info(&dev->dev, "at 0x%08X mapped to 0x%08X, irq=%d, bus %d, %s\n", + dev_info(&dev->dev, "at 0x%08X mapped to 0x%08X, irq=%d, bus %d, %s ver_major %d\n", mem, (u32) ss->regs, ss->irq_dma, - master->bus_num, pio ? "PIO" : "DMA"); + master->bus_num, pio ? "PIO" : "DMA", ss->ver_major); return 0; out_free_irq_2: diff --git a/drivers/spi/spi_mxs.h b/drivers/spi/spi_mxs.h index ba605bf3b56e..c9e271e92f8b 100644 --- a/drivers/spi/spi_mxs.h +++ b/drivers/spi/spi_mxs.h @@ -46,6 +46,8 @@ struct mxs_spi { spinlock_t lock; struct list_head queue; + u32 ver_major; + struct completion done; }; |