Skip to content

Commit 4fcc7c2

Browse files
vladimirolteanbroonie
authored andcommitted
spi: spi-fsl-dspi: Don't access reserved fields in SPI_MCR
The SPI_MCR_PCSIS macro assumes that the controller has a number of chip select signals equal to 6. That is not always the case, but actually is described through the driver-specific "spi-num-chipselects" device tree binding. LS1028A for example only has 4 chip selects. Don't write to the upper bits of the PCSIS field, which are reserved in the reference manual. Fixes: 349ad66 ("spi:Add Freescale DSPI driver for Vybrid VF610 platform") Signed-off-by: Vladimir Oltean <[email protected]> Tested-by: Michael Walle <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 85dadb7 commit 4fcc7c2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/spi/spi-fsl-dspi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#define SPI_MCR 0x00
2424
#define SPI_MCR_MASTER BIT(31)
25-
#define SPI_MCR_PCSIS (0x3F << 16)
25+
#define SPI_MCR_PCSIS(x) ((x) << 16)
2626
#define SPI_MCR_CLR_TXF BIT(11)
2727
#define SPI_MCR_CLR_RXF BIT(10)
2828
#define SPI_MCR_XSPI BIT(3)
@@ -1200,7 +1200,10 @@ static const struct regmap_config dspi_xspi_regmap_config[] = {
12001200

12011201
static void dspi_init(struct fsl_dspi *dspi)
12021202
{
1203-
unsigned int mcr = SPI_MCR_PCSIS;
1203+
unsigned int mcr;
1204+
1205+
/* Set idle states for all chip select signals to high */
1206+
mcr = SPI_MCR_PCSIS(GENMASK(dspi->ctlr->num_chipselect - 1, 0));
12041207

12051208
if (dspi->devtype_data->trans_mode == DSPI_XSPI_MODE)
12061209
mcr |= SPI_MCR_XSPI;

0 commit comments

Comments
 (0)