Skip to content

Commit

Permalink
spi: dw: De-assert chip-select on reset
Browse files Browse the repository at this point in the history
SPI memory operations implementation will require to have the CS register
cleared before executing the operation in order not to have the
transmission automatically started prior the Tx FIFO is pre-initialized.
Let's clear the register then on explicit controller reset to fulfil the
requirements in case of an error or having the CS left set by a bootloader
or another software.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Link: https://lore.kernel.org/r/20201007235511.4935-14-Sergey.Semin@baikalelectronics.ru
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Serge Semin authored and Mark Brown committed Oct 8, 2020
1 parent c6cb381 commit fbddc98
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/spi/spi-dw.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,16 @@ static inline void spi_umask_intr(struct dw_spi *dws, u32 mask)
}

/*
* This disables the SPI controller, interrupts, clears the interrupts status,
* and re-enable the controller back. Transmit and receive FIFO buffers are
* cleared when the device is disabled.
* This disables the SPI controller, interrupts, clears the interrupts status
* and CS, then re-enables the controller back. Transmit and receive FIFO
* buffers are cleared when the device is disabled.
*/
static inline void spi_reset_chip(struct dw_spi *dws)
{
spi_enable_chip(dws, 0);
spi_mask_intr(dws, 0xff);
dw_readl(dws, DW_SPI_ICR);
dw_writel(dws, DW_SPI_SER, 0);
spi_enable_chip(dws, 1);
}

Expand Down

0 comments on commit fbddc98

Please sign in to comment.