Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andreas Larsson and committed by
Grant Likely
8922a366 c3f3e771

+8 -1
+1
drivers/spi/spi-fsl-lib.h
··· 71 71 72 72 #ifdef CONFIG_SPI_FSL_SPI 73 73 int type; 74 + u8 max_bits_per_word; 74 75 75 76 void (*set_shifts)(u32 *rx_shift, u32 *tx_shift, 76 77 int bits_per_word, int msb_first);
+7 -1
drivers/spi/spi-fsl-spi.c
··· 213 213 214 214 /* Make sure its a bit width we support [4..16, 32] */ 215 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 218 return -EINVAL; 218 219 219 220 if (!hz) ··· 521 520 mpc8xxx_spi = spi_master_get_devdata(master); 522 521 mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg; 523 522 mpc8xxx_spi->spi_remove = fsl_spi_remove; 523 + mpc8xxx_spi->max_bits_per_word = 32; 524 524 mpc8xxx_spi->type = fsl_spi_get_type(dev); 525 525 526 526 ret = fsl_spi_cpm_init(mpc8xxx_spi); ··· 559 557 560 558 /* Enable SPI interface */ 561 559 regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE; 560 + if (mpc8xxx_spi->max_bits_per_word < 8) { 561 + regval &= ~SPMODE_LEN(0xF); 562 + regval |= SPMODE_LEN(mpc8xxx_spi->max_bits_per_word - 1); 563 + } 562 564 if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) 563 565 regval |= SPMODE_OP; 564 566