spi: spi-fsl-dspi: Use max_native_cs instead of num_chipselect to set SPI_MCR
If cs-gpios property is used in devicetree then ctlr->num_chipselect value
may be changed by spi_get_gpio_descs().
So use ctlr->max_native_cs instead of ctlr->num_chipselect to set SPI_MCR
Fixes: 4fcc7c2292
(spi: spi-fsl-dspi: Don't access reserved fields in SPI_MCR)
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Link: https://lore.kernel.org/r/20201201085916.63543-1-fido_max@inbox.ru
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
122541f2b1
commit
2c2b3ad2c4
|
@ -1165,7 +1165,7 @@ static int dspi_init(struct fsl_dspi *dspi)
|
|||
unsigned int mcr;
|
||||
|
||||
/* Set idle states for all chip select signals to high */
|
||||
mcr = SPI_MCR_PCSIS(GENMASK(dspi->ctlr->num_chipselect - 1, 0));
|
||||
mcr = SPI_MCR_PCSIS(GENMASK(dspi->ctlr->max_native_cs - 1, 0));
|
||||
|
||||
if (dspi->devtype_data->trans_mode == DSPI_XSPI_MODE)
|
||||
mcr |= SPI_MCR_XSPI;
|
||||
|
@ -1250,7 +1250,7 @@ static int dspi_probe(struct platform_device *pdev)
|
|||
|
||||
pdata = dev_get_platdata(&pdev->dev);
|
||||
if (pdata) {
|
||||
ctlr->num_chipselect = pdata->cs_num;
|
||||
ctlr->num_chipselect = ctlr->max_native_cs = pdata->cs_num;
|
||||
ctlr->bus_num = pdata->bus_num;
|
||||
|
||||
/* Only Coldfire uses platform data */
|
||||
|
@ -1263,7 +1263,7 @@ static int dspi_probe(struct platform_device *pdev)
|
|||
dev_err(&pdev->dev, "can't get spi-num-chipselects\n");
|
||||
goto out_ctlr_put;
|
||||
}
|
||||
ctlr->num_chipselect = cs_num;
|
||||
ctlr->num_chipselect = ctlr->max_native_cs = cs_num;
|
||||
|
||||
of_property_read_u32(np, "bus-num", &bus_num);
|
||||
ctlr->bus_num = bus_num;
|
||||
|
|
Loading…
Reference in New Issue