Commit fab5ef07 authored by Olaf Hering's avatar Olaf Hering Committed by Linus Torvalds

[PATCH] ppc32: serial console autodetection

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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 7f0fdc5d
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/root_dev.h> #include <linux/root_dev.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/console.h>
#include <asm/residual.h> #include <asm/residual.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -473,6 +474,60 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5, ...@@ -473,6 +474,60 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
break; 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 */ #endif /* CONFIG_PPC_MULTIPLATFORM */
struct bi_record *find_bootinfo(void) struct bi_record *find_bootinfo(void)
......
...@@ -118,7 +118,7 @@ ihandle prom_stdout __initdata = 0; ...@@ -118,7 +118,7 @@ ihandle prom_stdout __initdata = 0;
char *prom_display_paths[FB_MAX] __initdata = { 0, }; char *prom_display_paths[FB_MAX] __initdata = { 0, };
phandle prom_display_nodes[FB_MAX] __initdata; phandle prom_display_nodes[FB_MAX] __initdata;
unsigned int prom_num_displays __initdata = 0; 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; static ihandle prom_disp_node __initdata = 0;
unsigned int rtas_data; /* physical pointer */ unsigned int rtas_data; /* physical pointer */
...@@ -880,6 +880,11 @@ prom_init(int r3, int r4, prom_entry pp) ...@@ -880,6 +880,11 @@ prom_init(int r3, int r4, prom_entry pp)
for (i = 0; i < prom_num_displays; ++i) for (i = 0; i < prom_num_displays; ++i)
prom_display_paths[i] = PTRUNRELOC(prom_display_paths[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("returning 0x");
prom_print_hex(phys); prom_print_hex(phys);
prom_print("from prom_init\n"); prom_print("from prom_init\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment