aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/tty.c
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2010-07-13 16:35:17 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2010-07-13 17:08:12 -0400
commitce0aa5dd20e44372f9617dd67c984f41fcdbed88 (patch)
tree8d418e91b8c9df1193121dc85f1864ff0195a42e /arch/x86/boot/tty.c
parentfa97bdf92709adaaf8b9a5164a895e262a4fcf60 (diff)
x86, setup: Make the setup code also accept console=uart8250
Make the boot code also accept the console=uart8250,io,0x2f8,115200n form of early console. Also add back simple_guess_base(), otherwise those simple_strtoull(,,0) are not going to work. Signed-off-by: Yinghai Lu <yinghai@kernel.org> LKML-Reference: <4C3CCE05.4090505@kernel.org> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/boot/tty.c')
-rw-r--r--arch/x86/boot/tty.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/arch/x86/boot/tty.c b/arch/x86/boot/tty.c
index f3ceee20ff12..f6d52e65f97a 100644
--- a/arch/x86/boot/tty.c
+++ b/arch/x86/boot/tty.c
@@ -170,7 +170,7 @@ static void early_serial_init(int baud)
170 outb(c & ~DLAB, early_serial_base + LCR); 170 outb(c & ~DLAB, early_serial_base + LCR);
171} 171}
172 172
173void console_init(void) 173static int parse_earlyprintk(void)
174{ 174{
175 int baud = DEFAULT_BAUD; 175 int baud = DEFAULT_BAUD;
176 char arg[32]; 176 char arg[32];
@@ -208,6 +208,63 @@ void console_init(void)
208 baud = DEFAULT_BAUD; 208 baud = DEFAULT_BAUD;
209 } 209 }
210 210
211 return baud;
212}
213
214#define BASE_BAUD (1843200/16)
215static unsigned int probe_baud(int port)
216{
217 unsigned char lcr, dll, dlh;
218 unsigned int quot;
219
220 lcr = inb(port + LCR);
221 outb(lcr | DLAB, port + LCR);
222 dll = inb(port + DLL);
223 dlh = inb(port + DLH);
224 outb(lcr, port + LCR);
225 quot = (dlh << 8) | dll;
226
227 return BASE_BAUD / quot;
228}
229
230static int parse_console_uart8250(void)
231{
232 char optstr[64], *options;
233 int baud = DEFAULT_BAUD;
234
235 /*
236 * console=uart8250,io,0x3f8,115200n8
237 * need to make sure it is last one console !
238 */
239 if (cmdline_find_option("console", optstr, sizeof optstr) <= 0)
240 return baud;
241
242 options = optstr;
243
244 if (!strncmp(options, "uart8250,io,", 12))
245 early_serial_base = simple_strtoull(options + 12, &options, 0);
246 else if (!strncmp(options, "uart,io,", 8))
247 early_serial_base = simple_strtoull(options + 8, &options, 0);
248 else
249 return baud;
250
251 if (options && (options[0] == ','))
252 baud = simple_strtoull(options + 1, &options, 0);
253 else
254 baud = probe_baud(early_serial_base);
255
256 return baud;
257}
258
259void console_init(void)
260{
261 int baud;
262
263 baud = parse_earlyprintk();
264
265 if (!early_serial_base)
266 baud = parse_console_uart8250();
267
211 if (early_serial_base != 0) 268 if (early_serial_base != 0)
212 early_serial_init(baud); 269 early_serial_init(baud);
213} 270}