aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrent Piepho <tpiepho@gmail.com>2013-10-01 16:14:25 -0400
committerMark Brown <broonie@linaro.org>2013-10-17 20:00:28 -0400
commit58f46e41c1925236a1c34873caa5d1247f846005 (patch)
treebc7496cce85063d1868e0e6928a8bba9db015185
parent61e6cfa80de5760bbe406f4e815b7739205754d2 (diff)
spi: spi-mxs: Always set LOCK_CS
There are two bits which control the CS line in the CTRL0 register: LOCK_CS and IGNORE_CRC. The latter would be better named DEASSERT_CS in SPI mode. LOCK_CS keeps CS asserted though the entire transfer. This should always be set. The DMA code will always set it, explicitly on the first segment of the first transfer, and then implicitly on all the rest by never clearing the bit from the value read from the ctrl0 register. The PIO code will explicitly set it for the first transfer, leave it set for intermediate transfers, and then clear it for the final transfer. It should not clear it. The only reason to not set LOCK_CS would be to attempt an altered protocol where CS pulses between each word. Though don't get your hopes up if you want to do this, as the hardware doesn't appear to do this in any sane manner. It appears to be related to the hardware FIFO fill level. The code can be simplified by just setting LOCK_CS once and then not needing to deal with it at all in the PIO and DMA transfer functions. Signed-off-by: Trent Piepho <tpiepho@gmail.com> Cc: Marek Vasut <marex@denx.de> Cc: Fabio Estevam <fabio.estevam@freescale.com> Cc: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/spi/spi-mxs.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index de7b1141b90f..e6172aedf859 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -79,6 +79,8 @@ static int mxs_spi_setup_transfer(struct spi_device *dev,
79 79
80 mxs_ssp_set_clk_rate(ssp, hz); 80 mxs_ssp_set_clk_rate(ssp, hz);
81 81
82 writel(BM_SSP_CTRL0_LOCK_CS,
83 ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
82 writel(BF_SSP_CTRL1_SSP_MODE(BV_SSP_CTRL1_SSP_MODE__SPI) | 84 writel(BF_SSP_CTRL1_SSP_MODE(BV_SSP_CTRL1_SSP_MODE__SPI) |
83 BF_SSP_CTRL1_WORD_LENGTH 85 BF_SSP_CTRL1_WORD_LENGTH
84 (BV_SSP_CTRL1_WORD_LENGTH__EIGHT_BITS) | 86 (BV_SSP_CTRL1_WORD_LENGTH__EIGHT_BITS) |
@@ -147,8 +149,6 @@ static inline void mxs_spi_enable(struct mxs_spi *spi)
147{ 149{
148 struct mxs_ssp *ssp = &spi->ssp; 150 struct mxs_ssp *ssp = &spi->ssp;
149 151
150 writel(BM_SSP_CTRL0_LOCK_CS,
151 ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
152 writel(BM_SSP_CTRL0_IGNORE_CRC, 152 writel(BM_SSP_CTRL0_IGNORE_CRC,
153 ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR); 153 ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
154} 154}
@@ -157,8 +157,6 @@ static inline void mxs_spi_disable(struct mxs_spi *spi)
157{ 157{
158 struct mxs_ssp *ssp = &spi->ssp; 158 struct mxs_ssp *ssp = &spi->ssp;
159 159
160 writel(BM_SSP_CTRL0_LOCK_CS,
161 ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
162 writel(BM_SSP_CTRL0_IGNORE_CRC, 160 writel(BM_SSP_CTRL0_IGNORE_CRC,
163 ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET); 161 ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
164} 162}
@@ -232,8 +230,6 @@ static int mxs_spi_txrx_dma(struct mxs_spi *spi, int cs,
232 ctrl0 &= ~BM_SSP_CTRL0_XFER_COUNT; 230 ctrl0 &= ~BM_SSP_CTRL0_XFER_COUNT;
233 ctrl0 |= BM_SSP_CTRL0_DATA_XFER | mxs_spi_cs_to_reg(cs); 231 ctrl0 |= BM_SSP_CTRL0_DATA_XFER | mxs_spi_cs_to_reg(cs);
234 232
235 if (*first)
236 ctrl0 |= BM_SSP_CTRL0_LOCK_CS;
237 if (!write) 233 if (!write)
238 ctrl0 |= BM_SSP_CTRL0_READ; 234 ctrl0 |= BM_SSP_CTRL0_READ;
239 235