arm/exynos: Correct SPI session commands.
Some initialization / shutdown commands should be paired correctly in a SPI I/O session. For example, setting CS should be enabled and disabled in each read; and the bus width (byte or word) should be configured only when opening / closing the SPI device. Change-Id: Ie56b1c3a6df7d542f7ea8f1193ac435987f937ba Signed-off-by: Hung-Te Lin <hungte@chromium.org> Signed-off-by: Gabe Black <gabeblack@chromium.org> Reviewed-on: http://review.coreboot.org/3706 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
8b95c13420
commit
e42030d236
|
@ -102,7 +102,6 @@ int exynos_spi_open(struct exynos_spi *regs)
|
||||||
|
|
||||||
/* now set rx and tx channel ON */
|
/* now set rx and tx channel ON */
|
||||||
setbits_le32(®s->ch_cfg, SPI_RX_CH_ON | SPI_TX_CH_ON | SPI_CH_HS_EN);
|
setbits_le32(®s->ch_cfg, SPI_RX_CH_ON | SPI_TX_CH_ON | SPI_CH_HS_EN);
|
||||||
clrbits_le32(®s->cs_reg, SPI_SLAVE_SIG_INACT); /* CS low */
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +109,8 @@ int exynos_spi_read(struct exynos_spi *regs, void *dest, u32 len, u32 off)
|
||||||
{
|
{
|
||||||
int upto, todo;
|
int upto, todo;
|
||||||
int i;
|
int i;
|
||||||
|
clrbits_le32(®s->cs_reg, SPI_SLAVE_SIG_INACT); /* CS low */
|
||||||
|
|
||||||
/* Send read instruction (0x3h) followed by a 24 bit addr */
|
/* Send read instruction (0x3h) followed by a 24 bit addr */
|
||||||
writel((SF_READ_DATA_CMD << 24) | off, ®s->tx_data);
|
writel((SF_READ_DATA_CMD << 24) | off, ®s->tx_data);
|
||||||
|
|
||||||
|
@ -123,6 +124,11 @@ int exynos_spi_read(struct exynos_spi *regs, void *dest, u32 len, u32 off)
|
||||||
|
|
||||||
setbits_le32(®s->cs_reg, SPI_SLAVE_SIG_INACT);/* make the CS high */
|
setbits_le32(®s->cs_reg, SPI_SLAVE_SIG_INACT);/* make the CS high */
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int exynos_spi_close(struct exynos_spi *regs)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Let put controller mode to BYTE as
|
* Let put controller mode to BYTE as
|
||||||
* SPI driver does not support WORD mode yet
|
* SPI driver does not support WORD mode yet
|
||||||
|
@ -131,11 +137,6 @@ int exynos_spi_read(struct exynos_spi *regs, void *dest, u32 len, u32 off)
|
||||||
SPI_MODE_CH_WIDTH_WORD | SPI_MODE_BUS_WIDTH_WORD);
|
SPI_MODE_CH_WIDTH_WORD | SPI_MODE_BUS_WIDTH_WORD);
|
||||||
writel(0, ®s->swap_cfg);
|
writel(0, ®s->swap_cfg);
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
int exynos_spi_close(struct exynos_spi *regs)
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Flush spi tx, rx fifos and reset the SPI controller
|
* Flush spi tx, rx fifos and reset the SPI controller
|
||||||
* and clear rx/tx channel
|
* and clear rx/tx channel
|
||||||
|
|
|
@ -102,7 +102,6 @@ int exynos_spi_open(struct exynos_spi *regs)
|
||||||
|
|
||||||
/* now set rx and tx channel ON */
|
/* now set rx and tx channel ON */
|
||||||
setbits_le32(®s->ch_cfg, SPI_RX_CH_ON | SPI_TX_CH_ON | SPI_CH_HS_EN);
|
setbits_le32(®s->ch_cfg, SPI_RX_CH_ON | SPI_TX_CH_ON | SPI_CH_HS_EN);
|
||||||
clrbits_le32(®s->cs_reg, SPI_SLAVE_SIG_INACT); /* CS low */
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +109,8 @@ int exynos_spi_read(struct exynos_spi *regs, void *dest, u32 len, u32 off)
|
||||||
{
|
{
|
||||||
int upto, todo;
|
int upto, todo;
|
||||||
int i;
|
int i;
|
||||||
|
clrbits_le32(®s->cs_reg, SPI_SLAVE_SIG_INACT); /* CS low */
|
||||||
|
|
||||||
/* Send read instruction (0x3h) followed by a 24 bit addr */
|
/* Send read instruction (0x3h) followed by a 24 bit addr */
|
||||||
writel((SF_READ_DATA_CMD << 24) | off, ®s->tx_data);
|
writel((SF_READ_DATA_CMD << 24) | off, ®s->tx_data);
|
||||||
|
|
||||||
|
@ -123,6 +124,11 @@ int exynos_spi_read(struct exynos_spi *regs, void *dest, u32 len, u32 off)
|
||||||
|
|
||||||
setbits_le32(®s->cs_reg, SPI_SLAVE_SIG_INACT);/* make the CS high */
|
setbits_le32(®s->cs_reg, SPI_SLAVE_SIG_INACT);/* make the CS high */
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int exynos_spi_close(struct exynos_spi *regs)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Let put controller mode to BYTE as
|
* Let put controller mode to BYTE as
|
||||||
* SPI driver does not support WORD mode yet
|
* SPI driver does not support WORD mode yet
|
||||||
|
@ -131,11 +137,6 @@ int exynos_spi_read(struct exynos_spi *regs, void *dest, u32 len, u32 off)
|
||||||
SPI_MODE_CH_WIDTH_WORD | SPI_MODE_BUS_WIDTH_WORD);
|
SPI_MODE_CH_WIDTH_WORD | SPI_MODE_BUS_WIDTH_WORD);
|
||||||
writel(0, ®s->swap_cfg);
|
writel(0, ®s->swap_cfg);
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
int exynos_spi_close(struct exynos_spi *regs)
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Flush spi tx, rx fifos and reset the SPI controller
|
* Flush spi tx, rx fifos and reset the SPI controller
|
||||||
* and clear rx/tx channel
|
* and clear rx/tx channel
|
||||||
|
|
Loading…
Reference in New Issue