From patchwork Sat Nov 12 21:21:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624548 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 4240BC43217 for ; Sat, 12 Nov 2022 21:21:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235062AbiKLVVf (ORCPT ); Sat, 12 Nov 2022 16:21:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235050AbiKLVVe (ORCPT ); Sat, 12 Nov 2022 16:21:34 -0500 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83BB815805; Sat, 12 Nov 2022 13:21:33 -0800 (PST) Received: by mail-qk1-x72e.google.com with SMTP id g10so5333772qkl.6; Sat, 12 Nov 2022 13:21:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IQFfyExI23+erN827zqnus+ZsfTP6ThOACFwJyPon2s=; b=UCtUwLwVmjQTkvMKmyJiNoDcBXr9dYQHOD9QEoW9/jb3JDLVq81xuclgbQVti+hvhH A6omZZIxoEmUd+vrSCcsIfjfjlhVgV2sj5hc/ZeGSFizKmhwwzDBEPha6gdjYtQDFUgZ KYFQQCsyTJLuOZ3ixLkxCYzsnJN5rrzm+wAqzyXGj98vJKSyP0ISuzl3G2S9G8JNuinw XELTeQDb5/GlzSmIjQMjXpFocijdOmvBS7jFtyHwpFl/PLLSqQLJFbWeyK+xPCND2n/X Yw8tpDdRaL/Kx6Cb9ZUVPZQ2Jtbtlx5nAvIbcApBZ7jPaz8MYcCSbVnZa6JI41ZpOg1S eikg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IQFfyExI23+erN827zqnus+ZsfTP6ThOACFwJyPon2s=; b=d4+iZ61ZdXMH8t9YrXYgAyHMT+9IrBRcYhsrKpvp+AMxstA36UsS9tDZTdPQ7AEwi5 E1X+/Am7TJvtyqrkZzM5WBkowp2SFqBFm5/Byluw/jLZTFtax/Era2eelcko1rdOx7qn 6+Y1f88EEtUWL3jbDqadYjZzo+6iay/fTlfiWaz/Q/0Z/7x8sVD3duc5Ch2CBGo6hMnl rfX7GvPndjhPhmQVCek5itG8S8sR3uLzrAdcZjLnPb6IqBxb8XJHAw+LfNJBwcfHlzTM 3lnMnW1LJDo3qetGPv4cKJYrmQUvW1vHFr8F51jTJWLozTQHLWijgMLG8VWvL1SnHYkY pSmA== X-Gm-Message-State: ANoB5pnWP7RRnj1FIXMhhuQm3/K7vy3aCZFWMo3bJLkYCaeMWJr9KI3l oifXoHYtCXxghcyBX2Oe/B1w7GYcLgYxLg== X-Google-Smtp-Source: AA0mqf5mIDwSQg434DYAbJrxqAJx+WwbbWg4rmtusH7B3nDTOX2gzQhIAcSpCehsoG7JrKwtVOvqUg== X-Received: by 2002:a37:54c3:0:b0:6fa:4749:cbe3 with SMTP id i186-20020a3754c3000000b006fa4749cbe3mr6106929qkb.171.1668288092320; Sat, 12 Nov 2022 13:21:32 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:31 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 01/14] serial: liteuart: use KBUILD_MODNAME as driver name Date: Sat, 12 Nov 2022 16:21:12 -0500 Message-Id: <20221112212125.448824-2-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Replace hard-coded instances of "liteuart" with KBUILD_MODNAME. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index 4c0604325ee9..32b81bd03d0c 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -57,7 +57,7 @@ static struct console liteuart_console; static struct uart_driver liteuart_driver = { .owner = THIS_MODULE, - .driver_name = "liteuart", + .driver_name = KBUILD_MODNAME, .dev_name = "ttyLXU", .major = 0, .minor = 0, @@ -322,7 +322,7 @@ static struct platform_driver liteuart_platform_driver = { .probe = liteuart_probe, .remove = liteuart_remove, .driver = { - .name = "liteuart", + .name = KBUILD_MODNAME, .of_match_table = liteuart_of_match, }, }; @@ -368,7 +368,7 @@ static int liteuart_console_setup(struct console *co, char *options) } static struct console liteuart_console = { - .name = "liteuart", + .name = KBUILD_MODNAME, .write = liteuart_console_write, .device = uart_console_device, .setup = liteuart_console_setup, From patchwork Sat Nov 12 21:21:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624413 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 8D0A1C43219 for ; Sat, 12 Nov 2022 21:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235073AbiKLVVg (ORCPT ); Sat, 12 Nov 2022 16:21:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbiKLVVf (ORCPT ); Sat, 12 Nov 2022 16:21:35 -0500 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BB2A116E; Sat, 12 Nov 2022 13:21:34 -0800 (PST) Received: by mail-qv1-xf32.google.com with SMTP id u7so5645079qvn.13; Sat, 12 Nov 2022 13:21:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h9s8/P3zcC35a/7U8wwUtQnHUttoN7Pw9xSfTjSoDyA=; b=lS7cf1+1z6f/If/JJO2IahlbNk2YHn+QDZi2DLAe50NrMq6e9i7W/+gNE8pm8R+tCj rBFr0PRY2lSXCq0+qjR6j7EKo6RgeOKtdjbwn8iqEmM5FZZ3XkILmTkr9eEJk3sitOqb XT55PetzmpaYeX15oVC1VmTD6Jf4SEY+Qqm19TnlBLZB+1vLsGOjYmmFoIrulEzkO5Jl SfTTj9Vien8cfb97+pjJNlDiV1A+XXbHPgMB6R3gBFsgvZBawMSR3fJOJNsVUNvuisND fwGNxUaLocC7X8UN6k9SlgTQslxmqF1cOEbslU5sSvKUB0+idTP9gHWtWbLbpd+YdKbE SpmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h9s8/P3zcC35a/7U8wwUtQnHUttoN7Pw9xSfTjSoDyA=; b=0gxjIZhBYKHQxYc6yu0/45tWAs1l80PvaNRd8KDEJguGKtkQS1HqxxoZ2gzKCyOiDo qp8bANcxVeNLfs+PPNAI615b6UXY7ir73SHiVnRMAIkG4Wu6hibcpL12wuehRrPFIqxQ pXNbXxKrTmA1cgzxX70o0Uoe9O8kd/xfxnbmU1CNWnUaATQpLN2Nu0ivFQl58ZPmSHNr WZ8tpnb1Xfs2n3VmLKv1JGNZpmGvwdr6fLSEM7ToiXlh87GHx7Czo40Ti8o0VRdu8hYc lVEm13nBgFD3GzrX9buDd3TpNYNbSUb55+f5JMzyxLAcLtM0lnMRFc2WEZ0c5SVMdrJp T6Ww== X-Gm-Message-State: ANoB5pmFHRzWJS+th4Hin2x2Vc+7aGWpfwHW7r7aPT404gL9UtEbuAOQ eM1SED8lPOyK0KMRr10V67/Q002kC5zlLA== X-Google-Smtp-Source: AA0mqf4oGVW5Jxi8N45W8IDFia/ztpx3l4FXI2ndBnJ1vVDNtabMyBR+M28zGdNJiczwkf3dqdUVWg== X-Received: by 2002:ad4:4f11:0:b0:4bb:7436:49de with SMTP id fb17-20020ad44f11000000b004bb743649demr7014739qvb.27.1668288093369; Sat, 12 Nov 2022 13:21:33 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:32 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 02/14] serial: liteuart: use bit number macros Date: Sat, 12 Nov 2022 16:21:13 -0500 Message-Id: <20221112212125.448824-3-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Replace magic bit constants (e.g., 1, 2, 4) with BIT(x) expressions. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index 32b81bd03d0c..1497d4cdc221 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -38,8 +38,8 @@ #define OFF_EV_ENABLE 0x14 /* events */ -#define EV_TX 0x1 -#define EV_RX 0x2 +#define EV_TX BIT(0) +#define EV_RX BIT(1) struct liteuart_port { struct uart_port port; From patchwork Sat Nov 12 21:21:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624547 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 33843C433FE for ; Sat, 12 Nov 2022 21:21:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234976AbiKLVVm (ORCPT ); Sat, 12 Nov 2022 16:21:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235067AbiKLVVh (ORCPT ); Sat, 12 Nov 2022 16:21:37 -0500 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A89FD116E; Sat, 12 Nov 2022 13:21:35 -0800 (PST) Received: by mail-qv1-xf30.google.com with SMTP id x13so5679211qvn.6; Sat, 12 Nov 2022 13:21:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8/8DPEq9jxGYQguFphHAE7bQWgOJIibend0gpSldrS0=; b=pRD6w1gRCDzRGm1uW8MIeuaDnD+7DSCddkxcWGyWGiaYUOOhRBAtNKCByPwmkfUFAX NgNUEsXck9OsSIWfmsiEu1NTRvglPNJwt0gOpuYU+XeO4GZBpaYgfY+rywUTciUeQ3DL zV2jMtncMGRtIf//3oiSiGervTkqCQAGFbt0nFDPjaP9G12y0bwf66U37d3C2RlkBQSL HJqZ35yZIKFoMSKCxlwq0k/zjnYuGXEzrBX09mU39/46ANYs38+nPc6pWGfIE2NFuz+P J+R4SHQrucUoY19+IylRagorvNoWm4ZSpMtqyXt4YQwp3EYu68EkNXCbI+azdCiXcB8W GWpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8/8DPEq9jxGYQguFphHAE7bQWgOJIibend0gpSldrS0=; b=SQowBztMEdKLfaNgVIZ/u91IxnyzGLSFpbuwct2UegZ38g/ym0JWqTHMDzo5+wxb/R s3rKfbdiI21usHyrCVHd7t759tDhjuRx4v7Ret9KhJMeRXTjN1j18JIChmkVMhTceIvc CaJMr8yvgb3J04Gaq8/L4+Gf3RM8Uuzc5MqwdX3YU83LU4WeggO+oYjQtaiBl5ROW30D qIJ+RBF0rgSy78ViI2E9KsiZDCsVZQvGAGHF0OqAwyclt7m5Dn+5ybeF2UlgGFe4vxln KPAB2ShKoBzCmWOfBadjnjfCIMKvwkrzti2UeszGYQcE4QKqBet5HjUbTHsLjHvZB6ij e4mA== X-Gm-Message-State: ANoB5pndsNBWYxmmzh+43p9kQAN+pi65VTuUfxvo6EEjZ/srYLCEENxG nWzhrIUpfdRLbOqOuazXPH0+kqNFdTyBRg== X-Google-Smtp-Source: AA0mqf48SrqNEHPc/iMt+ke4qYur4Vq4FuEW6ojat5AjEpCoJcUd4DmynIMXMhdItAswccLTn2mYyg== X-Received: by 2002:a05:6214:5911:b0:4b9:e098:e334 with SMTP id lp17-20020a056214591100b004b9e098e334mr7136818qvb.38.1668288094516; Sat, 12 Nov 2022 13:21:34 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:33 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 03/14] serial: liteuart: remove unused uart_ops stubs Date: Sat, 12 Nov 2022 16:21:14 -0500 Message-Id: <20221112212125.448824-4-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Remove stub uart_ops methods that are not called unconditionally from serial_core. Document stubs that are expected to be present. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index 1497d4cdc221..90f6280c5452 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -122,6 +122,7 @@ static unsigned int liteuart_get_mctrl(struct uart_port *port) static void liteuart_stop_tx(struct uart_port *port) { + /* not used in LiteUART, but called unconditionally from serial_core */ } static void liteuart_start_tx(struct uart_port *port) @@ -154,11 +155,6 @@ static void liteuart_stop_rx(struct uart_port *port) del_timer(&uart->timer); } -static void liteuart_break_ctl(struct uart_port *port, int break_state) -{ - /* LiteUART doesn't support sending break signal */ -} - static int liteuart_startup(struct uart_port *port) { struct liteuart_port *uart = to_liteuart_port(port); @@ -197,15 +193,6 @@ static const char *liteuart_type(struct uart_port *port) return "liteuart"; } -static void liteuart_release_port(struct uart_port *port) -{ -} - -static int liteuart_request_port(struct uart_port *port) -{ - return 0; -} - static void liteuart_config_port(struct uart_port *port, int flags) { /* @@ -232,13 +219,10 @@ static const struct uart_ops liteuart_ops = { .stop_tx = liteuart_stop_tx, .start_tx = liteuart_start_tx, .stop_rx = liteuart_stop_rx, - .break_ctl = liteuart_break_ctl, .startup = liteuart_startup, .shutdown = liteuart_shutdown, .set_termios = liteuart_set_termios, .type = liteuart_type, - .release_port = liteuart_release_port, - .request_port = liteuart_request_port, .config_port = liteuart_config_port, .verify_port = liteuart_verify_port, }; From patchwork Sat Nov 12 21:21:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624412 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 64D51C4332F for ; Sat, 12 Nov 2022 21:21:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235104AbiKLVVn (ORCPT ); Sat, 12 Nov 2022 16:21:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235076AbiKLVVh (ORCPT ); Sat, 12 Nov 2022 16:21:37 -0500 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1896E15805; Sat, 12 Nov 2022 13:21:36 -0800 (PST) Received: by mail-qv1-xf29.google.com with SMTP id h10so5668091qvq.7; Sat, 12 Nov 2022 13:21:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8WawqzZk7R2Fk2wsVcJJHQ6DiWGY8oW1x9eP6skVjzc=; b=erGeth7XdHfXrFpCTX/lYo73hGW1D0dqNev6FMVSG8CXXdRMZY3tyotII4xjilTBnY DUwUs6FCzhgnK/+2inHdJR4d5Fqr0tzu+z0KP4/OfNsMpduXbPI+5LsCmgi/R884m74x ktisuAj80uxFVLsCExMjSCtXIYOR3B9gwTWRBGQL8Wu3KNsutn9jKvV5OBHA2khtu1zd ZhLbcrELCGQSBxlQcAaDqcHtUrgFoRgKj7KH0j6n/3HseYf2xcqsVBjCUS2KlgruBQto eeXACw+hW92+l04OVRSlsE1cd0D+9YuAIUj1eKSQAKNzCGX0nXRtkC+JJJhzriIZgfvI QkvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8WawqzZk7R2Fk2wsVcJJHQ6DiWGY8oW1x9eP6skVjzc=; b=Mk+aDpZX2sB483Z7XacpiVTBvKsay5cuv9RmzuBitr5HPeOwUDggKlNZON20n0pMs7 JrR/3ku7oXMZAHkhAPSTS2yKaA5isqnGmF7f7lYKSJOm1MuduXcgPIldU6C/W7B6Ppek cjnuC0J54r0npiljrljRrCHE1DkPmqSM8Kgf3yJsY1j0eA5S6bnt95zC9MJBfSJVK9Wn ajaj8bSucmNWz5gpTjgJCC/x/E1DtzcAfNM3c5VqhVk4OVAbW4vVzNktUFywLYsDLGg/ klhT6DKWgoomw9qRVkAadxbPVIy7nDYRw+Bf08UHtNHoAR1ZZpSY2Zjcx9B8y4LNhO83 KBuw== X-Gm-Message-State: ANoB5pkzapBo7WYQ+hWNHd9ec9JibjkJhBhHWyQbSVOTof/WiHlE+W0G tyAuDsF8Ie+s7GkQzrlIeKDMD0hSZaUD6w== X-Google-Smtp-Source: AA0mqf7Pkj08SSSJd6Z6HZd8iDuwDEZjc08P8XHOy/so1Qh0m/rm9iPzJHBVOd+8RwstHE1QrdfIbQ== X-Received: by 2002:a0c:f951:0:b0:4bb:b2b1:c10f with SMTP id i17-20020a0cf951000000b004bbb2b1c10fmr7204628qvo.64.1668288095476; Sat, 12 Nov 2022 13:21:35 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:35 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 04/14] serial: liteuart: don't set unused port fields Date: Sat, 12 Nov 2022 16:21:15 -0500 Message-Id: <20221112212125.448824-5-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Remove regshift and iobase port fields, since they are unused by the driver. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index 90f6280c5452..5b684fd198b7 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -264,9 +264,7 @@ static int liteuart_probe(struct platform_device *pdev) port->iotype = UPIO_MEM; port->flags = UPF_BOOT_AUTOCONF; port->ops = &liteuart_ops; - port->regshift = 2; port->fifosize = 16; - port->iobase = 1; port->type = PORT_UNKNOWN; port->line = dev_id; spin_lock_init(&port->lock); From patchwork Sat Nov 12 21:21:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624546 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 1327AC4332F for ; Sat, 12 Nov 2022 21:21:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235123AbiKLVVs (ORCPT ); Sat, 12 Nov 2022 16:21:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235090AbiKLVVl (ORCPT ); Sat, 12 Nov 2022 16:21:41 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6BDD15837; Sat, 12 Nov 2022 13:21:37 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id e15so4887281qts.1; Sat, 12 Nov 2022 13:21:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MThhfi/+6K/LOJrqVDZeVBTVPExj3Q+f1CKmXTQaNyE=; b=AXOzRqyTDqtG7FZH8oEjR5QhNTkyr2FlKau53ZFDhVib8/PNf3gjqWtsOM7WzW1POP Mcsr+vDOSi7xwYwij+2JrEfpTNWySGA1Fn0c68CsMxt+/w6pFzB1W6AUfpItAee/Bhou E9LrxymO110qQgsYT6c6heWr85C/3PQojXd5fWJeMGKdptulmEsNidex8RUQl93A1cRi t3oiG8QQ1xlDhrOSNb87f8L1vugHuQewTvX2FWwZu9zfNk0+wTwYdfxMbIX7W7zIZ04h g1w+I8471NbkxRzuu1D0xkr5EiVGjo+gOXdmlRUuWZ2BJ9NO5AsUiYXx9G5CXdApOOOv Ir8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MThhfi/+6K/LOJrqVDZeVBTVPExj3Q+f1CKmXTQaNyE=; b=vsxKS7KSnYwmo6p5Sc4xBmwgEod4AODa42MjNLKrlBhhSpM4OXhKULEPYND+kqfVUA f17h/LeS6eAzomrZUYvaeg0QkMGehy1eQVtI1trCglNrnFkPlEKIDoEEbB2wvfxh9bmk kgLDoofaxE7d/mQPQahEr2bOhdONy6uqKogGakLy/MQsYR92a7ilB15I8ObwGVC+P2EC ts/S/JGLGlmGGw59UWb9SiNUIEI/QYuBkO/XwVESFM+8WP3GzcZ1DnujvQkuG4Xqjj4U MgPVgJzrssZJ71exELy6+4JtwwVtJxKYkfouM+Wj2GbGCfYBmSc1JrnHT7isu3gcfHCA 5vSg== X-Gm-Message-State: ANoB5pnBSOVu+eU1b0cpg2b7ydEhM0rV/nQbDN8VOnOv1EKi2nuwFyv0 2Fr8k9TColOW3gjh45EGd4WtPJXJwYvuXA== X-Google-Smtp-Source: AA0mqf7KT7/puQTnvyn7b/0aDs9Jlhff0nTEpnRSr5ep4SBi4A/yZo+xMVVXS2w2NVbh40Q+I7n6lA== X-Received: by 2002:a05:622a:59c7:b0:3a5:4c53:8923 with SMTP id gc7-20020a05622a59c700b003a54c538923mr6815383qtb.267.1668288096553; Sat, 12 Nov 2022 13:21:36 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:36 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 05/14] serial: liteuart: minor style fix in liteuart_init() Date: Sat, 12 Nov 2022 16:21:16 -0500 Message-Id: <20221112212125.448824-6-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index 5b684fd198b7..047d5ad32e13 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -398,12 +398,10 @@ static int __init liteuart_init(void) return res; res = platform_driver_register(&liteuart_platform_driver); - if (res) { + if (res) uart_unregister_driver(&liteuart_driver); - return res; - } - return 0; + return res; } static void __exit liteuart_exit(void) From patchwork Sat Nov 12 21:21:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624411 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 DB873C4332F for ; Sat, 12 Nov 2022 21:22:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235095AbiKLVVy (ORCPT ); Sat, 12 Nov 2022 16:21:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235091AbiKLVVl (ORCPT ); Sat, 12 Nov 2022 16:21:41 -0500 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C128315801; Sat, 12 Nov 2022 13:21:38 -0800 (PST) Received: by mail-qk1-x72f.google.com with SMTP id k4so5327058qkj.8; Sat, 12 Nov 2022 13:21:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ffs7WthYcxxlp9KpB8gp7rdODwrO1odw2XTkcOVFYl0=; b=fu7M1MXORgQuaanuE/aWKr8EMJsr5jPdK4A9VgySyuFCJO9sus1ArdI+0pstFJuIUx /F87VjCTbqCD4c8EGTxzDnFvPRKFqOBY+v04r6u+K2K++MbayeZ0ecNf21RqnaJODqui SGwH98YVuq9LG8Q0jmuEwatdnHC9n+JmTfWWxeOo01Z8g3aPmOnET1AOFYzbMWkH5OS1 2Rioc67FOg5aIpRARvQbWWPWyQA5ph3uD4a7cnKxZUbv/6QE+gVzkA6ZN7EqCt1v3oIy /4hK3F7ed/6eAC5L+Q0IadSDF4lCVEd4pOsFRtPW2OAobjrjwFPLem8te15I7vkebhUw nfmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ffs7WthYcxxlp9KpB8gp7rdODwrO1odw2XTkcOVFYl0=; b=5d3+hZtuVeLpXNv9Jn+MQeZekyvygDW5OWT4aSHfG9EacfJ19YUirrTfBtcrWd1VCg eOYMM0vMEkrA/0TBElHYSRfdPHRmyqKmpD/zsiTlVr1twCLSJJy4OUxTjklIz/OBb8Tx zo9d9+2VvM4h8IYifzTGbYg/tV80GdNHs33iwFVuUlkkEccuVcNxxz4gULWhwfrYeqSf cYkDKYxrtGAtOCCiS3QR4OuTVhRY/LWDv7+pBi+iaCsAK3Hy4eG4aIrwjNppmFRh/mVj CMVLHARRmIoxAw1cv8UBzN2PtIUHtO4xk4PVvTw1cgvZrNAlITNJm2UboyQ2qwvL00EH KlPg== X-Gm-Message-State: ANoB5pnk6JP8RTt8noZSQ7QS7uaDWM8pD9wCBinCGicbh9cC5o2hzEtu u92U8Nb/ci5P2CvxVxkD+r6I1i1J/RJFuA== X-Google-Smtp-Source: AA0mqf4qBL9Vzk4md+k5YMO8+Uv/GJn2OwiCn8KzO3ZC9M65uUOVgmJ1XZWJCF5Q3MqHLemOQRXGLA== X-Received: by 2002:a05:620a:892:b0:6f9:60e1:bd7c with SMTP id b18-20020a05620a089200b006f960e1bd7cmr6128970qka.412.1668288097461; Sat, 12 Nov 2022 13:21:37 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:37 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 06/14] serial: liteuart: move tty_flip_buffer_push() out of rx loop Date: Sat, 12 Nov 2022 16:21:17 -0500 Message-Id: <20221112212125.448824-7-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Calling tty_flip_buffer_push() for each individual received character is overkill. Move it out of the rx loop, and only call it once per set of characters received together. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index 047d5ad32e13..ff3486860989 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -86,10 +86,10 @@ static void liteuart_timer(struct timer_list *t) /* no overflow bits in status */ if (!(uart_handle_sysrq_char(port, ch))) uart_insert_char(port, status, 0, ch, flg); - - tty_flip_buffer_push(&port->state->port); } + tty_flip_buffer_push(&port->state->port); + mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); } From patchwork Sat Nov 12 21:21:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624545 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 04299C433FE for ; Sat, 12 Nov 2022 21:22:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235146AbiKLVV4 (ORCPT ); Sat, 12 Nov 2022 16:21:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235092AbiKLVVl (ORCPT ); Sat, 12 Nov 2022 16:21:41 -0500 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F2B715A1D; Sat, 12 Nov 2022 13:21:39 -0800 (PST) Received: by mail-qt1-x82f.google.com with SMTP id l15so4874485qtv.4; Sat, 12 Nov 2022 13:21:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lj3jgN94Up18U7wVvpj0Zgp4+ZbcXYE4CuLEGeta7KA=; b=hT5YiZaCxVZ1nPy9zMoXb3qQqnPNsZ7o9pju+19OsVVMRh096IvhsGw3wrI3WyLprx qdPk33wgAo8ELhrFTjh2rJ6nwlND9hL1trHMue0kGpziwDe/aXDdF5A2OAztsgcbx0KP Devs53QoRNOxuZgtr9LpArCBscEp1EFIfWc+Wyv3CtrjVMAZaawDoetYCdxvKkAIXK+p 9bltTnJY5s/ewqlCSBZchvfwRncppJ3X2Q13ZUWTkSl1J1V1hikyiJ7EuSqzDPfs6J42 fk4qATFyjlt2NIP+fFBwR1ezjd70Ex5775RmWUNZKvqFjJYSuQJMGm3sO+iqGRD2Oco2 2lVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lj3jgN94Up18U7wVvpj0Zgp4+ZbcXYE4CuLEGeta7KA=; b=esRuAhsIkXxasbv3VU+/CPPofmVzwoyrT/cBYNwuG1l0SpbpwmrQwVsv5YZwFv8Kw6 Dx1rD15Y3z4JMOB/7pozgKyzADyOOM8ptoM3ziK93ncBMae2Gg57FgwzkabPVPo+DvMg S3v4SzG4nosa8KPjigJKEg10yGTaqGVs2sOVD9aN4hsUMDRDZNGn8z9x7NxFIRgM9o8r PsDyChdt2w32tlGISkXUf2Tx7BKSI0vYykpapOmaywcVi22C50jp4Lsn0J58pkomD4VE 8SeZ5l0VDM28AVPm+4FR4bxNVkkgxdPqN6EXi4uRi+4xUcwekd8Y+RodIwQzqWV5FIae 8oyQ== X-Gm-Message-State: ANoB5pnrD9wbFNQv0L+A565zHMdQeLMGTE0WMvhSeuPQYqcjgRnRvxZz VyNcmTzY6vLVGV4DgOvyeA9W1LnBTwAYHQ== X-Google-Smtp-Source: AA0mqf776Ls7iEIplNJANnecNoE8bcN5Xr/bW7Ap/UWRiwTpsId1B0vgXlwLHmLHMKf0ePUo0KQbfg== X-Received: by 2002:ac8:474b:0:b0:3a5:177d:d9cb with SMTP id k11-20020ac8474b000000b003a5177dd9cbmr6770535qtp.64.1668288098440; Sat, 12 Nov 2022 13:21:38 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:38 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 07/14] serial: liteuart: rx loop should only ack rx events Date: Sat, 12 Nov 2022 16:21:18 -0500 Message-Id: <20221112212125.448824-8-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org While receiving characters, it is necessary to acknowledge each one by writing to the EV_PENDING register's EV_RX bit. Ensure we do not also gratuitously set the EV_TX bit in the process. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index ff3486860989..b5ab48aa35cf 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -81,7 +81,7 @@ static void liteuart_timer(struct timer_list *t) port->icount.rx++; /* necessary for RXEMPTY to refresh its value */ - litex_write8(membase + OFF_EV_PENDING, EV_TX | EV_RX); + litex_write8(membase + OFF_EV_PENDING, EV_RX); /* no overflow bits in status */ if (!(uart_handle_sysrq_char(port, ch))) From patchwork Sat Nov 12 21:21:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624410 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 20216C43219 for ; Sat, 12 Nov 2022 21:22:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235153AbiKLVV5 (ORCPT ); Sat, 12 Nov 2022 16:21:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235096AbiKLVVl (ORCPT ); Sat, 12 Nov 2022 16:21:41 -0500 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71A4115A36; Sat, 12 Nov 2022 13:21:40 -0800 (PST) Received: by mail-qk1-x732.google.com with SMTP id d7so2946169qkk.3; Sat, 12 Nov 2022 13:21:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ysSI5FqkSkAdCqfOrlzY0olMSzKAxmyo3p2qEMQhEV8=; b=ZeyUCP31FCfmExvkf6Z0PI3w/Y3U89wZ6yeeShdpc9LKg74ByWcgDc6K2MlMp+L3vp aBgE7tlx/NrajJNENJ9ZTtfQ10AICFYsDmvDmhMx/P991C/a+GfbpSWFs3/GGTXPzaja GVTA5/NjS8EbKhFKOR9T6LQXFaMpgcY/5uY5a5xC/jVJTLHlublOHO77C0L47/GPoIlX OIe4k0j/iqWSv7jPkEoTUu8nfuhrhGaJJaN8GWQV9SzWP0bISpZjZmNw6ropLOkOQd27 oG8ZNmZ5eki4OWdErFlGDEXGg25/AW8fzcFHwZYehthrg2ZWjMwZB8AN305JrfodBWX5 uZDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ysSI5FqkSkAdCqfOrlzY0olMSzKAxmyo3p2qEMQhEV8=; b=NFx3Q8hRDD7WAItUEaY0zPwq8uc6LQVMz5XyilYCTkajX7aF8NvdFvFun0tRGamEHi PH3+C0NTQ2UsUSn2YXA4chMi0nh5KQ0Iktp0vc4A14NxIFw1eDTKsyBST0YFRcqo0bVD 9ZCqW7GEUapDR0QKa+UTUgtt0nl4E/MrmKCKJ15YDzq22za17xHGbZxx8uppqrzA5kyJ 6Tq3AzkT5/4HyisM5GcZb+zhj0ZIzB5GmoKjYVbVybPR6H1Q7wovQgYP5HHBpDYV9RE2 6w/dQ8OyZrKKo6iIJ4MIUETVxnaUQXKHah07Uwmwm3iMtlaw8P5x7N1NwlYNQGUQn5so y6+A== X-Gm-Message-State: ANoB5pmz9yW7qFb69i0MrnyYkAcxwVVXhcqVjsFtwzfJWENGOjY55Pot 5OYOqOrwCGmc1lDYkXZNCCDkIqseI1VLTQ== X-Google-Smtp-Source: AA0mqf72dmQ34/r2PT7PVsQdiLQttJYIn7qr+jCqsdUHzdd5vAjMZom7J6AkmdwZFn0vjw5wbj39uQ== X-Received: by 2002:a05:620a:179f:b0:6fa:3f37:5af with SMTP id ay31-20020a05620a179f00b006fa3f3705afmr6091048qkb.572.1668288099339; Sat, 12 Nov 2022 13:21:39 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:39 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 08/14] serial: liteuart: simplify passing of uart_insert_char() flag Date: Sat, 12 Nov 2022 16:21:19 -0500 Message-Id: <20221112212125.448824-9-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Simply provide the hard-coded TTY_NORMAL flag to uart_insert_char() directly -- no need to dedicate a variable for that exclusive purpose. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index b5ab48aa35cf..e9e99d6b5fef 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -72,7 +72,6 @@ static void liteuart_timer(struct timer_list *t) struct liteuart_port *uart = from_timer(uart, t, timer); struct uart_port *port = &uart->port; unsigned char __iomem *membase = port->membase; - unsigned int flg = TTY_NORMAL; int ch; unsigned long status; @@ -85,7 +84,7 @@ static void liteuart_timer(struct timer_list *t) /* no overflow bits in status */ if (!(uart_handle_sysrq_char(port, ch))) - uart_insert_char(port, status, 0, ch, flg); + uart_insert_char(port, status, 0, ch, TTY_NORMAL); } tty_flip_buffer_push(&port->state->port); From patchwork Sat Nov 12 21:21:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624544 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 A475CC4167D for ; Sat, 12 Nov 2022 21:22:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231530AbiKLVWD (ORCPT ); Sat, 12 Nov 2022 16:22:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235116AbiKLVVr (ORCPT ); Sat, 12 Nov 2022 16:21:47 -0500 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8541E16591; Sat, 12 Nov 2022 13:21:41 -0800 (PST) Received: by mail-qk1-x735.google.com with SMTP id x18so5339982qki.4; Sat, 12 Nov 2022 13:21:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5/vT56mbrwM9r6/VHK5niKCx7aUlk+R45UC8FZrUKyA=; b=LRpW5kHwxusY1glBj850u+y7jQrP+SZ4AoSXheoTDc/JGlIHoxkT9bc9bSuF7S3jLG /Ki2s9AkagchVVQJKhqcLhqIJvS4JR2XP+ReMt6Bpb2zDphebqhcEJE28YAsy7+mzuzj xoE2gD6w9NnGjXVWDkiBH+SEhS1KKDzOi8btIjN/Wvu8HAewxJakolR80VC9wH9kINiu Y1i0J5D2pZ6aFQ40qaYrEidgql8uVwWmxBPfD9nETNI/gkeJLLw8ouXePznGbijjXwV4 XFOV+sWwQhWcARjjRQsGclr8rtPhwofxeyX+486E/S337wFeDIEUwuQwVrvNRb7LjobI 4rQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5/vT56mbrwM9r6/VHK5niKCx7aUlk+R45UC8FZrUKyA=; b=tno0HuZgkOUlrKmM18UVTRAzP1KtlZ/krUACK7wwJm3LsuMayshTT/A6VDN3cEpxJm JX03x14Ac5ETaPCY0Wkfi+eVbzOmNnB7bbuqIaM+2j4rfEdS3nv6ey2yJtJjQC/XGUvl HGvcvvDZir6KLtsckUXx+OXRFmvj9pqJIUsGhLfLSviZXEwA0N/gIU+D0EyRlmqpcjWc w6FxCFQ6djRHRo6PxZ2kyrG7DsHFMhQppcQ1t0VMvwxqg4aIxID2JjMoGsAAXle2JrCB 0s434Lc1Pidat8iGr3l/k46+uqD69ZvS3IPiL/ld1FiqQPVeqzj0Aog6vZBLZNCnRkXi ue1w== X-Gm-Message-State: ANoB5pnn0oj6GK98SKOx8GMavCiP4qXlzL+WezBwUmrjRLJ5QXzN4T22 Q0jRMQx+xNIlU9V4MdsFJvA0S3c9ZakG1Q== X-Google-Smtp-Source: AA0mqf4YaY9nZ6a3ag/GiPM1XvnCMeIf/MoycyD5j0uRqMGYw6uQhwWYdONqr7yCei+iuU7KszQ/3Q== X-Received: by 2002:a05:620a:a15:b0:6fa:19c4:a6c7 with SMTP id i21-20020a05620a0a1500b006fa19c4a6c7mr6192955qka.51.1668288100251; Sat, 12 Nov 2022 13:21:40 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:39 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 09/14] serial: liteuart: fix rx loop variable types Date: Sat, 12 Nov 2022 16:21:20 -0500 Message-Id: <20221112212125.448824-10-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Update variable types to match the signature of uart_insert_char() which consumes them. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index e9e99d6b5fef..974da0f73257 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -72,8 +72,7 @@ static void liteuart_timer(struct timer_list *t) struct liteuart_port *uart = from_timer(uart, t, timer); struct uart_port *port = &uart->port; unsigned char __iomem *membase = port->membase; - int ch; - unsigned long status; + unsigned int status, ch; while ((status = !litex_read8(membase + OFF_RXEMPTY)) == 1) { ch = litex_read8(membase + OFF_RXTX); From patchwork Sat Nov 12 21:21:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624409 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 EEAF3C4332F for ; Sat, 12 Nov 2022 21:22:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235091AbiKLVWE (ORCPT ); Sat, 12 Nov 2022 16:22:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235119AbiKLVVr (ORCPT ); Sat, 12 Nov 2022 16:21:47 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0A7515738; Sat, 12 Nov 2022 13:21:41 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id e15so4887341qts.1; Sat, 12 Nov 2022 13:21:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v7F9S0T1jHPDEpUbaqxSzeQEs/x70iRlU8Bxi6Hwul4=; b=M7PJUojqhBgBIoTiJebAXTjImoD1KkEFisgCsYlzPUNHuCQRlkjwR9stkG9PF7z0x/ BZzqxU1PyElsSgNZpC+9oRV1gbQ/4Duo2N8VEEs8aD+rr3CjwB3d9OKRrfmoX7gZh6pe dZAG/kNmGWEYbtBjN9gHSwEviFgjbCHJHizx9XpyRWyT8yLDlDpCoVq6azmZcUY/nE+z hVSUA5ykZpvZ4FZZJ7+Qv5hLruFoE6NiqIEHxAct9r9hscqzri+4WDCrrcjgpt8KtHSW 0fy/c/UYYrlXcqi9RsSuK2YpRLGMM2jXGNf03ZIcCY3x89HQBXB4QyJ7sb5vJtjrq7Kl hcEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v7F9S0T1jHPDEpUbaqxSzeQEs/x70iRlU8Bxi6Hwul4=; b=xV+hnMKd4iMm8ZhJHE7iFWOY/SL4DEFA+Ic0IJIzAbwDoEt6ylNgouDwG4sszt89oJ 0IcFbJQBMph6gvMxp0NeOPtaDURyh2RhbDsJDWLFQycd8w4PRr6XM/bmv5kZNVximjrG BpZsw9pOJ+G7quV02eVNK4YC272JDyw93bN3qZHhR8p9GqWwIIYi6d7TvZgyFIigkkRE 3SZYoqdgUeptwIbvDI6/RJcPyaHV7cEcJXGds7d3aRKanAoMl8MtZzJsmWYhyrjBd54O ExesEy+6NZfmu4mI8eRCRsBeaLLUCPJEIQeZnpHveXbzl4Dbes614B3d4n0XObxWqHMr IaCw== X-Gm-Message-State: ANoB5pmFTX4YcweYKZKVQotjq53CLY6CrvannIMk6V52Qj9ob1MeYDzp xhXTnWirwgG9Oi+BWP8ccoS8tymzwulirQ== X-Google-Smtp-Source: AA0mqf43IC6vi/w6Ldd2KMRXHNrZv5G/4wrr5jT0RwmAm99lfaLg8z5ejQAZqHR5ZPHhiZH1/pTjuw== X-Received: by 2002:a05:622a:1714:b0:3a5:2029:df77 with SMTP id h20-20020a05622a171400b003a52029df77mr6659600qtk.225.1668288101159; Sat, 12 Nov 2022 13:21:41 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:40 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 10/14] serial: liteuart: separate rx loop from poll timer Date: Sat, 12 Nov 2022 16:21:21 -0500 Message-Id: <20221112212125.448824-11-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Convert the rx loop into its own dedicated function, and (for now) call it from the poll timer. This is in preparation for adding irq support to the receive path. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index 974da0f73257..172ac190ba2f 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -67,10 +67,8 @@ static struct uart_driver liteuart_driver = { #endif }; -static void liteuart_timer(struct timer_list *t) +static void liteuart_rx_chars(struct uart_port *port) { - struct liteuart_port *uart = from_timer(uart, t, timer); - struct uart_port *port = &uart->port; unsigned char __iomem *membase = port->membase; unsigned int status, ch; @@ -87,6 +85,14 @@ static void liteuart_timer(struct timer_list *t) } tty_flip_buffer_push(&port->state->port); +} + +static void liteuart_timer(struct timer_list *t) +{ + struct liteuart_port *uart = from_timer(uart, t, timer); + struct uart_port *port = &uart->port; + + liteuart_rx_chars(port); mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); } From patchwork Sat Nov 12 21:21:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624543 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 227DFC433FE for ; Sat, 12 Nov 2022 21:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235021AbiKLVWI (ORCPT ); Sat, 12 Nov 2022 16:22:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235133AbiKLVVx (ORCPT ); Sat, 12 Nov 2022 16:21:53 -0500 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46D4717E27; Sat, 12 Nov 2022 13:21:43 -0800 (PST) Received: by mail-qt1-x82e.google.com with SMTP id z6so4875247qtv.5; Sat, 12 Nov 2022 13:21:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fmWYDGpb8IgSQuNUIhuOc4E9EPEFJS+O6JKsCfcl04A=; b=cvlZfzUOE4fIt0ylPCWhzQf5qAHZnEqXbhj8O+qwvQOTp4EJud9fQeAEZPphl3kdWC KXVmf1d4Cp4xQGd6zioJfGaWmsThJ/ry6Hh0tsg7FkQJVMzAD5cB7nFDi9Lu97XAQWSt rIIQ8v33Hyrywe9aN32h69DZD/61u/oKTT/tApu1+E9njOKD9CxGhTgw1MpPh7iCk1Zw 1RoHqqLgjnCdanRFmdemtNvyuJYkW/LiE3pH3+FxKFSRyKJ7TZVoVfPLrI0gMltOZeSS 9hyggEiXSseJvROugFk6g/hbl6lZGA4RikQYGrmcZBSi7expFOcDLtWwH+84m3tsheyo 6g1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fmWYDGpb8IgSQuNUIhuOc4E9EPEFJS+O6JKsCfcl04A=; b=z2C/v2+ZUjC+vHj2Z6tgorPZqRTisFhfzZv2WVEyK6cY6N61p3JTM1StTmKI2orHO5 1Y0AHRQnld30vddi1u8Sc4R5ysVlTxi0kiy/za3PVUmiOmW8zY2652cq/9qvMq4jI0J3 ivAn6cYMcI9K212hFQ2CctKQQNeKsWVBTedkHRhulfOqcrFsTznI5l4vVEEfX/+krBCa Nj7lGMtO+xD2wuNV6TOlADEr54nBcxp7yhR8Tyvb9EwMxib9A4UvoI5GOGmcsFEWsulz aJ0tlAgepWIRdvXkXmT4kRsBfBFPQesWu66nHbUewcwgFb9NMpWPm0AWIfIDdkPE7ExM X7hg== X-Gm-Message-State: ANoB5pmZKipNdMltnZ9gyBsCRedk+hdgOmMpOgYuX6fgB36zoB4MtWkd S84Mm5kDB7Ri4ACD/YyN7y1AWbvKFNAzyw== X-Google-Smtp-Source: AA0mqf4mbOHSoDknDH/1f83OctrJlSQPBqDcY3z5fUZm5qe2VaS7RWdHVzq69d8Dxr95QyPJj1VKUQ== X-Received: by 2002:ac8:118f:0:b0:3a5:9191:da4c with SMTP id d15-20020ac8118f000000b003a59191da4cmr6741736qtj.540.1668288102087; Sat, 12 Nov 2022 13:21:42 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:41 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 11/14] serial: liteuart: move function definitions Date: Sat, 12 Nov 2022 16:21:22 -0500 Message-Id: <20221112212125.448824-12-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Move definitions for liteuart_[stop|start]_tx(), liteuart_stop_rx(), and liteuart_putchar() to a more convenient location in preparation for adding IRQ support. This patch contains no functional changes. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 98 +++++++++++++++++------------------ 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index 172ac190ba2f..cf1ce597b45e 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -67,36 +67,6 @@ static struct uart_driver liteuart_driver = { #endif }; -static void liteuart_rx_chars(struct uart_port *port) -{ - unsigned char __iomem *membase = port->membase; - unsigned int status, ch; - - while ((status = !litex_read8(membase + OFF_RXEMPTY)) == 1) { - ch = litex_read8(membase + OFF_RXTX); - port->icount.rx++; - - /* necessary for RXEMPTY to refresh its value */ - litex_write8(membase + OFF_EV_PENDING, EV_RX); - - /* no overflow bits in status */ - if (!(uart_handle_sysrq_char(port, ch))) - uart_insert_char(port, status, 0, ch, TTY_NORMAL); - } - - tty_flip_buffer_push(&port->state->port); -} - -static void liteuart_timer(struct timer_list *t) -{ - struct liteuart_port *uart = from_timer(uart, t, timer); - struct uart_port *port = &uart->port; - - liteuart_rx_chars(port); - - mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); -} - static void liteuart_putchar(struct uart_port *port, unsigned char ch) { while (litex_read8(port->membase + OFF_TXFULL)) @@ -105,25 +75,6 @@ static void liteuart_putchar(struct uart_port *port, unsigned char ch) litex_write8(port->membase + OFF_RXTX, ch); } -static unsigned int liteuart_tx_empty(struct uart_port *port) -{ - /* not really tx empty, just checking if tx is not full */ - if (!litex_read8(port->membase + OFF_TXFULL)) - return TIOCSER_TEMT; - - return 0; -} - -static void liteuart_set_mctrl(struct uart_port *port, unsigned int mctrl) -{ - /* modem control register is not present in LiteUART */ -} - -static unsigned int liteuart_get_mctrl(struct uart_port *port) -{ - return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; -} - static void liteuart_stop_tx(struct uart_port *port) { /* not used in LiteUART, but called unconditionally from serial_core */ @@ -159,6 +110,55 @@ static void liteuart_stop_rx(struct uart_port *port) del_timer(&uart->timer); } +static void liteuart_rx_chars(struct uart_port *port) +{ + unsigned char __iomem *membase = port->membase; + unsigned int status, ch; + + while ((status = !litex_read8(membase + OFF_RXEMPTY)) == 1) { + ch = litex_read8(membase + OFF_RXTX); + port->icount.rx++; + + /* necessary for RXEMPTY to refresh its value */ + litex_write8(membase + OFF_EV_PENDING, EV_RX); + + /* no overflow bits in status */ + if (!(uart_handle_sysrq_char(port, ch))) + uart_insert_char(port, status, 0, ch, TTY_NORMAL); + } + + tty_flip_buffer_push(&port->state->port); +} + +static void liteuart_timer(struct timer_list *t) +{ + struct liteuart_port *uart = from_timer(uart, t, timer); + struct uart_port *port = &uart->port; + + liteuart_rx_chars(port); + + mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); +} + +static unsigned int liteuart_tx_empty(struct uart_port *port) +{ + /* not really tx empty, just checking if tx is not full */ + if (!litex_read8(port->membase + OFF_TXFULL)) + return TIOCSER_TEMT; + + return 0; +} + +static void liteuart_set_mctrl(struct uart_port *port, unsigned int mctrl) +{ + /* modem control register is not present in LiteUART */ +} + +static unsigned int liteuart_get_mctrl(struct uart_port *port) +{ + return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; +} + static int liteuart_startup(struct uart_port *port) { struct liteuart_port *uart = to_liteuart_port(port); From patchwork Sat Nov 12 21:21:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624408 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 6C500C433FE for ; Sat, 12 Nov 2022 21:22:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235133AbiKLVWV (ORCPT ); Sat, 12 Nov 2022 16:22:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235145AbiKLVVy (ORCPT ); Sat, 12 Nov 2022 16:21:54 -0500 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31D7D18E32; Sat, 12 Nov 2022 13:21:44 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id d8so2115611qki.13; Sat, 12 Nov 2022 13:21:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K4iHEj9GzsVhhsWXwgpXJUYpNlSEHLmzm/JsgBx/hzw=; b=EZSQB4szI1sqawbShitBG+hzdiK94qL8rotIka8T4R2AOXMEXnwnsPqjgi0OFSykcR Wj4xQgi5MSxXfhOOaNDiM2udoMgu+tPEn+eygOQeSbf2fE+0isZpODtq5sInTDiNFfye yJ4PG6QLktQy4Tz4QvFL+F2xMu6f05Xzl+PJcOX0PKSwhSE+QuTgeVO4oO1VeG4v/Vio E4KRfk9aL48mSGN+rA0AD4VYJLfISEQP4jrCdHnN/Q3v+QpJum/aX6sb8O3Dgy/210Ld mudcSj1Ci/sDA6Lnp91oChlRxHP9T+ZOtGiDz6lJjqo3Oj0kXH/cEvso/8OtCmyWtNk1 YLJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K4iHEj9GzsVhhsWXwgpXJUYpNlSEHLmzm/JsgBx/hzw=; b=42djFdXAMGNw/iua9V+o9Qcz/Tj24F63EFa1kSg/nh3nlaKNaDXANUQI2weQUahW+j HjxPPpzi5Phg35X/ZJW7TYfx6YI6YhqZOaUekeoCjcgGAP9AKjkHyEYFS1ff3dmuGPZs X4gv5Ga9m14rrAOoVROqgxm66ath6f0joAxCJrzjpdE6rhSZ/ttnDAQJpCSiJ3/B3MTp fgbkW1MHGzKI3aw7zyIpc5MeaiFFa+oCF+pxFas//bg/2/vBD8U62/++EwOmF7TUzjog gdomPSytF/UuS4stg9coAkjfIzT0Z5l9ZcLXLOoLWu2HR2WKJ7I/VzqEhkmeaiVxIQsH 4+UA== X-Gm-Message-State: ANoB5pkNPsmea2QhfUoyNXbCOg4GTBkjzFsacdPMDhlEPH54sChTOMVi GlhvL9hD7zKelVe2RUqiiFzAK1YSXYkFDA== X-Google-Smtp-Source: AA0mqf7kqd9AcWKjMOWpFgbx6/iBsL2fXv3FyvWzV6AzGX32D/t7+8FzKy/VHkdItv3i7ioTfW2/Eg== X-Received: by 2002:a37:86c3:0:b0:6fa:d7e:7b4 with SMTP id i186-20020a3786c3000000b006fa0d7e07b4mr6006823qkd.373.1668288103069; Sat, 12 Nov 2022 13:21:43 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:42 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 12/14] serial: liteuart: add IRQ support for the RX path Date: Sat, 12 Nov 2022 16:21:23 -0500 Message-Id: <20221112212125.448824-13-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Add support for IRQ-driven RX. Support for the TX path will be added in a separate commit. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 61 +++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index cf1ce597b45e..e30adb30277f 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -130,13 +131,29 @@ static void liteuart_rx_chars(struct uart_port *port) tty_flip_buffer_push(&port->state->port); } +static irqreturn_t liteuart_interrupt(int irq, void *data) +{ + struct liteuart_port *uart = data; + struct uart_port *port = &uart->port; + u8 isr = litex_read8(port->membase + OFF_EV_PENDING); + + /* for now, only rx path triggers interrupts */ + isr &= EV_RX; + + spin_lock(&port->lock); + if (isr & EV_RX) + liteuart_rx_chars(port); + spin_unlock(&port->lock); + + return IRQ_RETVAL(isr); +} + static void liteuart_timer(struct timer_list *t) { struct liteuart_port *uart = from_timer(uart, t, timer); struct uart_port *port = &uart->port; - liteuart_rx_chars(port); - + liteuart_interrupt(0, port); mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); } @@ -162,19 +179,42 @@ static unsigned int liteuart_get_mctrl(struct uart_port *port) static int liteuart_startup(struct uart_port *port) { struct liteuart_port *uart = to_liteuart_port(port); + int ret; + u8 irq_mask = 0; - /* disable events */ - litex_write8(port->membase + OFF_EV_ENABLE, 0); + if (port->irq) { + ret = request_irq(port->irq, liteuart_interrupt, 0, + KBUILD_MODNAME, uart); + if (ret == 0) { + /* only enable rx interrupts at this time */ + irq_mask = EV_RX; + } else { + pr_err(pr_fmt("line %d irq %d failed: using polling\n"), + port->line, port->irq); + port->irq = 0; + } + } - /* prepare timer for polling */ - timer_setup(&uart->timer, liteuart_timer, 0); - mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); + if (!port->irq) { + timer_setup(&uart->timer, liteuart_timer, 0); + mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); + } + + litex_write8(port->membase + OFF_EV_ENABLE, irq_mask); return 0; } static void liteuart_shutdown(struct uart_port *port) { + struct liteuart_port *uart = to_liteuart_port(port); + + litex_write8(port->membase + OFF_EV_ENABLE, 0); + + if (port->irq) + free_irq(port->irq, port); + else + del_timer_sync(&uart->timer); } static void liteuart_set_termios(struct uart_port *port, struct ktermios *new, @@ -263,6 +303,13 @@ static int liteuart_probe(struct platform_device *pdev) goto err_erase_id; } + /* get irq */ + ret = platform_get_irq_optional(pdev, 0); + if (ret < 0 && ret != -ENXIO) + return ret; + if (ret > 0) + port->irq = ret; + /* values not from device tree */ port->dev = &pdev->dev; port->iotype = UPIO_MEM; From patchwork Sat Nov 12 21:21:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624542 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 B2460C433FE for ; Sat, 12 Nov 2022 21:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235216AbiKLVWV (ORCPT ); Sat, 12 Nov 2022 16:22:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235159AbiKLVV6 (ORCPT ); Sat, 12 Nov 2022 16:21:58 -0500 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3441418E3F; Sat, 12 Nov 2022 13:21:45 -0800 (PST) Received: by mail-qk1-x736.google.com with SMTP id z1so5323835qkl.9; Sat, 12 Nov 2022 13:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RnlgHyHxWkwP8NBkj8ItqSrcSz+jgPdiCkwmRSzVrD8=; b=N/5v4fSSSIAGk863cGwJ2LOZwHTkOlTFVZw5GBTZwG0fYggDGLhFLWEbS3SyaPoxGu bybG+F5QBHDGxXXIBEQAVFBTapHVzBwoE4+bix/ZqF+Zv6THz+qlPHG6LJAXOI2ieBi9 y5clfWPmRUsCgTSXm8Xg7XCFeWCHRRKfjZT+cayXiy7b1OKRMJRFOWcsHJT78V5laOI6 5qwdJVRt70KJt8CWEzCWWv+obmTrj2EFiRAv2FXVZVC6IIpvboeCwA5r5c+Vk+9cqf7B 1Z9snQ+4S8f6LCk7FilZj32bZUGhtTrESff7AGqGj5kEUoXJGOquWGl7iqr9XP8cz+jm +5NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RnlgHyHxWkwP8NBkj8ItqSrcSz+jgPdiCkwmRSzVrD8=; b=PubWIGmneq80zX3VUf/ZugHI7xLOwb8sIXb0z7V5TBK96Vl24nMMMSqrwQWu/grMYi DfTyyXtHbphLfNKdGLsBUcgvgRoZjQ9RAtmlHNkWZBge3YnxIWZnoVs4RFie1gP1zL5o S/q6VRJapN68YWxXUgjpcP8PyOgicjzrpWQUqqMUaQXTCVTGuN7XKwYGTz5hQPBxARcS mOsTmXyTpb4gcspuHaQo7HKdP1AWhLdirgXJ0ppntgy9sWtscx3RksycQx9WOrWQpbjb 7TalEiBOOvzvVlvJeYD1l0TksD1jW2R1aAmvCnaW39+ZDw2EtonSbFcOP5IMK5P06F/m f9eg== X-Gm-Message-State: ANoB5pnJKyVZNxAVUJvGgQOvE+Ol8Yc63VEmmsTpXkKSwpzX9Hwo7xxR pkWOakNUrobqo4dw7LZff8P0SFXn3QfwsA== X-Google-Smtp-Source: AA0mqf43wYR7w8wXm1JYc0EdjmCyTS+k0PyPOi4hh0jDhhXV/dw+Qdm1ofeA0z0DScZZuFPDEw0Hig== X-Received: by 2002:a05:620a:1202:b0:6fa:5f94:8b16 with SMTP id u2-20020a05620a120200b006fa5f948b16mr5871509qkj.215.1668288103983; Sat, 12 Nov 2022 13:21:43 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:43 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 13/14] serial: liteuart: add IRQ support for the TX path Date: Sat, 12 Nov 2022 16:21:24 -0500 Message-Id: <20221112212125.448824-14-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Modify the TX path to operate in an IRQ-compatible way, while maintaining support for polling mode via the poll timer. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 67 ++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index e30adb30277f..307c27398e30 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -46,6 +46,7 @@ struct liteuart_port { struct uart_port port; struct timer_list timer; u32 id; + bool poll_tx_started; }; #define to_liteuart_port(port) container_of(port, struct liteuart_port, port) @@ -78,29 +79,24 @@ static void liteuart_putchar(struct uart_port *port, unsigned char ch) static void liteuart_stop_tx(struct uart_port *port) { - /* not used in LiteUART, but called unconditionally from serial_core */ + if (port->irq) { + u8 irq_mask = litex_read8(port->membase + OFF_EV_ENABLE); + litex_write8(port->membase + OFF_EV_ENABLE, irq_mask & ~EV_TX); + } else { + struct liteuart_port *uart = to_liteuart_port(port); + uart->poll_tx_started = false; + } } static void liteuart_start_tx(struct uart_port *port) { - struct circ_buf *xmit = &port->state->xmit; - unsigned char ch; - - if (unlikely(port->x_char)) { - litex_write8(port->membase + OFF_RXTX, port->x_char); - port->icount.tx++; - port->x_char = 0; - } else if (!uart_circ_empty(xmit)) { - while (xmit->head != xmit->tail) { - ch = xmit->buf[xmit->tail]; - xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); - port->icount.tx++; - liteuart_putchar(port, ch); - } + if (port->irq) { + u8 irq_mask = litex_read8(port->membase + OFF_EV_ENABLE); + litex_write8(port->membase + OFF_EV_ENABLE, irq_mask | EV_TX); + } else { + struct liteuart_port *uart = to_liteuart_port(port); + uart->poll_tx_started = true; } - - if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) - uart_write_wakeup(port); } static void liteuart_stop_rx(struct uart_port *port) @@ -131,18 +127,47 @@ static void liteuart_rx_chars(struct uart_port *port) tty_flip_buffer_push(&port->state->port); } +static void liteuart_tx_chars(struct uart_port *port) +{ + struct circ_buf *xmit = &port->state->xmit; + + if (unlikely(port->x_char)) { + litex_write8(port->membase + OFF_RXTX, port->x_char); + port->x_char = 0; + port->icount.tx++; + return; + } + + while (!litex_read8(port->membase + OFF_TXFULL)) { + if (xmit->head == xmit->tail) + break; + litex_write8(port->membase + OFF_RXTX, xmit->buf[xmit->tail]); + xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); + port->icount.tx++; + } + + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) + uart_write_wakeup(port); + + if (uart_circ_empty(xmit)) + liteuart_stop_tx(port); +} + static irqreturn_t liteuart_interrupt(int irq, void *data) { struct liteuart_port *uart = data; struct uart_port *port = &uart->port; u8 isr = litex_read8(port->membase + OFF_EV_PENDING); - /* for now, only rx path triggers interrupts */ - isr &= EV_RX; + if (!(port->irq || uart->poll_tx_started)) + isr &= ~EV_TX; /* polling mode with tx stopped */ spin_lock(&port->lock); if (isr & EV_RX) liteuart_rx_chars(port); + if (isr & EV_TX) { + liteuart_tx_chars(port); + } spin_unlock(&port->lock); return IRQ_RETVAL(isr); @@ -196,6 +221,7 @@ static int liteuart_startup(struct uart_port *port) } if (!port->irq) { + uart->poll_tx_started = false; timer_setup(&uart->timer, liteuart_timer, 0); mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); } @@ -210,6 +236,7 @@ static void liteuart_shutdown(struct uart_port *port) struct liteuart_port *uart = to_liteuart_port(port); litex_write8(port->membase + OFF_EV_ENABLE, 0); + uart->poll_tx_started = false; if (port->irq) free_irq(port->irq, port); From patchwork Sat Nov 12 21:21:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 624407 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 3A434C4332F for ; Sat, 12 Nov 2022 21:22:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235174AbiKLVWW (ORCPT ); Sat, 12 Nov 2022 16:22:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235167AbiKLVWB (ORCPT ); Sat, 12 Nov 2022 16:22:01 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 911C119013; Sat, 12 Nov 2022 13:21:45 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id e15so4887413qts.1; Sat, 12 Nov 2022 13:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4NCT7lY3J4rHEmB/eCMozFwPMR+2ENWLul3W/EW/Ce8=; b=ibBpN+mSBrLOruOHKikiQOy1KhKqal2y5bUcjXK4ClO1BHI2gzyH4zxhWvr14HLmtj aVcfH3Qd6G27BpBpmWlIyzjJGeUZ5QabY+U/uyl/QrZpraxCO7yYR/1tRDYlK7YTnOx9 AaEpn5kCukLOB3mJlw778PfWrLuvvIEHRjWvwbHHJuP/3KOf7rvS4e6gR58PlCX5tApD Mj2yTab+sc8N4mbgrCx8Q8pP9jteZ9U3DDcXgUBkJOUf7tqs6AWXx3Ljg7XQ6nHexUCB 3kYXez+RbpGpEXrrPilWX6q0GGXwRxaeetxJZSmHh/BWV08BOTi26YYOSXKyT1fgCLOD d7zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4NCT7lY3J4rHEmB/eCMozFwPMR+2ENWLul3W/EW/Ce8=; b=ejdLDZgqZDSBch7ozxThNUlzg8G7Zm0m9DLBz04k/6UIhk0CDSTu88KQy1qACON5Oh P7AMFoSi4aljHPgMDBH5Qpc1uyEoHNAcjNbhNAVe0FVv9+Tqbvrzh9MD4GnvU6f9B9CD eDGxQZL15SPGGot3A9L1S6jgF1nO8Gosp66ULVmmGkNydw3eXpy7YQ+Kt15KPojrMJyn 1KJxRdWGWPzhD/RyIjDacbeLn6AkPDIBYaYg3FFolE3cG4d8kqwShn5ikF1rZgfgR6WO W/V+0ja5YSY450tdNgjOer4abzjTgbxbUQnaQ5rFkyO14EPHps/bmDjHFyLWtyjK6klM 1NVw== X-Gm-Message-State: ANoB5pktSJIY2SfYAaYTHr/Bhi+UurH9/E1rfZ49fzRC9snfxO6A/oGN pSuTfD63HYmMp1u8UzXRxmLA++cbocos/w== X-Google-Smtp-Source: AA0mqf4kGIjc6Cyy47M1gqYvdf3SoZIo7BjrXdBvoBI3boGlCxQookuql8wSIQfiQ5csBfaoARLkYQ== X-Received: by 2002:a05:622a:1c0d:b0:3a5:21f0:39f0 with SMTP id bq13-20020a05622a1c0d00b003a521f039f0mr6848653qtb.10.1668288104961; Sat, 12 Nov 2022 13:21:44 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id t8-20020a37ea08000000b006fa313bf185sm3811839qkj.8.2022.11.12.13.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 13:21:44 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org Subject: [PATCH v3 14/14] serial: liteuart: move polling putchar() function Date: Sat, 12 Nov 2022 16:21:25 -0500 Message-Id: <20221112212125.448824-15-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221112212125.448824-1-gsomlo@gmail.com> References: <20221112212125.448824-1-gsomlo@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The polling liteuart_putchar() function is only called from methods conditionally enabled by CONFIG_SERIAL_LITEUART_CONSOLE. Move its definition closer to the console code where it is dependent on the same config option. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index 307c27398e30..767c356e60c9 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -69,14 +69,6 @@ static struct uart_driver liteuart_driver = { #endif }; -static void liteuart_putchar(struct uart_port *port, unsigned char ch) -{ - while (litex_read8(port->membase + OFF_TXFULL)) - cpu_relax(); - - litex_write8(port->membase + OFF_RXTX, ch); -} - static void liteuart_stop_tx(struct uart_port *port) { if (port->irq) { @@ -389,6 +381,14 @@ static struct platform_driver liteuart_platform_driver = { #ifdef CONFIG_SERIAL_LITEUART_CONSOLE +static void liteuart_putchar(struct uart_port *port, unsigned char ch) +{ + while (litex_read8(port->membase + OFF_TXFULL)) + cpu_relax(); + + litex_write8(port->membase + OFF_RXTX, ch); +} + static void liteuart_console_write(struct console *co, const char *s, unsigned int count) {