diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /arch/microblaze/kernel/early_printk.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'arch/microblaze/kernel/early_printk.c')
-rw-r--r-- | arch/microblaze/kernel/early_printk.c | 87 |
1 files changed, 78 insertions, 9 deletions
diff --git a/arch/microblaze/kernel/early_printk.c b/arch/microblaze/kernel/early_printk.c index 7de84923ba07..c3616a080ebf 100644 --- a/arch/microblaze/kernel/early_printk.c +++ b/arch/microblaze/kernel/early_printk.c | |||
@@ -24,7 +24,8 @@ | |||
24 | static u32 early_console_initialized; | 24 | static u32 early_console_initialized; |
25 | static u32 base_addr; | 25 | static u32 base_addr; |
26 | 26 | ||
27 | static void early_printk_putc(char c) | 27 | #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE |
28 | static void early_printk_uartlite_putc(char c) | ||
28 | { | 29 | { |
29 | /* | 30 | /* |
30 | * Limit how many times we'll spin waiting for TX FIFO status. | 31 | * Limit how many times we'll spin waiting for TX FIFO status. |
@@ -45,25 +46,70 @@ static void early_printk_putc(char c) | |||
45 | out_be32(base_addr + 4, c & 0xff); | 46 | out_be32(base_addr + 4, c & 0xff); |
46 | } | 47 | } |
47 | 48 | ||
48 | static void early_printk_write(struct console *unused, | 49 | static void early_printk_uartlite_write(struct console *unused, |
49 | const char *s, unsigned n) | 50 | const char *s, unsigned n) |
50 | { | 51 | { |
51 | while (*s && n-- > 0) { | 52 | while (*s && n-- > 0) { |
52 | early_printk_putc(*s); | 53 | early_printk_uartlite_putc(*s); |
53 | if (*s == '\n') | 54 | if (*s == '\n') |
54 | early_printk_putc('\r'); | 55 | early_printk_uartlite_putc('\r'); |
55 | s++; | 56 | s++; |
56 | } | 57 | } |
57 | } | 58 | } |
58 | 59 | ||
59 | static struct console early_serial_console = { | 60 | static struct console early_serial_uartlite_console = { |
60 | .name = "earlyser", | 61 | .name = "earlyser", |
61 | .write = early_printk_write, | 62 | .write = early_printk_uartlite_write, |
62 | .flags = CON_PRINTBUFFER, | 63 | .flags = CON_PRINTBUFFER, |
63 | .index = -1, | 64 | .index = -1, |
64 | }; | 65 | }; |
66 | #endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */ | ||
65 | 67 | ||
66 | static struct console *early_console = &early_serial_console; | 68 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
69 | static void early_printk_uart16550_putc(char c) | ||
70 | { | ||
71 | /* | ||
72 | * Limit how many times we'll spin waiting for TX FIFO status. | ||
73 | * This will prevent lockups if the base address is incorrectly | ||
74 | * set, or any other issue on the UARTLITE. | ||
75 | * This limit is pretty arbitrary, unless we are at about 10 baud | ||
76 | * we'll never timeout on a working UART. | ||
77 | */ | ||
78 | |||
79 | #define UART_LSR_TEMT 0x40 /* Transmitter empty */ | ||
80 | #define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */ | ||
81 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) | ||
82 | |||
83 | unsigned retries = 10000; | ||
84 | |||
85 | while (--retries && | ||
86 | !((in_be32(base_addr + 0x14) & BOTH_EMPTY) == BOTH_EMPTY)) | ||
87 | ; | ||
88 | |||
89 | if (retries) | ||
90 | out_be32(base_addr, c & 0xff); | ||
91 | } | ||
92 | |||
93 | static void early_printk_uart16550_write(struct console *unused, | ||
94 | const char *s, unsigned n) | ||
95 | { | ||
96 | while (*s && n-- > 0) { | ||
97 | early_printk_uart16550_putc(*s); | ||
98 | if (*s == '\n') | ||
99 | early_printk_uart16550_putc('\r'); | ||
100 | s++; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | static struct console early_serial_uart16550_console = { | ||
105 | .name = "earlyser", | ||
106 | .write = early_printk_uart16550_write, | ||
107 | .flags = CON_PRINTBUFFER, | ||
108 | .index = -1, | ||
109 | }; | ||
110 | #endif /* CONFIG_SERIAL_8250_CONSOLE */ | ||
111 | |||
112 | static struct console *early_console; | ||
67 | 113 | ||
68 | void early_printk(const char *fmt, ...) | 114 | void early_printk(const char *fmt, ...) |
69 | { | 115 | { |
@@ -84,20 +130,43 @@ int __init setup_early_printk(char *opt) | |||
84 | if (early_console_initialized) | 130 | if (early_console_initialized) |
85 | return 1; | 131 | return 1; |
86 | 132 | ||
133 | #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE | ||
87 | base_addr = early_uartlite_console(); | 134 | base_addr = early_uartlite_console(); |
88 | if (base_addr) { | 135 | if (base_addr) { |
89 | early_console_initialized = 1; | 136 | early_console_initialized = 1; |
90 | #ifdef CONFIG_MMU | 137 | #ifdef CONFIG_MMU |
91 | early_console_reg_tlb_alloc(base_addr); | 138 | early_console_reg_tlb_alloc(base_addr); |
92 | #endif | 139 | #endif |
140 | early_console = &early_serial_uartlite_console; | ||
93 | early_printk("early_printk_console is enabled at 0x%08x\n", | 141 | early_printk("early_printk_console is enabled at 0x%08x\n", |
94 | base_addr); | 142 | base_addr); |
95 | 143 | ||
96 | /* register_console(early_console); */ | 144 | /* register_console(early_console); */ |
97 | 145 | ||
98 | return 0; | 146 | return 0; |
99 | } else | 147 | } |
100 | return 1; | 148 | #endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */ |
149 | |||
150 | #ifdef CONFIG_SERIAL_8250_CONSOLE | ||
151 | base_addr = early_uart16550_console(); | ||
152 | base_addr &= ~3; /* clear register offset */ | ||
153 | if (base_addr) { | ||
154 | early_console_initialized = 1; | ||
155 | #ifdef CONFIG_MMU | ||
156 | early_console_reg_tlb_alloc(base_addr); | ||
157 | #endif | ||
158 | early_console = &early_serial_uart16550_console; | ||
159 | |||
160 | early_printk("early_printk_console is enabled at 0x%08x\n", | ||
161 | base_addr); | ||
162 | |||
163 | /* register_console(early_console); */ | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | #endif /* CONFIG_SERIAL_8250_CONSOLE */ | ||
168 | |||
169 | return 1; | ||
101 | } | 170 | } |
102 | 171 | ||
103 | void __init disable_early_printk(void) | 172 | void __init disable_early_printk(void) |