Skip to content

Commit 811ff80

Browse files
William Zhangbroonie
authored andcommitted
spi: bcm63xx-hsspi: Fix multi-bit mode setting
Currently the driver always sets the controller to dual data bit mode for both tx and rx data in the profile mode control register even for single data bit transfer. Luckily the opcode is set correctly according to SPI transfer data bit width so it does not actually cause issues. This change fixes the problem by setting tx and rx data bit mode field correctly according to the actual SPI transfer tx and rx data bit width. Fixes: 142168e ("spi: bcm63xx-hsspi: add bcm63xx HSSPI driver") Signed-off-by: William Zhang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c00d5e9 commit 811ff80

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/spi/spi-bcm63xx-hsspi.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t)
215215
int step_size = HSSPI_BUFFER_LEN;
216216
const u8 *tx = t->tx_buf;
217217
u8 *rx = t->rx_buf;
218-
u32 val;
218+
u32 val = 0;
219219
unsigned long limit;
220220

221221
bcm63xx_hsspi_set_clk(bs, spi, t->speed_hz);
@@ -233,11 +233,16 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t)
233233
step_size -= HSSPI_OPCODE_LEN;
234234

235235
if ((opcode == HSSPI_OP_READ && t->rx_nbits == SPI_NBITS_DUAL) ||
236-
(opcode == HSSPI_OP_WRITE && t->tx_nbits == SPI_NBITS_DUAL))
236+
(opcode == HSSPI_OP_WRITE && t->tx_nbits == SPI_NBITS_DUAL)) {
237237
opcode |= HSSPI_OP_MULTIBIT;
238238

239-
__raw_writel(1 << MODE_CTRL_MULTIDATA_WR_SIZE_SHIFT |
240-
1 << MODE_CTRL_MULTIDATA_RD_SIZE_SHIFT | 0xff,
239+
if (t->rx_nbits == SPI_NBITS_DUAL)
240+
val |= 1 << MODE_CTRL_MULTIDATA_RD_SIZE_SHIFT;
241+
if (t->tx_nbits == SPI_NBITS_DUAL)
242+
val |= 1 << MODE_CTRL_MULTIDATA_WR_SIZE_SHIFT;
243+
}
244+
245+
__raw_writel(val | 0xff,
241246
bs->regs + HSSPI_PROFILE_MODE_CTRL_REG(chip_select));
242247

243248
while (pending > 0) {

0 commit comments

Comments
 (0)