From patchwork Mon Aug 6 14:07:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10557217 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5305896FA for ; Mon, 6 Aug 2018 14:08:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EBDA295A5 for ; Mon, 6 Aug 2018 14:08:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32C16295A7; Mon, 6 Aug 2018 14:08:08 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB737295B4 for ; Mon, 6 Aug 2018 14:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727112AbeHFQRV (ORCPT ); Mon, 6 Aug 2018 12:17:21 -0400 Received: from xavier.telenet-ops.be ([195.130.132.52]:34890 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728311AbeHFQRV (ORCPT ); Mon, 6 Aug 2018 12:17:21 -0400 Received: from ramsan.of.borg ([84.194.111.163]) by xavier.telenet-ops.be with bizsmtp id Kq821y00C3XaVaC01q82Vc; Mon, 06 Aug 2018 16:08:03 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1fmgB0-0000Ne-2L; Mon, 06 Aug 2018 16:08:02 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1fmgB0-0006HT-1A; Mon, 06 Aug 2018 16:08:02 +0200 From: Geert Uytterhoeven To: Chris Brandt , Laurent Pinchart , Ulrich Hecht , Yoshinori Sato Cc: Greg Kroah-Hartman , Jiri Slaby , linux-renesas-soc@vger.kernel.org, linux-sh@vger.kernel.org, linux-serial@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH/RFC 1/4] sh-sci: Use a separate sci_port for earlycon Date: Mon, 6 Aug 2018 16:07:52 +0200 Message-Id: <20180806140755.24087-2-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180806140755.24087-1-geert+renesas@glider.be> References: <20180806140755.24087-1-geert+renesas@glider.be> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yoshinori Sato The first sh-sci port and earlycon use the same sci_port. Hence after the initialization of the first port, earlycon may die. Fis this by assigning a separate sci_port for earlycon. Signed-off-by: Yoshinori Sato [geert: Rebased, reworded] Signed-off-by: Geert Uytterhoeven --- I still don't fully understand why Sato-san needed this for H8/300, and we never needed it on Renesas ARM SoCs before. Also, I don't like the early index. --- drivers/tty/serial/sh-sci.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index ac4424bf6b136cc4..cf3195bed0246a3d 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -164,6 +164,8 @@ struct sci_port { #define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS static struct sci_port sci_ports[SCI_NPORTS]; +#define EARLY_INDEX 256 +static struct sci_port earlycon_port; static unsigned long sci_ports_in_use; static struct uart_driver sci_uart_driver; @@ -2941,12 +2943,16 @@ static void serial_console_putchar(struct uart_port *port, int ch) static void serial_console_write(struct console *co, const char *s, unsigned count) { - struct sci_port *sci_port = &sci_ports[co->index]; - struct uart_port *port = &sci_port->port; unsigned short bits, ctrl, ctrl_temp; + struct sci_port *sci_port; + struct uart_port *port; unsigned long flags; int locked = 1; + sci_port = (co->index != EARLY_INDEX) ? + &sci_ports[co->index] : &earlycon_port; + port = &sci_port->port; + #if defined(SUPPORT_SYSRQ) if (port->sysrq) locked = 0; @@ -3367,12 +3373,13 @@ static int __init early_console_setup(struct earlycon_device *device, device->port.serial_in = sci_serial_in; device->port.serial_out = sci_serial_out; device->port.type = type; - memcpy(&sci_ports[0].port, &device->port, sizeof(struct uart_port)); + device->con->index = EARLY_INDEX; + memcpy(&earlycon_port.port, &device->port, sizeof(struct uart_port)); port_cfg.type = type; - sci_ports[0].cfg = &port_cfg; - sci_ports[0].params = sci_probe_regmap(&port_cfg); - port_cfg.scscr = sci_serial_in(&sci_ports[0].port, SCSCR); - sci_serial_out(&sci_ports[0].port, SCSCR, + earlycon_port.cfg = &port_cfg; + earlycon_port.params = sci_probe_regmap(&port_cfg); + port_cfg.scscr = sci_serial_in(&earlycon_port.port, SCSCR); + sci_serial_out(&earlycon_port.port, SCSCR, SCSCR_RE | SCSCR_TE | port_cfg.scscr); device->con->write = serial_console_write; From patchwork Mon Aug 6 14:07:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10557211 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9AC82157D for ; Mon, 6 Aug 2018 14:08:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ADA0295A8 for ; Mon, 6 Aug 2018 14:08:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F417295A9; Mon, 6 Aug 2018 14:08:07 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CFA0295A8 for ; Mon, 6 Aug 2018 14:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730195AbeHFQRW (ORCPT ); Mon, 6 Aug 2018 12:17:22 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:32784 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730072AbeHFQRV (ORCPT ); Mon, 6 Aug 2018 12:17:21 -0400 Received: from ramsan.of.borg ([84.194.111.163]) by albert.telenet-ops.be with bizsmtp id Kq821y0083XaVaC06q82ij; Mon, 06 Aug 2018 16:08:03 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1fmgB0-0000Ng-30; Mon, 06 Aug 2018 16:08:02 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1fmgB0-0006HW-1s; Mon, 06 Aug 2018 16:08:02 +0200 From: Geert Uytterhoeven To: Chris Brandt , Laurent Pinchart , Ulrich Hecht , Yoshinori Sato Cc: Greg Kroah-Hartman , Jiri Slaby , linux-renesas-soc@vger.kernel.org, linux-sh@vger.kernel.org, linux-serial@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH/RFC 2/4] sh-sci: Take into account regshift to fix earlycon breakage Date: Mon, 6 Aug 2018 16:07:53 +0200 Message-Id: <20180806140755.24087-3-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180806140755.24087-1-geert+renesas@glider.be> References: <20180806140755.24087-1-geert+renesas@glider.be> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With the compressed SCIF address range, the SCIF ports on most Renesas SoCs now use regshift 1. However, the earlycon setup code always assumes regshift zero, breaking earlycon on R-Car, RZ/A1, and RZ/G SoCs. Fix this by initializing regshift to 1 for the generic SCIF case, and adding a special entry for RZ/A2 SoCs that do need regshift 0. Signed-off-by: Geert Uytterhoeven Fixes: 2d4dd0da45401c7a ("serial: sh-sci: Allow for compressed SCIF address") --- Tested on R-Car Gen2 and Gen3. This depends on the previous patch. Else the kernel hangs when initializing SCIF0 (why??). --- drivers/tty/serial/sh-sci.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index cf3195bed0246a3d..caf4422d9e2e59e4 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3390,9 +3390,17 @@ static int __init sci_early_console_setup(struct earlycon_device *device, { return early_console_setup(device, PORT_SCI); } +static int __init rza2_early_console_setup(struct earlycon_device *device, + const char *opt) +{ + /* RZ/A2 uses the default regshift zero */ + return early_console_setup(device, PORT_SCIF); +} static int __init scif_early_console_setup(struct earlycon_device *device, const char *opt) { + /* Other plain SCIF variants */ + device->port.regshift = 1; return early_console_setup(device, PORT_SCIF); } static int __init scifa_early_console_setup(struct earlycon_device *device, @@ -3412,6 +3420,7 @@ static int __init hscif_early_console_setup(struct earlycon_device *device, } OF_EARLYCON_DECLARE(sci, "renesas,sci", sci_early_console_setup); +OF_EARLYCON_DECLARE(scif, "renesas,scif-r7s9210", rza2_early_console_setup); OF_EARLYCON_DECLARE(scif, "renesas,scif", scif_early_console_setup); OF_EARLYCON_DECLARE(scifa, "renesas,scifa", scifa_early_console_setup); OF_EARLYCON_DECLARE(scifb, "renesas,scifb", scifb_early_console_setup); From patchwork Mon Aug 6 14:07:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10557215 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CF9F90E3 for ; Mon, 6 Aug 2018 14:08:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19E93295A5 for ; Mon, 6 Aug 2018 14:08:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E21D295A8; Mon, 6 Aug 2018 14:08:08 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFDC2295A7 for ; Mon, 6 Aug 2018 14:08:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729818AbeHFQRW (ORCPT ); Mon, 6 Aug 2018 12:17:22 -0400 Received: from baptiste.telenet-ops.be ([195.130.132.51]:48200 "EHLO baptiste.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730055AbeHFQRV (ORCPT ); Mon, 6 Aug 2018 12:17:21 -0400 Received: from ramsan.of.borg ([84.194.111.163]) by baptiste.telenet-ops.be with bizsmtp id Kq821y0063XaVaC01q824F; Mon, 06 Aug 2018 16:08:03 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1fmgB0-0000Nk-3n; Mon, 06 Aug 2018 16:08:02 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1fmgB0-0006HZ-2V; Mon, 06 Aug 2018 16:08:02 +0200 From: Geert Uytterhoeven To: Chris Brandt , Laurent Pinchart , Ulrich Hecht , Yoshinori Sato Cc: Greg Kroah-Hartman , Jiri Slaby , linux-renesas-soc@vger.kernel.org, linux-sh@vger.kernel.org, linux-serial@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH/RFC 3/4] Revert "serial: sh-sci: Compute the regshift value for SCI ports" Date: Mon, 6 Aug 2018 16:07:54 +0200 Message-Id: <20180806140755.24087-4-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180806140755.24087-1-geert+renesas@glider.be> References: <20180806140755.24087-1-geert+renesas@glider.be> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This reverts commit dfc80387aefb78161f83732804c6d01c89c24595. Deriving the proper regshift value from the register block size is fragile, as it may have been rounded up. Furthermore we will need plat_sci_port.regshift again. Signed-off-by: Geert Uytterhoeven --- arch/sh/kernel/cpu/sh3/setup-sh770x.c | 1 + arch/sh/kernel/cpu/sh4/setup-sh7750.c | 3 ++- arch/sh/kernel/cpu/sh4/setup-sh7760.c | 10 ++-------- drivers/tty/serial/sh-sci.c | 8 +------- include/linux/serial_sci.h | 1 + 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/arch/sh/kernel/cpu/sh3/setup-sh770x.c b/arch/sh/kernel/cpu/sh3/setup-sh770x.c index 59a88611df55ac8f..592cd9ab30c4272f 100644 --- a/arch/sh/kernel/cpu/sh3/setup-sh770x.c +++ b/arch/sh/kernel/cpu/sh3/setup-sh770x.c @@ -111,6 +111,7 @@ static struct platform_device rtc_device = { static struct plat_sci_port scif0_platform_data = { .type = PORT_SCI, .ops = &sh770x_sci_port_ops, + .regshift = 1, }; static struct resource scif0_resources[] = { diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7750.c b/arch/sh/kernel/cpu/sh4/setup-sh7750.c index 57d30689204d03b9..d98a55416306baef 100644 --- a/arch/sh/kernel/cpu/sh4/setup-sh7750.c +++ b/arch/sh/kernel/cpu/sh4/setup-sh7750.c @@ -39,10 +39,11 @@ static struct platform_device rtc_device = { static struct plat_sci_port sci_platform_data = { .type = PORT_SCI, + .regshift = 2, }; static struct resource sci_resources[] = { - DEFINE_RES_MEM(0xffe00000, 0x20), + DEFINE_RES_MEM(0xffe00000, 0x100), DEFINE_RES_IRQ(evt2irq(0x4e0)), }; diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7760.c b/arch/sh/kernel/cpu/sh4/setup-sh7760.c index e51fe1734e1368e8..0c0cdfc69dcc3e33 100644 --- a/arch/sh/kernel/cpu/sh4/setup-sh7760.c +++ b/arch/sh/kernel/cpu/sh4/setup-sh7760.c @@ -200,18 +200,12 @@ static struct platform_device scif2_device = { }; static struct plat_sci_port scif3_platform_data = { - /* - * This is actually a SIM card module serial port, based on an SCI with - * additional registers. The sh-sci driver doesn't support the SIM port - * type, declare it as a SCI. Don't declare the additional registers in - * the memory resource or the driver will compute an incorrect regshift - * value. - */ .type = PORT_SCI, + .regshift = 2, }; static struct resource scif3_resources[] = { - DEFINE_RES_MEM(0xfe480000, 0x10), + DEFINE_RES_MEM(0xfe480000, 0x100), DEFINE_RES_IRQ(evt2irq(0xc00)), DEFINE_RES_IRQ(evt2irq(0xc20)), DEFINE_RES_IRQ(evt2irq(0xc40)), diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index caf4422d9e2e59e4..955c057dff6e8c78 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -2895,15 +2895,9 @@ static int sci_init_single(struct platform_device *dev, port->type = p->type; port->flags = UPF_FIXED_PORT | UPF_BOOT_AUTOCONF | p->flags; + port->regshift = p->regshift; port->fifosize = sci_port->params->fifosize; - if (port->type == PORT_SCI) { - if (sci_port->reg_size >= 0x20) - port->regshift = 2; - else - port->regshift = 1; - } - if (regtype == SCIx_SH4_SCIF_REGTYPE) if (sci_port->reg_size >= 0x20) port->regshift = 1; diff --git a/include/linux/serial_sci.h b/include/linux/serial_sci.h index c0e795d95477daea..eebb12fc473f49a2 100644 --- a/include/linux/serial_sci.h +++ b/include/linux/serial_sci.h @@ -57,6 +57,7 @@ struct plat_sci_port { /* * Platform overrides if necessary, defaults otherwise. */ + unsigned char regshift; unsigned char regtype; struct plat_sci_port_ops *ops; From patchwork Mon Aug 6 14:07:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10557203 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 646FD157D for ; Mon, 6 Aug 2018 14:08:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5225B295A7 for ; Mon, 6 Aug 2018 14:08:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46614295C9; Mon, 6 Aug 2018 14:08:06 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67B66295A8 for ; Mon, 6 Aug 2018 14:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728198AbeHFQRV (ORCPT ); Mon, 6 Aug 2018 12:17:21 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:60806 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729756AbeHFQRU (ORCPT ); Mon, 6 Aug 2018 12:17:20 -0400 Received: from ramsan.of.borg ([84.194.111.163]) by andre.telenet-ops.be with bizsmtp id Kq821y0073XaVaC01q82P1; Mon, 06 Aug 2018 16:08:03 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1fmgB0-0000Nt-5P; Mon, 06 Aug 2018 16:08:02 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1fmgB0-0006Hc-3A; Mon, 06 Aug 2018 16:08:02 +0200 From: Geert Uytterhoeven To: Chris Brandt , Laurent Pinchart , Ulrich Hecht , Yoshinori Sato Cc: Greg Kroah-Hartman , Jiri Slaby , linux-renesas-soc@vger.kernel.org, linux-sh@vger.kernel.org, linux-serial@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH/RFC 4/4] sh-sci: Derive regshift value from DT compatible value Date: Mon, 6 Aug 2018 16:07:55 +0200 Message-Id: <20180806140755.24087-5-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180806140755.24087-1-geert+renesas@glider.be> References: <20180806140755.24087-1-geert+renesas@glider.be> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Deriving the proper regshift value from the register block size is fragile (it may have been rounded up in DT, and the mapping granularity is usually PAGE_SIZE anyway), and turned out to be inappropriate for earlycon support (the size is not easily available). On DT systems, derive it from the compatible value instead. This requires adding an entry for RZ/A2 serial ports, which use an atypical regshift value. On non-DT systems the regshift value is still derived from the register block size, as before. Signed-off-by: Geert Uytterhoeven --- - Sato-san: I assume this fixes SCI on H8/300, too? Cfr. your patch "serial: sh-sci: byte allocated register support" (https://www.spinics.net/lists/linux-sh/msg53175.html). - Getting rid of the regshift setup for non-DT systems probably means we'll have to add ".regshift = 1" to each and every SH board file describing SCIF serial ports :-( Any other suggestions? --- drivers/tty/serial/sh-sci.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 955c057dff6e8c78..c4342e61b8db72c3 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -2898,9 +2898,10 @@ static int sci_init_single(struct platform_device *dev, port->regshift = p->regshift; port->fifosize = sci_port->params->fifosize; - if (regtype == SCIx_SH4_SCIF_REGTYPE) + if (!dev->dev.of_node && regtype == SCIx_SH4_SCIF_REGTYPE) { if (sci_port->reg_size >= 0x20) port->regshift = 1; + } /* * The UART port needs an IRQ value, so we peg this to the RX IRQ @@ -3100,43 +3101,49 @@ static int sci_remove(struct platform_device *dev) } -#define SCI_OF_DATA(type, regtype) (void *)((type) << 16 | (regtype)) +#define SCI_OF_DATA(type, regtype, regshift) \ + (void *)((type) << 16 | (regtype) << 8 | (regshift)) #define SCI_OF_TYPE(data) ((unsigned long)(data) >> 16) -#define SCI_OF_REGTYPE(data) ((unsigned long)(data) & 0xffff) +#define SCI_OF_REGTYPE(data) (((unsigned long)(data) >> 8) & 0xff) +#define SCI_OF_REGSHIFT(data) ((unsigned long)(data) & 0xff) static const struct of_device_id of_sci_match[] = { /* SoC-specific types */ { .compatible = "renesas,scif-r7s72100", - .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH2_SCIF_FIFODATA_REGTYPE), + .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH2_SCIF_FIFODATA_REGTYPE, + 0), + }, { + .compatible = "renesas,scif-r7s9210", + .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH4_SCIF_REGTYPE, 0), }, /* Family-specific types */ { .compatible = "renesas,rcar-gen1-scif", - .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH4_SCIF_BRG_REGTYPE), + .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH4_SCIF_BRG_REGTYPE, 0), }, { .compatible = "renesas,rcar-gen2-scif", - .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH4_SCIF_BRG_REGTYPE), + .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH4_SCIF_BRG_REGTYPE, 0), }, { .compatible = "renesas,rcar-gen3-scif", - .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH4_SCIF_BRG_REGTYPE), + .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH4_SCIF_BRG_REGTYPE, 0), }, /* Generic types */ { .compatible = "renesas,scif", - .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH4_SCIF_REGTYPE), + .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH4_SCIF_REGTYPE, 1), }, { .compatible = "renesas,scifa", - .data = SCI_OF_DATA(PORT_SCIFA, SCIx_SCIFA_REGTYPE), + .data = SCI_OF_DATA(PORT_SCIFA, SCIx_SCIFA_REGTYPE, 0), }, { .compatible = "renesas,scifb", - .data = SCI_OF_DATA(PORT_SCIFB, SCIx_SCIFB_REGTYPE), + .data = SCI_OF_DATA(PORT_SCIFB, SCIx_SCIFB_REGTYPE, 0), }, { .compatible = "renesas,hscif", - .data = SCI_OF_DATA(PORT_HSCIF, SCIx_HSCIF_REGTYPE), + .data = SCI_OF_DATA(PORT_HSCIF, SCIx_HSCIF_REGTYPE, 0), }, { .compatible = "renesas,sci", - .data = SCI_OF_DATA(PORT_SCI, SCIx_SCI_REGTYPE), + .data = SCI_OF_DATA(PORT_SCI, SCIx_SCI_REGTYPE, 0), }, { /* Terminator */ }, @@ -3179,6 +3186,7 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev, p->type = SCI_OF_TYPE(data); p->regtype = SCI_OF_REGTYPE(data); + p->regshift = SCI_OF_REGSHIFT(data); sp->has_rtscts = of_property_read_bool(np, "uart-has-rtscts");