1 Subject: [PATCH] autodetect serial console on efika
2 From: Olaf Hering <olh@suse.de>
4 Efika boards have to be booted with console=ttyPSC0 unless there is a
5 graphics card plugged in. Detect if the firmware stdout is the serial
9 arch/powerpc/platforms/52xx/efika.c | 50 ++++++++++++++++++++++++++++++++++++
10 1 file changed, 50 insertions(+)
12 --- a/arch/powerpc/platforms/52xx/efika.c
13 +++ b/arch/powerpc/platforms/52xx/efika.c
15 #include <linux/utsrelease.h>
16 #include <linux/pci.h>
18 +#include <linux/console.h>
21 #include <asm/machdep.h>
22 @@ -211,12 +212,61 @@ static int __init efika_probe(void)
27 + * Per default, input/output-device points to the keyboard/screen
28 + * If no card is installed, the built-in serial port is used as a fallback.
29 + * But unfortunately, the firmware does not connect /chosen/{stdin,stdout}
30 + * the the built-in serial node. Instead, a /failsafe node is created.
31 + * More advanced hardware configurations cant be detected,
32 + * boot with console=xyz123 to point the kernel to the correct device
34 +static void __init efika_init_early(void)
36 +#ifdef CONFIG_SERIAL_MPC52xx
37 + struct device_node *stdout_node;
38 + const char *property;
40 + if (strstr(cmd_line, "console="))
42 + /* find the boot console from /chosen/stdout */
45 + property = of_get_property(of_chosen, "linux,stdout-path", NULL);
48 + stdout_node = of_find_node_by_path(property);
51 + property = of_get_property(stdout_node, "device_type", NULL);
52 + if (property && strcmp(property, "serial") == 0) {
54 + * The 9pin connector is either /failsafe or /builtin/serial.
55 + * The optional graphics card has also type 'serial' in VGA mode.
57 + property = of_get_property(stdout_node, "name", NULL);
59 + if (strcmp(property, "failsafe") == 0)
60 + add_preferred_console("ttyPSC", 0, NULL);
62 + if (strcmp(property, "serial") == 0) {
63 + property = of_get_property(stdout_node, "model", NULL);
64 + if (property && strcmp(property, "mpc5200-serial") == 0)
65 + add_preferred_console("ttyPSC", 0, NULL);
70 + of_node_put(stdout_node);
76 .name = EFIKA_PLATFORM_NAME,
78 .setup_arch = efika_setup_arch,
79 .init = mpc52xx_declare_of_platform_devices,
80 + .init_early = efika_init_early,
81 .show_cpuinfo = efika_show_cpuinfo,
82 .init_IRQ = mpc52xx_init_irq,
83 .get_irq = mpc52xx_get_irq,