summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2014-02-15 07:53:18 +0200
committerKyösti Mälkki <kyosti.malkki@gmail.com>2014-03-04 15:27:53 +0100
commit4770749edca1e54c9a04b48ca6909d786139fa1b (patch)
tree05ef5eeba7586e3ba28f24eca77b349b2305580a /src/lib
parent1d7541feeba372ec3d1d441442238e1c65972bd7 (diff)
uart8250io: Unify calls with generic UART
Change-Id: I6d56648e56f2177e1d5332497321e718df18300c Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/5234 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/uart8250.c51
1 files changed, 33 insertions, 18 deletions
diff --git a/src/lib/uart8250.c b/src/lib/uart8250.c
index 3171e00d13..8e1714d190 100644
--- a/src/lib/uart8250.c
+++ b/src/lib/uart8250.c
@@ -40,40 +40,30 @@
#define SINGLE_CHAR_TIMEOUT (50 * 1000)
#define FIFO_TIMEOUT (16 * SINGLE_CHAR_TIMEOUT)
-static inline int uart8250_can_tx_byte(unsigned base_port)
+static int uart8250_can_tx_byte(unsigned base_port)
{
return inb(base_port + UART_LSR) & UART_LSR_THRE;
}
-static inline void uart8250_wait_to_tx_byte(unsigned base_port)
+static void uart8250_tx_byte(unsigned base_port, unsigned char data)
{
unsigned long int i = SINGLE_CHAR_TIMEOUT;
while (i-- && !uart8250_can_tx_byte(base_port));
+ outb(data, base_port + UART_TBR);
}
-static inline void uart8250_wait_until_sent(unsigned base_port)
+static void uart8250_tx_flush(unsigned base_port)
{
unsigned long int i = FIFO_TIMEOUT;
while (i-- && !(inb(base_port + UART_LSR) & UART_LSR_TEMT));
}
-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)
-{
- 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));
@@ -84,7 +74,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 */
@@ -107,10 +97,35 @@ void uart8250_init(unsigned base_port, unsigned divisor)
ENABLE_TRACE;
}
+/* FIXME: Needs uart index from Kconfig.
+ * Already use array as a work-around for ROMCC.
+ */
+static const unsigned bases[1] = { CONFIG_TTYS0_BASE };
+
void uart_init(void)
{
unsigned int div;
div = uart_baudrate_divisor(default_baudrate(), BAUDRATE_REFCLK,
BAUDRATE_OVERSAMPLE);
- uart8250_init(CONFIG_TTYS0_BASE, div);
+ uart8250_init(bases[0], div);
+}
+
+void uart_tx_byte(unsigned char data)
+{
+ uart8250_tx_byte(bases[0], data);
+}
+
+unsigned char uart_rx_byte(void)
+{
+ return uart8250_rx_byte(bases[0]);
+}
+
+int uart_can_rx_byte(void)
+{
+ return uart8250_can_rx_byte(bases[0]);
+}
+
+void uart_tx_flush(void)
+{
+ uart8250_tx_flush(bases[0]);
}