summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-pxa2xx.c
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2013-12-18 17:31:47 (GMT)
committerMark Brown <broonie@linaro.org>2013-12-20 11:53:57 (GMT)
commit6fd8b8503a0dcf66510314dc054745087ae89f94 (patch)
treeb063aa60bd1d7c02806a87768da67253ac1ee2eb /drivers/spi/spi-pxa2xx.c
parent6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff)
downloadlinux-6fd8b8503a0dcf66510314dc054745087ae89f94.tar.xz
spi: spi-imx: Fix out-of-order CS/SCLK operation at low speeds
Problem: -------- The problem this patch addresses has the following assumptions about the SPI bus setup: - The hardware used to find this is Freescale i.MX537 @ 1200MHz - The SPI SCLK operate at very low speed, less than 200 kHz - There are two SPI devices attached to the bus - Each device uses different GPIO for chipselect - Each device requires different SCLK signal polarity The observation of the SCLK and GPIO chipselect lines with a logic analyzer shows, that the SCLK polarity change does sometimes happen after the GPIO chipselect is asserted. The SPI slave device reacts on that by counting the SCLK polarity change as a clock pulse, which disrupts the communication with the SPI slave device. Explanation: ------------ We found an interesting correlation, that the maximum delay between the write into the ECSPIx_CONFIGREG register and the change of SCLK polarity at each SCLK frequency of 10 kHz, 20 kHz, 50 kHz and 100 kHz is 100 uS, 50 uS, 20 uS and 10 uS respectively. This lead us to a theory, that at SCLK frequency of 1 Hz, the delay would be 1 S. Therefore, the time it takes for the write to ECSPIx_CONFIGREG to take effect in the hardware is up to the duration of 1 tick of the SCLK clock. During this delay period, if the SCLK frequency is too low, the execution of the spi-imx.c driver can advance so much, that the GPIO chipselect will be asserted. The GPIO chipselect is asserted almost immediatelly. Solution: --------- The solution this patch presents is simple. We calculate the resulting SCLK clock first by dividing the ECSPI block clock by both dividers that are to be programmed into the configuration register. Based on the resulting SCLK clock, we derive the delay it will take for the changes to get really applied. We are extra careful here so we delay twice as long as we should. Note that the patch does not create additional overhead at high speeds as the delay will likely be close to zero there. Signed-off-by: Marek Vasut <marex@denx.de> To: linux-spi@vger.kernel.org Cc: Fabio Estevam <fabio.estevam@freescale.com> Cc: Huang Shijie <b32955@freescale.com> Cc: Mark Brown <broonie@kernel.org> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-pxa2xx.c')
0 files changed, 0 insertions, 0 deletions