diff options
author | Chen Gong <g.chen@freescale.com> | 2008-07-24 00:29:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-24 13:47:30 -0400 |
commit | a61f5345eba34772a71523227de890a28410f320 (patch) | |
tree | 28c038919fa2d526dbf6992d88956409d0beffc2 /drivers/spi/spi_mpc83xx.c | |
parent | 708d8cefd0f6d8dc13027f899e865ccfa5f63871 (diff) |
spi: spi_mpc83xx clockrate fixes
This updates the SPI clock rate calculations for the spi_mpc83xx driver.
Some boundary conditions were wrong, and in several cases divide-by-16
wasn't always needed
Signed-off-by: Chen Gong <g.chen@freescale.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi/spi_mpc83xx.c')
-rw-r--r-- | drivers/spi/spi_mpc83xx.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c index 6832da6f7109..070c6219e2d6 100644 --- a/drivers/spi/spi_mpc83xx.c +++ b/drivers/spi/spi_mpc83xx.c | |||
@@ -266,21 +266,24 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
266 | 266 | ||
267 | cs->hw_mode |= SPMODE_LEN(bits_per_word); | 267 | cs->hw_mode |= SPMODE_LEN(bits_per_word); |
268 | 268 | ||
269 | if ((mpc83xx_spi->spibrg / hz) >= 64) { | 269 | if ((mpc83xx_spi->spibrg / hz) > 64) { |
270 | pm = mpc83xx_spi->spibrg / (hz * 64) - 1; | 270 | pm = mpc83xx_spi->spibrg / (hz * 64); |
271 | if (pm > 0x0f) { | 271 | if (pm > 16) { |
272 | dev_err(&spi->dev, "Requested speed is too " | 272 | cs->hw_mode |= SPMODE_DIV16; |
273 | "low: %d Hz. Will use %d Hz instead.\n", | 273 | pm /= 16; |
274 | hz, mpc83xx_spi->spibrg / 1024); | 274 | if (pm > 16) { |
275 | pm = 0x0f; | 275 | dev_err(&spi->dev, "Requested speed is too " |
276 | "low: %d Hz. Will use %d Hz instead.\n", | ||
277 | hz, mpc83xx_spi->spibrg / 1024); | ||
278 | pm = 16; | ||
279 | } | ||
276 | } | 280 | } |
277 | cs->hw_mode |= SPMODE_PM(pm) | SPMODE_DIV16; | 281 | } else |
278 | } else { | ||
279 | pm = mpc83xx_spi->spibrg / (hz * 4); | 282 | pm = mpc83xx_spi->spibrg / (hz * 4); |
280 | if (pm) | 283 | if (pm) |
281 | pm--; | 284 | pm--; |
282 | cs->hw_mode |= SPMODE_PM(pm); | 285 | |
283 | } | 286 | cs->hw_mode |= SPMODE_PM(pm); |
284 | regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); | 287 | regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); |
285 | if (cs->hw_mode != regval) { | 288 | if (cs->hw_mode != regval) { |
286 | unsigned long flags; | 289 | unsigned long flags; |