]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - drivers/serial/mcfuart.c
rename CFG_ macros to CONFIG_SYS
[karo-tx-uboot.git] / drivers / serial / mcfuart.c
index 88f3eb10abf8f3b4b67d5459b503cb3b6f8e7830..e04fc298d960d8d338140db468a1022b6342753d 100644 (file)
@@ -29,8 +29,6 @@
 
 #include <common.h>
 
-#ifdef CONFIG_MCFUART
-
 #include <asm/immap.h>
 #include <asm/uart.h>
 
@@ -43,7 +41,7 @@ int serial_init(void)
        volatile uart_t *uart;
        u32 counter;
 
-       uart = (volatile uart_t *)(CFG_UART_BASE);
+       uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
 
        uart_port_conf();
 
@@ -63,8 +61,8 @@ int serial_init(void)
        uart->umr = UART_UMR_SB_STOP_BITS_1;
 
        /* Setting up BaudRate */
-       counter = (u32) (gd->bus_clk / (gd->baudrate));
-       counter >>= 5;
+       counter = (u32) ((gd->bus_clk / 32) + (gd->baudrate / 2));
+       counter = counter / gd->baudrate;
 
        /* write to CTUR: divide counter upper byte */
        uart->ubg1 = (u8) ((counter & 0xff00) >> 8);
@@ -78,7 +76,7 @@ int serial_init(void)
 
 void serial_putc(const char c)
 {
-       volatile uart_t *uart = (volatile uart_t *)(CFG_UART_BASE);
+       volatile uart_t *uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
 
        if (c == '\n')
                serial_putc('\r');
@@ -98,7 +96,7 @@ void serial_puts(const char *s)
 
 int serial_getc(void)
 {
-       volatile uart_t *uart = (volatile uart_t *)(CFG_UART_BASE);
+       volatile uart_t *uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
 
        /* Wait for a character to arrive. */
        while (!(uart->usr & UART_USR_RXRDY)) ;
@@ -107,14 +105,14 @@ int serial_getc(void)
 
 int serial_tstc(void)
 {
-       volatile uart_t *uart = (volatile uart_t *)(CFG_UART_BASE);
+       volatile uart_t *uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
 
        return (uart->usr & UART_USR_RXRDY);
 }
 
 void serial_setbrg(void)
 {
-       volatile uart_t *uart = (volatile uart_t *)(CFG_UART_BASE);
+       volatile uart_t *uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
        u32 counter;
 
        counter = ((gd->bus_clk / gd->baudrate)) >> 5;
@@ -130,4 +128,3 @@ void serial_setbrg(void)
 
        uart->ucr = UART_UCR_RX_ENABLED | UART_UCR_TX_ENABLED;
 }
-#endif                         /* CONFIG_MCFUART */