Author: stepan
Date: Fri Apr 22 03:45:11 2011
New Revision: 6538
URL: https://tracker.coreboot.org/trac/coreboot/changeset/6538

Log:
The UART divider should be calculated based on the base frequency
and baudrate, not hardcoded in addition to that.

Signed-off-by: Stefan Reinauer <stefan.reina...@coreboot.org>
Acked-by: Peter Stuge <pe...@stuge.se>

Modified:
   trunk/src/console/uart8250_console.c
   trunk/src/include/uart8250.h
   trunk/src/lib/uart8250.c
   trunk/src/mainboard/iwave/iWRainbowG6/Kconfig

Modified: trunk/src/console/uart8250_console.c
==============================================================================
--- trunk/src/console/uart8250_console.c        Thu Apr 21 23:26:58 2011        
(r6537)
+++ trunk/src/console/uart8250_console.c        Fri Apr 22 03:45:11 2011        
(r6538)
@@ -25,7 +25,13 @@
 {
        static const unsigned char div[8] = { 1, 2, 3, 6, 12, 24, 48, 96 };
        int b_index = 0;
-       unsigned int divisor = CONFIG_TTYS0_DIV;
+       /* TODO the divisor calculation is hard coded to standard UARTs. Some
+        * UARTs won't work with these values. This should be a property of the
+        * UART used, worst case a Kconfig variable. For now live with hard
+        * codes as the only devices that might be different are the iWave
+        * iRainbowG6 and the OXPCIe952 card (and the latter is memory mapped)
+        */
+       unsigned int divisor = 115200 / CONFIG_TTYS0_BAUD;
 
        if (get_option(&b_index, "baud_rate") == 0) {
                divisor = div[b_index];

Modified: trunk/src/include/uart8250.h
==============================================================================
--- trunk/src/include/uart8250.h        Thu Apr 21 23:26:58 2011        (r6537)
+++ trunk/src/include/uart8250.h        Fri Apr 22 03:45:11 2011        (r6538)
@@ -28,13 +28,9 @@
 #ifndef CONFIG_TTYS0_BAUD
 #define CONFIG_TTYS0_BAUD 115200
 #endif
-
-#ifndef CONFIG_TTYS0_DIV
 #if ((115200%CONFIG_TTYS0_BAUD) != 0)
 #error Bad ttys0 baud rate
 #endif
-#define CONFIG_TTYS0_DIV       (115200/CONFIG_TTYS0_BAUD)
-#endif
 
 /* Line Control Settings */
 #ifndef CONFIG_TTYS0_LCS

Modified: trunk/src/lib/uart8250.c
==============================================================================
--- trunk/src/lib/uart8250.c    Thu Apr 21 23:26:58 2011        (r6537)
+++ trunk/src/lib/uart8250.c    Fri Apr 22 03:45:11 2011        (r6538)
@@ -88,6 +88,12 @@
 #if defined(__PRE_RAM__) || defined(__SMM__)
 void uart_init(void)
 {
+       /* TODO the divisor calculation is hard coded to standard UARTs. Some
+        * UARTs won't work with these values. This should be a property of the
+        * UART used, worst case a Kconfig variable. For now live with hard
+        * codes as the only devices that might be different are the iWave
+        * iRainbowG6 and the OXPCIe952 card (and the latter is memory mapped)
+        */
 #if CONFIG_USE_OPTION_TABLE && !defined(__SMM__)
         static const unsigned char divisor[] = { 1, 2, 3, 6, 12, 24, 48, 96 };
         unsigned ttys0_div, ttys0_index;
@@ -97,7 +103,7 @@
 
        uart8250_init(CONFIG_TTYS0_BASE, ttys0_div);
 #else
-       uart8250_init(CONFIG_TTYS0_BASE, CONFIG_TTYS0_DIV);
+       uart8250_init(CONFIG_TTYS0_BASE, (115200 / CONFIG_TTYS0_BAUD));
 #endif
 }
 #endif

Modified: trunk/src/mainboard/iwave/iWRainbowG6/Kconfig
==============================================================================
--- trunk/src/mainboard/iwave/iWRainbowG6/Kconfig       Thu Apr 21 23:26:58 
2011        (r6537)
+++ trunk/src/mainboard/iwave/iWRainbowG6/Kconfig       Fri Apr 22 03:45:11 
2011        (r6538)
@@ -37,9 +37,7 @@
        int
        default 10
 
-# WTF, is this 19200?
-config TTYS0_DIV
-       int
-       default 6
+# This mainboard might have a higher clocked UART or might not be able to run
+# serial output at 115200 baud
 
 endif

-- 
coreboot mailing list: coreboot@coreboot.org
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to