summaryrefslogtreecommitdiffstats
path: root/drivers/spi/bfin_spi.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2010-01-17 23:08:42 +0100
committerWolfgang Denk <wd@denx.de>2010-01-17 23:08:42 +0100
commit3e3989619f5ed3ee28002d985f3da28540586ab9 (patch)
treed4434455cafdc0c750aa26e642949232ffd0b2d3 /drivers/spi/bfin_spi.c
parent64917ca38933d10b3763f61df7a1e58e1e127b52 (diff)
parent846a6391e4bc9fdd721753a1021953ff0ca17c27 (diff)
downloadtalos-obmc-uboot-3e3989619f5ed3ee28002d985f3da28540586ab9.tar.gz
talos-obmc-uboot-3e3989619f5ed3ee28002d985f3da28540586ab9.zip
Merge branch 'master' of git://git.denx.de/u-boot-blackfin
Diffstat (limited to 'drivers/spi/bfin_spi.c')
-rw-r--r--drivers/spi/bfin_spi.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/spi/bfin_spi.c b/drivers/spi/bfin_spi.c
index 2a72f99b24..f28d42b489 100644
--- a/drivers/spi/bfin_spi.c
+++ b/drivers/spi/bfin_spi.c
@@ -85,6 +85,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
unsigned int max_hz, unsigned int mode)
{
struct bfin_spi_slave *bss;
+ ulong sclk;
u32 mmr_base;
u32 baud;
@@ -105,7 +106,11 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
default: return NULL;
}
- baud = get_sclk() / (2 * max_hz);
+ sclk = get_sclk();
+ baud = sclk / (2 * max_hz);
+ /* baud should be rounded up */
+ if (sclk % (2 * max_hz))
+ baud += 1;
if (baud < 2)
baud = 2;
else if (baud > (u16)-1)
@@ -314,6 +319,10 @@ void spi_release_bus(struct spi_slave *slave)
SSYNC();
}
+#ifndef CONFIG_BFIN_SPI_IDLE_VAL
+# define CONFIG_BFIN_SPI_IDLE_VAL 0xff
+#endif
+
int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
void *din, unsigned long flags)
{
@@ -340,7 +349,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
/* todo: take advantage of hardware fifos and setup RX dma */
while (bytes--) {
- u8 value = (tx ? *tx++ : 0);
+ u8 value = (tx ? *tx++ : CONFIG_BFIN_SPI_IDLE_VAL);
debug("%s: tx:%x ", __func__, value);
write_SPI_TDBR(bss, value);
SSYNC();
OpenPOWER on IntegriCloud