From patchwork Mon Dec 14 10:24:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 67254 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nBEAcSu3000323 for ; Mon, 14 Dec 2009 10:38:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756680AbZLNKiS (ORCPT ); Mon, 14 Dec 2009 05:38:18 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756582AbZLNKiP (ORCPT ); Mon, 14 Dec 2009 05:38:15 -0500 Received: from mail-yw0-f182.google.com ([209.85.211.182]:32976 "EHLO mail-yw0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756565AbZLNKiO (ORCPT ); Mon, 14 Dec 2009 05:38:14 -0500 Received: by ywh12 with SMTP id 12so2944541ywh.21 for ; Mon, 14 Dec 2009 02:38:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :subject; bh=6VvfFBBPeDi3izlXbi5NkQvlJ6oriWTB9spO4Bgk0bc=; b=u1OZJTYbV2tcC7O2ZgFDMPC9jy6kttC0l32NhKD4hb0DAmhnLcJJybdRmSkhSwud++ O+JuzAOzgs2XZ50QLRjQVYYWsO5mPGVc+Ja7IqE1YvuR0D4H1t9yw5vXSbzxVwFfKcjC O48KL2cXo60VUM9M94Wyeu1wId4lwjR86yy8g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=iOFJAvwXZWWK8wMd9MBnjSl/pxrKMAvbaJL+RZkKjzZ/zr3vJcV0AYxoMOr4TD9IrY mtxKlq8fpVvjW52wcQrVaLH9zWT6XEmMiU7P0/xcQgtC1yfPsoxP+cHtA51aNLCbGYw5 ZkcbElbpOZf8PmBWFPdq1GRMhh7cL+2VzbtCU= Received: by 10.90.58.20 with SMTP id g20mr956129aga.36.1260786627717; Mon, 14 Dec 2009 02:30:27 -0800 (PST) Received: from rxone.opensource.se (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id 15sm2033008gxk.0.2009.12.14.02.30.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 14 Dec 2009 02:30:27 -0800 (PST) From: Magnus Damm To: linux-sh@vger.kernel.org Cc: Magnus Damm , lethal@linux-sh.org Date: Mon, 14 Dec 2009 19:24:42 +0900 Message-Id: <20091214102442.13038.43809.sendpatchset@rxone.opensource.se> Subject: [PATCH] sh-sci: Extend sh-sci driver with early console V2 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org --- 0001/arch/sh/kernel/early_printk.c +++ work/arch/sh/kernel/early_printk.c 2009-12-14 15:57:25.000000000 +0900 @@ -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 * earlyprintk= parsing to give priority. */ -static struct console *early_console = -#ifdef CONFIG_SH_STANDARD_BIOS - &bios_console -#elif defined(CONFIG_EARLY_SCIF_CONSOLE) - &scif_console -#else - NULL -#endif - ; +static struct console *early_console; static int __init setup_early_printk(char *buf) { --- 0001/arch/sh/kernel/setup.c +++ work/arch/sh/kernel/setup.c 2009-12-14 15:58:45.000000000 +0900 @@ -423,6 +423,9 @@ void __init setup_arch(char **cmdline_p) plat_early_device_setup(); + /* Let earlyprintk output early console messages */ + early_platform_driver_probe("earlyprintk", 1, 1); + sh_mv_setup(); /* --- 0001/drivers/serial/sh-sci.c +++ work/drivers/serial/sh-sci.c 2009-12-14 15:57:25.000000000 +0900 @@ -1043,10 +1043,14 @@ static void __devinit sci_init_single(st sci_port->port.iotype = UPIO_MEM; sci_port->port.line = index; sci_port->port.fifosize = 1; - sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL; - sci_port->dclk = clk_get(&dev->dev, "peripheral_clk"); - sci_port->enable = sci_clk_enable; - sci_port->disable = sci_clk_disable; + + if (dev) { + sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL; + sci_port->dclk = clk_get(&dev->dev, "peripheral_clk"); + sci_port->enable = sci_clk_enable; + 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.function = sci_break_timer; @@ -1057,7 +1061,6 @@ static void __devinit sci_init_single(st sci_port->port.irq = p->irqs[SCIx_TXI_IRQ]; sci_port->port.flags = p->flags; - sci_port->port.dev = &dev->dev; sci_port->type = sci_port->port.type = p->type; memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs)); @@ -1101,7 +1104,7 @@ static void serial_console_write(struct 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 uart_port *port; @@ -1119,9 +1122,14 @@ static int __init serial_console_setup(s if (co->index >= SCI_NPORTS) co->index = 0; - sci_port = &sci_ports[co->index]; - port = &sci_port->port; - co->data = port; + if (co->data) { + port = co->data; + sci_port = to_sci_port(port); + } else { + sci_port = &sci_ports[co->index]; + port = &sci_port->port; + co->data = port; + } /* * Also need to check port->type, we don't actually have any @@ -1165,6 +1173,15 @@ static int __init sci_console_init(void) return 0; } 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 */ #if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) @@ -1250,6 +1267,21 @@ static int __devinit sci_probe(struct pl struct sh_sci_priv *priv; 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); if (!priv) return -ENOMEM; @@ -1349,6 +1381,10 @@ static void __exit sci_exit(void) 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_exit(sci_exit);