diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2015-03-02 14:58:55 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-03-06 20:29:03 +0000 |
commit | 45746e82cf89f432f9c986a52137d8a64b78aba9 (patch) | |
tree | d9df29e0bf19318698df1e045caa9c0317a9d3f1 /drivers/spi/spi-dw.h | |
parent | 1a18f9f753209977450c94dcd354dd4fa5370966 (diff) | |
download | talos-op-linux-45746e82cf89f432f9c986a52137d8a64b78aba9.tar.gz talos-op-linux-45746e82cf89f432f9c986a52137d8a64b78aba9.zip |
spi: dw: make sure SPI controller is enabled
The error handling is partially broken since the controller is disabled on
error and is not re-enabled until condition occurs, i.e. mode (poll, PIO/DMA),
chip (cs_change), or speed (clk_div) is changed. In the result of these changes
we will have a predictable state of the SPi controller independently on how
successfull was a previous transfer.
The patch disables interrupts and re-enables the SPI controller wherever it
needs to be done. Thus most of the time the SPI controller is kept enabled. The
runtime PM, when it will be implemented, must take care of the controller
disabling and re-enabling.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-dw.h')
-rw-r--r-- | drivers/spi/spi-dw.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index 3d32be68c142..1a7f083c2217 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h @@ -217,6 +217,18 @@ static inline void spi_umask_intr(struct dw_spi *dws, u32 mask) } /* + * This does disable the SPI controller, interrupts, and re-enable 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); + spi_enable_chip(dws, 1); +} + +/* * Each SPI slave device to work with dw_api controller should * has such a structure claiming its working mode (PIO/DMA etc), * which can be save in the "controller_data" member of the |