From: Laurent Pinchart <laurentp@cse-semaphore.com>
To: linuxppc-dev@ozlabs.org
Cc: kumar.gala@freescale.com, vbordug@ru.mvista.com
Subject: [PATCH] cpm2: Round the baud-rate clock divider to the nearest integer.
Date: Thu, 20 Nov 2008 13:32:23 +0100 [thread overview]
Message-ID: <200811201332.24061.laurentp@cse-semaphore.com> (raw)
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
next reply other threads:[~2008-11-20 12:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-20 12:32 Laurent Pinchart [this message]
2008-11-20 15:32 ` [PATCH] cpm2: Round the baud-rate clock divider to the nearest integer 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200811201332.24061.laurentp@cse-semaphore.com \
--to=laurentp@cse-semaphore.com \
--cc=kumar.gala@freescale.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=vbordug@ru.mvista.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).