Commit ce1807b2 authored by Daniel Mack's avatar Daniel Mack Committed by Grant Likely

spi/i.mx: drain MXC SPI transfer buffer when probing device

On the MX31litekit, the bootloader seems to communicate with the MC13783
PMIC chip before booting Linux. However, it does not flush all the
buffers properly after that, which makes the imx-spi driver read
bogus data when probing the MC13783.

Fix that by draining the SPI receive buffer on startup.
Signed-off-by: default avatarDaniel Mack <daniel@caiaq.de>
Acked-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent d33c861e
...@@ -44,6 +44,9 @@ ...@@ -44,6 +44,9 @@
#define MXC_CSPIINT 0x0c #define MXC_CSPIINT 0x0c
#define MXC_RESET 0x1c #define MXC_RESET 0x1c
#define MX3_CSPISTAT 0x14
#define MX3_CSPISTAT_RR (1 << 3)
/* generic defines to abstract from the different register layouts */ /* generic defines to abstract from the different register layouts */
#define MXC_INT_RR (1 << 0) /* Receive data ready interrupt */ #define MXC_INT_RR (1 << 0) /* Receive data ready interrupt */
#define MXC_INT_TE (1 << 1) /* Transmit FIFO empty interrupt */ #define MXC_INT_TE (1 << 1) /* Transmit FIFO empty interrupt */
...@@ -593,6 +596,11 @@ static int __init spi_imx_probe(struct platform_device *pdev) ...@@ -593,6 +596,11 @@ static int __init spi_imx_probe(struct platform_device *pdev)
if (!cpu_is_mx31() || !cpu_is_mx35()) if (!cpu_is_mx31() || !cpu_is_mx35())
writel(1, spi_imx->base + MXC_RESET); writel(1, spi_imx->base + MXC_RESET);
/* drain receive buffer */
if (cpu_is_mx31() || cpu_is_mx35())
while (readl(spi_imx->base + MX3_CSPISTAT) & MX3_CSPISTAT_RR)
readl(spi_imx->base + MXC_CSPIRXDATA);
spi_imx->intctrl(spi_imx, 0); spi_imx->intctrl(spi_imx, 0);
ret = spi_bitbang_start(&spi_imx->bitbang); ret = spi_bitbang_start(&spi_imx->bitbang);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment