zephyr/drivers/spi
Chuck Jordan df962d9a0e spi: Stability improvements to the DesignWare SPI driver
I've found many problems with the SPI driver and this repairs many of them.

The baud rate divisor was being derived from the CPU clock. But, some
targets may have a seperate clock attached to SPI. If the soc.h file
defines the symbol SPI_DW_SPI_CLOCK, it will use this instead
of CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC for the baud rate calculation.

completed() had a mistake where it would terminate the SPI transaction
too early, well before the tx data has cleared the FIFO. I found I couldn't
drive an OLED display correctly because completed() was wrong.
The repair is to now consider a new flag called spi->last_tx,
which will be set after the TX interrupt occurs with nothing to send any
longer. There is also a while loop added to SPIN until BUSY drops.

Another improvement is that push_data will NOT consider RX fifo size
if there is no RX going on. The calculation here when RX is going on
could go negative. I've added a check for that and prevent TX handling
if RX buffer is full. I think that is the intention -- to deal with RX first
if its fifos are more full.

In spi_dw_transceive, if we are only doing spi_write w/o reading,
don't enable RX interrupts at all. The OLED I'm working with failed
to have a pull-up on MISO SPI signal. As a result, a huge number of
garbage RX events arrive, and the interrupt handler finds there is
no rx buffer, so it tosses the data. But this is a waist of realtime.
It seems WRONG to enable RX interrupts if its something your not using,
so software can GATE these spurious events in this way.

With these changes, SPI can be used much more reliably, with FIFOs
that are deeper, and SPI devices that only require TX.

Change-Id: I0fe0745f2381c61c8a19ce086496b422a32a30a5
Signed-off-by: Chuck Jordan <cjordan@synopsys.com>
2016-05-21 00:48:16 +00:00
..
Kconfig spi: use syslog infratructure for debugging 2016-05-12 10:57:27 +00:00
Kconfig.dw spi: For spi_dw, added SPI_DW_FIFO_DEPTH as configurable paramter 2016-05-19 01:24:57 +00:00
Makefile arm: K64 SPI module driver 2016-03-09 15:50:16 +00:00
spi_dw.c spi: Stability improvements to the DesignWare SPI driver 2016-05-21 00:48:16 +00:00
spi_dw.h spi: Stability improvements to the DesignWare SPI driver 2016-05-21 00:48:16 +00:00
spi_dw_quark_se_ss_regs.h spi: dw: arc: add delay between writing DR strobe bit and reading FIFO 2016-03-12 03:18:54 +00:00
spi_dw_regs.h spi: add macro so that txftlr register can be read 2016-05-18 23:18:19 +00:00
spi_intel.c spi: use syslog infratructure for debugging 2016-05-12 10:57:27 +00:00
spi_intel.h spi: consalidate and simplify 2016-05-12 10:57:26 +00:00
spi_k64.c spi/k64: convert to use DEVICE_AND_API_INIT() 2016-04-15 22:06:13 +00:00
spi_k64_priv.h arm: K64 SPI module driver 2016-03-09 15:50:16 +00:00
spi_qmsi.c spi: consalidate and simplify 2016-05-12 10:57:26 +00:00