diff options
| author | Valentin Longchamp <[email protected]> | 2012-08-15 05:31:49 +0000 |
|---|---|---|
| committer | Prafulla Wadaskar <[email protected]> | 2012-09-03 17:28:51 +0530 |
| commit | 8203b201eaa1b33758956294b3ec70b326f8ba5c (patch) | |
| tree | 28a16a951302bfb2adea574bb3d6208899c55cdd /drivers | |
| parent | f46b4a1aadb4ab834bcf333a9dd4c7804296e185 (diff) | |
kw_spi: fix clock prescaler computation
The computation was not correct with low clock values: setting a 1MHz
clock would result in an overlap that would then configure a 25Mhz
clock.
This patch implements a correct computation method according to the
kirkwood functionnal spec. table 600 (Serial Memory Interface
Configuration Register).
Signed-off-by: Valentin Longchamp <[email protected]>
cc: Holger Brunck <[email protected]>
cc: Prafulla Wadaskar <[email protected]>
Acked-by: Prafulla Wadaskar <[email protected]>
Signed-off-by: Prafulla Wadaskar <[email protected]>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/spi/kirkwood_spi.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c index f4523a39291..a7cda751bd0 100644 --- a/drivers/spi/kirkwood_spi.c +++ b/drivers/spi/kirkwood_spi.c @@ -56,8 +56,9 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, writel(~KWSPI_CSN_ACT | KWSPI_SMEMRDY, &spireg->ctrl); /* calculate spi clock prescaller using max_hz */ - data = ((CONFIG_SYS_TCLK / 2) / max_hz) & KWSPI_CLKPRESCL_MASK; - data |= 0x10; + data = ((CONFIG_SYS_TCLK / 2) / max_hz) + 0x10; + data = data < KWSPI_CLKPRESCL_MIN ? KWSPI_CLKPRESCL_MIN : data; + data = data > KWSPI_CLKPRESCL_MASK ? KWSPI_CLKPRESCL_MASK : data; /* program spi clock prescaller using max_hz */ writel(KWSPI_ADRLEN_3BYTE | data, &spireg->cfg); |
