From patchwork Thu Mar 16 16:01:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13177941 X-Patchwork-Delegate: geert@linux-m68k.org 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 16B2EC6FD19 for ; Thu, 16 Mar 2023 16:01:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229488AbjCPQB1 (ORCPT ); Thu, 16 Mar 2023 12:01:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbjCPQB0 (ORCPT ); Thu, 16 Mar 2023 12:01:26 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C03B6BBB3; Thu, 16 Mar 2023 09:01:23 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.98,265,1673881200"; d="scan'208";a="156196531" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 17 Mar 2023 01:01:23 +0900 Received: from localhost.localdomain (unknown [10.226.93.88]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 67E45401207E; Fri, 17 Mar 2023 01:01:20 +0900 (JST) From: Biju Das To: Greg Kroah-Hartman Cc: Biju Das , Jiri Slaby , Yoshihiro Shimoda , Geert Uytterhoeven , Stephen Boyd , linux-serial@vger.kernel.org, Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH] tty: serial: sh-sci: Fix transmit end interrupt handler Date: Thu, 16 Mar 2023 16:01:18 +0000 Message-Id: <20230316160118.133182-1-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The RZ SCI/ RZ/A1 SCIF has only 4 interrupts. The fourth interrupt is transmit end interrupt, so shuffle the interrupts to fix the transmit end interrupt handler for these IPs. Fixes: 392fb8df528b ("serial: sh-sci: Use platform_get_irq_optional() for optional interrupts") Suggested-by: Geert Uytterhoeven Signed-off-by: Biju Das --- Tested the SCI0 interface on RZ/G2UL by connecting to PMOD USBUART. 39: 0 GICv3 437 Level 1004d000.serial:rx err 40: 12 GICv3 438 Edge 1004d000.serial:rx full 41: 70 GICv3 439 Edge 1004d000.serial:tx empty 42: 18 GICv3 440 Level 1004d000.serial:tx end --- drivers/tty/serial/sh-sci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 7bd080720929..9b07b45a6948 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -2841,6 +2842,7 @@ static int sci_init_single(struct platform_device *dev, struct uart_port *port = &sci_port->port; const struct resource *res; unsigned int i; + int irq_cnt; int ret; sci_port->cfg = p; @@ -2864,6 +2866,14 @@ static int sci_init_single(struct platform_device *dev, sci_port->irqs[i] = platform_get_irq(dev, i); } + /* + * RZ SCI/ RZ/A1 SCIF has only 4 interrupts. The fourth interrupt + * is transmit end interrupt, so shuffle the interrupts. + */ + irq_cnt = platform_irq_count(dev); + if (irq_cnt == 4) + swap(sci_port->irqs[SCIx_BRI_IRQ], sci_port->irqs[SCIx_TEI_IRQ]); + /* The SCI generates several interrupts. They can be muxed together or * connected to different interrupt lines. In the muxed case only one * interrupt resource is specified as there is only one interrupt ID.