Skip to content

Commit 2a05259

Browse files
wangxiaoningnxpbroonie
authored andcommitted
spi: lpspi: fix using CS discontinuously on i.MX8DXLEVK
SPI common code does not support using CS discontinuously for now. However, i.MX8DXL-EVK only uses CS1 without CS0. Therefore, add a flag is_only_cs1 to set the correct TCR[PCS]. Signed-off-by: Clark Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 768ba49 commit 2a05259

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/spi/spi-fsl-lpspi.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct fsl_lpspi_data {
9898
struct clk *clk_ipg;
9999
struct clk *clk_per;
100100
bool is_slave;
101+
bool is_only_cs1;
101102
bool is_first_byte;
102103

103104
void *rx_buf;
@@ -257,10 +258,9 @@ static void fsl_lpspi_set_cmd(struct fsl_lpspi_data *fsl_lpspi)
257258

258259
temp |= fsl_lpspi->config.bpw - 1;
259260
temp |= (fsl_lpspi->config.mode & 0x3) << 30;
261+
temp |= (fsl_lpspi->config.chip_select & 0x3) << 24;
260262
if (!fsl_lpspi->is_slave) {
261263
temp |= fsl_lpspi->config.prescale << 27;
262-
temp |= (fsl_lpspi->config.chip_select & 0x3) << 24;
263-
264264
/*
265265
* Set TCR_CONT will keep SS asserted after current transfer.
266266
* For the first transfer, clear TCR_CONTC to assert SS.
@@ -421,7 +421,10 @@ static int fsl_lpspi_setup_transfer(struct spi_controller *controller,
421421
fsl_lpspi->config.mode = spi->mode;
422422
fsl_lpspi->config.bpw = t->bits_per_word;
423423
fsl_lpspi->config.speed_hz = t->speed_hz;
424-
fsl_lpspi->config.chip_select = spi->chip_select;
424+
if (fsl_lpspi->is_only_cs1)
425+
fsl_lpspi->config.chip_select = 1;
426+
else
427+
fsl_lpspi->config.chip_select = spi->chip_select;
425428

426429
if (!fsl_lpspi->config.speed_hz)
427430
fsl_lpspi->config.speed_hz = spi->max_speed_hz;
@@ -835,6 +838,8 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
835838
fsl_lpspi = spi_controller_get_devdata(controller);
836839
fsl_lpspi->dev = &pdev->dev;
837840
fsl_lpspi->is_slave = is_slave;
841+
fsl_lpspi->is_only_cs1 = of_property_read_bool((&pdev->dev)->of_node,
842+
"fsl,spi-only-use-cs1-sel");
838843

839844
controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
840845
controller->transfer_one = fsl_lpspi_transfer_one;

0 commit comments

Comments
 (0)