From patchwork Mon Apr 10 09:47:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 9672253 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0657360244 for ; Mon, 10 Apr 2017 09:47:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB5B227816 for ; Mon, 10 Apr 2017 09:47:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF98727D0C; Mon, 10 Apr 2017 09:47:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 95E4B27816 for ; Mon, 10 Apr 2017 09:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Date:Message-ID:To:Subject :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=TEPJxTTI6Lbp9JsFOSKNBZ9PzU+jw7TGMrs+fbi34rU=; b=qkbi7fzYeGocJa 6gl2gu/AjEVimbW9XODEZLGLTtVFRviPB7/J1NNuBh4Hzc88UMWQquJ98MMNOWMnqqeIQebSbWBKV nk6cFirCDL4TAVjswkVcnFd1+86kyRcT6SvXRknASZ/CwEBj2jqbGpogYEA6HJAl+FHcMU2jueZIA LTvbnAjBBRNF12VZSiBlDmtClmqiiyPiDSC+kpnK48/Ay3sSfwGEsEI8faBbhvmi56oL8r8AaAUTx FscXnNwvssPtDjZIsyyZpt/Biuxt6NqzbTaCs901iicdJXyix05j9UIdO62a4c5NrSl390gakDbDv GoNMXjhvH4VOlUqCmRxw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cxVvB-0007br-Qt; Mon, 10 Apr 2017 09:47:41 +0000 Received: from mail1.bemta12.messagelabs.com ([216.82.251.6]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cxVv7-0007PD-Am for linux-arm-kernel@lists.infradead.org; Mon, 10 Apr 2017 09:47:39 +0000 Received: from [216.82.249.212] by server-6.bemta-12.messagelabs.com id 8E/2D-05692-2A45BE85; Mon, 10 Apr 2017 09:47:14 +0000 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 Received: (qmail 14908 invoked from network); 10 Apr 2017 09:47:13 -0000 Received: from 195-215-56-170-static.dk.customer.tdc.net (HELO CPH-EX1.SDESIGNS.COM) (195.215.56.170) by server-13.tower-219.messagelabs.com with AES128-SHA encrypted SMTP; 10 Apr 2017 09:47:13 -0000 Received: from [172.27.0.114] (172.27.0.114) by CPH-EX1.sdesigns.com (192.168.10.36) with Microsoft SMTP Server (TLS) id 14.3.294.0; Mon, 10 Apr 2017 11:47:10 +0200 From: Marc Gonzalez Subject: [PATCH v2] serial: 8250_early: Add earlycon support for Palmchip UART To: linux-serial , Peter Hurley , Greg Kroah-Hartman 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 X-Originating-IP: [172.27.0.114] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170410_024737_394758_6452BAC2 X-CRM114-Status: GOOD ( 14.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Herring , Mans Rullgard , Russell King , Mason , Vineet Gupta , Thibaud Cornic , Robin Murphy , LKML , Masahiro Yamada , Linux ARM , Scott Wood , Jiri Slaby , Andreas Farber , Jean Delvare Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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;