Commit 7b6fd3bf authored by Magnus Damm's avatar Magnus Damm Committed by Paul Mundt

sh-sci: Extend sh-sci driver with early console V2

This is V2 of early serial console support for the sh-sci
driver. The early serial console is using early platform
devices and "earlyprintk". To use this feature the early
platform devices must be broken out to one device per port
and the desired port should be selected on the kernel command
line like: "earlyprintk=sh-sci.N[,baudrate][,keep]"
Signed-off-by: default avatarMagnus Damm <damm@opensource.se>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 0eb37e26
...@@ -191,15 +191,7 @@ static void scif_sercon_init(char *s) ...@@ -191,15 +191,7 @@ static void scif_sercon_init(char *s)
* Setup a default console, if more than one is compiled in, rely on the * Setup a default console, if more than one is compiled in, rely on the
* earlyprintk= parsing to give priority. * earlyprintk= parsing to give priority.
*/ */
static struct console *early_console = static struct console *early_console;
#ifdef CONFIG_SH_STANDARD_BIOS
&bios_console
#elif defined(CONFIG_EARLY_SCIF_CONSOLE)
&scif_console
#else
NULL
#endif
;
static int __init setup_early_printk(char *buf) static int __init setup_early_printk(char *buf)
{ {
......
...@@ -423,6 +423,9 @@ void __init setup_arch(char **cmdline_p) ...@@ -423,6 +423,9 @@ void __init setup_arch(char **cmdline_p)
plat_early_device_setup(); plat_early_device_setup();
/* Let earlyprintk output early console messages */
early_platform_driver_probe("earlyprintk", 1, 1);
sh_mv_setup(); sh_mv_setup();
/* /*
......
...@@ -1043,10 +1043,14 @@ static void __devinit sci_init_single(struct platform_device *dev, ...@@ -1043,10 +1043,14 @@ static void __devinit sci_init_single(struct platform_device *dev,
sci_port->port.iotype = UPIO_MEM; sci_port->port.iotype = UPIO_MEM;
sci_port->port.line = index; sci_port->port.line = index;
sci_port->port.fifosize = 1; sci_port->port.fifosize = 1;
if (dev) {
sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL; sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL;
sci_port->dclk = clk_get(&dev->dev, "peripheral_clk"); sci_port->dclk = clk_get(&dev->dev, "peripheral_clk");
sci_port->enable = sci_clk_enable; sci_port->enable = sci_clk_enable;
sci_port->disable = sci_clk_disable; sci_port->disable = sci_clk_disable;
sci_port->port.dev = &dev->dev;
}
sci_port->break_timer.data = (unsigned long)sci_port; sci_port->break_timer.data = (unsigned long)sci_port;
sci_port->break_timer.function = sci_break_timer; sci_port->break_timer.function = sci_break_timer;
...@@ -1057,7 +1061,6 @@ static void __devinit sci_init_single(struct platform_device *dev, ...@@ -1057,7 +1061,6 @@ static void __devinit sci_init_single(struct platform_device *dev,
sci_port->port.irq = p->irqs[SCIx_TXI_IRQ]; sci_port->port.irq = p->irqs[SCIx_TXI_IRQ];
sci_port->port.flags = p->flags; sci_port->port.flags = p->flags;
sci_port->port.dev = &dev->dev;
sci_port->type = sci_port->port.type = p->type; sci_port->type = sci_port->port.type = p->type;
memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs)); memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs));
...@@ -1101,7 +1104,7 @@ static void serial_console_write(struct console *co, const char *s, ...@@ -1101,7 +1104,7 @@ static void serial_console_write(struct console *co, const char *s,
sci_port->disable(port); sci_port->disable(port);
} }
static int __init serial_console_setup(struct console *co, char *options) static int __devinit serial_console_setup(struct console *co, char *options)
{ {
struct sci_port *sci_port; struct sci_port *sci_port;
struct uart_port *port; struct uart_port *port;
...@@ -1119,9 +1122,14 @@ static int __init serial_console_setup(struct console *co, char *options) ...@@ -1119,9 +1122,14 @@ static int __init serial_console_setup(struct console *co, char *options)
if (co->index >= SCI_NPORTS) if (co->index >= SCI_NPORTS)
co->index = 0; co->index = 0;
if (co->data) {
port = co->data;
sci_port = to_sci_port(port);
} else {
sci_port = &sci_ports[co->index]; sci_port = &sci_ports[co->index];
port = &sci_port->port; port = &sci_port->port;
co->data = port; co->data = port;
}
/* /*
* Also need to check port->type, we don't actually have any * Also need to check port->type, we don't actually have any
...@@ -1165,6 +1173,15 @@ static int __init sci_console_init(void) ...@@ -1165,6 +1173,15 @@ static int __init sci_console_init(void)
return 0; return 0;
} }
console_initcall(sci_console_init); console_initcall(sci_console_init);
static struct sci_port early_serial_port;
static struct console early_serial_console = {
.name = "early_ttySC",
.write = serial_console_write,
.flags = CON_PRINTBUFFER,
};
static char early_serial_buf[32];
#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */ #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) #if defined(CONFIG_SERIAL_SH_SCI_CONSOLE)
...@@ -1250,6 +1267,21 @@ static int __devinit sci_probe(struct platform_device *dev) ...@@ -1250,6 +1267,21 @@ static int __devinit sci_probe(struct platform_device *dev)
struct sh_sci_priv *priv; struct sh_sci_priv *priv;
int i, ret = -EINVAL; int i, ret = -EINVAL;
#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
if (is_early_platform_device(dev)) {
if (dev->id == -1)
return -ENOTSUPP;
early_serial_console.index = dev->id;
early_serial_console.data = &early_serial_port.port;
sci_init_single(NULL, &early_serial_port, dev->id, p);
serial_console_setup(&early_serial_console, early_serial_buf);
if (!strstr(early_serial_buf, "keep"))
early_serial_console.flags |= CON_BOOT;
register_console(&early_serial_console);
return 0;
}
#endif
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
...@@ -1349,6 +1381,10 @@ static void __exit sci_exit(void) ...@@ -1349,6 +1381,10 @@ static void __exit sci_exit(void)
uart_unregister_driver(&sci_uart_driver); uart_unregister_driver(&sci_uart_driver);
} }
#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
early_platform_init_buffer("earlyprintk", &sci_driver,
early_serial_buf, ARRAY_SIZE(early_serial_buf));
#endif
module_init(sci_init); module_init(sci_init);
module_exit(sci_exit); module_exit(sci_exit);
......
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