14 #include <linux/kernel.h>
16 #include <linux/string.h>
17 #include <linux/tty.h>
19 #include <asm/processor.h>
20 #include <linux/fcntl.h>
21 #include <asm/setup.h>
24 static u32 early_console_initialized;
27 #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
28 static void early_printk_uartlite_putc(
char c)
40 while (--retries && (
in_be32(base_addr + 8) & (1 << 3)))
49 static void early_printk_uartlite_write(
struct console *
unused,
50 const char *
s,
unsigned n)
52 while (*s && n-- > 0) {
54 early_printk_uartlite_putc(
'\r');
55 early_printk_uartlite_putc(*s);
60 static struct console early_serial_uartlite_console = {
62 .write = early_printk_uartlite_write,
68 #ifdef CONFIG_SERIAL_8250_CONSOLE
69 static void early_printk_uart16550_putc(
char c)
79 #define UART_LSR_TEMT 0x40
80 #define UART_LSR_THRE 0x20
81 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
83 unsigned retries = 10000;
93 static void early_printk_uart16550_write(
struct console *unused,
94 const char *s,
unsigned n)
96 while (*s && n-- > 0) {
98 early_printk_uart16550_putc(
'\r');
99 early_printk_uart16550_putc(*s);
104 static struct console early_serial_uart16550_console = {
106 .write = early_printk_uart16550_write,
112 static struct console *early_console;
120 if (early_console_initialized) {
123 early_console->
write(early_console, buf, n);
132 if (early_console_initialized)
135 base_addr = of_early_console(&version);
138 early_console_reg_tlb_alloc(base_addr);
141 #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
144 "at 0x%08x\n", base_addr);
145 early_console = &early_serial_uartlite_console;
148 #ifdef CONFIG_SERIAL_8250_CONSOLE
151 "at 0x%08x\n", base_addr);
152 early_console = &early_serial_uart16550_console;
162 early_console_initialized = 1;
172 if (!early_console_initialized || !early_console)
198 if (!early_console_initialized || !early_console)
202 early_console_initialized = 0;