From patchwork Wed Apr 26 12:29:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 677483 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 4CD22C77B78 for ; Wed, 26 Apr 2023 12:32:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240891AbjDZMcK (ORCPT ); Wed, 26 Apr 2023 08:32:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240901AbjDZMcJ (ORCPT ); Wed, 26 Apr 2023 08:32:09 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2066.outbound.protection.outlook.com [40.107.92.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B1445FD7; Wed, 26 Apr 2023 05:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WCj7J26wkxUpqUpB2I9TsI5GmnI5YXUDvBy84hBT53y/7FkTizd+XkFGYxnqZ1rmuyF+94QGbEyPO+vQwaaT10JaNbJ90jxLtV//3kBLl7TDA9vxA6Sc1nNlvcmBJk6W6WOhwMjq3tPQESrGSwFbR3e8pztsqN/P4hTDEbHiKnv0dXzr0Bn+Qd9UzOmfadYAwMIENdY+41LB5bcrZPj/vTXQncbVDtxbh5G1oV68cQSRLkLTjuDvZ5vB31HpRnBUhRE89qWs9ThQkj5seSGvgzHO2ZP0u4mGN4pgtGzNXSzMmHCCitmzW9LgBVqBk6A5+3QQGrONOUnwyFUvv3B0LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iqJ//Oo+zLDyplCLQQiefn9lJDoAiKyV4HuW7cJ+/h8=; b=FjfXXAWBTDu6ILXBiZZt2IbskeVJdnooTWtynopffGuVjaaCaS5xxGIsEPy63Bqw06ZYKMEz8hrbDxx/XE64wfBEm0bQBn/PH2UHtat3sSq5i6EstutOdv3L8VhtvAdRd5eYeswx2ywG76FAYau8OFCKFiHxqML6SKbYK8cvldHZUHgfEPvU/fO3mZihvx2fYmYqTtpqPiRrJXmpt+3PaTwF3orbMuq/5FNMGw3nNN6um1+WzNpPXHVcSuJD8O6V4R4mgg2Pttzu/jP+QavS9Ib2SDSxvDunaltWaVIt5pR7IEH6X0JloqcPcOwRHCziYcmrI3yxe6poTzAqn2hpqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iqJ//Oo+zLDyplCLQQiefn9lJDoAiKyV4HuW7cJ+/h8=; b=gTnaRxGKHoyv1qD4gYilQIo6/x/BaGIRJMQnJVNWrb2imaka/NfgXgl8ZBAovnw9GDKXZeRLE2yCwdow9RE6JAQ2qx8wCZ6nnZr48AZhwus3aG8X3g9OGbTgTEupQcCWaLO/G3YFBdDChtgBnrCJmClv6TUDJJISsgAKpVWZ1Q4= Received: from DS7PR03CA0220.namprd03.prod.outlook.com (2603:10b6:5:3ba::15) by CH0PR02MB7914.namprd02.prod.outlook.com (2603:10b6:610:113::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20; Wed, 26 Apr 2023 12:31:34 +0000 Received: from DM3NAM02FT054.eop-nam02.prod.protection.outlook.com (2603:10b6:5:3ba:cafe::3c) by DS7PR03CA0220.outlook.office365.com (2603:10b6:5:3ba::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21 via Frontend Transport; Wed, 26 Apr 2023 12:31:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT054.mail.protection.outlook.com (10.13.5.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.21 via Frontend Transport; Wed, 26 Apr 2023 12:31:33 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 26 Apr 2023 05:31:10 -0700 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Wed, 26 Apr 2023 05:31:10 -0700 Envelope-to: git@amd.com, manikanta.guntupalli@amd.com, michal.simek@amd.com, radhey.shyam.pandey@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, manion05gk@gmail.com, jirislaby@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Received: from [172.23.64.1] (port=50334 helo=xhdvnc101.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1preHc-0004Gj-FL; Wed, 26 Apr 2023 05:30:04 -0700 Received: by xhdvnc101.xilinx.com (Postfix, from userid 90444) id 614E021314; Wed, 26 Apr 2023 17:59:51 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , , CC: , , , , , Manikanta Guntupalli Subject: [PATCH 1/2] dt-bindings: Add optional gpio property to uartps node to support rs485 Date: Wed, 26 Apr 2023 17:59:46 +0530 Message-ID: <1682512187-8828-2-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1682512187-8828-1-git-send-email-manikanta.guntupalli@amd.com> References: <1682512187-8828-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3NAM02FT054:EE_|CH0PR02MB7914:EE_ X-MS-Office365-Filtering-Correlation-Id: 705aef79-bc08-495d-2596-08db46522bc2 X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1pFc56hf4D8GhtgxyJq9+RYGfcCzTLl91Vt/zkH+3kmN5+Qv8sfIhdU0ifyx6g24MH4IFxY3No5epyhU6Un0ppYjAUaznTHnf+u1qo7jtM9s3HZbSltt0WDcTl8yaSD0zzTeqi6TqqpwmVfJX6jY0mSvQTm+lfffxnK0wX2IbleJX5GPijY15J6uAJ2bFBG8Sjy446kgQNie2lCcsiD2qYtovJlyuty3oJ4zJuCsj40fWIoSN3gYhNN68YKwj1FLiBRg+8asN/hIBLsOFcM8e26FCUv7H0RiIOzfw8C6kpl/CIOGeCMWNjoIWp9TtcDcRa7oPfwlI8+suLF4U2TZ63j8me9/C4k984gd6maGNGeQN910EIoiiy125HKeInSTfOghKBvag2GTi6T2NtKLmNoyNMaafwFJ2JPd0m4rJrxPm2Cg2/RxmS/Z6CoQiuBG1Tpc+ww/QsCTQsJaDVbH00XAV2eO6lBGkdHSiNyexN1DH3uN+AcCELVjEqizDeXVaJb9ju+wgORx9hVPaCVCrraY93qvEtAWf/4zkP/B86rI/BkFHy40jFQ2heVNHyD+0IctCx/9GdRZSTbTMoInE/sfbla7ca6DY/lM531TOAtFHBjgi2DEuCfthm+Z0BDYhTc+rw8giVGpqmtFkMbhtfGwVmmJHwKuSi6IZBEJ89RPOAyiajwIYoXvsI3dsLX5uwZU/8H2nVhXcr3ukt+pnx3H0iv81/n4k3kGqkGAA0Ctgpv+6yUdWIIDi707bT5f X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(396003)(39860400002)(136003)(376002)(451199021)(46966006)(36840700001)(40470700004)(6266002)(186003)(26005)(42882007)(921005)(82740400003)(356005)(4326008)(40480700001)(5660300002)(316002)(70206006)(70586007)(6666004)(336012)(47076005)(2616005)(36860700001)(41300700001)(82310400005)(36756003)(110136005)(42186006)(6636002)(83170400001)(40460700003)(54906003)(8676002)(8936002)(2906002)(4744005)(7416002)(44832011)(7636003)(478600001)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2023 12:31:33.7526 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 705aef79-bc08-495d-2596-08db46522bc2 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT054.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR02MB7914 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Add optional gpio property to uartps node and add reference to rs485.yaml Signed-off-by: Manikanta Guntupalli --- Documentation/devicetree/bindings/serial/cdns,uart.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/serial/cdns,uart.yaml b/Documentation/devicetree/bindings/serial/cdns,uart.yaml index a8b323d7bf94..34ed0d80b923 100644 --- a/Documentation/devicetree/bindings/serial/cdns,uart.yaml +++ b/Documentation/devicetree/bindings/serial/cdns,uart.yaml @@ -46,6 +46,10 @@ properties: power-domains: maxItems: 1 + txrx-gpios: + description: Optional GPIO to switch transmit and receive modes via pmod. + maxItems: 1 + required: - compatible - reg @@ -55,6 +59,7 @@ required: allOf: - $ref: serial.yaml# + - $ref: rs485.yaml# - if: properties: compatible: From patchwork Wed Apr 26 12:29:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 677484 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 54388C7618E for ; Wed, 26 Apr 2023 12:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240667AbjDZMbV (ORCPT ); Wed, 26 Apr 2023 08:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240547AbjDZMbU (ORCPT ); Wed, 26 Apr 2023 08:31:20 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2041.outbound.protection.outlook.com [40.107.102.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9171B4C04; Wed, 26 Apr 2023 05:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=loG7U5cJ+Z3Pgdc6xcLTSqGj90kjbHHbYlFUWdHJDaPgaW8NaaZ5zrgUfWuQwODsdtTJffAWhr1dmU808TWinEJU8m4dwsidh5xaXJumxNuYN4EjnjyhBzsdzykaXI3xTu02OlrYKfhawtSXFjfeBu8e5rv+5GV9b1lo8zHdsWiskem6bzBvncLS53eDYlayk3d5VvEtUeBWBYvvguoqKArbXHhAP038ZfJwFWIdR5IX1Ygx5FQOBY1gMcHk+Jv3ut6JpSj5QKozgOXPVrfFIewuSxxYykvMvTVmZkb+x7bFN+aYFw3YIdIu/ZDJcbjTz6UwL6biDqRxAfEOvtYQSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=opw2PFF3KyAbkOspTpPzGHVTV2PCAIJhDuzgh8smGOU=; b=NQAD4xQc3RVlDVF32GlwIAG7gZiL7sSB17arYfidSWS9T4FSALkaNxrLcsojI00Swf50GPQxlEO4+tJtH9gpH9HMRJNckgdPCCq02mr30zzvDSmchaSo6echHo7hJ+Fjt6cUocyT80kqfGgecQ5TkogSI9QSa+CNgFop6AKWVU7NaQ7zAYK3aDB4QBiIwYoQPmFK06+yx62wS+EJuwuGhK+sTBFV5+kgBekchGiwczZ9u035jfQtsnGIISCZX7usHkWHNBJ8Pc67rTZnEg75C00QnydqC65io33N+L6gICcsJMO15ZEjTh1yQCxeSWfZ+W6/ozinWLEwCLJ5+l8WSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=amd.com smtp.mailfrom=xilinx.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=opw2PFF3KyAbkOspTpPzGHVTV2PCAIJhDuzgh8smGOU=; b=iWJnzcQaiDMn4z19qccVwzaQvBU61WxSJfadr9s/WbH42rSmlyrcuk8Shh2lnQuRJEm/739yjiAhmpL8VqTLFGQXMhZ4PkyislFHfzZzUUfYJ/lnIAKoEqpGYsCpnTm5sxQpBPFCkXbipM1iaoGhWXirxYgflXYFBH9aeB7notQ= Received: from DM5PR07CA0094.namprd07.prod.outlook.com (2603:10b6:4:ae::23) by CH2PR02MB6791.namprd02.prod.outlook.com (2603:10b6:610:ab::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20; Wed, 26 Apr 2023 12:30:30 +0000 Received: from DM3NAM02FT046.eop-nam02.prod.protection.outlook.com (2603:10b6:4:ae:cafe::63) by DM5PR07CA0094.outlook.office365.com (2603:10b6:4:ae::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21 via Frontend Transport; Wed, 26 Apr 2023 12:30:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT046.mail.protection.outlook.com (10.13.4.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.22 via Frontend Transport; Wed, 26 Apr 2023 12:30:30 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 26 Apr 2023 05:30:22 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Wed, 26 Apr 2023 05:30:22 -0700 Envelope-to: git@amd.com, manikanta.guntupalli@amd.com, michal.simek@amd.com, radhey.shyam.pandey@amd.com, shubhrajyoti.datta@amd.com, srinivas.goud@amd.com, manion05gk@gmail.com, jirislaby@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Received: from [172.23.64.1] (port=50338 helo=xhdvnc101.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1preHp-0000lG-KD; Wed, 26 Apr 2023 05:30:18 -0700 Received: by xhdvnc101.xilinx.com (Postfix, from userid 90444) id A418A2131D; Wed, 26 Apr 2023 17:59:52 +0530 (IST) From: Manikanta Guntupalli To: , , , , , , , , , CC: , , , , , Manikanta Guntupalli Subject: [PATCH 2/2] tty: serial: uartps: Add rs485 support to uartps driver Date: Wed, 26 Apr 2023 17:59:47 +0530 Message-ID: <1682512187-8828-3-git-send-email-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1682512187-8828-1-git-send-email-manikanta.guntupalli@amd.com> References: <1682512187-8828-1-git-send-email-manikanta.guntupalli@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3NAM02FT046:EE_|CH2PR02MB6791:EE_ X-MS-Office365-Filtering-Correlation-Id: e701a54c-e124-4757-ea80-08db4652061c X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Da/C2N3PT0OYrZQF/RxIcJ9EsnAwxGVm0G9n3BM6gQJnJC91eVGXMgxI8Qy+NiEEcZCdv2Ybso61WlPzoXaYW2/1Cgdm6/a0GoGAY9nlC22q/HnO5JNKldxH4Xlkj/LXb6ebDqeuQCljX1gk38eoGGGzqmE9qNpSheAK7bvpg7LY7J2CzNjG+s235uRTiThONw5nRvC8jGP6r3v6C79V/gTbr1asMyzeqbg0c6mXG7uTiktGWtHE2/+y00caz4Q4uJbqCEwWc2WXSbAIM0lJXCehCkW7EPIWFbC7nm4EnRf1rdSvIg9TNU63st4mOZoHBeF1fegHGXi+xuqJX0Hau9uMGMFWZxjz8+phgSgR7Lf1hLZYJFmM+854dKudq+PFdg32LaNE0MUwG0DCD3RsufUyEnROeDWylehzmKTa01r2VGBlBTvYmHHPg41TW9PXcaEc/w7HNPldhDXTBBj8+yK6hzQ87OMTmVvADl6BuzlyV9muHFjaGutDKadye1hyNXWxGnoVpOnN6BzdtDJzdRVvAEAph0QRDa6TUErZvYbubN6Vx6aLA5Ws67DMacUu7D2/G+Tr215Kk3gTCpt+5TBeGE4nmwczfh6By36DzXa/Zs6/tNSwS+KBZkAwf+SMfblNXSMqjuuZBkohh/kTTasQWBK1ZtQ+Zk7FR7qeXV22Pok6rYfp1KBMpvctBaAzAsCGBv9kMr96jglWEOD//QHXIi3kWL2MK3YZacjuqytvIIvvMqAZEub5ZbDjQT7w X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(396003)(39860400002)(376002)(136003)(451199021)(46966006)(36840700001)(40470700004)(6636002)(54906003)(42186006)(110136005)(83380400001)(2616005)(47076005)(478600001)(36860700001)(7636003)(26005)(6666004)(356005)(316002)(82740400003)(4326008)(921005)(70586007)(70206006)(41300700001)(42882007)(336012)(83170400001)(186003)(6266002)(5660300002)(36756003)(44832011)(2906002)(40460700003)(7416002)(82310400005)(40480700001)(8676002)(8936002)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2023 12:30:30.6096 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e701a54c-e124-4757-ea80-08db4652061c X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT046.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR02MB6791 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Add rs485 half duplex mode support to uartps driver by making GPIO high before tx and low before rx. Signed-off-by: Manikanta Guntupalli --- drivers/tty/serial/xilinx_uartps.c | 96 +++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 8e521c69a959..339b962460ee 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #define CDNS_UART_TTY_NAME "ttyPS" #define CDNS_UART_NAME "xuartps" @@ -193,6 +195,7 @@ MODULE_PARM_DESC(rx_timeout, "Rx timeout, 1-255"); * @clk_rate_change_nb: Notifier block for clock changes * @quirks: Flags for RXBS support. * @cts_override: Modem control state override + * @gpiod: Pointer to the gpio descriptor */ struct cdns_uart { struct uart_port *port; @@ -203,10 +206,16 @@ struct cdns_uart { struct notifier_block clk_rate_change_nb; u32 quirks; bool cts_override; + struct gpio_desc *gpiod; }; struct cdns_platform_data { u32 quirks; }; + +struct serial_rs485 cdns_rs485_supported = { + .flags = SER_RS485_ENABLED, +}; + #define to_cdns_uart(_nb) container_of(_nb, struct cdns_uart, \ clk_rate_change_nb) @@ -305,6 +314,27 @@ static void cdns_uart_handle_rx(void *dev_id, unsigned int isrstatus) tty_flip_buffer_push(&port->state->port); } +/** + * cdns_rs485_tx_setup - Tx setup specific to rs485 + * @cdns_uart: Handle to the cdns_uart + */ +static void cdns_rs485_tx_setup(struct cdns_uart *cdns_uart) +{ + gpiod_set_value(cdns_uart->gpiod, 1); +} + +/** + * cdns_rs485_rx_setup - Rx setup specific to rs485 + * @cdns_uart: Handle to the cdns_uart + */ + +static void cdns_rs485_rx_setup(struct cdns_uart *cdns_uart) +{ + gpiod_set_value(cdns_uart->gpiod, 0); +} + +static unsigned int cdns_uart_tx_empty(struct uart_port *port); + /** * cdns_uart_handle_tx - Handle the bytes to be Txed. * @dev_id: Id of the UART port @@ -313,12 +343,17 @@ static void cdns_uart_handle_rx(void *dev_id, unsigned int isrstatus) static void cdns_uart_handle_tx(void *dev_id) { struct uart_port *port = (struct uart_port *)dev_id; + struct cdns_uart *cdns_uart = port->private_data; struct circ_buf *xmit = &port->state->xmit; + unsigned long time_out; unsigned int numbytes; + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) + cdns_rs485_tx_setup(cdns_uart); + if (uart_circ_empty(xmit)) { writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IDR); - return; + goto rs485_rx_setup; } numbytes = port->fifosize; @@ -332,6 +367,21 @@ static void cdns_uart_handle_tx(void *dev_id) if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) uart_write_wakeup(port); + +rs485_rx_setup: + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) { + time_out = jiffies + usecs_to_jiffies(TX_TIMEOUT); + /* Wait for tx completion */ + while ((cdns_uart_tx_empty(cdns_uart->port) != TIOCSER_TEMT) && + time_before(jiffies, time_out)) + cpu_relax(); + + /* + * Default Rx should be setup, because RX signaling path + * need to enable to receive data. + */ + cdns_rs485_rx_setup(cdns_uart); + } } /** @@ -829,6 +879,9 @@ static int cdns_uart_startup(struct uart_port *port) (CDNS_UART_CR_TXRST | CDNS_UART_CR_RXRST)) cpu_relax(); + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) + cdns_rs485_rx_setup(cdns_uart); + /* * Clear the RX disable bit and then set the RX enable bit to enable * the receiver. @@ -1455,6 +1508,25 @@ MODULE_DEVICE_TABLE(of, cdns_uart_of_match); /* Temporary variable for storing number of instances */ static int instances; +/** + * cdns_rs485_config - Called when an application calls TIOCSRS485 ioctl. + * @port: Pointer to the uart_port structure + * @termios: Pointer to the ktermios structure + * @rs485: Pointer to the serial_rs485 structure + * + * Return: 0 + */ +static int cdns_rs485_config(struct uart_port *port, struct ktermios *termios, + struct serial_rs485 *rs485) +{ + port->rs485 = *rs485; + + if (rs485->flags & SER_RS485_ENABLED) + dev_dbg(port->dev, "Setting UART to RS485\n"); + + return 0; +} + /** * cdns_uart_probe - Platform driver probe * @pdev: Pointer to the platform device structure @@ -1597,9 +1669,30 @@ static int cdns_uart_probe(struct platform_device *pdev) port->private_data = cdns_uart_data; port->read_status_mask = CDNS_UART_IXR_TXEMPTY | CDNS_UART_IXR_RXTRIG | CDNS_UART_IXR_OVERRUN | CDNS_UART_IXR_TOUT; + port->rs485_config = cdns_rs485_config; + port->rs485_supported = cdns_rs485_supported; cdns_uart_data->port = port; platform_set_drvdata(pdev, port); + rc = uart_get_rs485_mode(port); + + if (rc) + goto err_out_clk_notifier; + + cdns_uart_data->gpiod = devm_gpiod_get_optional(&pdev->dev, "txrx", + GPIOD_OUT_LOW); + + if (IS_ERR(cdns_uart_data->gpiod)) { + rc = PTR_ERR(cdns_uart_data->gpiod); + dev_err(port->dev, "xuartps: devm_gpiod_get_optional failed\n"); + goto err_out_clk_notifier; + } + + if (cdns_uart_data->gpiod) { + gpiod_direction_output(cdns_uart_data->gpiod, GPIOD_OUT_LOW); + gpiod_set_value(cdns_uart_data->gpiod, 0); + } + pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, UART_AUTOSUSPEND_TIMEOUT); pm_runtime_set_active(&pdev->dev); @@ -1646,6 +1739,7 @@ static int cdns_uart_probe(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); +err_out_clk_notifier: #ifdef CONFIG_COMMON_CLK clk_notifier_unregister(cdns_uart_data->uartclk, &cdns_uart_data->clk_rate_change_nb);