]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
blackfin: Enable early print via the generic serial API.
authorSonic Zhang <sonic.zhang@analog.com>
Wed, 13 Mar 2013 11:06:16 +0000 (19:06 +0800)
committerSonic Zhang <sonic.zhang@analog.com>
Mon, 13 May 2013 08:26:27 +0000 (16:26 +0800)
Remove blackfin specific implementation of the generic serial API when
early print macro is defined.

In BFIN_BOOT_BYPASS mode, don't call generic serial_puts, because
early print in bypass mode is running before code binary is relocated
to the link address.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
arch/blackfin/cpu/serial.c
arch/blackfin/cpu/serial.h
include/configs/bfin_adi_common.h

index 36d2a5c8e4121546de3a17e9615530ad98707c5a..89290d675e8269e8a29e4596c0851fd36f76237d 100644 (file)
@@ -197,13 +197,16 @@ static void uart_loop(uint32_t uart_base, int state)
 
 static inline void __serial_set_baud(uint32_t uart_base, uint32_t baud)
 {
+#ifdef CONFIG_DEBUG_EARLY_SERIAL
+       serial_early_set_baud(uart_base, baud);
+#else
        uint16_t divisor = (get_uart_clk() + (baud * 8)) / (baud * 16)
                        - ANOMALY_05000230;
 
        /* Program the divisor to get the baud rate we want */
        serial_set_divisor(uart_base, divisor);
+#endif
 }
-#ifdef CONFIG_SYS_BFIN_UART
 
 static void uart_puts(uint32_t uart_base, const char *s)
 {
@@ -313,65 +316,39 @@ void bfin_serial_initialize(void)
 #endif
 }
 
-#else
-
-/* Symbol for our assembly to call. */
-void serial_set_baud(uint32_t baud)
-{
-       serial_early_set_baud(UART_BASE, baud);
-}
-
-/* Symbol for common u-boot code to call.
- * Setup the baudrate (brg: baudrate generator).
- */
-void serial_setbrg(void)
+#ifdef CONFIG_DEBUG_EARLY_SERIAL
+inline void uart_early_putc(uint32_t uart_base, const char c)
 {
-       serial_set_baud(gd->baudrate);
-}
-
-/* Symbol for our assembly to call. */
-void serial_initialize(void)
-{
-       serial_early_init(UART_BASE);
-}
-
-/* Symbol for common u-boot code to call. */
-int serial_init(void)
-{
-       serial_initialize();
-       serial_setbrg();
-       uart_lsr_clear(UART_BASE);
-       return 0;
-}
+       /* send a \r for compatibility */
+       if (c == '\n')
+               uart_early_putc(uart_base, '\r');
 
-int serial_tstc(void)
-{
-       return uart_tstc(UART_BASE);
-}
+       /* wait for the hardware fifo to clear up */
+       while (!(_lsr_read(pUART) & THRE))
+               continue;
 
-int serial_getc(void)
-{
-       return uart_getc(UART_BASE);
+       /* queue the character for transmission */
+       bfin_write(&pUART->thr, c);
+       SSYNC();
 }
 
-void serial_putc(const char c)
+void uart_early_puts(const char *s)
 {
-       uart_putc(UART_BASE, c);
+       while (*s)
+               uart_early_putc(UART_BASE, *s++);
 }
 
-void serial_puts(const char *s)
+/* Symbol for our assembly to call. */
+void _serial_early_set_baud(uint32_t baud)
 {
-       while (*s)
-               serial_putc(*s++);
+       serial_early_set_baud(UART_BASE, baud);
 }
 
-LOOP(
-void serial_loop(int state)
+/* Symbol for our assembly to call. */
+void _serial_early_init(void)
 {
-       uart_loop(UART_BASE, state);
+       serial_early_init(UART_BASE);
 }
-)
-
 #endif
 
 #endif
index d67fd81c0964c5dbf087915d6490119a78f8b190..87a337d1b4e8b862e3a6cab8ff819a5794958ed7 100644 (file)
@@ -78,16 +78,16 @@ static inline void serial_early_puts(const char *s)
 #else
 
 .macro serial_early_init
-#if defined(CONFIG_DEBUG_EARLY_SERIAL) && defined(BFIN_BOOT_BYPASS)
-       call _serial_initialize;
+#if defined(CONFIG_DEBUG_EARLY_SERIAL) && !defined(CONFIG_UART_MEM)
+       call __serial_early_init;
 #endif
 .endm
 
 .macro serial_early_set_baud
-#if defined(CONFIG_DEBUG_EARLY_SERIAL) && defined(BFIN_BOOT_BYPASS)
+#if defined(CONFIG_DEBUG_EARLY_SERIAL) && !defined(CONFIG_UART_MEM)
        R0.L = LO(CONFIG_BAUDRATE);
        R0.H = HI(CONFIG_BAUDRATE);
-       call _serial_set_baud;
+       call __serial_early_set_baud;
 #endif
 .endm
 
@@ -121,7 +121,7 @@ static inline void serial_early_puts(const char *s)
        R0.L = 7b; \
        R0.H = 7b; \
        update_serial_early_string_addr \
-       call _serial_puts;
+       call _uart_early_puts;
 #else
 # define serial_early_puts(str)
 #endif
index d3ae3a71cd7827c7c302e82c8ca10f9434805fd2..c986ba3d3e46432ead359013b49a988a39c1e3c8 100644 (file)
 #ifndef CONFIG_BAUDRATE
 # define CONFIG_BAUDRATE       57600
 #endif
-#ifndef CONFIG_DEBUG_EARLY_SERIAL
-# define CONFIG_SYS_BFIN_UART
-#endif
 
 /*
  * Debug Settings