From patchwork Fri Feb 17 11:42:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 654873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B80CDC64ED6 for ; Fri, 17 Feb 2023 11:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbjBQLnH (ORCPT ); Fri, 17 Feb 2023 06:43:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229828AbjBQLnG (ORCPT ); Fri, 17 Feb 2023 06:43:06 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C6164241F6; Fri, 17 Feb 2023 03:43:05 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.97,304,1669042800"; d="scan'208";a="153224451" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 17 Feb 2023 20:43:05 +0900 Received: from localhost.localdomain (unknown [10.226.92.177]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id D79AE40029C4; Fri, 17 Feb 2023 20:43:02 +0900 (JST) From: Biju Das To: Greg Kroah-Hartman Cc: Biju Das , Jiri Slaby , linux-serial@vger.kernel.org, Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlund?= , Fabrizio Castro , linux-renesas-soc@vger.kernel.org Subject: [PATCH v4 1/6] serial: 8250_em: Use dev_err_probe() Date: Fri, 17 Feb 2023 11:42:50 +0000 Message-Id: <20230217114255.226517-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230217114255.226517-1-biju.das.jz@bp.renesas.com> References: <20230217114255.226517-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org This patch simplifies probe() by using dev_err() instead of dev_err_probe() and added a local variable 'dev' to replace '&pdev->dev'. Signed-off-by: Biju Das --- v3->v4: * Split from patch#1 * Replaced dev_err->dev_err_probe() in probe() * Added a local variable 'dev' to replace '&pdev->dev' in probe(). v2->v3: * Dropped sclk from priv. * Dropped unneeded clk_disable_unprepare from remove(). * Retained Rb tags from Geert and Andy as the changes are trivial. v1->v2: * replaced devm_clk_get->devm_clk_get_enabled() and updated clk handling in probe(). * Added Rb tag from Geert. --- drivers/tty/serial/8250/8250_em.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/tty/serial/8250/8250_em.c b/drivers/tty/serial/8250/8250_em.c index f8e99995eee9..785153d8502d 100644 --- a/drivers/tty/serial/8250/8250_em.c +++ b/drivers/tty/serial/8250/8250_em.c @@ -79,6 +79,7 @@ static void serial8250_em_serial_dl_write(struct uart_8250_port *up, int value) static int serial8250_em_probe(struct platform_device *pdev) { struct serial8250_em_priv *priv; + struct device *dev = &pdev->dev; struct uart_8250_port up; struct resource *regs; int irq, ret; @@ -88,27 +89,23 @@ static int serial8250_em_probe(struct platform_device *pdev) return irq; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!regs) { - dev_err(&pdev->dev, "missing registers\n"); - return -EINVAL; - } + if (!regs) + return dev_err_probe(dev, -EINVAL, "missing registers\n"); - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; - priv->sclk = devm_clk_get(&pdev->dev, "sclk"); - if (IS_ERR(priv->sclk)) { - dev_err(&pdev->dev, "unable to get clock\n"); - return PTR_ERR(priv->sclk); - } + priv->sclk = devm_clk_get(dev, "sclk"); + if (IS_ERR(priv->sclk)) + return dev_err_probe(dev, PTR_ERR(priv->sclk), "unable to get clock\n"); memset(&up, 0, sizeof(up)); up.port.mapbase = regs->start; up.port.irq = irq; up.port.type = PORT_UNKNOWN; up.port.flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_IOREMAP; - up.port.dev = &pdev->dev; + up.port.dev = dev; up.port.private_data = priv; clk_prepare_enable(priv->sclk); @@ -122,9 +119,8 @@ static int serial8250_em_probe(struct platform_device *pdev) ret = serial8250_register_8250_port(&up); if (ret < 0) { - dev_err(&pdev->dev, "unable to register 8250 port\n"); clk_disable_unprepare(priv->sclk); - return ret; + return dev_err_probe(dev, ret, "unable to register 8250 port\n"); } priv->line = ret; From patchwork Fri Feb 17 11:42:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 654872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEBC0C64ED6 for ; Fri, 17 Feb 2023 11:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229760AbjBQLnU (ORCPT ); Fri, 17 Feb 2023 06:43:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbjBQLnR (ORCPT ); Fri, 17 Feb 2023 06:43:17 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CA1FB241F6; Fri, 17 Feb 2023 03:43:15 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.97,304,1669042800"; d="scan'208";a="153224476" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 17 Feb 2023 20:43:15 +0900 Received: from localhost.localdomain (unknown [10.226.92.177]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id AD3084002630; Fri, 17 Feb 2023 20:43:12 +0900 (JST) From: Biju Das To: Greg Kroah-Hartman Cc: Biju Das , Jiri Slaby , linux-serial@vger.kernel.org, Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlund?= , Fabrizio Castro , linux-renesas-soc@vger.kernel.org Subject: [PATCH v4 4/6] serial: 8250_em: Update port type as PORT_16750 Date: Fri, 17 Feb 2023 11:42:53 +0000 Message-Id: <20230217114255.226517-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230217114255.226517-1-biju.das.jz@bp.renesas.com> References: <20230217114255.226517-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The UART IP found on {RZ/V2M, EMMA mobile} SoC is Register-compatible with the general-purpose 16750 UART chip. This patch updates port type from 16550A->16750 and also enables 64-bytes fifo support. Signed-off-by: Biju Das --- v3->v4: * Both {RZ/V2M, EMMA mobile} SoC is Register-compatible with the general-purpose 16750 UART chip. So started using generic compatible and removed struct serial8250_em_hw_info. * Removed Rb tag from Ilpo as it is new change. v2->v3: * Replaced of_device_get_match_data()->device_get_match_data(). * Replaced of_device.h->property.h * Dropped struct serial8250_em_hw_info *info from priv and started using a local variable info in probe(). * Retained Rb tag from Ilpo as changes are trivial. v2: * New patch --- drivers/tty/serial/8250/8250_em.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_em.c b/drivers/tty/serial/8250/8250_em.c index 9781bf73ed0c..499d7a8847ec 100644 --- a/drivers/tty/serial/8250/8250_em.c +++ b/drivers/tty/serial/8250/8250_em.c @@ -102,8 +102,8 @@ static int serial8250_em_probe(struct platform_device *pdev) memset(&up, 0, sizeof(up)); up.port.mapbase = regs->start; up.port.irq = irq; - up.port.type = PORT_UNKNOWN; - up.port.flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_IOREMAP; + up.port.type = PORT_16750; + up.port.flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_IOREMAP | UPF_FIXED_TYPE; up.port.dev = dev; up.port.private_data = priv; From patchwork Fri Feb 17 11:42:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 654871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8890C64ED8 for ; Fri, 17 Feb 2023 11:43:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230244AbjBQLnX (ORCPT ); Fri, 17 Feb 2023 06:43:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbjBQLnU (ORCPT ); Fri, 17 Feb 2023 06:43:20 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3EEE15BDBD; Fri, 17 Feb 2023 03:43:19 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.97,304,1669042800"; d="scan'208";a="153224482" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 17 Feb 2023 20:43:19 +0900 Received: from localhost.localdomain (unknown [10.226.92.177]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 085854002630; Fri, 17 Feb 2023 20:43:15 +0900 (JST) From: Biju Das To: Greg Kroah-Hartman Cc: Biju Das , Jiri Slaby , linux-serial@vger.kernel.org, Geert Uytterhoeven , =?utf-8?q?Niklas_S=C3=B6derlund?= , Fabrizio Castro , linux-renesas-soc@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 5/6] serial: 8250_em: Use pseudo offset for UART_FCR Date: Fri, 17 Feb 2023 11:42:54 +0000 Message-Id: <20230217114255.226517-6-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230217114255.226517-1-biju.das.jz@bp.renesas.com> References: <20230217114255.226517-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org UART_FCR shares the same offset with UART_IIR. We cannot use UART_FCR in serial8250_em_serial_in() as it overlaps with UART_IIR. This patch introduces a macro UART_FCR_EM with a high value to avoid overlapping with existing UART_* register defines. This will help us to use UART_FCR_EM consistently in serial8250_em_ serial{_in/_out} function to read/write FCR register. Signed-off-by: Biju Das Suggested-by: Ilpo Järvinen --- v4: * New patch. Used UART_FCR_EM for read/write of FCR register. --- drivers/tty/serial/8250/8250_em.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_em.c b/drivers/tty/serial/8250/8250_em.c index 499d7a8847ec..4165fd3bb17a 100644 --- a/drivers/tty/serial/8250/8250_em.c +++ b/drivers/tty/serial/8250/8250_em.c @@ -19,6 +19,13 @@ #define UART_DLL_EM 9 #define UART_DLM_EM 10 +/* + * A high value for UART_FCR_EM avoids overlapping with existing UART_* + * register defines. UART_FCR_EM_HW is the real HW register offset. + */ +#define UART_FCR_EM 0x10003 +#define UART_FCR_EM_HW 3 + struct serial8250_em_priv { int line; }; @@ -29,12 +36,14 @@ static void serial8250_em_serial_out(struct uart_port *p, int offset, int value) case UART_TX: /* TX @ 0x00 */ writeb(value, p->membase); break; - case UART_FCR: /* FCR @ 0x0c (+1) */ case UART_LCR: /* LCR @ 0x10 (+1) */ case UART_MCR: /* MCR @ 0x14 (+1) */ case UART_SCR: /* SCR @ 0x20 (+1) */ writel(value, p->membase + ((offset + 1) << 2)); break; + case UART_FCR_EM: + writel(value, p->membase + (UART_FCR_EM_HW << 2)); + break; case UART_IER: /* IER @ 0x04 */ value &= 0x0f; /* only 4 valid bits - not Xscale */ fallthrough; @@ -54,6 +63,8 @@ static unsigned int serial8250_em_serial_in(struct uart_port *p, int offset) case UART_MSR: /* MSR @ 0x1c (+1) */ case UART_SCR: /* SCR @ 0x20 (+1) */ return readl(p->membase + ((offset + 1) << 2)); + case UART_FCR_EM: + return readl(p->membase + (UART_FCR_EM_HW << 2)); case UART_IER: /* IER @ 0x04 */ case UART_IIR: /* IIR @ 0x08 */ case UART_DLL_EM: /* DLL @ 0x24 (+9) */