Skip to content

Commit

Permalink
spi/spi-fsl-spi: Add support for setting a maximum number of bits per…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
Andreas Larsson authored and Grant Likely committed Apr 7, 2013
1 parent c3f3e77 commit 8922a36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions drivers/spi/spi-fsl-lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct mpc8xxx_spi {

#ifdef CONFIG_SPI_FSL_SPI
int type;
u8 max_bits_per_word;

void (*set_shifts)(u32 *rx_shift, u32 *tx_shift,
int bits_per_word, int msb_first);
Expand Down
8 changes: 7 additions & 1 deletion drivers/spi/spi-fsl-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ static int fsl_spi_setup_transfer(struct spi_device *spi,

/* Make sure its a bit width we support [4..16, 32] */
if ((bits_per_word < 4)
|| ((bits_per_word > 16) && (bits_per_word != 32)))
|| ((bits_per_word > 16) && (bits_per_word != 32))
|| (bits_per_word > mpc8xxx_spi->max_bits_per_word))
return -EINVAL;

if (!hz)
Expand Down Expand Up @@ -520,6 +521,7 @@ static struct spi_master * fsl_spi_probe(struct device *dev,
mpc8xxx_spi = spi_master_get_devdata(master);
mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg;
mpc8xxx_spi->spi_remove = fsl_spi_remove;
mpc8xxx_spi->max_bits_per_word = 32;
mpc8xxx_spi->type = fsl_spi_get_type(dev);

ret = fsl_spi_cpm_init(mpc8xxx_spi);
Expand Down Expand Up @@ -557,6 +559,10 @@ static struct spi_master * fsl_spi_probe(struct device *dev,

/* Enable SPI interface */
regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE;
if (mpc8xxx_spi->max_bits_per_word < 8) {
regval &= ~SPMODE_LEN(0xF);
regval |= SPMODE_LEN(mpc8xxx_spi->max_bits_per_word - 1);
}
if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE)
regval |= SPMODE_OP;

Expand Down

0 comments on commit 8922a36

Please sign in to comment.