SX1: add hardware V2 support
[oweals/u-boot.git] / cpu / ixp / serial.c
index 2015958571423aa5705e46b8525bcc2309b841c1..dd26af49b54d00e21fb5dac5519dd82031cdcfa8 100644 (file)
 #include <common.h>
 #include <asm/arch/ixp425.h>
 
+/*
+ *               14.7456 MHz
+ * Baud Rate = --------------
+ *              16 x Divisor
+ */
+#define SERIAL_CLOCK 921600
+
 DECLARE_GLOBAL_DATA_PTR;
 
 void serial_setbrg (void)
 {
        unsigned int quot = 0;
-       int uart = CFG_IXP425_CONSOLE;
-
-       if (gd->baudrate == 1200)
-               quot = 192;
-       else if (gd->baudrate == 9600)
-               quot = 96;
-       else if (gd->baudrate == 19200)
-               quot = 48;
-       else if (gd->baudrate == 38400)
-               quot = 24;
-       else if (gd->baudrate == 57600)
-               quot = 16;
-       else if (gd->baudrate == 115200)
-               quot = 8;
+       int uart = CONFIG_SYS_IXP425_CONSOLE;
+
+       if ((gd->baudrate <= SERIAL_CLOCK) && (SERIAL_CLOCK % gd->baudrate == 0))
+               quot = SERIAL_CLOCK / gd->baudrate;
        else
                hang ();
 
@@ -61,11 +58,14 @@ void serial_setbrg (void)
        DLL(uart) = quot & 0xff;
        DLH(uart) = quot >> 8;
        LCR(uart) = LCR_WLS0 | LCR_WLS1;
-
+#ifdef CONFIG_SERIAL_RTS_ACTIVE
+       MCR(uart) = MCR_RTS;                            /* set RTS active */
+#else
+       MCR(uart) = 0;                                  /* set RTS inactive */
+#endif
        IER(uart) = IER_UUE;
 }
 
-
 /*
  * Initialise the serial port with the given baudrate. The settings
  * are always 8 data bits, no parity, 1 stop bit, no start bits.
@@ -85,9 +85,9 @@ int serial_init (void)
 void serial_putc (const char c)
 {
        /* wait for room in the tx FIFO on UART */
-       while ((LSR(CFG_IXP425_CONSOLE) & LSR_TEMT) == 0);
+       while ((LSR(CONFIG_SYS_IXP425_CONSOLE) & LSR_TEMT) == 0);
 
-       THR(CFG_IXP425_CONSOLE) = c;
+       THR(CONFIG_SYS_IXP425_CONSOLE) = c;
 
        /* If \n, also do \r */
        if (c == '\n')
@@ -101,7 +101,7 @@ void serial_putc (const char c)
  */
 int serial_tstc (void)
 {
-       return LSR(CFG_IXP425_CONSOLE) & LSR_DR;
+       return LSR(CONFIG_SYS_IXP425_CONSOLE) & LSR_DR;
 }
 
 /*
@@ -111,9 +111,9 @@ int serial_tstc (void)
  */
 int serial_getc (void)
 {
-       while (!(LSR(CFG_IXP425_CONSOLE) & LSR_DR));
+       while (!(LSR(CONFIG_SYS_IXP425_CONSOLE) & LSR_DR));
 
-       return (char) RBR(CFG_IXP425_CONSOLE) & 0xff;
+       return (char) RBR(CONFIG_SYS_IXP425_CONSOLE) & 0xff;
 }
 
 void