Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753002AbdDJJrV (ORCPT ); Mon, 10 Apr 2017 05:47:21 -0400 Received: from mail1.bemta12.messagelabs.com ([216.82.251.6]:54602 "EHLO mail1.bemta12.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751134AbdDJJrS (ORCPT ); Mon, 10 Apr 2017 05:47:18 -0400 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJKsWRWlGSWpSXmKPExsVy+LrFKt1FIa8 jDJ4v57Ro3lRs0bx4PZvF0ruf2Cw+/97FarHp8TVWi8u75rBZnFncy25x+zKvxY+H05ksjl36 x2jxf88OdouDH56wWvxt/sFk0fJ0BqPFoa2PWCz23vvM6CDgsWbeGkaPluYeNo/+dZ9ZPf4d7 mfyWPFnPZvHplWdbB77565h99i8pN7jzelT7B4npn9n8Tiz4AhQ6HS1x5b9nxk9Pm+SC+CLYs 3MS8qvSGDN6JhyiKVggkTFrXfODYxvRLoYuTiEBJYxSlyfu5Oli5GTg03AROLm/XNgtrCAn8S x5RdZQYpEBLoYJTb1tbOAOMwCU1gkVj1fzNTFyMHBK+As8XJLMUgDi4CqxJb571lBbFGBBImL f6aA2bwCghInZz4BG8osoC/RtHUOM4QtL7H9LYQtJKAt8X7jYrB6CQEFiamTW5knMPLOQtI+C 0n7LCTtCxiZVzFqFKcWlaUW6ZoY6SUVZaZnlOQmZuboGhoa6eWmFhcnpqfmJCYV6yXn525iBE ZZPQMD4w7GiwujDzFKcjApifKmW76OEOJLyk+pzEgszogvKs1JLT7EKMPBoSTBey4IKCdYlJq eWpGWmQOMd5i0BAePkghvNUiat7ggMbc4Mx0idYpRUUqcNyQYKCEAksgozYNrg6WYS4yyUsK8 jAwMDEI8BalFuZklqPKvGMU5GJWEeXtBpvBk5pXATX8FtJgJaPGZXS9BFpckIqSkGhgn3v6j9 f6QecbfPDlTay7mqM6gk+Il64/Mfv3sX05Ir3Bz2o7rz6w3N96J5BBbvIL9oeeMpat6O40Ltj r5f+xm4w1+8NW/3kTEe7VBpM9BgfUn+NZdOW0YKNp26Z3F5qXz/uhXPyp1neEZKzPh40y/MNW CdesfcVX+//pf5qR9R/GnlEt3alOVWIozEg21mIuKEwHUP17cLAMAAA== X-Env-Sender: Marc_Gonzalez@sigmadesigns.com X-Msg-Ref: server-13.tower-219.messagelabs.com!1491817632!154559287!1 X-Originating-IP: [195.215.56.170] X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked From: Marc Gonzalez Subject: [PATCH v2] serial: 8250_early: Add earlycon support for Palmchip UART To: linux-serial , Peter Hurley , Greg Kroah-Hartman CC: Russell King , Andreas Farber , Jean Delvare , Rob Herring , Mans Rullgard , Jiri Slaby , Masahiro Yamada , Vineet Gupta , Scott Wood , Robin Murphy , Thibaud Cornic , Mason , Linux ARM , LKML Message-ID: <7a016ff6-08fc-2811-92e0-7c4603fa8586@sigmadesigns.com> Date: Mon, 10 Apr 2017 11:47:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0 SeaMonkey/2.48 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit X-Originating-IP: [172.27.0.114] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3088 Lines: 93 Define an OF early console for Palmchip UART, which can be enabled by passing "earlycon" on the boot command line. Signed-off-by: Marc Gonzalez --- drivers/tty/serial/8250/8250_early.c | 24 ++++++++++++++++++++++++ drivers/tty/serial/8250/8250_port.c | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c index 85a12f032402..82fc48eca1df 100644 --- a/drivers/tty/serial/8250/8250_early.c +++ b/drivers/tty/serial/8250/8250_early.c @@ -39,6 +39,7 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offset) { + int reg_offset = offset; offset <<= port->regshift; switch (port->iotype) { @@ -52,6 +53,8 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offse return ioread32be(port->membase + offset); case UPIO_PORT: return inb(port->iobase + offset); + case UPIO_AU: + return port->serial_in(port, reg_offset); default: return 0; } @@ -59,6 +62,7 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offse static void __init serial8250_early_out(struct uart_port *port, int offset, int value) { + int reg_offset = offset; offset <<= port->regshift; switch (port->iotype) { @@ -77,6 +81,9 @@ static void __init serial8250_early_out(struct uart_port *port, int offset, int case UPIO_PORT: outb(value, port->iobase + offset); break; + case UPIO_AU: + port->serial_out(port, reg_offset, value); + break; } } @@ -172,3 +179,20 @@ OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup); OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup); #endif + +#ifdef CONFIG_SERIAL_8250_RT288X + +unsigned int au_serial_in(struct uart_port *p, int offset); +void au_serial_out(struct uart_port *p, int offset, int value); + +static int __init early_au_setup(struct earlycon_device *dev, const char *opt) +{ + dev->port.serial_in = au_serial_in; + dev->port.serial_out = au_serial_out; + dev->port.iotype = UPIO_AU; + dev->con->write = early_serial8250_write; + return 0; +} +OF_EARLYCON_DECLARE(palmchip, "ralink,rt2880-uart", early_au_setup); + +#endif diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 080d5a59d0a7..1f08d22d1a80 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -313,7 +313,7 @@ static const s8 au_io_out_map[8] = { -1, /* UART_SCR (unmapped) */ }; -static unsigned int au_serial_in(struct uart_port *p, int offset) +unsigned int au_serial_in(struct uart_port *p, int offset) { if (offset >= ARRAY_SIZE(au_io_in_map)) return UINT_MAX; @@ -323,7 +323,7 @@ static unsigned int au_serial_in(struct uart_port *p, int offset) return __raw_readl(p->membase + (offset << p->regshift)); } -static void au_serial_out(struct uart_port *p, int offset, int value) +void au_serial_out(struct uart_port *p, int offset, int value) { if (offset >= ARRAY_SIZE(au_io_out_map)) return; -- 2.11.0