From patchwork Wed Jan 10 11:11:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 762151 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2073.outbound.protection.outlook.com [40.107.100.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8C4B47F4C; Wed, 10 Jan 2024 11:11:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2OfQR/Ax" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cH3jiY6B7w8nlZii12GpA1Z4Y8pH1E27tECAa7mHUJmt0vA8s+vYsbJe1iqzpTv8PGcHo1G3gMexJrntmmfiJyiTrT7vRDX3YgJ8IdPUSYIQmkB8nm0mb1fuFLDkg52P5A8CrRnIR/mKL9OR49t/sB08pCpQSF2lVhYvWPTKNAVGkf5I7Fqtwx7rQXH1EZxb8LS27N/ZMIho80O+fCpUt53oi9Pb4807f62ZK984J9JexR76kZfAeqIyqx6vPIbt2yNymCUQNc5k4Tfu8wOr31gRRB5QLOCqoErrlxyCHy7sqyg+TNSRfkhCsyyGsQkwUO+t4vXoau2ICkkdYti9KQ== 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=Ryzx4qBqBJCq7RdfAaphiPfrmxkQ2zuHY1gruHd8I18=; b=Z0OOHC+G5br9dfwKKtWwbgV/ekFngX2XIiytTMUZiZeategM2LZCq6cKgncHcgIAvYl9/tla6sPbH3HakCTjbCdRXJsk8PkYjEUjSx0EkjngK1HtMrp+BMXZhEOoqnQlq8eGHOa6fqSxJATgpanDBw2mj5S0jf9lHXHDsyhISjek06Mes4kEFOnLAHfHQireCdOizM9E08X7j7lGd8C1yK93fthLZHG64U/gTw6hPHHRxBzvxbLlr6OOuAxfU/2hVBQ5H+sKyLHc8dwTC/BgisLsVBv+Zn6zXHiMYdC3VBOWRzDvPMz4UbruF+KLzVWLXKVK9vQ1+k4iHWhfGcxxtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ryzx4qBqBJCq7RdfAaphiPfrmxkQ2zuHY1gruHd8I18=; b=2OfQR/Ax0BB6nsP/du/fQ19b7UP0qbZHNeYSjuE1f/k0mdTMLfoMt9MDxMK75Rm/ld5g2O/zols5pfqxpyX4oN8YdiIz1eqr4EX5VyOewS0u7MoN+Tc3E73szAI/mN1SHf+FjCL6x2+79/7HU7nvd01w6Eacs/jZLPVes2E4H2Q= Received: from CY5PR20CA0026.namprd20.prod.outlook.com (2603:10b6:930:3::23) by IA1PR12MB8311.namprd12.prod.outlook.com (2603:10b6:208:3fa::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.27; Wed, 10 Jan 2024 11:11:52 +0000 Received: from CY4PEPF0000E9D4.namprd03.prod.outlook.com (2603:10b6:930:3:cafe::76) by CY5PR20CA0026.outlook.office365.com (2603:10b6:930:3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.18 via Frontend Transport; Wed, 10 Jan 2024 11:11:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D4.mail.protection.outlook.com (10.167.241.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7181.14 via Frontend Transport; Wed, 10 Jan 2024 11:11:51 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 10 Jan 2024 05:11:50 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 10 Jan 2024 05:11:50 -0600 Received: from xhdsgoud40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Wed, 10 Jan 2024 05:11:45 -0600 From: Manikanta Guntupalli To: , , , , , , , , , , CC: , , , , Manikanta Guntupalli , Conor Dooley Subject: [PATCH V8 1/3] dt-bindings: Add reference to rs485.yaml Date: Wed, 10 Jan 2024 16:41:05 +0530 Message-ID: <20240110111107.3645284-2-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240110111107.3645284-1-manikanta.guntupalli@amd.com> References: <20240110111107.3645284-1-manikanta.guntupalli@amd.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D4:EE_|IA1PR12MB8311:EE_ X-MS-Office365-Filtering-Correlation-Id: 5affdcdd-992a-44e9-0765-08dc11ccf24c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5Xc5yo9xsQ+bK5R++6zUnr4fJjgwUxAsgYKPflFwT1MzdK+FbRD3qNNIHh/Dp+jVQLdryWPcc6BBuFe99B13nV6WdfEsWwNuMP3QOJIq1PQ5AsK9pIOXbWbAU3afZcdpWO+oy0HlMxynVvb1uxJT34esMEHbaxqpM65ZtTpThxf7Jl+tBNSmzvcpQc+miJNeDKGSroF1Eeo3CKscpgMK7cB78KjP80h3tE8wTJ2dOT+ZojOigKx/O2gRSYp6NPXW0qJGyTnQiF2GSLQW11ADyi/FqY9SD2/HGLOZrSAKvYwg79ZNYszeS9u/p885DsFo8rCx8DJZne1Ix21D9/q6sSFrZrBTyMPSHVwr2w/Z3L7XjUlWB6odKU64UQpDOKPs+tkhu57hZLIJUscBwwVVrzfTY8HQF/lkvOH50WxmGeXg9PhmvBAiu7LsrmLTRfGf7KzzavD3KkUXLE6sp+bYBMXE18WquFKJmiLGqnSEBHDopuWlnV3p8UeyolKTOocPjVMV8fe16sTRdIQDpiLkp7bzozcDViEgr87PV9sHUR33rQny+qVdOYU5FNfR8UDWphzWhzjtpEHOShDEhxYAfRlTRbCTHQul0T1jQX1YcfLF4iRB6Ay+y1y3hJgTB4KpeBLqXGaR/ORSwc6DGXk9WSmDC80OlMTVdehsYHq5sVSO3xoZq/+1cyt0p0qOFirBoTo+lVZNiTylu1yrUHinvpAjpbiVmf+ToeppI54pPuMBgN8lh7LQMMUkLFCx26ZskevSeq4Zdekh5eEDU0QD/hz5fZ6EoRXb3U8h0eceX48= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(396003)(346002)(136003)(39860400002)(230922051799003)(1800799012)(451199024)(64100799003)(82310400011)(186009)(36840700001)(46966006)(40470700004)(40480700001)(40460700003)(83380400001)(921011)(41300700001)(70586007)(356005)(36756003)(81166007)(86362001)(70206006)(82740400003)(36860700001)(47076005)(426003)(336012)(1076003)(26005)(2616005)(4326008)(2906002)(110136005)(316002)(478600001)(6666004)(54906003)(8936002)(44832011)(5660300002)(7416002)(8676002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2024 11:11:51.4274 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5affdcdd-992a-44e9-0765-08dc11ccf24c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8311 Xilinx/AMD Kria SOM KD240 board has a rs485 compatible peripheral. Update the binding to have rs485 support. Acked-by: Conor Dooley Signed-off-by: Manikanta Guntupalli --- Changes for V2: Modify optional gpio name to xlnx,phy-ctrl-gpios. Update commit description. Changes for V3: Modify optional gpio name to rts-gpios. Update commit description. Changes for V4: Update rts-gpios description. Changes for V5: Remove rts-gpios description. Update commit message and description. Changes for V6: Update commit description. Changes for V7: Update commit description. Changes for V8: None. --- Documentation/devicetree/bindings/serial/cdns,uart.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/serial/cdns,uart.yaml b/Documentation/devicetree/bindings/serial/cdns,uart.yaml index e35ad1109efc..2129247d7c81 100644 --- a/Documentation/devicetree/bindings/serial/cdns,uart.yaml +++ b/Documentation/devicetree/bindings/serial/cdns,uart.yaml @@ -55,6 +55,7 @@ required: allOf: - $ref: serial.yaml# + - $ref: rs485.yaml# - if: properties: compatible: From patchwork Wed Jan 10 11:11:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 761697 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2070.outbound.protection.outlook.com [40.107.212.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5796D47F4C; Wed, 10 Jan 2024 11:12:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="zn0iNtWW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XBVGXO3fspjm41Oii85eA7cPCOC5r6Ff6XJz5OVjS9riNHet4MQdGwBp2Ibu8o+AfNHrH/HbJPneVLw9QzK6GUFUIKG2JOyX8Mlxd+inzr8Wy7IDCyurwujyGb0KlpV3qoiY6dOoMmPFoReuhOFDB7dPhFHWwnfiSoUJkvLkICluBPeB4IKYvu5ygwb5eubcki5F/eOqRt7yTWfipQLp+pDcSmoz6FquN+YhOJoDFyZiBwnRonQe5nft5Tuci6fyo5xD7sZYsC59CVTElZ6OTPA+kr9N4k2xBS9vdEMrgGyu0mXKj9EoHz1oJYyJMusOldc/PVb+J8DYoZ73PnSR8A== 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=PggO/CIE7RzqqtiQPmq1qBWNVywZYffCBedCKdYKkuo=; b=AosOeqi0tUc9Z3M41DA7tPLzL6bS4e3tHkQU5vX72u0wA3fTipHxafY4wLd8yEvn8+4hjkCAQc8WNS2Tlt2vq3xplMI7cDo+ZnyUxR/PNFjfjdkAUBeAAS7pzJa+RKonJoJBnloU+sEAqprBuTfSefOAi6na/VO127EXllpGXopFDEAntQb+NIQpOYc9KrLIitfGZzoKC8fV/jsFnAOLufxf/f8JsEJRtl9lCGYmw1hMOXio78HMWXRFmTHPs5oLbZQJZOnZHsP7psqHW+hS0tGeL6jcDR6cF6Tww0FRpLV5HhgolglSh3rJFV1eXVFdVOojZrgyk/dT3EtBIQFmhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PggO/CIE7RzqqtiQPmq1qBWNVywZYffCBedCKdYKkuo=; b=zn0iNtWWvNehAyirBDRhn2H7E9sQDQZSn9c2UOwpzaGSJ+uM3ctTENATB271DZnqCG2iGDRvsn5M+VEc0rTjzho9lEaX7xs3LP+9xo4F154Otm+xuQysl0e2owohdbAm2NyTZbXMRW4dKS7UXgg2wtYVybECx+1OEo/IjdG73Pc= Received: from CY5P221CA0125.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:1f::31) by BN9PR12MB5195.namprd12.prod.outlook.com (2603:10b6:408:11c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.18; Wed, 10 Jan 2024 11:11:58 +0000 Received: from CY4PEPF0000E9CE.namprd03.prod.outlook.com (2603:10b6:930:1f:cafe::70) by CY5P221CA0125.outlook.office365.com (2603:10b6:930:1f::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.17 via Frontend Transport; Wed, 10 Jan 2024 11:11:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9CE.mail.protection.outlook.com (10.167.241.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7181.14 via Frontend Transport; Wed, 10 Jan 2024 11:11:57 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 10 Jan 2024 05:11:57 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 10 Jan 2024 05:11:56 -0600 Received: from xhdsgoud40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Wed, 10 Jan 2024 05:11:52 -0600 From: Manikanta Guntupalli To: , , , , , , , , , , CC: , , , , Manikanta Guntupalli Subject: [PATCH V8 2/3] tty: serial: uartps: Relocate cdns_uart_tx_empty to facilitate rs485 Date: Wed, 10 Jan 2024 16:41:06 +0530 Message-ID: <20240110111107.3645284-3-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240110111107.3645284-1-manikanta.guntupalli@amd.com> References: <20240110111107.3645284-1-manikanta.guntupalli@amd.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9CE:EE_|BN9PR12MB5195:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a06ca67-5565-4cde-a2ba-08dc11ccf61a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4w9xn4qfVTtmzTmW9iRMuMFZP0dXeiEQlHJ5Yy7+3LXoCUY3VZvlP4Uu6ChK2gPBx8DJ0BQQkUp0Tw4QAGJgkJOL7ztX5vpHRRWyp9WwRogAa4LyNqmyD4IYZpfiMaumA9Vwcml0+GWQ3dkP9K9qX/7MCJnpoUijXporrvXI+zPcYOK+mnZAqrlHTkVHQ/LcKzZE//ee7yYKYT1g37keThXxwtyHBZckXENmVyjXWJYQTyygvIijw5jUK4pnuwVM7MWgbpHNg5QE7cbWiH+/zH/kVXiZ9G/NCB2xyoY55fU0S1U92ctS1e8Qd8ECdTSt9ZFGZcmpfcU/p9kHgwlFzBQf5W4bhV0/WxvMw+b0kWuaDxOS4ak+5IYmpAu7bDAAOa8cX+PjeEBGosIjkxAn+h/G1zG0UwGfV73Xb0jJBCafcz3AgrMXoXSKKGpeJBEVArxhCvOzepCKLf1wzeO+dIMLjAr5+tk6XUN3k5px0RNbAwB434pRS422TB5NofcgeZtiHpYh6Xo4H30MLsAXijFeLkYGE+Q+0UkWXQXW+VTpVi59zsi11eHhvQg06F7yZtN9MbyV98AQ7XoBUfejpA2+AjNSwWCCbuYhle9A01z8XiMkI1zhHfUhB8KJI3He66cInlFkjYSlqIH58rEcO8ZcQpJJxdgb+VV8i0SNWHrGvMAwJsLz83tCWjLVyMKhCnPsvAAMWUsRAq6alY9socreESOga+eOchQGklQPXyyA/YBN3L1Eg2Stc+9HpizJZB107FeKkZiIP/Tq7mZCsOGYNE57H6hkz1ICNGkyEzg= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(376002)(136003)(396003)(346002)(230922051799003)(82310400011)(1800799012)(186009)(64100799003)(451199024)(46966006)(40470700004)(36840700001)(70206006)(70586007)(54906003)(2616005)(40480700001)(40460700003)(26005)(110136005)(316002)(44832011)(8676002)(8936002)(1076003)(4326008)(83380400001)(336012)(426003)(6666004)(5660300002)(2906002)(47076005)(478600001)(7416002)(36860700001)(82740400003)(921011)(86362001)(41300700001)(356005)(81166007)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2024 11:11:57.8615 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a06ca67-5565-4cde-a2ba-08dc11ccf61a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9CE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5195 Relocate cdns_uart_tx_empty function to avoid prototype statement in rs485 changes. Signed-off-by: Manikanta Guntupalli --- Changes since V4: This patch introduced in V4. Changes for V5: None. Changes for V6: None. Changes for V7: None. Changes for V8: None. --- drivers/tty/serial/xilinx_uartps.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 920762d7b4a4..aafcc2179e0e 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -305,6 +305,21 @@ static void cdns_uart_handle_rx(void *dev_id, unsigned int isrstatus) tty_flip_buffer_push(&port->state->port); } +/** + * cdns_uart_tx_empty - Check whether TX is empty + * @port: Handle to the uart port structure + * + * Return: TIOCSER_TEMT on success, 0 otherwise + */ +static unsigned int cdns_uart_tx_empty(struct uart_port *port) +{ + unsigned int status; + + status = readl(port->membase + CDNS_UART_SR); + status &= (CDNS_UART_SR_TXEMPTY | CDNS_UART_SR_TACTIVE); + return (status == CDNS_UART_SR_TXEMPTY) ? TIOCSER_TEMT : 0; +} + /** * cdns_uart_handle_tx - Handle the bytes to be Txed. * @dev_id: Id of the UART port @@ -626,21 +641,6 @@ static void cdns_uart_stop_rx(struct uart_port *port) writel(regval, port->membase + CDNS_UART_CR); } -/** - * cdns_uart_tx_empty - Check whether TX is empty - * @port: Handle to the uart port structure - * - * Return: TIOCSER_TEMT on success, 0 otherwise - */ -static unsigned int cdns_uart_tx_empty(struct uart_port *port) -{ - unsigned int status; - - status = readl(port->membase + CDNS_UART_SR) & - (CDNS_UART_SR_TXEMPTY | CDNS_UART_SR_TACTIVE); - return (status == CDNS_UART_SR_TXEMPTY) ? TIOCSER_TEMT : 0; -} - /** * cdns_uart_break_ctl - Based on the input ctl we have to start or stop * transmitting char breaks From patchwork Wed Jan 10 11:11:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 762150 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2043.outbound.protection.outlook.com [40.107.100.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07377481D8; Wed, 10 Jan 2024 11:12:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="x/W0YWJm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oFgA1JzCxeL4z7IXP3njwFnGcw5OnDDpN3/qxK4dilvJN9rh8/cshnY/TWz9q0ViX22adB+dCULcPnuplX9ApxPLvRTh7NP8e9GRdJGkQdhSRauNByP4CfQFcER/6bR+eaiStfGjYdt10Uai/bNxiBjrtt48KrUIKMwkxglvUoJKCTUD1OHxgVaE7CfPsNqiyfBVHcvFkkBKfBssZR1VfKG54gVlGlp9rXoj9RwMMWE33TRh4JMlHQW3Inawu9k28lEpNhnbSXj8Av0M4gZkVS9RmAqsKNZOsJ8fCltyW+9/pJ3kwhlILqIeOoS6vzBAXDA3ZRmp4frES2y1tr+SVg== 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=IGuopZAN+nviV6zohQFz7G1AMxus+RySCPj1jrLficU=; b=Qg6Gzeb6iFeAAdJlNgM+NXv6X9NWFmrOVOzgPNGB4tbEaPUvXMikYM6tGIcUtnMU1hUmofzcMvrM/QHO4cOBTClf6GbwEXHv+ML+ZpuE2JIdUKD/ble2rKSjcN9csnFC8TiQo8XYukTJBKgsRxIE7wK48qa376N1qH5dqPKNAkcj1uqfBmEku223EziWdm4NSXIGWm3f6xCcp6v7hKudfdNk3+XL2Q0eq4PQC2YKRWGsKlYjKDZ1zw7937fgvL75E1kyQYdFhNWhvON/xQ9Dz2D3kLeUhTJlNuFM5eSr+8ETaT40N6ttkQKZmryMgCDfuLpmuJhalR1hP9Lcazvwhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IGuopZAN+nviV6zohQFz7G1AMxus+RySCPj1jrLficU=; b=x/W0YWJmZ/+0pm8kmtGsbPzUcmPpsoeczqZy7UBOigUC2m+rmveG8/TAWcN6RhKnl9J02x+f/K7Xszw/ayo7aG1Nch+CVwVBYAzimZ6PD2WfdqdLXXJZ/CpeK6pCwqZVuGDep85yDpDvkCzS3xjwniXKfpC/YTu+LpRtKk3Tb5M= Received: from DM6PR03CA0036.namprd03.prod.outlook.com (2603:10b6:5:40::49) by DS7PR12MB5789.namprd12.prod.outlook.com (2603:10b6:8:74::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.17; Wed, 10 Jan 2024 11:12:04 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:5:40:cafe::47) by DM6PR03CA0036.outlook.office365.com (2603:10b6:5:40::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.17 via Frontend Transport; Wed, 10 Jan 2024 11:12:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000FCBE.mail.protection.outlook.com (10.167.242.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7181.14 via Frontend Transport; Wed, 10 Jan 2024 11:12:03 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 10 Jan 2024 05:12:03 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Wed, 10 Jan 2024 03:12:01 -0800 Received: from xhdsgoud40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Wed, 10 Jan 2024 05:11:58 -0600 From: Manikanta Guntupalli To: , , , , , , , , , , CC: , , , , Manikanta Guntupalli Subject: [PATCH V8 3/3] tty: serial: uartps: Add rs485 support to uartps driver Date: Wed, 10 Jan 2024 16:41:07 +0530 Message-ID: <20240110111107.3645284-4-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240110111107.3645284-1-manikanta.guntupalli@amd.com> References: <20240110111107.3645284-1-manikanta.guntupalli@amd.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBE:EE_|DS7PR12MB5789:EE_ X-MS-Office365-Filtering-Correlation-Id: 388df47e-3ecc-4d51-1228-08dc11ccf995 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FWakF7xyGGQZpvt41vH6XzjAnGCYWl27PYAXNM18mQ5ynxlwwUMNbHFhk3oLI2z9qhFbqdAkH97PtNek1hB+S8sxwHF4nMR/EUGb176b2MPSqjhGLanx3y058EGO01g1kezRWf0kb4u/FsRKaEdVvPBCoULU2GwhPIQHlXtXmiiBu+RUHfAcbbKGxG//PYGbmF54jHTYB/VSPiq11l8b8B8wVfGRhcY3uOkjXUUo5eA3328tBLHSPkPKzraUgv0B1+LiTJBRmAXiwyAuZ9lDsAseZZ6fyiRTHNDvnX6hlfHfwVUx7wun2wxUmgaYODn1ng2bEYvolqfhT8pgjycx6BYHRxGHU3wErEf/k0D8CTKKTsTZ5VjIl+kEg+I08S1/XgFb5JVPjnITptcjtf05LWYBfK6nr0SEZLyNgF47mnYSYiWFh1S9K+jz8q6jFnMuLwZ+dG21teiEYTSdP3yXR9qUfg/Ni3qIjxyWVHV20g+b98Cmx15OJY16LcnRjkY7UfZ6fdh/uE9eTxWUbGM3xA5J5aVYIEw4y2U9IACVdC6V+fEfn5i3JrOEry1gOlxtbFb49uP9ITr8iJLApVRHzcBQtPxmHop/EQMmU3kMi8W6aU9M/f1hM91rKAi86Q3pZ6FETpDuFiOzRjNUj1qcoNqWfdUr5a041IwXD1H1Sd+1m5Bd8Q1UOrfIVxvZEvfWJCTEik3UpPg1sY1UVYc7HiNljosTC5OnTTJM4ErqdNzy4WFqlnPJjgor3pQxpeni538u+yr9HfEIAng/VfAEaZd8Z/tZ8AV+1I+7Hmpkvz8= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(136003)(346002)(396003)(39860400002)(376002)(230922051799003)(1800799012)(64100799003)(451199024)(82310400011)(186009)(36840700001)(40470700004)(46966006)(478600001)(30864003)(7416002)(83380400001)(2906002)(5660300002)(316002)(2616005)(1076003)(26005)(4326008)(44832011)(426003)(336012)(47076005)(40480700001)(36860700001)(8676002)(8936002)(86362001)(41300700001)(82740400003)(356005)(40460700003)(6666004)(110136005)(54906003)(70586007)(70206006)(81166007)(921011)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2024 11:12:03.6970 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 388df47e-3ecc-4d51-1228-08dc11ccf995 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5789 Add rs485 support to uartps driver. Use either rts-gpios or RTS to control RS485 phy as driver or a receiver. Signed-off-by: Manikanta Guntupalli --- Changes for V2: Modify optional gpio name to xlnx,phy-ctrl-gpios. Update commit description. Add support for RTS, delay_rts_before_send and delay_rts_after_send in RS485 mode. Changes for V3: Modify optional gpio name to rts-gpios. Update commit description. Move cdns_uart_tx_empty function to avoid prototype statement. Remove assignment of struct serial_rs485 to port->rs485 as serial core performs that. Switch to native RTS in non GPIO case. Handle rs485 during stop tx. Remove explicit calls to configure gpio direction and value, as devm_gpiod_get_optional performs that by using GPIOD_OUT_LOW argument. Update implementation to support configuration of GPIO/RTS value based on user configuration of SER_RS485_RTS_ON_SEND and SER_RS485_RTS_AFTER_SEND. Move implementation to start_tx from handle_tx. Changes for V4: Create separate patch for cdns_uart_tx_empty relocation. Call cdns_rs485_rx_setup() before uart_add_one_port() in probe. Update gpio descriptor name to gpiod_rts. Instead of cdns_rs485_config_gpio_rts_high() and cdns_rs485_config_gpio_rts_low() functions for RTS/GPIO value configuration implement cdns_rts_gpio_enable(). Disable auto rts and call cdns_uart_stop_tx() from cdns_rs485_config. Use timer instead of mdelay for delay_rts_before_send and delay_rts_after_send. Update cdns_uart_set_mctrl to support GPIO/RTS. Changes for V5: None. Changes for V6: Disable the TX and RX in cdns_rs485_config() when rs485 disabled. Hold lock for cdns_uart_handle_tx() in cdns_rs485_tx_callback(). Changes for V7: None. Changes for V8: Use hrtimer instead of timer list. Simplify cdns_rs485_tx_setup() and cdns_rs485_rx_setup(). Update argument of cdns_rts_gpio_enable() in cdns_uart_set_mctrl(). Add cdns_calc_after_tx_delay() to calculate required delay after tx. Add hrtimer setup in cdns_rs485_config(). Move enable TX Empty interrupt and rs485 rx callback scheduling part to cdns_uart_handle_tx(). --- drivers/tty/serial/xilinx_uartps.c | 241 ++++++++++++++++++++++++++++- 1 file changed, 233 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index aafcc2179e0e..3247fd3e91fd 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -22,7 +22,9 @@ #include #include #include -#include +#include +#include +#include #define CDNS_UART_TTY_NAME "ttyPS" #define CDNS_UART_NAME "xuartps" @@ -193,6 +195,10 @@ 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_rts: Pointer to the gpio descriptor + * @rs485_tx_started: RS485 tx state + * @tx_timer: Timer for tx + * @stop_tx_timer: Timer for stop tx */ struct cdns_uart { struct uart_port *port; @@ -203,10 +209,22 @@ struct cdns_uart { struct notifier_block clk_rate_change_nb; u32 quirks; bool cts_override; + struct gpio_desc *gpiod_rts; + bool rs485_tx_started; + struct hrtimer tx_timer; + struct hrtimer stop_tx_timer; }; struct cdns_platform_data { u32 quirks; }; + +struct serial_rs485 cdns_rs485_supported = { + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | + SER_RS485_RTS_AFTER_SEND, + .delay_rts_before_send = 1, + .delay_rts_after_send = 1, +}; + #define to_cdns_uart(_nb) container_of(_nb, struct cdns_uart, \ clk_rate_change_nb) @@ -305,6 +323,55 @@ static void cdns_uart_handle_rx(void *dev_id, unsigned int isrstatus) tty_flip_buffer_push(&port->state->port); } +/** + * cdns_rts_gpio_enable - Configure RTS/GPIO to high/low + * @cdns_uart: Handle to the cdns_uart + * @enable: Value to be set to RTS/GPIO + */ +static void cdns_rts_gpio_enable(struct cdns_uart *cdns_uart, bool enable) +{ + u32 val; + + if (cdns_uart->gpiod_rts) { + gpiod_set_value(cdns_uart->gpiod_rts, enable); + } else { + val = readl(cdns_uart->port->membase + CDNS_UART_MODEMCR); + if (enable) + val &= ~CDNS_UART_MODEMCR_RTS; + else + val |= CDNS_UART_MODEMCR_RTS; + writel(val, cdns_uart->port->membase + CDNS_UART_MODEMCR); + } +} + +/** + * 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) +{ + bool enable; + + enable = cdns_uart->port->rs485.flags & SER_RS485_RTS_ON_SEND; + cdns_rts_gpio_enable(cdns_uart, enable); + + cdns_uart->rs485_tx_started = true; +} + +/** + * 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) +{ + bool enable; + + enable = cdns_uart->port->rs485.flags & SER_RS485_RTS_AFTER_SEND; + cdns_rts_gpio_enable(cdns_uart, enable); + + cdns_uart->rs485_tx_started = false; +} + /** * cdns_uart_tx_empty - Check whether TX is empty * @port: Handle to the uart port structure @@ -320,6 +387,37 @@ static unsigned int cdns_uart_tx_empty(struct uart_port *port) return (status == CDNS_UART_SR_TXEMPTY) ? TIOCSER_TEMT : 0; } +/** + * cdns_rs485_rx_callback - Timer rx callback handler for rs485. + * @t: Handle to the hrtimer structure + */ +static enum hrtimer_restart cdns_rs485_rx_callback(struct hrtimer *t) +{ + struct cdns_uart *cdns_uart = container_of(t, struct cdns_uart, tx_timer); + + /* + * Default Rx should be setup, because Rx signaling path + * need to enable to receive data. + */ + cdns_rs485_rx_setup(cdns_uart); + + return HRTIMER_NORESTART; +} + +/** + * cdns_calc_after_tx_delay - calculate delay required for after tx. + * @cdns_uart: Handle to the cdns_uart + */ +static u64 cdns_calc_after_tx_delay(struct cdns_uart *cdns_uart) +{ + /* + * Frame time + stop bit time + rs485.delay_rts_after_send + */ + return cdns_uart->port->frame_time + + DIV_ROUND_UP(cdns_uart->port->frame_time, 7) + + (u64)cdns_uart->port->rs485.delay_rts_after_send * NSEC_PER_MSEC; +} + /** * cdns_uart_handle_tx - Handle the bytes to be Txed. * @dev_id: Id of the UART port @@ -328,6 +426,7 @@ static unsigned int cdns_uart_tx_empty(struct uart_port *port) 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 int numbytes; @@ -347,6 +446,16 @@ static void cdns_uart_handle_tx(void *dev_id) if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) uart_write_wakeup(port); + + /* Enable the TX Empty interrupt */ + writel(CDNS_UART_IXR_TXEMPTY, cdns_uart->port->membase + CDNS_UART_IER); + + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED && + (uart_circ_empty(xmit) || uart_tx_stopped(port))) { + cdns_uart->tx_timer.function = &cdns_rs485_rx_callback; + hrtimer_start(&cdns_uart->tx_timer, + ns_to_ktime(cdns_calc_after_tx_delay(cdns_uart)), HRTIMER_MODE_REL); + } } /** @@ -579,6 +688,21 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb, } #endif +/** + * cdns_rs485_tx_callback - Timer tx callback handler for rs485. + * @t: Handle to the hrtimer structure + */ +static enum hrtimer_restart cdns_rs485_tx_callback(struct hrtimer *t) +{ + struct cdns_uart *cdns_uart = container_of(t, struct cdns_uart, tx_timer); + + uart_port_lock(cdns_uart->port); + cdns_uart_handle_tx(cdns_uart->port); + uart_port_unlock(cdns_uart->port); + + return HRTIMER_NORESTART; +} + /** * cdns_uart_start_tx - Start transmitting bytes * @port: Handle to the uart port structure @@ -586,6 +710,7 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb, static void cdns_uart_start_tx(struct uart_port *port) { unsigned int status; + struct cdns_uart *cdns_uart = port->private_data; if (uart_tx_stopped(port)) return; @@ -604,10 +729,38 @@ static void cdns_uart_start_tx(struct uart_port *port) writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_ISR); + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) { + if (!cdns_uart->rs485_tx_started) { + cdns_uart->tx_timer.function = &cdns_rs485_tx_callback; + cdns_rs485_tx_setup(cdns_uart); + return hrtimer_start(&cdns_uart->tx_timer, + ms_to_ktime(port->rs485.delay_rts_before_send), + HRTIMER_MODE_REL); + } else { + if (hrtimer_get_remaining(&cdns_uart->tx_timer)) + hrtimer_cancel(&cdns_uart->tx_timer); + } + } cdns_uart_handle_tx(port); +} - /* Enable the TX Empty interrupt */ - writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IER); +/** + * cdns_rs485_stop_tx_callback - Timer stop tx callback handler for rs485. + * @t: Handle to the timer list structure + */ +static enum hrtimer_restart cdns_rs485_stop_tx_callback(struct hrtimer *t) +{ + unsigned int regval; + struct cdns_uart *cdns_uart = container_of(t, struct cdns_uart, stop_tx_timer); + + cdns_rs485_rx_setup(cdns_uart); + + regval = readl(cdns_uart->port->membase + CDNS_UART_CR); + regval |= CDNS_UART_CR_TX_DIS; + /* Disable the transmitter */ + writel(regval, cdns_uart->port->membase + CDNS_UART_CR); + + return HRTIMER_NORESTART; } /** @@ -617,11 +770,21 @@ static void cdns_uart_start_tx(struct uart_port *port) static void cdns_uart_stop_tx(struct uart_port *port) { unsigned int regval; + struct cdns_uart *cdns_uart = port->private_data; - regval = readl(port->membase + CDNS_UART_CR); - regval |= CDNS_UART_CR_TX_DIS; - /* Disable the transmitter */ - writel(regval, port->membase + CDNS_UART_CR); + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) { + if (cdns_uart->rs485_tx_started) + hrtimer_start(&cdns_uart->stop_tx_timer, + ns_to_ktime(cdns_calc_after_tx_delay(cdns_uart)), + HRTIMER_MODE_REL); + else + cdns_rs485_stop_tx_callback(&cdns_uart->stop_tx_timer); + } else { + regval = readl(port->membase + CDNS_UART_CR); + regval |= CDNS_UART_CR_TX_DIS; + /* Disable the transmitter */ + writel(regval, port->membase + CDNS_UART_CR); + } } /** @@ -829,6 +992,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. @@ -888,6 +1054,7 @@ static void cdns_uart_shutdown(struct uart_port *port) { int status; unsigned long flags; + struct cdns_uart *cdns_uart = port->private_data; uart_port_lock_irqsave(port, &flags); @@ -903,6 +1070,11 @@ static void cdns_uart_shutdown(struct uart_port *port) uart_port_unlock_irqrestore(port, flags); free_irq(port->irq, port); + + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) { + hrtimer_cancel(&cdns_uart->tx_timer); + hrtimer_cancel(&cdns_uart->stop_tx_timer); + } } /** @@ -1032,7 +1204,7 @@ static void cdns_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) mode_reg &= ~CDNS_UART_MR_CHMODE_MASK; if (mctrl & TIOCM_RTS) - val |= CDNS_UART_MODEMCR_RTS; + cdns_rts_gpio_enable(cdns_uart_data, mctrl & TIOCM_RTS); if (mctrl & TIOCM_DTR) val |= CDNS_UART_MODEMCR_DTR; if (mctrl & TIOCM_LOOP) @@ -1455,6 +1627,42 @@ 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) +{ + u32 val; + struct cdns_uart *cdns_uart = port->private_data; + + if (rs485->flags & SER_RS485_ENABLED) { + dev_dbg(port->dev, "Setting UART to RS485\n"); + /* Make sure auto RTS is disabled */ + val = readl(port->membase + CDNS_UART_MODEMCR); + val &= ~CDNS_UART_MODEMCR_FCM; + writel(val, port->membase + CDNS_UART_MODEMCR); + + /* Timer setup */ + hrtimer_init(&cdns_uart->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + hrtimer_init(&cdns_uart->stop_tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + cdns_uart->tx_timer.function = &cdns_rs485_tx_callback; + cdns_uart->stop_tx_timer.function = &cdns_rs485_stop_tx_callback; + + /* Disable transmitter and make Rx setup*/ + cdns_uart_stop_tx(port); + } else { + hrtimer_cancel(&cdns_uart->tx_timer); + hrtimer_cancel(&cdns_uart->stop_tx_timer); + } + return 0; +} + /** * cdns_uart_probe - Platform driver probe * @pdev: Pointer to the platform device structure @@ -1597,9 +1805,23 @@ 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_rts = devm_gpiod_get_optional(&pdev->dev, "rts", + GPIOD_OUT_LOW); + if (IS_ERR(cdns_uart_data->gpiod_rts)) { + rc = PTR_ERR(cdns_uart_data->gpiod_rts); + dev_err(port->dev, "xuartps: devm_gpiod_get_optional failed\n"); + goto err_out_clk_notifier; + } + pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, UART_AUTOSUSPEND_TIMEOUT); pm_runtime_set_active(&pdev->dev); @@ -1618,6 +1840,8 @@ static int cdns_uart_probe(struct platform_device *pdev) console_port = port; } #endif + if (cdns_uart_data->port->rs485.flags & SER_RS485_ENABLED) + cdns_rs485_rx_setup(cdns_uart_data); rc = uart_add_one_port(&cdns_uart_uart_driver, port); if (rc) { @@ -1646,6 +1870,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);