Skip to content

Commit 10c24e0

Browse files
Félix Piédallubroonie
authored andcommitted
spi: omap2-mcspi: Disable multi-mode when the previous message kept CS asserted
When the last transfer of a SPI message has the cs_change flag, the CS is kept asserted after the message. The next message can't use multi-mode because the CS will be briefly deasserted before the first transfer. Remove the early exit of the list_for_each_entry because the last transfer actually needs to be always checked. Fixes: d153ff4 ("spi: omap2-mcspi: Add support for MULTI-mode") Signed-off-by: Félix Piédallu <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent a5bf527 commit 10c24e0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/spi/spi-omap2-mcspi.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ struct omap2_mcspi {
134134
size_t max_xfer_len;
135135
u32 ref_clk_hz;
136136
bool use_multi_mode;
137+
bool last_msg_kept_cs;
137138
};
138139

139140
struct omap2_mcspi_cs {
@@ -1269,6 +1270,10 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,
12691270
* multi-mode is applicable.
12701271
*/
12711272
mcspi->use_multi_mode = true;
1273+
1274+
if (mcspi->last_msg_kept_cs)
1275+
mcspi->use_multi_mode = false;
1276+
12721277
list_for_each_entry(tr, &msg->transfers, transfer_list) {
12731278
if (!tr->bits_per_word)
12741279
bits_per_word = msg->spi->bits_per_word;
@@ -1289,22 +1294,17 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,
12891294

12901295
if (list_is_last(&tr->transfer_list, &msg->transfers)) {
12911296
/* Check if transfer asks to keep the CS status after the whole message */
1292-
if (tr->cs_change)
1297+
if (tr->cs_change) {
12931298
mcspi->use_multi_mode = false;
1299+
mcspi->last_msg_kept_cs = true;
1300+
} else {
1301+
mcspi->last_msg_kept_cs = false;
1302+
}
12941303
} else {
12951304
/* Check if transfer asks to change the CS status after the transfer */
12961305
if (!tr->cs_change)
12971306
mcspi->use_multi_mode = false;
12981307
}
1299-
1300-
/*
1301-
* If at least one message is not compatible, switch back to single mode
1302-
*
1303-
* The bits_per_word of certain transfer can be different, but it will have no
1304-
* impact on the signal itself.
1305-
*/
1306-
if (!mcspi->use_multi_mode)
1307-
break;
13081308
}
13091309

13101310
omap2_mcspi_set_mode(ctlr);

0 commit comments

Comments
 (0)