[PATCH] cpm: rounding of brg clockdivider

Esben Haabendal eha at doredevelopment.dk
Tue Oct 2 17:24:03 EST 2007


Do rounding of brg clockdivider instead of truncate to get more precise baudrates

Something similar might be needed for cpm_fastbrg...

---
commit 52d631eb8f64cef794d6aa66494e253cf268894e
tree 956149a0eb5beb9afb280f4593615929eab7b779
parent 300070dd6b5e71af0c6fbecd32388905dbdd3ea5
author Esben Haabendal <eha at doredevelopment.dk> Wed, 19 Sep 2007 13:18:59 +0200
committer Esben Haabendal <esben at esben.doredevelopment.dk> Wed, 19 Sep 2007 13:18:59 +0200

 arch/powerpc/sysdev/cpm2_common.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/sysdev/cpm2_common.c b/arch/powerpc/sysdev/cpm2_common.c
index 9058da2..a2c8157 100644
--- a/arch/powerpc/sysdev/cpm2_common.c
+++ b/arch/powerpc/sysdev/cpm2_common.c
@@ -102,7 +102,9 @@ cpm_setbrg(uint brg, uint rate)
                brg -= 4;
        }
        bp += brg;
-       out_be32(bp, (((BRG_UART_CLK / rate) - 1) << 1) | CPM_BRG_EN);
+       /* Set the BRG clock divider to get the best match to the requested
+        * baudrate (rounding required) */
+       out_be32(bp, ((((((BRG_UART_CLK*2)/rate)+1)/2)-1) << 1) | CPM_BRG_EN);
 
        cpm2_unmap(bp);
 }




!-------------------------------------------------------------flip-

-- 
Esben Haabendal
Embedded Software Consultant
Doré Development ApS




More information about the Linuxppc-dev mailing list