diff options
author | Mark A. Greer <mgreer@animalcreek.com> | 2014-07-01 23:28:32 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-07-03 14:49:05 -0400 |
commit | 97ca0d6cc118716840ea443e010cb3d5f2d25eaf (patch) | |
tree | 63b55425bbb4f75caa656e812c9d9cd9714405d9 | |
parent | 7171511eaec5bf23fb06078f59784a3a0626b38f (diff) |
spi: omap2-mcspi: Configure hardware when slave driver changes mode
Commit id 2bd16e3e23d9df41592c6b257c59b6860a9cc3ea
(spi: omap2-mcspi: Do not configure the controller
on each transfer unless needed) does its job too
well so omap2_mcspi_setup_transfer() isn't called
even when an SPI slave driver changes 'spi->mode'.
The result is that the mode requested by the SPI
slave driver never takes effect.
Fix this by adding the 'mode' member to the
omap2_mcspi_cs structure which holds the mode
value that the hardware is configured for.
When the SPI slave driver changes 'spi->mode'
it will be different than the value of this new
member and the SPI master driver will know that
the hardware must be reconfigured (by calling
omap2_mcspi_setup_transfer()).
Fixes: 2bd16e3e23 (spi: omap2-mcspi: Do not configure the controller on each transfer unless needed)
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Cc: stable@vger.kernel.org
-rw-r--r-- | drivers/spi/spi-omap2-mcspi.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 4dc77df38864..68441fa448de 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c | |||
@@ -149,6 +149,7 @@ struct omap2_mcspi_cs { | |||
149 | void __iomem *base; | 149 | void __iomem *base; |
150 | unsigned long phys; | 150 | unsigned long phys; |
151 | int word_len; | 151 | int word_len; |
152 | u16 mode; | ||
152 | struct list_head node; | 153 | struct list_head node; |
153 | /* Context save and restore shadow register */ | 154 | /* Context save and restore shadow register */ |
154 | u32 chconf0, chctrl0; | 155 | u32 chconf0, chctrl0; |
@@ -926,6 +927,8 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi, | |||
926 | 927 | ||
927 | mcspi_write_chconf0(spi, l); | 928 | mcspi_write_chconf0(spi, l); |
928 | 929 | ||
930 | cs->mode = spi->mode; | ||
931 | |||
929 | dev_dbg(&spi->dev, "setup: speed %d, sample %s edge, clk %s\n", | 932 | dev_dbg(&spi->dev, "setup: speed %d, sample %s edge, clk %s\n", |
930 | speed_hz, | 933 | speed_hz, |
931 | (spi->mode & SPI_CPHA) ? "trailing" : "leading", | 934 | (spi->mode & SPI_CPHA) ? "trailing" : "leading", |
@@ -998,6 +1001,7 @@ static int omap2_mcspi_setup(struct spi_device *spi) | |||
998 | return -ENOMEM; | 1001 | return -ENOMEM; |
999 | cs->base = mcspi->base + spi->chip_select * 0x14; | 1002 | cs->base = mcspi->base + spi->chip_select * 0x14; |
1000 | cs->phys = mcspi->phys + spi->chip_select * 0x14; | 1003 | cs->phys = mcspi->phys + spi->chip_select * 0x14; |
1004 | cs->mode = 0; | ||
1001 | cs->chconf0 = 0; | 1005 | cs->chconf0 = 0; |
1002 | cs->chctrl0 = 0; | 1006 | cs->chctrl0 = 0; |
1003 | spi->controller_state = cs; | 1007 | spi->controller_state = cs; |
@@ -1079,6 +1083,16 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) | |||
1079 | cs = spi->controller_state; | 1083 | cs = spi->controller_state; |
1080 | cd = spi->controller_data; | 1084 | cd = spi->controller_data; |
1081 | 1085 | ||
1086 | /* | ||
1087 | * The slave driver could have changed spi->mode in which case | ||
1088 | * it will be different from cs->mode (the current hardware setup). | ||
1089 | * If so, set par_override (even though its not a parity issue) so | ||
1090 | * omap2_mcspi_setup_transfer will be called to configure the hardware | ||
1091 | * with the correct mode on the first iteration of the loop below. | ||
1092 | */ | ||
1093 | if (spi->mode != cs->mode) | ||
1094 | par_override = 1; | ||
1095 | |||
1082 | omap2_mcspi_set_enable(spi, 0); | 1096 | omap2_mcspi_set_enable(spi, 0); |
1083 | list_for_each_entry(t, &m->transfers, transfer_list) { | 1097 | list_for_each_entry(t, &m->transfers, transfer_list) { |
1084 | if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) { | 1098 | if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) { |