]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ppc32: serial console autodetection
authorOlaf Hering <olh@suse.de>
Sun, 11 Jul 2004 02:28:39 +0000 (19:28 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sun, 11 Jul 2004 02:28:39 +0000 (19:28 -0700)
We have something like this in our kernel since many months.  It sets the
console device to what OF uses.  ppc64 does the same, and it works ok.
serial is found on CHRP, ch-a is used on all powermacs.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/ppc/kernel/setup.c
arch/ppc/syslib/prom_init.c

index f95465b557dfe3452990a50f1ec1b6d456209fa7..e2f75033c5b09246549ae63925d75164ae629047 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/cpu.h>
+#include <linux/console.h>
 
 #include <asm/residual.h>
 #include <asm/io.h>
@@ -473,6 +474,60 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
                break;
        }
 }
+
+#ifdef CONFIG_SERIAL_CORE_CONSOLE
+extern char *of_stdout_device;
+
+static int __init set_preferred_console(void)
+{
+       struct device_node *prom_stdout;
+       char *name;
+       int offset;
+
+       /* The user has requested a console so this is already set up. */
+       if (strstr(saved_command_line, "console="))
+               return -EBUSY;
+
+       prom_stdout = find_path_device(of_stdout_device);
+       if (!prom_stdout)
+               return -ENODEV;
+
+       name = (char *)get_property(prom_stdout, "name", NULL);
+       if (!name)
+               return -ENODEV;
+
+       if (strcmp(name, "serial") == 0) {
+               int i;
+               u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i);
+               if (i > 8) {
+                       switch (reg[1]) {
+                               case 0x3f8:
+                                       offset = 0;
+                                       break;
+                               case 0x2f8:
+                                       offset = 1;
+                                       break;
+                               case 0x898:
+                                       offset = 2;
+                                       break;
+                               case 0x890:
+                                       offset = 3;
+                                       break;
+                               default:
+                                       /* We dont recognise the serial port */
+                                       return -ENODEV;
+                       }
+               }
+       } else if (strcmp(name, "ch-a") == 0)
+               offset = 0;
+       else if (strcmp(name, "ch-b") == 0)
+               offset = 1;
+       else
+               return -ENODEV;
+       return add_preferred_console("ttyS", offset, NULL);
+}
+console_initcall(set_preferred_console);
+#endif /* CONFIG_SERIAL_CORE_CONSOLE */
 #endif /* CONFIG_PPC_MULTIPLATFORM */
 
 struct bi_record *find_bootinfo(void)
index 932608875eccae3d92697f07d6ad90fbdc37fe76..79888ad60310291ca286bb1c2bb06eb46eb9b358 100644 (file)
@@ -118,7 +118,7 @@ ihandle prom_stdout __initdata = 0;
 char *prom_display_paths[FB_MAX] __initdata = { 0, };
 phandle prom_display_nodes[FB_MAX] __initdata;
 unsigned int prom_num_displays __initdata = 0;
-static char *of_stdout_device __initdata = 0;
+char *of_stdout_device __initdata = 0;
 static ihandle prom_disp_node __initdata = 0;
 
 unsigned int rtas_data;   /* physical pointer */
@@ -880,6 +880,11 @@ prom_init(int r3, int r4, prom_entry pp)
        for (i = 0; i < prom_num_displays; ++i)
                prom_display_paths[i] = PTRUNRELOC(prom_display_paths[i]);
 
+#ifdef CONFIG_SERIAL_CORE_CONSOLE
+       /* Relocate the of stdout for console autodetection */
+       of_stdout_device = PTRUNRELOC(of_stdout_device);
+#endif
+
        prom_print("returning 0x");
        prom_print_hex(phys);
        prom_print("from prom_init\n");