[coreboot-gerrit] New patch to review for coreboot: 5841f15 uart8250io: Unify calls with generic UART

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Sat Feb 15 11:08:15 CET 2014


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5234

-gerrit

commit 5841f155c4332e62170528569dd39a2d5a6dbecf
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Sat Feb 15 07:53:18 2014 +0200

    uart8250io: Unify calls with generic UART
    
    Change-Id: I6d56648e56f2177e1d5332497321e718df18300c
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/arch/x86/lib/romcc_console.c    |  8 +++-----
 src/arch/x86/lib/romstage_console.c |  6 +++---
 src/console/uart8250_console.c      | 10 +++++-----
 src/include/uart8250.h              | 11 -----------
 src/lib/uart8250.c                  | 31 ++++++++++++++++++++++++-------
 5 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/src/arch/x86/lib/romcc_console.c b/src/arch/x86/lib/romcc_console.c
index 0f0e017..5a88146 100644
--- a/src/arch/x86/lib/romcc_console.c
+++ b/src/arch/x86/lib/romcc_console.c
@@ -20,6 +20,7 @@
 #include <stdint.h>
 #include <console/loglevel.h>
 #include <console/post_codes.h>
+#include <console/uart.h>
 #include <console/ne2k.h>
 
 /* __PRE_RAM__ */
@@ -28,9 +29,6 @@
  * we could use the same code on all architectures.
  */
 #define console_loglevel CONFIG_DEFAULT_CONSOLE_LOGLEVEL
-#if CONFIG_CONSOLE_SERIAL8250
-#include <uart8250.h>
-#endif
 
 #include <console/util.c>
 
