aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-fsl-spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-fsl-spi.c')
-rw-r--r--drivers/spi/spi-fsl-spi.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index 119f7af94537..f35488ed62a9 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -239,12 +239,6 @@ static int fsl_spi_setup_transfer(struct spi_device *spi,
239 if (!bits_per_word) 239 if (!bits_per_word)
240 bits_per_word = spi->bits_per_word; 240 bits_per_word = spi->bits_per_word;
241 241
242 /* Make sure its a bit width we support [4..16, 32] */
243 if ((bits_per_word < 4)
244 || ((bits_per_word > 16) && (bits_per_word != 32))
245 || (bits_per_word > mpc8xxx_spi->max_bits_per_word))
246 return -EINVAL;
247
248 if (!hz) 242 if (!hz)
249 hz = spi->max_speed_hz; 243 hz = spi->max_speed_hz;
250 244
@@ -362,18 +356,28 @@ static int fsl_spi_bufs(struct spi_device *spi, struct spi_transfer *t,
362static void fsl_spi_do_one_msg(struct spi_message *m) 356static void fsl_spi_do_one_msg(struct spi_message *m)
363{ 357{
364 struct spi_device *spi = m->spi; 358 struct spi_device *spi = m->spi;
365 struct spi_transfer *t; 359 struct spi_transfer *t, *first;
366 unsigned int cs_change; 360 unsigned int cs_change;
367 const int nsecs = 50; 361 const int nsecs = 50;
368 int status; 362 int status;
369 363
370 cs_change = 1; 364 /* Don't allow changes if CS is active */
371 status = 0; 365 first = list_first_entry(&m->transfers, struct spi_transfer,
366 transfer_list);
372 list_for_each_entry(t, &m->transfers, transfer_list) { 367 list_for_each_entry(t, &m->transfers, transfer_list) {
373 if (t->bits_per_word || t->speed_hz) { 368 if ((first->bits_per_word != t->bits_per_word) ||
374 /* Don't allow changes if CS is active */ 369 (first->speed_hz != t->speed_hz)) {
375 status = -EINVAL; 370 status = -EINVAL;
371 dev_err(&spi->dev,
372 "bits_per_word/speed_hz should be same for the same SPI transfer\n");
373 return;
374 }
375 }
376 376
377 cs_change = 1;
378 status = -EINVAL;
379 list_for_each_entry(t, &m->transfers, transfer_list) {
380 if (t->bits_per_word || t->speed_hz) {
377 if (cs_change) 381 if (cs_change)
378 status = fsl_spi_setup_transfer(spi, t); 382 status = fsl_spi_setup_transfer(spi, t);
379 if (status < 0) 383 if (status < 0)
@@ -641,6 +645,10 @@ static struct spi_master * fsl_spi_probe(struct device *dev,
641 if (mpc8xxx_spi->type == TYPE_GRLIB) 645 if (mpc8xxx_spi->type == TYPE_GRLIB)
642 fsl_spi_grlib_probe(dev); 646 fsl_spi_grlib_probe(dev);
643 647
648 master->bits_per_word_mask =
649 (SPI_BPW_RANGE_MASK(4, 16) | SPI_BPW_MASK(32)) &
650 SPI_BPW_RANGE_MASK(1, mpc8xxx_spi->max_bits_per_word);
651
644 if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) 652 if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE)
645 mpc8xxx_spi->set_shifts = fsl_spi_qe_cpu_set_shifts; 653 mpc8xxx_spi->set_shifts = fsl_spi_qe_cpu_set_shifts;
646 654