1 From 5c05917e7fe313a187ad6ebb94c1c6cf42862a0b Mon Sep 17 00:00:00 2001
2 From: Yinghai Lu <yhlu.kernel@gmail.com>
3 Date: Thu, 24 Jul 2008 17:29:40 -0700
4 Subject: x86: usb debug port early console, v4
7 From: Yinghai Lu <yhlu.kernel@gmail.com>
9 commit 5c05917e7fe313a187ad6ebb94c1c6cf42862a0b upstream.
11 based on work from Eric, and add some timeout so don't dead loop when debug
12 device is not installed
14 v2: fix checkpatch warning
15 v3: move ehci struct def to linux/usrb/ehci_def.h from host/ehci.h
16 also add CONFIG_EARLY_PRINTK_DBGP to disable it by default
17 v4: address comments from Ingo, seperate ehci reg def moving to another patch
18 also add auto detect port that connect to debug device for Nvidia
21 Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
22 Cc: Andrew Morton <akpm@linux-foundation.org>
23 Cc: Andi Kleen <andi@firstfloor.org>
24 Cc: "Arjan van de Ven" <arjan@infradead.org>
25 Cc: "Eric W. Biederman" <ebiederm@xmission.com>
26 Cc: "Greg KH" <greg@kroah.com>
27 Signed-off-by: Ingo Molnar <mingo@elte.hu>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
31 Documentation/kernel-parameters.txt | 3
32 arch/x86/Kconfig.debug | 13
33 arch/x86/kernel/early_printk.c | 762 +++++++++++++++++++++++++++++++++++-
34 3 files changed, 774 insertions(+), 4 deletions(-)
36 --- a/arch/x86/Kconfig.debug
37 +++ b/arch/x86/Kconfig.debug
38 @@ -43,6 +43,19 @@ config EARLY_PRINTK
39 with klogd/syslogd or the X server. You should normally N here,
40 unless you want to debug such a crash.
42 +config EARLY_PRINTK_DBGP
43 + bool "Early printk via EHCI debug port"
45 + depends on EARLY_PRINTK
47 + Write kernel log output directly into the EHCI debug port.
49 + This is useful for kernel debugging when your machine crashes very
50 + early before the console code is initialized. For normal operation
51 + it is not recommended because it looks ugly and doesn't cooperate
52 + with klogd/syslogd or the X server. You should normally N here,
53 + unless you want to debug such a crash. You need usb debug device.
55 config DEBUG_STACKOVERFLOW
56 bool "Check for stack overflows"
57 depends on DEBUG_KERNEL
58 --- a/arch/x86/kernel/early_printk.c
59 +++ b/arch/x86/kernel/early_printk.c
61 #include <linux/init.h>
62 #include <linux/string.h>
63 #include <linux/screen_info.h>
64 +#include <linux/usb/ch9.h>
65 +#include <linux/pci_regs.h>
66 +#include <linux/pci_ids.h>
67 +#include <linux/errno.h>
69 #include <asm/processor.h>
70 #include <asm/fcntl.h>
71 #include <asm/setup.h>
72 #include <xen/hvc-console.h>
73 +#include <asm/pci-direct.h>
74 +#include <asm/pgtable.h>
75 +#include <asm/fixmap.h>
76 +#include <linux/usb/ehci_def.h>
78 /* Simple VGA output */
79 #define VGABASE (__ISA_IO_base + 0xb8000)
80 @@ -78,6 +86,7 @@ static int early_serial_base = 0x3f8; /
81 static int early_serial_putc(unsigned char ch)
83 unsigned timeout = 0xffff;
85 while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
87 outb(ch, early_serial_base + TXR);
88 @@ -151,6 +160,721 @@ static struct console early_serial_conso
92 +#ifdef CONFIG_EARLY_PRINTK_DBGP
94 +static struct ehci_caps __iomem *ehci_caps;
95 +static struct ehci_regs __iomem *ehci_regs;
96 +static struct ehci_dbg_port __iomem *ehci_debug;
97 +static unsigned int dbgp_endpoint_out;
105 +static struct ehci_dev ehci_dev;
107 +#define USB_DEBUG_DEVNUM 127
109 +#define DBGP_DATA_TOGGLE 0x8800
111 +static inline u32 dbgp_pid_update(u32 x, u32 tok)
113 + return ((x ^ DBGP_DATA_TOGGLE) & 0xffff00) | (tok & 0xff);
116 +static inline u32 dbgp_len_update(u32 x, u32 len)
118 + return (x & ~0x0f) | (len & 0x0f);
122 + * USB Packet IDs (PIDs)
126 +#define USB_PID_OUT 0xe1
127 +#define USB_PID_IN 0x69
128 +#define USB_PID_SOF 0xa5
129 +#define USB_PID_SETUP 0x2d
131 +#define USB_PID_ACK 0xd2
132 +#define USB_PID_NAK 0x5a
133 +#define USB_PID_STALL 0x1e
134 +#define USB_PID_NYET 0x96
136 +#define USB_PID_DATA0 0xc3
137 +#define USB_PID_DATA1 0x4b
138 +#define USB_PID_DATA2 0x87
139 +#define USB_PID_MDATA 0x0f
141 +#define USB_PID_PREAMBLE 0x3c
142 +#define USB_PID_ERR 0x3c
143 +#define USB_PID_SPLIT 0x78
144 +#define USB_PID_PING 0xb4
145 +#define USB_PID_UNDEF_0 0xf0
147 +#define USB_PID_DATA_TOGGLE 0x88
148 +#define DBGP_CLAIM (DBGP_OWNER | DBGP_ENABLED | DBGP_INUSE)
150 +#define PCI_CAP_ID_EHCI_DEBUG 0xa
152 +#define HUB_ROOT_RESET_TIME 50 /* times are in msec */
153 +#define HUB_SHORT_RESET_TIME 10
154 +#define HUB_LONG_RESET_TIME 200
155 +#define HUB_RESET_TIMEOUT 500
157 +#define DBGP_MAX_PACKET 8
159 +static int dbgp_wait_until_complete(void)
162 + int loop = 0x100000;
165 + ctrl = readl(&ehci_debug->control);
166 + /* Stop when the transaction is finished */
167 + if (ctrl & DBGP_DONE)
169 + } while (--loop > 0);
175 + * Now that we have observed the completed transaction,
176 + * clear the done bit.
178 + writel(ctrl | DBGP_DONE, &ehci_debug->control);
179 + return (ctrl & DBGP_ERROR) ? -DBGP_ERRCODE(ctrl) : DBGP_LEN(ctrl);
182 +static void dbgp_mdelay(int ms)
187 + for (i = 0; i < 1000; i++)
192 +static void dbgp_breath(void)
194 + /* Sleep to give the debug port a chance to breathe */
197 +static int dbgp_wait_until_done(unsigned ctrl)
204 + writel(ctrl | DBGP_GO, &ehci_debug->control);
205 + ret = dbgp_wait_until_complete();
206 + pids = readl(&ehci_debug->pids);
207 + lpid = DBGP_PID_GET(pids);
213 + * If the port is getting full or it has dropped data
214 + * start pacing ourselves, not necessary but it's friendly.
216 + if ((lpid == USB_PID_NAK) || (lpid == USB_PID_NYET))
219 + /* If I get a NACK reissue the transmission */
220 + if (lpid == USB_PID_NAK) {
228 +static void dbgp_set_data(const void *buf, int size)
230 + const unsigned char *bytes = buf;
235 + for (i = 0; i < 4 && i < size; i++)
236 + lo |= bytes[i] << (8*i);
237 + for (; i < 8 && i < size; i++)
238 + hi |= bytes[i] << (8*(i - 4));
239 + writel(lo, &ehci_debug->data03);
240 + writel(hi, &ehci_debug->data47);
243 +static void dbgp_get_data(void *buf, int size)
245 + unsigned char *bytes = buf;
249 + lo = readl(&ehci_debug->data03);
250 + hi = readl(&ehci_debug->data47);
251 + for (i = 0; i < 4 && i < size; i++)
252 + bytes[i] = (lo >> (8*i)) & 0xff;
253 + for (; i < 8 && i < size; i++)
254 + bytes[i] = (hi >> (8*(i - 4))) & 0xff;
257 +static int dbgp_bulk_write(unsigned devnum, unsigned endpoint,
258 + const char *bytes, int size)
260 + u32 pids, addr, ctrl;
263 + if (size > DBGP_MAX_PACKET)
266 + addr = DBGP_EPADDR(devnum, endpoint);
268 + pids = readl(&ehci_debug->pids);
269 + pids = dbgp_pid_update(pids, USB_PID_OUT);
271 + ctrl = readl(&ehci_debug->control);
272 + ctrl = dbgp_len_update(ctrl, size);
276 + dbgp_set_data(bytes, size);
277 + writel(addr, &ehci_debug->address);
278 + writel(pids, &ehci_debug->pids);
280 + ret = dbgp_wait_until_done(ctrl);
287 +static int dbgp_bulk_read(unsigned devnum, unsigned endpoint, void *data,
290 + u32 pids, addr, ctrl;
293 + if (size > DBGP_MAX_PACKET)
296 + addr = DBGP_EPADDR(devnum, endpoint);
298 + pids = readl(&ehci_debug->pids);
299 + pids = dbgp_pid_update(pids, USB_PID_IN);
301 + ctrl = readl(&ehci_debug->control);
302 + ctrl = dbgp_len_update(ctrl, size);
306 + writel(addr, &ehci_debug->address);
307 + writel(pids, &ehci_debug->pids);
308 + ret = dbgp_wait_until_done(ctrl);
314 + dbgp_get_data(data, size);
318 +static int dbgp_control_msg(unsigned devnum, int requesttype, int request,
319 + int value, int index, void *data, int size)
321 + u32 pids, addr, ctrl;
322 + struct usb_ctrlrequest req;
326 + read = (requesttype & USB_DIR_IN) != 0;
327 + if (size > (read ? DBGP_MAX_PACKET:0))
330 + /* Compute the control message */
331 + req.bRequestType = requesttype;
332 + req.bRequest = request;
333 + req.wValue = value;
334 + req.wIndex = index;
335 + req.wLength = size;
337 + pids = DBGP_PID_SET(USB_PID_DATA0, USB_PID_SETUP);
338 + addr = DBGP_EPADDR(devnum, 0);
340 + ctrl = readl(&ehci_debug->control);
341 + ctrl = dbgp_len_update(ctrl, sizeof(req));
345 + /* Send the setup message */
346 + dbgp_set_data(&req, sizeof(req));
347 + writel(addr, &ehci_debug->address);
348 + writel(pids, &ehci_debug->pids);
349 + ret = dbgp_wait_until_done(ctrl);
353 + /* Read the result */
354 + return dbgp_bulk_read(devnum, 0, data, size);
358 +/* Find a PCI capability */
359 +static u32 __init find_cap(u32 num, u32 slot, u32 func, int cap)
364 + if (!(read_pci_config_16(num, slot, func, PCI_STATUS) &
365 + PCI_STATUS_CAP_LIST))
368 + pos = read_pci_config_byte(num, slot, func, PCI_CAPABILITY_LIST);
369 + for (bytes = 0; bytes < 48 && pos >= 0x40; bytes++) {
373 + id = read_pci_config_byte(num, slot, func, pos+PCI_CAP_LIST_ID);
379 + pos = read_pci_config_byte(num, slot, func,
380 + pos+PCI_CAP_LIST_NEXT);
385 +static u32 __init __find_dbgp(u32 bus, u32 slot, u32 func)
389 + class = read_pci_config(bus, slot, func, PCI_CLASS_REVISION);
390 + if ((class >> 8) != PCI_CLASS_SERIAL_USB_EHCI)
393 + return find_cap(bus, slot, func, PCI_CAP_ID_EHCI_DEBUG);
396 +static u32 __init find_dbgp(int ehci_num, u32 *rbus, u32 *rslot, u32 *rfunc)
398 + u32 bus, slot, func;
400 + for (bus = 0; bus < 256; bus++) {
401 + for (slot = 0; slot < 32; slot++) {
402 + for (func = 0; func < 8; func++) {
405 + cap = __find_dbgp(bus, slot, func);
409 + if (ehci_num-- != 0)
421 +static int ehci_reset_port(int port)
424 + u32 delay_time, delay;
427 + /* Reset the usb debug port */
428 + portsc = readl(&ehci_regs->port_status[port - 1]);
429 + portsc &= ~PORT_PE;
430 + portsc |= PORT_RESET;
431 + writel(portsc, &ehci_regs->port_status[port - 1]);
433 + delay = HUB_ROOT_RESET_TIME;
434 + for (delay_time = 0; delay_time < HUB_RESET_TIMEOUT;
435 + delay_time += delay) {
436 + dbgp_mdelay(delay);
438 + portsc = readl(&ehci_regs->port_status[port - 1]);
439 + if (portsc & PORT_RESET) {
440 + /* force reset to complete */
442 + writel(portsc & ~(PORT_RWC_BITS | PORT_RESET),
443 + &ehci_regs->port_status[port - 1]);
445 + portsc = readl(&ehci_regs->port_status[port-1]);
446 + } while ((portsc & PORT_RESET) && (--loop > 0));
449 + /* Device went away? */
450 + if (!(portsc & PORT_CONNECT))
453 + /* bomb out completely if something weird happend */
454 + if ((portsc & PORT_CSC))
457 + /* If we've finished resetting, then break out of the loop */
458 + if (!(portsc & PORT_RESET) && (portsc & PORT_PE))
464 +static int ehci_wait_for_port(int port)
469 + for (reps = 0; reps < 3; reps++) {
471 + status = readl(&ehci_regs->status);
472 + if (status & STS_PCD) {
473 + ret = ehci_reset_port(port);
482 +# define dbgp_printk early_printk
484 +static inline void dbgp_printk(const char *fmt, ...) { }
487 +typedef void (*set_debug_port_t)(int port);
489 +static void default_set_debug_port(int port)
493 +static set_debug_port_t set_debug_port = default_set_debug_port;
495 +static void nvidia_set_debug_port(int port)
498 + dword = read_pci_config(ehci_dev.bus, ehci_dev.slot, ehci_dev.func,
500 + dword &= ~(0x0f<<12);
501 + dword |= ((port & 0x0f)<<12);
502 + write_pci_config(ehci_dev.bus, ehci_dev.slot, ehci_dev.func, 0x74,
504 + dbgp_printk("set debug port to %d\n", port);
507 +static void __init detect_set_debug_port(void)
511 + vendorid = read_pci_config(ehci_dev.bus, ehci_dev.slot, ehci_dev.func,
514 + if ((vendorid & 0xffff) == 0x10de) {
515 + dbgp_printk("using nvidia set_debug_port\n");
516 + set_debug_port = nvidia_set_debug_port;
520 +static int __init ehci_setup(void)
522 + struct usb_debug_descriptor dbgp_desc;
523 + u32 cmd, ctrl, status, portsc, hcs_params;
524 + u32 debug_port, new_debug_port = 0, n_ports;
528 + int port_map_tried;
532 + port_map_tried = 0;
536 + hcs_params = readl(&ehci_caps->hcs_params);
537 + debug_port = HCS_DEBUG_PORT(hcs_params);
538 + n_ports = HCS_N_PORTS(hcs_params);
540 + dbgp_printk("debug_port: %d\n", debug_port);
541 + dbgp_printk("n_ports: %d\n", n_ports);
543 + for (i = 1; i <= n_ports; i++) {
544 + portsc = readl(&ehci_regs->port_status[i-1]);
545 + dbgp_printk("portstatus%d: %08x\n", i, portsc);
548 + if (port_map_tried && (new_debug_port != debug_port)) {
550 + set_debug_port(new_debug_port);
551 + goto try_next_time;
557 + /* Reset the EHCI controller */
558 + cmd = readl(&ehci_regs->command);
560 + writel(cmd, &ehci_regs->command);
562 + cmd = readl(&ehci_regs->command);
563 + } while ((cmd & CMD_RESET) && (--loop > 0));
566 + dbgp_printk("can not reset ehci\n");
569 + dbgp_printk("ehci reset done\n");
571 + /* Claim ownership, but do not enable yet */
572 + ctrl = readl(&ehci_debug->control);
573 + ctrl |= DBGP_OWNER;
574 + ctrl &= ~(DBGP_ENABLED | DBGP_INUSE);
575 + writel(ctrl, &ehci_debug->control);
577 + /* Start the ehci running */
578 + cmd = readl(&ehci_regs->command);
579 + cmd &= ~(CMD_LRESET | CMD_IAAD | CMD_PSE | CMD_ASE | CMD_RESET);
581 + writel(cmd, &ehci_regs->command);
583 + /* Ensure everything is routed to the EHCI */
584 + writel(FLAG_CF, &ehci_regs->configured_flag);
586 + /* Wait until the controller is no longer halted */
589 + status = readl(&ehci_regs->status);
590 + } while ((status & STS_HALT) && (--loop > 0));
593 + dbgp_printk("ehci can be started\n");
596 + dbgp_printk("ehci started\n");
598 + /* Wait for a device to show up in the debug port */
599 + ret = ehci_wait_for_port(debug_port);
601 + dbgp_printk("No device found in debug port\n");
602 + goto next_debug_port;
604 + dbgp_printk("ehci wait for port done\n");
606 + /* Enable the debug port */
607 + ctrl = readl(&ehci_debug->control);
608 + ctrl |= DBGP_CLAIM;
609 + writel(ctrl, &ehci_debug->control);
610 + ctrl = readl(&ehci_debug->control);
611 + if ((ctrl & DBGP_CLAIM) != DBGP_CLAIM) {
612 + dbgp_printk("No device in debug port\n");
613 + writel(ctrl & ~DBGP_CLAIM, &ehci_debug->control);
616 + dbgp_printk("debug ported enabled\n");
618 + /* Completely transfer the debug device to the debug controller */
619 + portsc = readl(&ehci_regs->port_status[debug_port - 1]);
620 + portsc &= ~PORT_PE;
621 + writel(portsc, &ehci_regs->port_status[debug_port - 1]);
625 + /* Find the debug device and make it device number 127 */
626 + for (devnum = 0; devnum <= 127; devnum++) {
627 + ret = dbgp_control_msg(devnum,
628 + USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
629 + USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0,
630 + &dbgp_desc, sizeof(dbgp_desc));
634 + if (devnum > 127) {
635 + dbgp_printk("Could not find attached debug device\n");
639 + dbgp_printk("Attached device is not a debug device\n");
642 + dbgp_endpoint_out = dbgp_desc.bDebugOutEndpoint;
644 + /* Move the device to 127 if it isn't already there */
645 + if (devnum != USB_DEBUG_DEVNUM) {
646 + ret = dbgp_control_msg(devnum,
647 + USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
648 + USB_REQ_SET_ADDRESS, USB_DEBUG_DEVNUM, 0, NULL, 0);
650 + dbgp_printk("Could not move attached device to %d\n",
654 + devnum = USB_DEBUG_DEVNUM;
655 + dbgp_printk("debug device renamed to 127\n");
658 + /* Enable the debug interface */
659 + ret = dbgp_control_msg(USB_DEBUG_DEVNUM,
660 + USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
661 + USB_REQ_SET_FEATURE, USB_DEVICE_DEBUG_MODE, 0, NULL, 0);
663 + dbgp_printk(" Could not enable the debug device\n");
666 + dbgp_printk("debug interface enabled\n");
668 + /* Perform a small write to get the even/odd data state in sync
670 + ret = dbgp_bulk_write(USB_DEBUG_DEVNUM, dbgp_endpoint_out, " ", 1);
672 + dbgp_printk("dbgp_bulk_write failed: %d\n", ret);
675 + dbgp_printk("small write doned\n");
679 + /* Things didn't work so remove my claim */
680 + ctrl = readl(&ehci_debug->control);
681 + ctrl &= ~(DBGP_CLAIM | DBGP_OUT);
682 + writel(ctrl, &ehci_debug->control);
686 + port_map_tried |= (1<<(debug_port - 1));
687 + new_debug_port = ((debug_port-1+1)%n_ports) + 1;
688 + if (port_map_tried != ((1<<n_ports) - 1)) {
689 + set_debug_port(new_debug_port);
690 + goto try_next_port;
693 + set_debug_port(new_debug_port);
694 + goto try_next_time;
700 +static int __init early_dbgp_init(char *s)
702 + u32 debug_port, bar, offset;
703 + u32 bus, slot, func, cap;
704 + void __iomem *ehci_bar;
711 + if (!early_pci_allowed())
716 + dbgp_num = simple_strtoul(s, &e, 10);
717 + dbgp_printk("dbgp_num: %d\n", dbgp_num);
719 + cap = find_dbgp(dbgp_num, &bus, &slot, &func);
723 + dbgp_printk("Found EHCI debug port on %02x:%02x.%1x\n", bus, slot,
726 + debug_port = read_pci_config(bus, slot, func, cap);
727 + bar = (debug_port >> 29) & 0x7;
728 + bar = (bar * 4) + 0xc;
729 + offset = (debug_port >> 16) & 0xfff;
730 + dbgp_printk("bar: %02x offset: %03x\n", bar, offset);
731 + if (bar != PCI_BASE_ADDRESS_0) {
732 + dbgp_printk("only debug ports on bar 1 handled.\n");
737 + bar_val = read_pci_config(bus, slot, func, PCI_BASE_ADDRESS_0);
738 + dbgp_printk("bar_val: %02x offset: %03x\n", bar_val, offset);
739 + if (bar_val & ~PCI_BASE_ADDRESS_MEM_MASK) {
740 + dbgp_printk("only simple 32bit mmio bars supported\n");
745 + /* double check if the mem space is enabled */
746 + byte = read_pci_config_byte(bus, slot, func, 0x04);
747 + if (!(byte & 0x2)) {
749 + write_pci_config_byte(bus, slot, func, 0x04, byte);
750 + dbgp_printk("mmio for ehci enabled\n");
754 + * FIXME I don't have the bar size so just guess PAGE_SIZE is more
755 + * than enough. 1K is the biggest I have seen.
757 + set_fixmap_nocache(FIX_DBGP_BASE, bar_val & PAGE_MASK);
758 + ehci_bar = (void __iomem *)__fix_to_virt(FIX_DBGP_BASE);
759 + ehci_bar += bar_val & ~PAGE_MASK;
760 + dbgp_printk("ehci_bar: %p\n", ehci_bar);
762 + ehci_caps = ehci_bar;
763 + ehci_regs = ehci_bar + HC_LENGTH(readl(&ehci_caps->hc_capbase));
764 + ehci_debug = ehci_bar + offset;
765 + ehci_dev.bus = bus;
766 + ehci_dev.slot = slot;
767 + ehci_dev.func = func;
769 + detect_set_debug_port();
771 + ret = ehci_setup();
773 + dbgp_printk("ehci_setup failed\n");
782 +static void early_dbgp_write(struct console *con, const char *str, u32 n)
790 + if (chunk > DBGP_MAX_PACKET)
791 + chunk = DBGP_MAX_PACKET;
792 + ret = dbgp_bulk_write(USB_DEBUG_DEVNUM,
793 + dbgp_endpoint_out, str, chunk);
799 +static struct console early_dbgp_console = {
800 + .name = "earlydbg",
801 + .write = early_dbgp_write,
802 + .flags = CON_PRINTBUFFER,
807 /* Console interface to a host file on AMD's SimNow! */
809 static int simnow_fd;
810 @@ -165,6 +889,7 @@ enum {
811 static noinline long simnow(long cmd, long a, long b, long c)
815 asm volatile("cpuid" :
817 "b" (a), "c" (b), "d" (c), "0" (MAGIC1), "D" (cmd + MAGIC2));
818 @@ -174,6 +899,7 @@ static noinline long simnow(long cmd, lo
819 static void __init simnow_init(char *str)
826 @@ -208,10 +934,11 @@ asmlinkage void early_printk(const char
830 -static int __initdata keep_early;
832 static int __init setup_early_printk(char *buf)
839 @@ -219,8 +946,7 @@ static int __init setup_early_printk(cha
841 early_console_initialized = 1;
843 - if (strstr(buf, "keep"))
845 + keep_early = (strstr(buf, "keep") != NULL);
847 if (!strncmp(buf, "serial", 6)) {
848 early_serial_init(buf + 6);
849 @@ -238,6 +964,17 @@ static int __init setup_early_printk(cha
850 simnow_init(buf + 6);
851 early_console = &simnow_console;
853 +#ifdef CONFIG_EARLY_PRINTK_DBGP
854 + } else if (!strncmp(buf, "dbgp", 4)) {
855 + if (early_dbgp_init(buf+4) < 0)
857 + early_console = &early_dbgp_console;
859 + * usb subsys will reset ehci controller, so don't keep
860 + * that early console
864 #ifdef CONFIG_HVC_XEN
865 } else if (!strncmp(buf, "xen", 3)) {
866 early_console = &xenboot_console;
867 @@ -251,4 +988,23 @@ static int __init setup_early_printk(cha
868 register_console(early_console);
872 +void __init enable_debug_console(char *buf)
875 + struct console *old_early_console = NULL;
877 + if (early_console_initialized && early_console) {
878 + old_early_console = early_console;
879 + unregister_console(early_console);
880 + early_console_initialized = 0;
883 + setup_early_printk(buf);
885 + if (early_console == old_early_console && old_early_console)
886 + register_console(old_early_console);
890 early_param("earlyprintk", setup_early_printk);
891 --- a/Documentation/kernel-parameters.txt
892 +++ b/Documentation/kernel-parameters.txt
893 @@ -661,11 +661,12 @@ and is between 256 and 4096 characters.
894 earlyprintk= [X86-32,X86-64,SH,BLACKFIN]
896 earlyprintk=serial[,ttySn[,baudrate]]
899 Append ",keep" to not disable it when the real console
902 - Only vga or serial at a time, not both.
903 + Only vga or serial or usb debug port at a time.
905 Currently only ttyS0 and ttyS1 are supported.