@@ -44,7 +42,7 @@
 static void __console_tx_byte(unsigned char byte)
 {
 #if CONFIG_CONSOLE_SERIAL8250
-	uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
+	uart_tx_byte(byte);
 #endif
 #if CONFIG_CONSOLE_NE2K
 	ne2k_append_data_byte(byte, CONFIG_CONSOLE_NE2K_IO_PORT);
@@ -65,7 +63,7 @@ static void __console_tx_char(int loglevel, unsigned char byte)
 {
 	if (console_loglevel >= loglevel) {
 #if CONFIG_CONSOLE_SERIAL8250
-		uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
+		uart_tx_byte(byte);
 #endif
 #if CONFIG_CONSOLE_NE2K
 		ne2k_append_data_byte(byte, CONFIG_CONSOLE_NE2K_IO_PORT);
diff --git a/src/arch/x86/lib/romstage_console.c b/src/arch/x86/lib/romstage_console.c
index 4981f39..89d7f82 100644
--- a/src/arch/x86/lib/romstage_console.c
+++ b/src/arch/x86/lib/romstage_console.c
@@ -26,7 +26,7 @@
 #include <console/spkmodem.h>
 #include <console/vtxprintf.h>
 
-#if CONFIG_CONSOLE_SERIAL8250 || CONFIG_CONSOLE_SERIAL8250MEM
+#if CONFIG_CONSOLE_SERIAL8250MEM
 #include <uart8250.h>
 #endif
 
@@ -42,7 +42,7 @@ void console_tx_byte(unsigned char byte)
 	}
 #endif
 #if CONFIG_CONSOLE_SERIAL8250
-	uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
+	uart_tx_byte(byte);
 #endif
 #if CONFIG_USBDEBUG && (CONFIG_USBDEBUG_IN_ROMSTAGE || !defined(__PRE_RAM__))
 	usb_tx_byte(0, byte);
@@ -64,7 +64,7 @@ void console_tx_flush(void)
 	uart8250_mem_tx_flush(CONFIG_OXFORD_OXPCIE_BASE_ADDRESS + 0x1000);
 #endif
 #if CONFIG_CONSOLE_SERIAL8250
-	uart8250_tx_flush(CONFIG_TTYS0_BASE);
+	uart_tx_flush();
 #endif
 #if CONFIG_CONSOLE_NE2K
 	ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
diff --git a/src/console/uart8250_console.c b/src/console/uart8250_console.c
index 196412c..52f59f6 100644
--- a/src/console/uart8250_console.c
+++ b/src/console/uart8250_console.c
@@ -18,7 +18,7 @@
  */
 
 #include <console/console.h>
-#include <uart8250.h>
+#include <console/uart.h>
 
 static void ttyS0_init(void)
 {
@@ -27,22 +27,22 @@ static void ttyS0_init(void)
 
 static void ttyS0_tx_byte(unsigned char data)
 {
-	uart8250_tx_byte(CONFIG_TTYS0_BASE, data);
+	uart_tx_byte(data);
 }
 
 static void ttyS0_tx_flush(void)
 {
-	uart8250_tx_flush(CONFIG_TTYS0_BASE);
+	uart_tx_flush();
 }
 
 static unsigned char ttyS0_rx_byte(void)
 {
-	return uart8250_rx_byte(CONFIG_TTYS0_BASE);
+	return uart_rx_byte();
 }
 
 static int ttyS0_tst_byte(void)
 {
-	return uart8250_can_rx_byte(CONFIG_TTYS0_BASE);
+	return uart_can_rx_byte();
 }
 
 static const struct console_driver uart8250_console __console = {
diff --git a/src/include/uart8250.h b/src/include/uart8250.h
index f2d59da..6a2518b 100644
--- a/src/include/uart8250.h
+++ b/src/include/uart8250.h
@@ -29,17 +29,6 @@
 unsigned uart_platform_divisor(void);
 unsigned uart_divisor(unsigned basefreq);
 
-#if CONFIG_CONSOLE_SERIAL8250
-unsigned char uart8250_rx_byte(unsigned base_port);
-int uart8250_can_rx_byte(unsigned base_port);
-void uart8250_tx_byte(unsigned base_port, unsigned char data);
-void uart8250_tx_flush(unsigned base_port);
-/* Yes it is silly to have three different uart init functions. But we used to
- * have three different sets of uart code, so it's an improvement.
- */
-void uart8250_init(unsigned base_port, unsigned divisor);
-void uart_init(void);
-#endif
 #if CONFIG_CONSOLE_SERIAL8250MEM
 void uartmem_init(void);
 
diff --git a/src/lib/uart8250.c b/src/lib/uart8250.c
index 4d2cb63..75caa06 100644
--- a/src/lib/uart8250.c
+++ b/src/lib/uart8250.c
@@ -19,7 +19,7 @@
  */
 
 #include <arch/io.h>
-#include <uart8250.h>
+#include <console/uart.h>
 #include <trace.h>
 #include "drivers/uart/uart8250reg.h"
 
@@ -51,23 +51,23 @@ static inline void uart8250_wait_until_sent(unsigned base_port)
 	while (i-- && !(inb(base_port + UART_LSR) & UART_LSR_TEMT));
 }
 
-void uart8250_tx_byte(unsigned base_port, unsigned char data)
+static void uart8250_tx_byte(unsigned base_port, unsigned char data)
 {
 	uart8250_wait_to_tx_byte(base_port);
 	outb(data, base_port + UART_TBR);
 }
 
-void uart8250_tx_flush(unsigned base_port)
+static void uart8250_tx_flush(unsigned base_port)
 {
 	uart8250_wait_until_sent(base_port);
 }
 
-int uart8250_can_rx_byte(unsigned base_port)
+static int uart8250_can_rx_byte(unsigned base_port)
 {
 	return inb(base_port + UART_LSR) & UART_LSR_DR;
 }
 
-unsigned char uart8250_rx_byte(unsigned base_port)
+static unsigned char uart8250_rx_byte(unsigned base_port)
 {
 	unsigned long int i = SINGLE_CHAR_TIMEOUT;
 	while (i-- && !uart8250_can_rx_byte(base_port));
@@ -78,7 +78,7 @@ unsigned char uart8250_rx_byte(unsigned base_port)
 		return 0x0;
 }
 
-void uart8250_init(unsigned base_port, unsigned divisor)
+static void uart8250_init(unsigned base_port, unsigned divisor)
 {
 	DISABLE_TRACE;
 	/* Disable interrupts */
@@ -101,8 +101,25 @@ void uart8250_init(unsigned base_port, unsigned divisor)
 	ENABLE_TRACE;
 }
 
+static const unsigned base = CONFIG_TTYS0_BASE;
+
 void uart_init(void)
 {
 	unsigned int div = uart_divisor(115200);
-	uart8250_init(CONFIG_TTYS0_BASE, div);
+	uart8250_init(base, div);
+}
+
+void uart_tx_byte(unsigned char data)
+{
+	uart8250_tx_byte(base, data);
+}
+
+unsigned char uart_rx_byte(void)
+{
+	return uart8250_rx_byte(base);
+}
+
+void uart_tx_flush(void)
+{
+	uart8250_tx_flush(base);
 }



More information about the coreboot-gerrit mailing list