提交 8922a366 编写于 作者: A Andreas Larsson 提交者: Grant Likely

spi/spi-fsl-spi: Add support for setting a maximum number of bits per word

Acked-by: NAnton Vorontsov <anton@enomsg.org>
Signed-off-by: NAndreas Larsson <andreas@gaisler.com>
Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
上级 c3f3e771
...@@ -71,6 +71,7 @@ struct mpc8xxx_spi { ...@@ -71,6 +71,7 @@ struct mpc8xxx_spi {
#ifdef CONFIG_SPI_FSL_SPI #ifdef CONFIG_SPI_FSL_SPI
int type; int type;
u8 max_bits_per_word;
void (*set_shifts)(u32 *rx_shift, u32 *tx_shift, void (*set_shifts)(u32 *rx_shift, u32 *tx_shift,
int bits_per_word, int msb_first); int bits_per_word, int msb_first);
......
...@@ -213,7 +213,8 @@ static int fsl_spi_setup_transfer(struct spi_device *spi, ...@@ -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] */ /* Make sure its a bit width we support [4..16, 32] */
if ((bits_per_word < 4) 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; return -EINVAL;
if (!hz) if (!hz)
...@@ -520,6 +521,7 @@ static struct spi_master * fsl_spi_probe(struct device *dev, ...@@ -520,6 +521,7 @@ static struct spi_master * fsl_spi_probe(struct device *dev,
mpc8xxx_spi = spi_master_get_devdata(master); mpc8xxx_spi = spi_master_get_devdata(master);
mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg; mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg;
mpc8xxx_spi->spi_remove = fsl_spi_remove; mpc8xxx_spi->spi_remove = fsl_spi_remove;
mpc8xxx_spi->max_bits_per_word = 32;
mpc8xxx_spi->type = fsl_spi_get_type(dev); mpc8xxx_spi->type = fsl_spi_get_type(dev);
ret = fsl_spi_cpm_init(mpc8xxx_spi); ret = fsl_spi_cpm_init(mpc8xxx_spi);
...@@ -557,6 +559,10 @@ static struct spi_master * fsl_spi_probe(struct device *dev, ...@@ -557,6 +559,10 @@ static struct spi_master * fsl_spi_probe(struct device *dev,
/* Enable SPI interface */ /* Enable SPI interface */
regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE; 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) if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE)
regval |= SPMODE_OP; regval |= SPMODE_OP;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册