aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBhuvanchandra DV <bhuvanchandra.dv@toradex.com>2015-12-10 00:55:30 -0500
committerMark Brown <broonie@kernel.org>2015-12-12 17:33:09 -0500
commitef22d1604c622d24ded69f40d40c3c6d83f71156 (patch)
tree00857ff3240d92db30110b13bf70af44189d4592 /drivers
parent8005c49d9aea74d382f474ce11afbbc7d7130bec (diff)
spi-fsl-dspi: Fix CTAR Register access
DSPI instances in Vybrid have a different amount of chip selects and CTARs (Clock and transfer Attributes Register). In case of DSPI1 we only have 2 CTAR registers and 4 CS. In present driver implementation CTAR offset is derived from CS instance which will lead to out of bound access if chip select instance is greater than CTAR register instance, hence use single CTAR0 register for all CS instances. Since we write the CTAR register anyway before each access, there is no value in using the additional CTAR registers. Also one should not program a value in CTAS for a CTAR register that is not present, hence configure CTAS to use CTAR0. Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Acked-by: Stefan Agner <stefan@agner.ch> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/spi/spi-fsl-dspi.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 59a11437db70..39412c9097c6 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -167,7 +167,7 @@ static inline int is_double_byte_mode(struct fsl_dspi *dspi)
167{ 167{
168 unsigned int val; 168 unsigned int val;
169 169
170 regmap_read(dspi->regmap, SPI_CTAR(dspi->cs), &val); 170 regmap_read(dspi->regmap, SPI_CTAR(0), &val);
171 171
172 return ((val & SPI_FRAME_BITS_MASK) == SPI_FRAME_BITS(8)) ? 0 : 1; 172 return ((val & SPI_FRAME_BITS_MASK) == SPI_FRAME_BITS(8)) ? 0 : 1;
173} 173}
@@ -257,7 +257,7 @@ static u32 dspi_data_to_pushr(struct fsl_dspi *dspi, int tx_word)
257 257
258 return SPI_PUSHR_TXDATA(d16) | 258 return SPI_PUSHR_TXDATA(d16) |
259 SPI_PUSHR_PCS(dspi->cs) | 259 SPI_PUSHR_PCS(dspi->cs) |
260 SPI_PUSHR_CTAS(dspi->cs) | 260 SPI_PUSHR_CTAS(0) |
261 SPI_PUSHR_CONT; 261 SPI_PUSHR_CONT;
262} 262}
263 263
@@ -290,7 +290,7 @@ static int dspi_eoq_write(struct fsl_dspi *dspi)
290 */ 290 */
291 if (tx_word && (dspi->len == 1)) { 291 if (tx_word && (dspi->len == 1)) {
292 dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM; 292 dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM;
293 regmap_update_bits(dspi->regmap, SPI_CTAR(dspi->cs), 293 regmap_update_bits(dspi->regmap, SPI_CTAR(0),
294 SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8)); 294 SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8));
295 tx_word = 0; 295 tx_word = 0;
296 } 296 }
@@ -339,7 +339,7 @@ static int dspi_tcfq_write(struct fsl_dspi *dspi)
339 339
340 if (tx_word && (dspi->len == 1)) { 340 if (tx_word && (dspi->len == 1)) {
341 dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM; 341 dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM;
342 regmap_update_bits(dspi->regmap, SPI_CTAR(dspi->cs), 342 regmap_update_bits(dspi->regmap, SPI_CTAR(0),
343 SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8)); 343 SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8));
344 tx_word = 0; 344 tx_word = 0;
345 } 345 }
@@ -407,7 +407,7 @@ static int dspi_transfer_one_message(struct spi_master *master,
407 regmap_update_bits(dspi->regmap, SPI_MCR, 407 regmap_update_bits(dspi->regmap, SPI_MCR,
408 SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF, 408 SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF,
409 SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF); 409 SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF);
410 regmap_write(dspi->regmap, SPI_CTAR(dspi->cs), 410 regmap_write(dspi->regmap, SPI_CTAR(0),
411 dspi->cur_chip->ctar_val); 411 dspi->cur_chip->ctar_val);
412 412
413 trans_mode = dspi->devtype_data->trans_mode; 413 trans_mode = dspi->devtype_data->trans_mode;
@@ -566,7 +566,7 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id)
566 if (!dspi->len) { 566 if (!dspi->len) {
567 if (dspi->dataflags & TRAN_STATE_WORD_ODD_NUM) { 567 if (dspi->dataflags & TRAN_STATE_WORD_ODD_NUM) {
568 regmap_update_bits(dspi->regmap, 568 regmap_update_bits(dspi->regmap,
569 SPI_CTAR(dspi->cs), 569 SPI_CTAR(0),
570 SPI_FRAME_BITS_MASK, 570 SPI_FRAME_BITS_MASK,
571 SPI_FRAME_BITS(16)); 571 SPI_FRAME_BITS(16));
572 dspi->dataflags &= ~TRAN_STATE_WORD_ODD_NUM; 572 dspi->dataflags &= ~TRAN_STATE_WORD_ODD_NUM;