summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCliff Cai <cliff.cai@analog.com>2009-12-07 08:03:06 +0000
committerMike Frysinger <vapier@gentoo.org>2010-01-17 09:17:27 -0500
commit581d92eefc1a060ea5c6eb42028880a37095953d (patch)
tree918445f57f9b6baeb4ee9469897cde6acdf7751a
parenta52ad4f99486ce3f404f83f75263e321956bb6d5 (diff)
Blackfin: bfin_spi: round up clock divider
If the requested clock cannot be exactly obtained, round it up so that we err on the side of slightly slower rather than slightly faster. Signed-off-by: Cliff Cai <cliff.cai@analog.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--drivers/spi/bfin_spi.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/spi/bfin_spi.c b/drivers/spi/bfin_spi.c
index 093166efed..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)