linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: Correct SPI clock frequency setting in spi_mpc8xxx
@ 2010-02-15 16:23 Ernst Schwab
  0 siblings, 0 replies; 4+ messages in thread
From: Ernst Schwab @ 2010-02-15 16:23 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f

Correct SPI clock frequency division factor rounding, preventing clock rates 
higher than the maximum specified clock frequency being used. 

Signed-off-by: Ernst Schwab <eschwab-BGeptl67XyCzQB+pC5nmwQ@public.gmane.org>
---
Tested on MPC8314.

diff -up linux-2.6.33-rc8.orig/drivers/spi/spi_mpc8xxx.c linux-2.6.33-rc8/drivers/spi/spi_mpc8xxx.c
--- linux-2.6.33-rc8.orig/drivers/spi/spi_mpc8xxx.c	2010-02-12 20:07:45.000000000 +0100
+++ linux-2.6.33-rc8/drivers/spi/spi_mpc8xxx.c	2010-02-15 14:08:33.000000000 +0100
@@ -365,7 +365,7 @@ int mpc8xxx_spi_setup_transfer(struct sp
 
 	if ((mpc8xxx_spi->spibrg / hz) > 64) {
 		cs->hw_mode |= SPMODE_DIV16;
-		pm = mpc8xxx_spi->spibrg / (hz * 64);
+		pm = (mpc8xxx_spi->spibrg - 1) / (hz * 64) + 1;
 
 		WARN_ONCE(pm > 16, "%s: Requested speed is too low: %d Hz. "
 			  "Will use %d Hz instead.\n", dev_name(&spi->dev),
@@ -373,7 +373,7 @@ int mpc8xxx_spi_setup_transfer(struct sp
 		if (pm > 16)
 			pm = 16;
 	} else
-		pm = mpc8xxx_spi->spibrg / (hz * 4);
+		pm = (mpc8xxx_spi->spibrg - 1) / (hz * 4) + 1;
 	if (pm)
 		pm--;
 


------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-02-16 17:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20100216151240.148f9413.eschwab@online.de>
2010-02-16 15:32 ` [PATCH] spi: Correct SPI clock frequency setting in spi_mpc8xxx Grant Likely
     [not found]   ` <fa686aa41002160732w1da68f35ifd0d21407b1052e4-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-16 16:43     ` Ernst Schwab
2010-02-16 17:39       ` Grant Likely
2010-02-15 16:23 Ernst Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).