aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-omap2-mcspi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r--drivers/spi/spi-omap2-mcspi.c14
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) {