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>
This commit is contained in:
Chen Gong 2008-07-23 21:29:52 -07:00 committed by Linus Torvalds
parent 708d8cefd0
commit a61f5345eb
1 changed files with 16 additions and 13 deletions

View File

@ -266,21 +266,24 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
cs->hw_mode |= SPMODE_LEN(bits_per_word); cs->hw_mode |= SPMODE_LEN(bits_per_word);
if ((mpc83xx_spi->spibrg / hz) >= 64) { if ((mpc83xx_spi->spibrg / hz) > 64) {
pm = mpc83xx_spi->spibrg / (hz * 64) - 1; pm = mpc83xx_spi->spibrg / (hz * 64);
if (pm > 0x0f) { if (pm > 16) {
dev_err(&spi->dev, "Requested speed is too " cs->hw_mode |= SPMODE_DIV16;
"low: %d Hz. Will use %d Hz instead.\n", pm /= 16;
hz, mpc83xx_spi->spibrg / 1024); if (pm > 16) {
pm = 0x0f; dev_err(&spi->dev, "Requested speed is too "
"low: %d Hz. Will use %d Hz instead.\n",
hz, mpc83xx_spi->spibrg / 1024);
pm = 16;
}
} }
cs->hw_mode |= SPMODE_PM(pm) | SPMODE_DIV16; } else
} else {
pm = mpc83xx_spi->spibrg / (hz * 4); pm = mpc83xx_spi->spibrg / (hz * 4);
if (pm) if (pm)
pm--; pm--;
cs->hw_mode |= SPMODE_PM(pm);
} cs->hw_mode |= SPMODE_PM(pm);
regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
if (cs->hw_mode != regval) { if (cs->hw_mode != regval) {
unsigned long flags; unsigned long flags;