Skip to content

Commit 742d595

Browse files
KamalDasubroonie
authored andcommitted
spi: bcm-qspi: Drive MSPI peripheral SSb pin on cs_change
As per the spi core implementation for MSPI devices when the transfer is the last one in the message, the chip may stay selected until the next transfer. On multi-device SPI busses with nothing blocking messages going to other devices, this is just a performance hint; starting a message to another device deselects this one. But in other cases, this can be used to ensure correctness. Some devices need protocol transactions to be built from a series of spi_message submissions, where the content of one message is determined by the results of previous messages and where the whole transaction ends when the chipselect goes intactive. On CS change after completing the last serial transfer, the MSPI driver drives SSb pin CDRAM register correctly according comments in core spi.h as shown below: case 1) EOM =1, cs_change =0: SSb inactive case 2) EOM =1, cs_change =1: SSb active case 3) EOM =0, cs_change =0: SSb active case 4) EOM =0, cs_change =1: SSb inactive Signed-off-by: Kamal Dasu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 0dadde3 commit 742d595

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

drivers/spi/spi-bcm-qspi.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -612,19 +612,15 @@ static int update_qspi_trans_byte_count(struct bcm_qspi *qspi,
612612
if (qt->trans->cs_change &&
613613
(flags & TRANS_STATUS_BREAK_CS_CHANGE))
614614
ret |= TRANS_STATUS_BREAK_CS_CHANGE;
615-
if (ret)
616-
goto done;
617615

618-
dev_dbg(&qspi->pdev->dev, "advance msg exit\n");
619616
if (bcm_qspi_mspi_transfer_is_last(qspi, qt))
620-
ret = TRANS_STATUS_BREAK_EOM;
617+
ret |= TRANS_STATUS_BREAK_EOM;
621618
else
622-
ret = TRANS_STATUS_BREAK_NO_BYTES;
619+
ret |= TRANS_STATUS_BREAK_NO_BYTES;
623620

624621
qt->trans = NULL;
625622
}
626623

627-
done:
628624
dev_dbg(&qspi->pdev->dev, "trans %p len %d byte %d ret %x\n",
629625
qt->trans, qt->trans ? qt->trans->len : 0, qt->byte, ret);
630626
return ret;
@@ -771,7 +767,16 @@ static int write_to_hw(struct bcm_qspi *qspi, struct spi_device *spi)
771767
bcm_qspi_write(qspi, MSPI, MSPI_NEWQP, 0);
772768
bcm_qspi_write(qspi, MSPI, MSPI_ENDQP, slot - 1);
773769

774-
if (tstatus & TRANS_STATUS_BREAK_DESELECT) {
770+
/*
771+
* case 1) EOM =1, cs_change =0: SSb inactive
772+
* case 2) EOM =1, cs_change =1: SSb stay active
773+
* case 3) EOM =0, cs_change =0: SSb stay active
774+
* case 4) EOM =0, cs_change =1: SSb inactive
775+
*/
776+
if (((tstatus & TRANS_STATUS_BREAK_DESELECT)
777+
== TRANS_STATUS_BREAK_CS_CHANGE) ||
778+
((tstatus & TRANS_STATUS_BREAK_DESELECT)
779+
== TRANS_STATUS_BREAK_EOM)) {
775780
mspi_cdram = read_cdram_slot(qspi, slot - 1) &
776781
~MSPI_CDRAM_CONT_BIT;
777782
write_cdram_slot(qspi, slot - 1, mspi_cdram);

0 commit comments

Comments
 (0)