[U-Boot] [PATCH] kirkwood_spi: small fixes
Michael Walle
michael at walle.cc
Wed Dec 21 23:49:36 CET 2011
- use proper defines for the control register
- deactivate CS properly
- instead of polling the IRQ status bit use SPI status bit directly
- add comments
Signed-off-by: Michael Walle <michael at walle.cc>
Cc: Prafulla Wadaskar <prafulla at marvell.com>
---
drivers/spi/kirkwood_spi.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index db8ba8b..60f3f09 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -55,7 +55,8 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
slave->bus = bus;
slave->cs = cs;
- writel(~KWSPI_CSN_ACT | KWSPI_SMEMRDY, &spireg->ctrl);
+ /* make sure cs is deactivated */
+ writel(0, &spireg->ctrl);
/* calculate spi clock prescaller using max_hz */
data = ((CONFIG_SYS_TCLK / 2) / max_hz) & KWSPI_CLKPRESCL_MASK;
@@ -63,9 +64,9 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
/* program spi clock prescaller using max_hz */
writel(KWSPI_ADRLEN_3BYTE | data, &spireg->cfg);
- debug("data = 0x%08x \n", data);
+ debug("data = 0x%08x\n", data);
- writel(KWSPI_SMEMRDIRQ, &spireg->irq_cause);
+ /* mask interrupt */
writel(KWSPI_IRQMASK, &spireg->irq_mask);
/* program mpp registers to select SPI_CSn */
@@ -113,12 +114,12 @@ void spi_init(void)
void spi_cs_activate(struct spi_slave *slave)
{
- writel(readl(&spireg->ctrl) | KWSPI_IRQUNMASK, &spireg->ctrl);
+ writel(readl(&spireg->ctrl) | KWSPI_CSN_ACT, &spireg->ctrl);
}
void spi_cs_deactivate(struct spi_slave *slave)
{
- writel(readl(&spireg->ctrl) & KWSPI_IRQMASK, &spireg->ctrl);
+ writel(readl(&spireg->ctrl) & ~KWSPI_CSN_ACT, &spireg->ctrl);
}
int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
@@ -148,7 +149,6 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
if (dout)
tmpdout = *(u32 *) dout & 0x0ff;
- writel(~KWSPI_SMEMRDIRQ, &spireg->irq_cause);
writel(tmpdout, &spireg->dout); /* Write the data out */
debug("*** spi_xfer: ... %08x written, bitlen %d\n",
tmpdout, bitlen);
@@ -159,7 +159,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
* The NE event must be read and cleared first
*/
for (tm = 0, isread = 0; tm < KWSPI_TIMEOUT; ++tm) {
- if (readl(&spireg->irq_cause) & KWSPI_SMEMRDIRQ) {
+ if (readl(&spireg->ctrl) & KWSPI_SMEMRDY) {
isread = 1;
tmpdin = readl(&spireg->din);
debug
--
1.7.2.5
More information about the U-Boot
mailing list