From patchwork Fri Dec 15 12:56:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 755302 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2084.outbound.protection.outlook.com [40.107.95.84]) (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 146772CCBB; Fri, 15 Dec 2023 12:57:11 +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="SStZbSYZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y3XV3KEW6zei8NZEE6YO43AqcJ7ZsavI+H+WGSQfpx+Lm6vBMeEyy/brND8vaYIrwIqV+VLD7NrLg00Rt1x0ySKYTl+mjltbgyX0UPggLfOB4lZNHkXqT6VL8uwTtBNAUB/XJtACJxYarvXauDHkaod42sveA1GHvp6SBtZbwvaej2/aJHbUl0zLtUbIIzw6B+Ra0RACfv1Ho0zgYJTRWlkjZkcPiTP8nWQjJZ1+xGOTKllfbCbYjrXi4LXAifW7knXc6rI+JihDj9eIv/kAxKlF2mXszVDiYd2j208AM5w7xPij1kC2Kj/fUTN4SbS4DxC+lzscpv5/X6irgnazNA== 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=L8xzfuOx7o3gYSo7AEgAczC5JX2sTLwHxgCXiR2HKe4=; b=KBUAlyXi+8FyiD2Kmq2Nysz+T8p0kUWQhePrX4zGXUIlOkOpw1PZJ9adfObc1UijpFamaRuXyUwQ+Ejg6kt8ineU+lh7wEmg+yn6txCkrOmuBVTr1C+rN5cchRNvddeAE8yKOL3ALIW61nBrb7e2QVQFM/DQS8dhFzmQL1AYOsMIxQ7SCT6kfz/I4DmfU8TlDKBb/ITFTYuR4tF3JlFJXYeSPxJU2Nzj0/f4/ABFHlBtopyA2S/mzH/HT0qrGZuZ+qR5bP4ZJY3aAZkI0U2p8vfO47MRMv5mCLYQLpWLF52nQ+62CUef3E+aW8SjDf6u1o5jlPndmOI1MWzxr8cBnQ== 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=L8xzfuOx7o3gYSo7AEgAczC5JX2sTLwHxgCXiR2HKe4=; b=SStZbSYZjn2H3wBfwucbl1lFSSDC7DebqNM9FlAZJs3O+kf39rXhzXec9ccnrU6YOjnJqAJPhpQA0sYxcw0EAX02UGDkbeJ5GRP9OFqKoe0Thtdo7YJxltAjma3ATeNb8hMo6FX7EbkG+Hgh9nYJyWGB5NUQl7j6DSM3QD+Y9gU= Received: from SA1P222CA0140.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c2::23) by LV2PR12MB5871.namprd12.prod.outlook.com (2603:10b6:408:174::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.28; Fri, 15 Dec 2023 12:57:09 +0000 Received: from SN1PEPF0002BA51.namprd03.prod.outlook.com (2603:10b6:806:3c2:cafe::60) by SA1P222CA0140.outlook.office365.com (2603:10b6:806:3c2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.31 via Frontend Transport; Fri, 15 Dec 2023 12:57:09 +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 SN1PEPF0002BA51.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Fri, 15 Dec 2023 12:57:09 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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; Fri, 15 Dec 2023 06:56:46 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 15 Dec 2023 06:56:46 -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; Fri, 15 Dec 2023 06:56:42 -0600 From: Manikanta Guntupalli To: , , , , , , , , , , CC: , , , , Manikanta Guntupalli Subject: [PATCH V6 1/3] dt-bindings: Add reference to rs485.yaml Date: Fri, 15 Dec 2023 18:26:25 +0530 Message-ID: <20231215125627.1691573-2-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231215125627.1691573-1-manikanta.guntupalli@amd.com> References: <20231215125627.1691573-1-manikanta.guntupalli@amd.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA51:EE_|LV2PR12MB5871:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c465424-66f0-4960-0b6b-08dbfd6d5942 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0AF5NTjiXzod/bamdVY7fcU3vDNI+ykyX9CawMjJaXRE6D6U5k3CQy7e6xPKcM/6mOH1tLTPeGOZMVW1gqS/BBMIXO6i54zdwqoP9NlJJaYl1YpOoWXZsGYFUf3CrAZDlxoNYjqlctarkUmAPbTofGAjNe6mSsm3VMH0KNqysxakwka1+JpNuaPq5uMhEH0U9VTmd24RoGwLRaX3MV21QS2zgnCft5tcPWs3fGSPhA4qHRM76ByAzyvdejGvaj0fC8LIG/TLk3858DgZkTNtkfXpSv40oDevfHNVxPH4XMJRWOCM2FkylvFDxL5WXZ//LuhIz0kvEnKNrgmB8B8k+SQ3hl7DphhYci2+0+wXYOjw34iCTInOtxdM3XbDo/g45fHpNXQsluYuo4XnKiSctGgyHOG5mppi1bEL5BhUoeWfhAdoJeIPr4rnnQ7VtZeATipmDk1wM7LPw2fRwo7PN118uWQFtpyQy2p0EjLWBONrHOMSISsAiNQ70vQxaXuHeKh+h//u1Wg1f8ZysL9fpA7RdM9H+Jy6H5VVv4X7xrKscM7FVldu1h6cRCVwthalq7u/QA2D5PobhmXDUByRu2zo6/jZ8BkoRHflld/QZuY++orSXqOgy3lSskMw7EubhNcJpAoeqhaqTjQgJCcmvgR5tHNCKaajWaxLfGYownNGQj4mXzZoj4ilyAaaOSHOBPDcJbOCsxoSnBqwuOP974UMXABvAU/qdykwC2/5R4u97PwfnO65f9hnq+5dxKSpBskqbEUvL3Oo9HAez0vCEGzGGWVEp0sfnoO2cK/UuIw= 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)(396003)(376002)(136003)(346002)(39860400002)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(82310400011)(40470700004)(36840700001)(46966006)(40480700001)(40460700003)(26005)(426003)(336012)(2616005)(1076003)(356005)(82740400003)(921008)(86362001)(36756003)(81166007)(47076005)(83380400001)(5660300002)(4326008)(44832011)(7416002)(36860700001)(6666004)(70586007)(316002)(70206006)(110136005)(8676002)(8936002)(54906003)(2906002)(41300700001)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2023 12:57:09.3195 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c465424-66f0-4960-0b6b-08dbfd6d5942 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: SN1PEPF0002BA51.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5871 Add rs485 support to uartps driver and Xilinx/AMD Kria SOM KD240 board have rs485 support. 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. --- 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 Fri Dec 15 12:56:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 755301 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2069.outbound.protection.outlook.com [40.107.92.69]) (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 0D56C2DB6F; Fri, 15 Dec 2023 12:57:27 +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="2l9i0X6I" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ciHtMz+J+1sX3H7nzpEwrgbDGLczhTvKtpKEA4orvWPwI9KTXZpWFpvs6AhfwLJlbZV3C3bInU2DbZnLe4h9AAahG8WlOqO9o1088IYAYo/voN+LhGH6U/kLe/D0GiAjjR4bCRUi9teeNUfiB9Ge9guDdEFoaBQpnUbmyLJ+Gh8+pJUtL7Hg59di9/Yw0b9/s5jvawma1KQjVTBJvTYkQjg0lv8nbpgVybUCBFurz2EoX8wbRYoiCnHrHYk3sZ34SqMAKX8rbBGiy2lK/YFQXtZ+c92rjocmceJzbockb26SwiatmV0SyTsAayeCEr0D3yCNxYt8BH5J0oHmjbi/WA== 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=GEZyYRkcFpu81Kr49e+lLK+8Va/GRLlXHwoDw6ZNMnc=; b=mRgZLJJxI3XrOPMTe0eTaAChI1Wz99uu8lb6zUtnn77yMbKsQBHkR+9XLNqZkshtNMQxNluicJZ9uy9S1MM/8g5EnPWvW5Q3VUqUr6KjXbqIuw1RYwznn6lSf8n0WYPEWkBHjNQVPCjguWnmz7sXC0bGGK2S+lyHUzVZEwTZ8vqxWCDSPqaoiUnVpFYXWMkmufDCP7DMHnjZSmWeVkQICXNBJX65g86RVP50dNDW0+6ihSvQfpj8kP6Jswj9K48+Y6yK7G+sYHwKKhoOJhP/2BSMX541CTz1sKD6radT/4gaT4FVlH3NJxyJk2DyV/DkXitvpp7xOrQkaZJkmX1wXQ== 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=GEZyYRkcFpu81Kr49e+lLK+8Va/GRLlXHwoDw6ZNMnc=; b=2l9i0X6Iure2Oa8RZjgwJSdPwOgYo7Wppnc5mJY+PG/Hk0F/YeLjgrslA6TM8/74tFQ+CxvxBOfniHv0Ni8RyH/HKXe2FIH5E9WeBF7B2oDPjnPIp9sp8hph7lnkVx3V4hVFfBxJXxMEl5U6qfeTsmt0Tc04nggrMtnI7oBIhFo= Received: from CY5PR15CA0205.namprd15.prod.outlook.com (2603:10b6:930:82::23) by BL1PR12MB5801.namprd12.prod.outlook.com (2603:10b6:208:391::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.31; Fri, 15 Dec 2023 12:57:24 +0000 Received: from CY4PEPF0000EDD7.namprd03.prod.outlook.com (2603:10b6:930:82:cafe::d) by CY5PR15CA0205.outlook.office365.com (2603:10b6:930:82::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.31 via Frontend Transport; Fri, 15 Dec 2023 12:57:23 +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 CY4PEPF0000EDD7.mail.protection.outlook.com (10.167.241.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Fri, 15 Dec 2023 12:57:23 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 15 Dec 2023 06:56:52 -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; Fri, 15 Dec 2023 06:56:48 -0600 From: Manikanta Guntupalli To: , , , , , , , , , , CC: , , , , Manikanta Guntupalli Subject: [PATCH V6 2/3] tty: serial: uartps: Relocate cdns_uart_tx_empty to facilitate rs485 Date: Fri, 15 Dec 2023 18:26:26 +0530 Message-ID: <20231215125627.1691573-3-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231215125627.1691573-1-manikanta.guntupalli@amd.com> References: <20231215125627.1691573-1-manikanta.guntupalli@amd.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD7:EE_|BL1PR12MB5801:EE_ X-MS-Office365-Filtering-Correlation-Id: 44ab060a-3dcf-4d21-bfc2-08dbfd6d61da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8lUVB0LX41EZrokY4kKvv7TP/+QctcT9VpnOSGrgjDZNv1nYNZfwgPNZfvK8tcIsqPOTkdgQ2df5hwYMG9o6FF4cEIJAuwIFyu8L5MCWnMrHi/CdXHnnS6+cuxZ7xqLjolgrfJ6FtFqM7+cb+1NmT5ibDAJP/j/VjMHvmMSjHAb/8DVnFQfvm0kOfB2VFCo9xoIpVk6NHgvjVxG7hlyvSrhEzH8Yu2n/TH/Jo4S5tFpHoT7oWq9NH/hripkrhz438GFUYWdNPCgMq+hrX5KppdPu5kQ74ARvZTOd2H6ad5xb+HbsOq6UnntF+Fc86sKBC26IxKc12uwDDpEdSjtsdyL2w1ePt3p+6BKC93qiblaQ3ZsndSCgI8XIkox+8n2jCgAGISVanmVZyOxXUtYIdCjhNx7XfLti/temMkBmo4cxwEXYSia6zkYEZmc0P917+4i2sMT4V095/RDjuu7NjLAL1mqQ/rRi8wXDo5GH2xJvOnGuegJTo5KfTV+18baVr7NAG5SGSsJRA6TB/1rZkIzbqaWzCU8N5V2/oP4dm690JoQHmaMPymLrfOR9cQxdGB0VUxRFBhR+3yDjEtPKPwnbGW3iyYuxkyVlXQQF7lR6AZYS5i0jhflMI3LbhCmHXDNaf4SP5pxJXoFWk4LNUAWMX0cc0UVskpSU1KK0IjozeQj5K/2+zI+AFYGo4QczTxJ49lTtPwFatUIS8A1MeBZmMJQuDpXTYiLLFYxR2cEmFfZXd+plyaU5mmVwBIupRqfzGSoEupT+9nOEy1OSyZ1kzOQiM9h9tjcKj1uCj9k= 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)(396003)(376002)(346002)(136003)(230922051799003)(1800799012)(186009)(64100799003)(82310400011)(451199024)(46966006)(40470700004)(36840700001)(40480700001)(40460700003)(36860700001)(47076005)(81166007)(356005)(82740400003)(2906002)(7416002)(921008)(36756003)(5660300002)(83380400001)(336012)(6666004)(426003)(1076003)(26005)(2616005)(478600001)(54906003)(70206006)(70586007)(41300700001)(86362001)(110136005)(4326008)(8676002)(8936002)(316002)(44832011)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2023 12:57:23.6951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 44ab060a-3dcf-4d21-bfc2-08dbfd6d61da 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: CY4PEPF0000EDD7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5801 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. --- 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 Fri Dec 15 12:56:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 754496 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2044.outbound.protection.outlook.com [40.107.94.44]) (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 434532DB67; Fri, 15 Dec 2023 12:57:27 +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="JFjv3tSX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FSwRJvqurKHxYIXB/V1avJKejXNWiNYqzOK1fhtnOP5bwNJgBiEmbsNqQh8w58U/UTq3TiQokt4jwT0b4e26hEFVqdSfdD8+NzeTW0eWZfOy/AL2WfAUfigK6Skza8Bb9AG9fXFH3NtEGIykJHEkeJx3x0UZh3N9OdMSdU/NqGDpi4KjJFjTLC6aK8c6imA8clOGFwyrTEfDXaKLuq4NQ75vvqwj7m8oDOp9KfAwi+U6AJhnjxZjT9VIIJvgSQOh8TfDW+crkh+ekYo95kLCqtE+LOwDEyoFZtLYYA3oVnHsOge/59xdJZcAs/UTVVzJKoL9ja0sP3svBndJxF7WYA== 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=8FbACE4kyCuZp9QvEztIo+ETHnGrgDPbRz5qy3uE/L8=; b=Z/CYboYelQWHIm6GUpATR6W7ZIMUzJhyLJiROsihexnPWf2JPx5TMCIsqIiQ8t6eUD9xkVRElMSI23kYShK6Ay5NxaRweIaMKJ5GqTP6ZlppPazvjqzGLtfY72l6rJ5Xg6jDysJNxjOy6wWttd8PzXZajn1aQtEkIwAIyE3ULkCEwyrxKjMeMlcEtB9rQwbTuv4dy+nMM9CWerWeJS50rgpCrourLVe0vCOq4neSghtKvOpw3Ryv7Bfkaofwahmrop/Id24LYmqukwqeL5vt9HAqMGhRmd1Z4Z/xPyNfnYCib9JRXrryaSm5Q+bT2nm4oBw7fvDHfwKYmdCgg29dUQ== 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=8FbACE4kyCuZp9QvEztIo+ETHnGrgDPbRz5qy3uE/L8=; b=JFjv3tSXEA85rkXQyMK3hb/Or0v5NUvGhlpVkWRyu75eLZONnWzTYZxvV0WaThX3orZKyGcjl7oeZvwdfs6mtJnFIwA9n3ErvtabETn4iYU0/yI1CNfF+KcFVx59uZuywntnZRyiZA6/xa4VdRHTT60rE05YOxEcliX8VTKwJ0c= Received: from CY5PR15CA0194.namprd15.prod.outlook.com (2603:10b6:930:82::12) by MW3PR12MB4393.namprd12.prod.outlook.com (2603:10b6:303:2c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.32; Fri, 15 Dec 2023 12:57:25 +0000 Received: from CY4PEPF0000EDD7.namprd03.prod.outlook.com (2603:10b6:930:82:cafe::7b) by CY5PR15CA0194.outlook.office365.com (2603:10b6:930:82::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.32 via Frontend Transport; Fri, 15 Dec 2023 12:57:24 +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 CY4PEPF0000EDD7.mail.protection.outlook.com (10.167.241.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Fri, 15 Dec 2023 12:57:24 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Fri, 15 Dec 2023 06:56:58 -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; Fri, 15 Dec 2023 06:56:54 -0600 From: Manikanta Guntupalli To: , , , , , , , , , , CC: , , , , Manikanta Guntupalli Subject: [PATCH V6 3/3] tty: serial: uartps: Add rs485 support to uartps driver Date: Fri, 15 Dec 2023 18:26:27 +0530 Message-ID: <20231215125627.1691573-4-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231215125627.1691573-1-manikanta.guntupalli@amd.com> References: <20231215125627.1691573-1-manikanta.guntupalli@amd.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD7:EE_|MW3PR12MB4393:EE_ X-MS-Office365-Filtering-Correlation-Id: a79ac0a2-162b-4dab-564d-08dbfd6d6273 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nWfK+rNaF4Kocp6TeqO2bJ5tjhL4GpksvuyN5JO0epkp+bDuHTuCHjlDluYKFdPbDavLN+pF2TL2FCNrStN/KFcWuq6hW8CKkA5ONzBgxZ/xMPB8DsERe04tah3Npm4T/IEenM8Ph4LUHewVICHWQIsxI9S/3mYaODlY0VarGGxh8leL8Awb6Ajn5+wMsbelz62BcwP8lBc41tJBqr6UAxxOpVBjyrLxD8KU0lGw3n2J/JlWwp4lHM+uuWNWFaiRhxr7cHMwiJzlQbvys7JENk5gc+rbYkkeL9tUnF6mcobzmXLaVaG+fL/XzJenOoviHj1NmK1ioVAKPI8N2pR9r+gZvmu0rXNxeDV9OFMpkB3ANy6oCsnUalxFoKJRxKJf9DlXFxc/VfQOf1lh5O8ohFAa7A9GHWAn2oI6MSuLUth2Qi3rw4uNhMJRAZ7uxLwHvdOf6M+e3dWzwRzLY2Lu6VwjMqS27fnskd8NNEwQ4vVnECcF4vpZOt79DN+zOLjNObWTxgQ5ZtZe85yS6+Te4k5RqOb5ddHxC9m43wjsEx6ptFurMSnOiEB4zPKM/RWhjEJJg4EhTQZqSRoqv2lijH2qFJfR7Qt3dnj4J6+IjJscMQL8i3QbfCNc6hdC3RlPRJ01cD0RBATQFmpL3SSoxSCognGiNRSZjTYH2oKmoWEQ5FcHr7ABWb04sT5PEzgqf7t4sDENjiQIXes3lv3vh1FbdmNe6GFw1UJqZXP0L3BJzOVR8Mwl8H0tkk9r2yXd3lc4uWPkHs/d/kOSHBdgxf6gB5NQx7lSNugDqQv5QJI= 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)(396003)(136003)(346002)(230922051799003)(186009)(82310400011)(64100799003)(451199024)(1800799012)(46966006)(36840700001)(40470700004)(40480700001)(40460700003)(26005)(426003)(336012)(2616005)(1076003)(82740400003)(356005)(36756003)(921008)(86362001)(81166007)(47076005)(83380400001)(4326008)(5660300002)(44832011)(7416002)(36860700001)(6666004)(70586007)(316002)(70206006)(110136005)(8676002)(8936002)(54906003)(2906002)(30864003)(41300700001)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2023 12:57:24.6483 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a79ac0a2-162b-4dab-564d-08dbfd6d6273 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: CY4PEPF0000EDD7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4393 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(). --- drivers/tty/serial/xilinx_uartps.c | 222 +++++++++++++++++++++++++++-- 1 file changed, 213 insertions(+), 9 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index aafcc2179e0e..04cc23deebdf 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 + * @timer: Timer for tx and rx + * @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 timer_list timer; + struct timer_list 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) +{ + if (cdns_uart->port->rs485.flags & SER_RS485_RTS_ON_SEND) + cdns_rts_gpio_enable(cdns_uart, 1); + else + cdns_rts_gpio_enable(cdns_uart, 0); + + 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) +{ + if (cdns_uart->port->rs485.flags & SER_RS485_RTS_AFTER_SEND) + cdns_rts_gpio_enable(cdns_uart, 1); + else + cdns_rts_gpio_enable(cdns_uart, 0); + + cdns_uart->rs485_tx_started = false; +} + /** * cdns_uart_tx_empty - Check whether TX is empty * @port: Handle to the uart port structure @@ -579,6 +646,44 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb, } #endif +/** + * cdns_rs485_rx_callback - Timer rx callback handler for rs485. + * @t: Handle to the timer list structure + */ +static void cdns_rs485_rx_callback(struct timer_list *t) +{ + struct cdns_uart *cdns_uart = from_timer(cdns_uart, t, timer); + + /* + * Default Rx should be setup, because Rx signaling path + * need to enable to receive data. + */ + cdns_rs485_rx_setup(cdns_uart); +} + +/** + * cdns_rs485_tx_callback - Timer tx callback handler for rs485. + * @t: Handle to the timer list structure + */ +static void cdns_rs485_tx_callback(struct timer_list *t) +{ + struct cdns_uart *cdns_uart = from_timer(cdns_uart, t, timer); + + uart_port_lock(cdns_uart->port); + cdns_uart_handle_tx(cdns_uart->port); + + /* Enable the TX Empty interrupt */ + writel(CDNS_UART_IXR_TXEMPTY, cdns_uart->port->membase + CDNS_UART_IER); + uart_port_unlock(cdns_uart->port); + + if (uart_circ_empty(&cdns_uart->port->state->xmit) || + uart_tx_stopped(cdns_uart->port)) { + timer_setup(&cdns_uart->timer, cdns_rs485_rx_callback, 0); + mod_timer(&cdns_uart->timer, jiffies + + msecs_to_jiffies(cdns_uart->port->rs485.delay_rts_after_send)); + } +} + /** * cdns_uart_start_tx - Start transmitting bytes * @port: Handle to the uart port structure @@ -586,6 +691,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 +710,40 @@ static void cdns_uart_start_tx(struct uart_port *port) writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_ISR); - cdns_uart_handle_tx(port); + if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) { + if (!cdns_uart->rs485_tx_started) { + timer_setup(&cdns_uart->timer, + cdns_rs485_tx_callback, 0); + cdns_rs485_tx_setup(cdns_uart); + mod_timer(&cdns_uart->timer, jiffies + + msecs_to_jiffies(port->rs485.delay_rts_before_send)); + } else { + if (!timer_pending(&cdns_uart->timer)) + mod_timer(&cdns_uart->timer, jiffies); + } + } else { + cdns_uart_handle_tx(port); - /* Enable the TX Empty interrupt */ - writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IER); + /* 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 void cdns_rs485_stop_tx_callback(struct timer_list *t) +{ + unsigned int regval; + struct cdns_uart *cdns_uart = from_timer(cdns_uart, t, 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); } /** @@ -617,11 +753,19 @@ 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) && + !timer_pending(&cdns_uart->stop_tx_timer) && + cdns_uart->rs485_tx_started) { + mod_timer(&cdns_uart->stop_tx_timer, jiffies + + msecs_to_jiffies(cdns_uart->port->rs485.delay_rts_after_send)); + } 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 +973,12 @@ 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) { + timer_setup(&cdns_uart->stop_tx_timer, + cdns_rs485_stop_tx_callback, 0); + cdns_rs485_rx_setup(cdns_uart); + } + /* * Clear the RX disable bit and then set the RX enable bit to enable * the receiver. @@ -888,6 +1038,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 +1054,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) { + del_timer_sync(&cdns_uart->timer); + del_timer_sync(&cdns_uart->stop_tx_timer); + } } /** @@ -1032,7 +1188,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, 1); if (mctrl & TIOCM_DTR) val |= CDNS_UART_MODEMCR_DTR; if (mctrl & TIOCM_LOOP) @@ -1455,6 +1611,37 @@ 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; + unsigned int ctrl_reg; + + 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); + /* Disable transmitter and make Rx setup*/ + cdns_uart_stop_tx(port); + } else { + /* Disable the TX and RX */ + ctrl_reg = readl(port->membase + CDNS_UART_CR); + ctrl_reg |= CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS; + writel(ctrl_reg, port->membase + CDNS_UART_CR); + } + return 0; +} + /** * cdns_uart_probe - Platform driver probe * @pdev: Pointer to the platform device structure @@ -1597,9 +1784,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 +1819,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 +1849,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);