mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-17 22:49:02 +00:00
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>
This commit is contained in:
parent
a52ad4f994
commit
581d92eefc
1 changed files with 6 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue