diff options
author | Wolfgang Denk <wd@denx.de> | 2010-06-18 01:20:49 +0200 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2010-06-18 01:20:49 +0200 |
commit | 54e19a7ded6e9dbdc3392a57d82f4f77b34e85b8 (patch) | |
tree | 9e796e38d4edeabec4d091ed89d6fe179e84956c /drivers | |
parent | 86caca1cd97ba71b7a7c82f2b0163682df35ce5d (diff) | |
parent | 1f241263e088a71b8f33f87b03a37c5418d41e2e (diff) |
Merge branch 'master' into next
Conflicts:
Makefile
Signed-off-by: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpio/s5p_gpio.c | 2 | ||||
-rw-r--r-- | drivers/serial/serial.c | 3 | ||||
-rw-r--r-- | drivers/spi/davinci_spi.c | 77 |
3 files changed, 47 insertions, 35 deletions
diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c index 0439477e462..a1bcddcf455 100644 --- a/drivers/gpio/s5p_gpio.c +++ b/drivers/gpio/s5p_gpio.c @@ -96,7 +96,7 @@ void gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode) value |= PULL_MODE(gpio, mode); break; default: - return; + break; } writel(value, &bank->pull); diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 8eda95cd3ed..1073ac0ae9c 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -30,6 +30,9 @@ #ifdef CONFIG_KIRKWOOD #include <asm/arch/kirkwood.h> #endif +#ifdef CONFIG_ORION5X +#include <asm/arch/orion5x.h> +#endif #if defined (CONFIG_SERIAL_MULTI) #include <serial.h> diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c index 60ba007aaab..08f837b66f6 100644 --- a/drivers/spi/davinci_spi.c +++ b/drivers/spi/davinci_spi.c @@ -113,7 +113,8 @@ int spi_claim_bus(struct spi_slave *slave) writel(0, &ds->regs->lvl); /* enable SPI */ - writel((readl(&ds->regs->gcr1) | SPIGCR1_SPIENA_MASK), &ds->regs->gcr1); + writel((readl(&ds->regs->gcr1) | + SPIGCR1_SPIENA_MASK), &ds->regs->gcr1); return 0; } @@ -131,12 +132,10 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, { struct davinci_spi_slave *ds = to_davinci_spi(slave); unsigned int len, data1_reg_val = readl(&ds->regs->dat1); - int ret, i; + unsigned int i_cnt = 0, o_cnt = 0, buf_reg_val; const u8 *txp = dout; /* dout can be NULL for read operation */ u8 *rxp = din; /* din can be NULL for write operation */ - ret = 0; - if (bitlen == 0) /* Finish any previously submitted transfers */ goto out; @@ -159,41 +158,51 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, readl(&ds->regs->buf); /* keep writing and reading 1 byte until done */ - for (i = 0; i < len; i++) { - /* wait till TXFULL is asserted */ - while (readl(&ds->regs->buf) & SPIBUF_TXFULL_MASK); - - /* write the data */ - data1_reg_val &= ~0xFFFF; - if (txp) { - data1_reg_val |= *txp; - txp++; + while ((i_cnt < len) || (o_cnt < len)) { + /* read RX buffer and flags */ + buf_reg_val = readl(&ds->regs->buf); + + /* if data is available */ + if ((i_cnt < len) && + (buf_reg_val & SPIBUF_RXEMPTY_MASK) == 0) { + /* + * If there is no read buffer simply + * ignore the read character + */ + if (rxp) + *rxp++ = buf_reg_val & 0xFF; + /* increment read words count */ + i_cnt++; } /* - * Write to DAT1 is required to keep the serial transfer going. - * We just terminate when we reach the end. + * if the tx buffer is empty and there + * is still data to transmit */ - if ((i == (len - 1)) && (flags & SPI_XFER_END)) { - /* clear CS hold */ - writel(data1_reg_val & - ~(1 << SPIDAT1_CSHOLD_SHIFT), &ds->regs->dat1); - } else { - /* enable CS hold */ - data1_reg_val |= ((1 << SPIDAT1_CSHOLD_SHIFT) | + if ((o_cnt < len) && + ((buf_reg_val & SPIBUF_TXFULL_MASK) == 0)) { + /* write the data */ + data1_reg_val &= ~0xFFFF; + if (txp) + data1_reg_val |= *txp++; + /* + * Write to DAT1 is required to keep + * the serial transfer going. + * We just terminate when we reach the end. + */ + if ((o_cnt == (len - 1)) && (flags & SPI_XFER_END)) { + /* clear CS hold */ + writel(data1_reg_val & + ~(1 << SPIDAT1_CSHOLD_SHIFT), + &ds->regs->dat1); + } else { + /* enable CS hold and write TX register */ + data1_reg_val |= ((1 << SPIDAT1_CSHOLD_SHIFT) | (slave->cs << SPIDAT1_CSNR_SHIFT)); - writel(data1_reg_val, &ds->regs->dat1); - } - - /* read the data - wait for data availability */ - while (readl(&ds->regs->buf) & SPIBUF_RXEMPTY_MASK); - - if (rxp) { - *rxp = readl(&ds->regs->buf) & 0xFF; - rxp++; - } else { - /* simply drop the read character */ - readl(&ds->regs->buf); + writel(data1_reg_val, &ds->regs->dat1); + } + /* increment written words count */ + o_cnt++; } } return 0; |