aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Larsson <andreas@gaisler.com>2013-02-15 10:52:25 -0500
committerGrant Likely <grant.likely@secretlab.ca>2013-04-07 05:07:56 -0400
commit8922a366ddd20964e3542e12f0315a8a88b3a638 (patch)
treef002ba035438fe7586259f24c757b99cff0d6e92
parentc3f3e7717f1cf01d9117a98ed89decc41d7cb5db (diff)
spi/spi-fsl-spi: Add support for setting a maximum number of bits per word
Acked-by: Anton Vorontsov <anton@enomsg.org> Signed-off-by: Andreas Larsson <andreas@gaisler.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
-rw-r--r--drivers/spi/spi-fsl-lib.h1
-rw-r--r--drivers/spi/spi-fsl-spi.c8
2 files changed, 8 insertions, 1 deletions
diff --git a/drivers/spi/spi-fsl-lib.h b/drivers/spi/spi-fsl-lib.h
index 5a9c36c7cb68..d5c788b584df 100644
--- a/drivers/spi/spi-fsl-lib.h
+++ b/drivers/spi/spi-fsl-lib.h
@@ -71,6 +71,7 @@ struct mpc8xxx_spi {
71 71
72#ifdef CONFIG_SPI_FSL_SPI 72#ifdef CONFIG_SPI_FSL_SPI
73 int type; 73 int type;
74 u8 max_bits_per_word;
74 75
75 void (*set_shifts)(u32 *rx_shift, u32 *tx_shift, 76 void (*set_shifts)(u32 *rx_shift, u32 *tx_shift,
76 int bits_per_word, int msb_first); 77 int bits_per_word, int msb_first);
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index b9064434e0f7..7eff63a284ff 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -213,7 +213,8 @@ static int fsl_spi_setup_transfer(struct spi_device *spi,
213 213
214 /* Make sure its a bit width we support [4..16, 32] */ 214 /* Make sure its a bit width we support [4..16, 32] */
215 if ((bits_per_word < 4) 215 if ((bits_per_word < 4)
216 || ((bits_per_word > 16) && (bits_per_word != 32))) 216 || ((bits_per_word > 16) && (bits_per_word != 32))
217 || (bits_per_word > mpc8xxx_spi->max_bits_per_word))
217 return -EINVAL; 218 return -EINVAL;
218 219
219 if (!hz) 220 if (!hz)
@@ -520,6 +521,7 @@ static struct spi_master * fsl_spi_probe(struct device *dev,
520 mpc8xxx_spi = spi_master_get_devdata(master); 521 mpc8xxx_spi = spi_master_get_devdata(master);
521 mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg; 522 mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg;
522 mpc8xxx_spi->spi_remove = fsl_spi_remove; 523 mpc8xxx_spi->spi_remove = fsl_spi_remove;
524 mpc8xxx_spi->max_bits_per_word = 32;
523 mpc8xxx_spi->type = fsl_spi_get_type(dev); 525 mpc8xxx_spi->type = fsl_spi_get_type(dev);
524 526
525 ret = fsl_spi_cpm_init(mpc8xxx_spi); 527 ret = fsl_spi_cpm_init(mpc8xxx_spi);
@@ -557,6 +559,10 @@ static struct spi_master * fsl_spi_probe(struct device *dev,
557 559
558 /* Enable SPI interface */ 560 /* Enable SPI interface */
559 regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE; 561 regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE;
562 if (mpc8xxx_spi->max_bits_per_word < 8) {
563 regval &= ~SPMODE_LEN(0xF);
564 regval |= SPMODE_LEN(mpc8xxx_spi->max_bits_per_word - 1);
565 }
560 if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) 566 if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE)
561 regval |= SPMODE_OP; 567 regval |= SPMODE_OP;
562 568