]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Blackfin: make baud calculation more accurate
authorMike Frysinger <vapier@gentoo.org>
Sun, 20 Apr 2008 07:11:53 +0000 (03:11 -0400)
committerMike Frysinger <vapier@gentoo.org>
Thu, 23 Oct 2008 09:03:51 +0000 (05:03 -0400)
We should use the algorithm in the Linux kernel so that the UART divisor
calculation is more accurate.  It also fixes problems on some picky UARTs
that have sampling anomalies.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
cpu/blackfin/serial.h

index 1f0f4b46c7df1793ff07671f90b0a308e2877d3d..ec40c266ac58a1b2bf2294221206f4edeec153ea 100644 (file)
@@ -175,11 +175,11 @@ static inline uint32_t serial_early_get_baud(void)
 __attribute__((always_inline))
 static inline void serial_early_set_baud(uint32_t baud)
 {
-       /* Translate from baud into divisor in terms of SCLK.
-        * The +1 is to make sure we over sample just a little
-        * rather than under sample the incoming signals.
+       /* Translate from baud into divisor in terms of SCLK.  The
+        * weird multiplication is to make sure we over sample just
+        * a little rather than under sample the incoming signals.
         */
-       uint16_t divisor = (get_sclk() / (baud * 16)) + 1;
+       uint16_t divisor = (get_sclk() + (baud * 8)) / (baud * 16) - ANOMALY_05000230;
 
        /* Set DLAB in LCR to Access DLL and DLH */
        ACCESS_LATCH();