Skip to contentSkip to conversation

spi_mpc83xx: fix clockrate calculation for low speed

PATCH David Brownell 1 participant 1 message Sep 8, 2008 2 messages not in the archive SPI

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 200809081236.33731.david-b-yBeKhBN/[email protected]

#2 lore raw

[ resend with cc to spi-devel ... this patch was already seen there ]

Quoted 32 lines · David Brownell

From: Peter Korsgaard <jacmet-OfajU3CKLf1/[email protected]>

Commit a61f5345 (spi_mpc83xx clockrate fixes) broke clockrate calculation for low speeds. SPMODE_DIV16 should be set if the divider is higher than 64, not only if the divider gets clipped to 1024.

Furthermore, the clipping check was off by a factor 16 as well.

---
for 2.6.27 please ...

 drivers/spi/spi_mpc83xx.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/spi/spi_mpc83xx.c +1 -5
@@ -267,16 +267,13 @@ int mpc83xx_spi_setup_transfer(struct sp
 	cs->hw_mode |= SPMODE_LEN(bits_per_word);
 
 	if ((mpc83xx_spi->spibrg / hz) > 64) {
+		cs->hw_mode |= SPMODE_DIV16;
 		pm = mpc83xx_spi->spibrg / (hz * 64);
 		if (pm > 16) {
-			cs->hw_mode |= SPMODE_DIV16;
-			pm /= 16;
-			if (pm > 16) {
-				dev_err(&spi->dev, "Requested speed is too "
-					"low: %d Hz. Will use %d Hz instead.\n",

drivers/spi/spi_mpc83xx.c int mpc83xx_spi_setup_transfer(struct sp · line 279

Quoted 10 lines
drivers/spi/spi_mpc83xx.c +4 -3
-					hz, mpc83xx_spi->spibrg / 1024);
-				pm = 16;
-			}
+			dev_err(&spi->dev, "Requested speed is too "
+				"low: %d Hz. Will use %d Hz instead.\n",
+				hz, mpc83xx_spi->spibrg / 1024);
+			pm = 16;
 		}
 	} else
 		pm = mpc83xx_spi->spibrg / (hz * 4);

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/