linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpm2: Round the baud-rate clock divider to the nearest integer.
@ 2008-11-20 12:32 Laurent Pinchart
  2008-11-20 15:32 ` Kumar Gala
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Laurent Pinchart @ 2008-11-20 12:32 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: kumar.gala, vbordug

Instead of rounding the divider down, improve the baud-rate generators
accuracy by rounding to the nearest integer.

Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
---
 arch/powerpc/sysdev/cpm2.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/sysdev/cpm2.c b/arch/powerpc/sysdev/cpm2.c
index f1c3395..474d176 100644
--- a/arch/powerpc/sysdev/cpm2.c
+++ b/arch/powerpc/sysdev/cpm2.c
@@ -129,7 +129,8 @@ void __cpm2_setbrg(uint brg, uint rate, uint clk, int div16, int src)
 		brg -= 4;
 	}
 	bp += brg;
-	val = (((clk / rate) - 1) << 1) | CPM_BRG_EN | src;
+	/* Round the clock divider to the nearest integer. */
+	val = (((clk * 2 / rate) - 1) & ~1) | CPM_BRG_EN | src;
 	if (div16)
 		val |= CPM_BRG_DIV16;
 
-- 
1.5.6.3

-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

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

end of thread, other threads:[~2009-01-27 17:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-20 12:32 [PATCH] cpm2: Round the baud-rate clock divider to the nearest integer Laurent Pinchart
2008-11-20 15:32 ` Kumar Gala
2008-11-20 15:57   ` Laurent Pinchart
2008-11-20 16:00     ` Kumar Gala
2008-11-20 16:42       ` Laurent Pinchart
2009-01-15 13:18       ` Laurent Pinchart
2009-01-15 14:42         ` Kumar Gala
2009-01-15 14:58           ` Laurent Pinchart
2009-01-15 17:54             ` Scott Wood
2009-01-15 18:57               ` Kumar Gala
2009-01-16  9:50                 ` Laurent Pinchart
2008-11-20 19:53 ` Scott Wood
2008-11-21 16:04   ` Laurent Pinchart
2008-11-21 17:00     ` Scott Wood
2009-01-27 17:20 ` Kumar Gala

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).