From patchwork Mon Dec 18 09:44:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 756223 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2058.outbound.protection.outlook.com [40.107.237.58]) (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 2661112B61; Mon, 18 Dec 2023 09:44:31 +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="PggktZv5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NIrgUHIoJWGHaeqNkxklYQsY8h54vd5qz+WAoJiuE+xAGhI4MMdr0o/IDN8Gaj2lLnZx5tTWr0H437CRNsIG3uwlCKTc7YxYRyfWmsaxU4R/zzBXDn2Sgtj6n1dihUQUP1xo3M528IeUPHXxRkXaa5kOOJEQimBUoZVlsaN55FZ8xoxj2iGKTxYbVYpB0C0cCHnKDy+lR6teQfyJBeg/iMBz4YXuzNR1AbrFdGLm7LwuTAvOd5hbSTSrmPF3MRqqffo/0hXIBm1BG2mkMOgPfFm91RLaj+SR3atPXtwnG2gBVEiCru6L97JOeEghyt2HU8l+qrNqA1khiH8E2JBYug== 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=vbhj58mQcIKLIJVwk71Rk+CDCC+Wx+mOoWWWEqARXPY=; b=mubDorlsbJjSB4lRxuQHe7a4ZQzz+3xrhY49U+8Xf1+E6nYTdWVyMeOcLiixpZHAfu+QO7naGHw+ZFaOi+vq9T28War3wrU7s/GNuR9/aySreS68Ni3DHW6bRiqtCYNIWMh8DQFrxU4aj7TSY4mtw9ivsS1RjP7Cuy/mO2ckmIxHzuwOgll08jSpK54C0ucRGKslENW9erSW5uAPxbwHbT+4d/rzFIW0d2K3L8CJYfZmUcvEyHzktwUpMCqjpj6wbaSlnaUznP5vxa2eYNRCqxCqnWQe9OAU0OaO0Aje8eVpsOlZ279URaYQ49UF6fb0XjI0xV7YKDqrG2rc/znewA== 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=vbhj58mQcIKLIJVwk71Rk+CDCC+Wx+mOoWWWEqARXPY=; b=PggktZv5IuHoBa8v8s9XLso55vKT5bDf3+RKxJGNptkFRmZp6pEjQzcQQYrTI4+M/7Yah8uFwMt/xwTtFUwBiCcRxH/gMIyDzP/7zTIyooJXow7Y6UIqv8yNbj4LMdECwoSi6zPjRqZGKjorbcbDsAtnZo9rv9A518HICfUslgg= Received: from CY8P220CA0031.NAMP220.PROD.OUTLOOK.COM (2603:10b6:930:47::17) by CH3PR12MB9252.namprd12.prod.outlook.com (2603:10b6:610:1ba::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.38; Mon, 18 Dec 2023 09:44:29 +0000 Received: from CY4PEPF0000EE3C.namprd03.prod.outlook.com (2603:10b6:930:47:cafe::a7) by CY8P220CA0031.outlook.office365.com (2603:10b6:930:47::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.29 via Frontend Transport; Mon, 18 Dec 2023 09:44:29 +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 CY4PEPF0000EE3C.mail.protection.outlook.com (10.167.242.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Mon, 18 Dec 2023 09:44:28 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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; Mon, 18 Dec 2023 03:44:28 -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; Mon, 18 Dec 2023 01:44:27 -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; Mon, 18 Dec 2023 03:44:23 -0600 From: Manikanta Guntupalli To: , , , , , , , , , , CC: , , , , Manikanta Guntupalli , Conor Dooley Subject: [PATCH V7 1/3] dt-bindings: Add reference to rs485.yaml Date: Mon, 18 Dec 2023 15:14:13 +0530 Message-ID: <20231218094415.2503672-2-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218094415.2503672-1-manikanta.guntupalli@amd.com> References: <20231218094415.2503672-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: CY4PEPF0000EE3C:EE_|CH3PR12MB9252:EE_ X-MS-Office365-Filtering-Correlation-Id: 0bbff0aa-d96c-4cd1-3574-08dbffadede5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: szQoueUoGtnwpwaVmi+thzBuDKoOs3HfkpPrv0ez5MV4Y+3fLi1ffNtH/7+BsuBaKr8Yh/TsY6fPdafpFmq175GUcuH7bYOanJxBdO5Fibuc3k00/Pg6O48QZxLFhSVKAhdGRxamSf/9+GH0rSCH6R9PlAA9yJDYtcQngY7Igi2IBEJ+xADxnFWpfxNovdmNyk9GLd6CJk0AYzL+R93h/Hcqfw7Vx03uQo0uWDaZxorj4QwMbiGL9g5oBjX24n4ssY5+FOPl7M8BYiLS6k9sMBhhm79TPd7ZO/xIk7vt5HijarmAvZvBahflOCIyAY6YR7lrOmDt4qEu3vVKtP6+Sx7E/I0mKpKMwaKwIQy4Kxto2fIeJ7hqU3I8FKloZc/xQJXbH82CTEwxfwpUATOuoUoI4Gc9pHEYtH3W9pzQlZ2VJ4zpY7ppM9iHijbYpBKRN+rbJ91kodJcqtW5hT5WQ/8n1aTQyTGSOo+pT6s40CjVChska1zIexnlYXq396jan1rnRPGeZpzp0tlF1328qz1f++FiCeqvh+BFflFXuiS2bfhodkpQ6V1FTX6AlaL8a1cjWBQKO311vqIP78RjOFD9NzZ8MgelpXBTZ7myd7AJeNjaRiUcjMAacBVSZw+5/f5H+/9Ibel6fgnD62ac7GYpHwcgiqpWGIF2atY+jmHdexz9Z19KqhL6Yk5635rQd2JN64P/mQgl0xSJ0kR0dtQCepdvm3TrUTeX194l21xpfI8u7vSuqVkag1ca6FQE+FrIWsFHs0Mto61s1esBKlYsNEbBDn+ikE7euq4q1LU= 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)(346002)(136003)(396003)(39860400002)(230922051799003)(186009)(451199024)(64100799003)(1800799012)(82310400011)(40470700004)(36840700001)(46966006)(82740400003)(7416002)(356005)(81166007)(2906002)(40460700003)(36756003)(921008)(41300700001)(86362001)(70586007)(54906003)(70206006)(110136005)(316002)(426003)(336012)(6666004)(83380400001)(40480700001)(2616005)(1076003)(478600001)(26005)(36860700001)(44832011)(5660300002)(8936002)(8676002)(4326008)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2023 09:44:28.7766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0bbff0aa-d96c-4cd1-3574-08dbffadede5 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: CY4PEPF0000EE3C.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9252 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. --- 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 Mon Dec 18 09:44:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 755648 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2047.outbound.protection.outlook.com [40.107.220.47]) (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 C57E6134A9; Mon, 18 Dec 2023 09:44:38 +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="gnE1HVuh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I//G7hyD5rRglomuKRSr4MOuKSXdIMnuZ6cNzwO708mBvP9Z3QM9cphI4paM/zrp93NkNcQOaMcnv9PMff6OsODUO4FyApNvbGHi2QIU/mFfX1fKU8P4zo+2e1qlIljitwVZijxp4vFsatvYZ9HLGw0AEBo/jmBUPSkG+7ldVBBG1j4ZA/maB1VyGFsdZHJZNzgu+W6xVblAPWYmTqJk8uweW2TG1Uys2x2JY7hi9Yz51iL33TuYkORttIqMPITUiLsFD5yFZkjDYGPa2zx7HmnEWaLV84jdi3AfKds8bQzvGiApx+AWZAvP0yx+mzlPGeXV+OJxNwq882oBFZD5iA== 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=3yA8w1IE8qRpYbPMWn888NhB54CMgVSX/1uZ5lq1Y6g=; b=eJb3hmx2jmLL0y7puBqul1IvfuLlHCAz96rK2o5BHAcH/se2BpxDX3LHaFzWMoaFUAAq+EjcqgzoQEO+iReShkZl/NaN0z6KUnV1Ff6qYvn7cEn5/quAU/hUcPAVjBa3qwkhZZfJw5fVvX59BTFNXF7j0S6oz4P5OiSM/OEOqBL1y+BXl9n2wTRmJpF1ba8h5CNziKdlzFx+Zu+uX5q0ue5ap2Ztr4Glm6aZWaM2vhZcuYmKBwaptfIwNWR2Mp9iPvOVbgvefh900xibF+q1lLM4Vlb5fvRtO9FpTY/sFuEHu1W1qojCfWXgHvqAFKx2HvUVs1pkm/n4mkgwp0Ig2g== 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=3yA8w1IE8qRpYbPMWn888NhB54CMgVSX/1uZ5lq1Y6g=; b=gnE1HVuhRZed0ApvmIYyYz4YN22Cz2dzdAC1L9wwpDwegVHkm/Zvhg+2aNt+SZGLnjR4KxwRt7/YJ693RnCEa7haYkJEcJrRmi+lm5DnOCKP44fzuXWXFgnRMeK1QM7N+PErzHps5OVvMPBhGQ0OpvBefgOYoYSon09am8VChn8= Received: from CY5PR15CA0073.namprd15.prod.outlook.com (2603:10b6:930:18::21) by SN7PR12MB7836.namprd12.prod.outlook.com (2603:10b6:806:34e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.37; Mon, 18 Dec 2023 09:44:34 +0000 Received: from CY4PEPF0000EE3F.namprd03.prod.outlook.com (2603:10b6:930:18:cafe::c0) by CY5PR15CA0073.outlook.office365.com (2603:10b6:930:18::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.38 via Frontend Transport; Mon, 18 Dec 2023 09:44:34 +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 CY4PEPF0000EE3F.mail.protection.outlook.com (10.167.242.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Mon, 18 Dec 2023 09:44:34 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) 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; Mon, 18 Dec 2023 03:44:33 -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; Mon, 18 Dec 2023 03:44:33 -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; Mon, 18 Dec 2023 03:44:29 -0600 From: Manikanta Guntupalli To: , , , , , , , , , , CC: , , , , Manikanta Guntupalli Subject: [PATCH V7 2/3] tty: serial: uartps: Relocate cdns_uart_tx_empty to facilitate rs485 Date: Mon, 18 Dec 2023 15:14:14 +0530 Message-ID: <20231218094415.2503672-3-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218094415.2503672-1-manikanta.guntupalli@amd.com> References: <20231218094415.2503672-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: CY4PEPF0000EE3F:EE_|SN7PR12MB7836:EE_ X-MS-Office365-Filtering-Correlation-Id: 044c168e-74c0-43f9-e28a-08dbffadf142 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QzH8NacNkFRijCDDA7WSsC5LWgTJwQqEWZ2o8q8C1yS/uWC3PnbXnKWtp1dcXi1MwtdDQ/C1BQQLYYFjy69wpV1ksU2XeXQqGOOiK8N/qlQugDcOKW36cQUtHTp2N1CpsR1v7+4G4VSXqAtU3rCCtMqMfN7fonkqFkwRg8LRmpsKnC45+SvOoYYAUOuzd2DeKPSd0zOVkI8pSmwkIVLClZW6sORV3sU0AMcRSeY/drD55r6VDGUNRU0PhSA2ZVQF2A/qGdV/ylwQR6+7FwFy0ycR0V0xYI4AUJphK1K9nD/t3bbT5yhH5/6zgUbLc/clbfM+rmAFcWUEd69y/sna/Y8Xjm4qRv/8K5zyadV2zkyF9TloeETVHupaGKejcZRnKo96QKhT6cTBwFRcKo058xx6k5JWylIHjuRBy03XlxDoa0U6Xo334emJiFU/GFEN5vICr7RcdSeB6hGioLs/VkE3E3X4liEmG/zdqJoQKK3zkPyU1DkK095z9OBS0o1wYn0nGpNe2JVT+ETrRMLAuCYPMByd6p4SRlp9gCpYqysU0cIX9pjJFjZE5pNyXpJQNcCE1Ci9Y3BXsQSzOaZnjgUbUTS5m8jMKoP+JcS0kzRPU5S3Mjrt0TRLv++LuElLgdXb3d6KuiMMJauLc03qir2MvdV8rTiWvmSwsgYxnHLaC2fWbRsqtWJlOmwU/bojL+gnV5nWDjMwqCzMPcFaGR9xrznBHO1ZKDEgMMu7P+EvvH2xgiD8kI75SuSLEJXkEf++vhEnOEAHVs7SGLikcDbnQw6h3t6s0Rd8XLxw9to= 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)(396003)(346002)(136003)(376002)(39860400002)(230922051799003)(186009)(64100799003)(82310400011)(451199024)(1800799012)(36840700001)(40470700004)(46966006)(40480700001)(921008)(40460700003)(70586007)(110136005)(8936002)(86362001)(81166007)(356005)(82740400003)(36756003)(36860700001)(83380400001)(47076005)(336012)(426003)(26005)(2616005)(1076003)(478600001)(2906002)(54906003)(8676002)(6666004)(70206006)(316002)(4326008)(5660300002)(44832011)(7416002)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2023 09:44:34.4236 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 044c168e-74c0-43f9-e28a-08dbffadf142 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: CY4PEPF0000EE3F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7836 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. --- 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 Mon Dec 18 09:44:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Guntupalli X-Patchwork-Id: 756222 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2056.outbound.protection.outlook.com [40.107.243.56]) (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 E915C125AD; Mon, 18 Dec 2023 09:44:43 +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="pEoALyrk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kVESFAjoeGwJuDdZM6ZSLp/kl+eCb6SL8tZXaAE42rKqjwS+Mknz7NtDZ5itK0v9dmoChyg8ZZMobt8doHuyE/iaQwQ14eRDnUMxnWm9RyutM9AY2EwPVVE/rzqONJkjo79P/8X276HJ58mqRSIt1YhPvUKbMT8/wV1r6YmH5jbN+A1LMMZmHoaY8TnA40agAOjxD7279F4DuRm5r+e0vqUPDzSHangSGg6ggQGwnupVidLoblL1lMvzRh+mNy8xK+BPVI4myLGVkIvpKOyaV0au8skfHFbBvnTL5zkR1UiFVwNJKj048cR0Rnhy8RzEZ3A/gQUBdvV+WI1oFQFTNg== 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=rDpFdlDo6QU4GK83BVBhq6ads/H/v+mnlTmia3x1EL0=; b=gq+qLVffJatW0qpeizkTJxTju6mgx3uSNSglAmkgg1aG3bwKqz+Ev48pO+0gfcP4nBTiCpr+Xk2zJG70kSKgzl49jl55U7yIeyW7coCCFt45NtFigGurRBf1nJMgU5f6oi/YjSC2Iqx+YIB3cB0Dq9ThqiUwA/GxJy0eLwS1ijkmUkIxjb9KAtLFar120yPVsLclzvAnHi+UqfuQV6l3qd7EDh5bcDH3QAoc/ovokr8jtS869D0A/9tNNteSrVhIe4K7Pz3y+zhmSqB9YUDlDBqPM94CWP7KeJw0PcyszvU09WVy26jFof3R1UVGCo389KzTLypbGRITxWmonUAb/g== 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=rDpFdlDo6QU4GK83BVBhq6ads/H/v+mnlTmia3x1EL0=; b=pEoALyrkqj6xrtU962UQ08FvH2SyfoiQPuXMEu8P+HPvcKsdAOR19Z5pPIGsQJRzckvPlqviSqZt991vhSY2JrX8uf2fzhAZ1avesF4t+oA1tsXQLAm03yZWICVwO4K/khuohcDc6mTBaChrDgtkPfAG63lG7NrQhgdLIA8rEyQ= Received: from SJ0PR03CA0141.namprd03.prod.outlook.com (2603:10b6:a03:33c::26) by PH0PR12MB5483.namprd12.prod.outlook.com (2603:10b6:510:ee::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.37; Mon, 18 Dec 2023 09:44:40 +0000 Received: from MWH0EPF000989E5.namprd02.prod.outlook.com (2603:10b6:a03:33c:cafe::9b) by SJ0PR03CA0141.outlook.office365.com (2603:10b6:a03:33c::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.37 via Frontend Transport; Mon, 18 Dec 2023 09:44:40 +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 MWH0EPF000989E5.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Mon, 18 Dec 2023 09:44:40 +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; Mon, 18 Dec 2023 03:44:39 -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; Mon, 18 Dec 2023 01:44:38 -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; Mon, 18 Dec 2023 03:44:35 -0600 From: Manikanta Guntupalli To: , , , , , , , , , , CC: , , , , Manikanta Guntupalli Subject: [PATCH V7 3/3] tty: serial: uartps: Add rs485 support to uartps driver Date: Mon, 18 Dec 2023 15:14:15 +0530 Message-ID: <20231218094415.2503672-4-manikanta.guntupalli@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218094415.2503672-1-manikanta.guntupalli@amd.com> References: <20231218094415.2503672-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: MWH0EPF000989E5:EE_|PH0PR12MB5483:EE_ X-MS-Office365-Filtering-Correlation-Id: bd468f04-baf9-4c3b-d96e-08dbffadf4c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SAGE5fyvZH4W/6UPRs/cFh1N5ei3YTF++Ly1omunqAZzoiPyjkgfFddwLoh4lBxIqGwxXQRiLfj7G8WiFS+V9+K7V/tBYfDPkkG71N55sQEk44GlG8ZaXDLtWmQwNwOmYzshYK3AXD4rSUj6rZ8KHcnwEGvyDCzWwMSsFenSIQOgV8qW6E4iC3yX8Xt1+oOsCYXD3Hb6bj7v+Dvtehp5fFQQTQW9YpxRNXOEhkuRlH+IqS0NNNyVP/xPzxts/Jr+62HJnQQNofNx+/oPMNI+u+4PdUnAipaDuSSeb53eT9i9Guf9LA3jjpb7heGqujqu1K/K1oafs/iXR0enCgUZ3uytsxfC8fefzzLJWChM54IPMtczbbdL3WICgINL45qSGV2WNjm6l5auguVnTIAQ+fDzGav8Jg9AbkZ43sVPq1wwp+XCFK5ljTtgDjRyzsdlS0Ec/p26TeHBbgU6tmuOTFWp/rOYXiCco+367uDGNx84tF5Q+XlIjkbza7lnQIO71c5pO7qbrveYefsecVXjCSrQ5ZoKoWFxprrEhMccXkZmOK9tmGmM1Z4AtKhTFnuogOHhIJPVK6j36/hFlKMxcoAcVPj8g8O2oJ+msnUv7zh0HVg6whnki8vpRVfuP/kA5A2KHSMXeFP5CydHLZrE3t1Cmx9cPMmkjl/AiiYvIeB6Tv7g0P6T5ESF3z/9iK40c+t8h31wM+cj+ghsq3XgIt5T7Pf/apj94xcVdq0gYi11+4BFvLXPjVUZHkKSa6p7B5KOlyKJ0iH02IiilZd7t3bD1Po+c23OpkFoSuZqFM8= 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)(346002)(39860400002)(376002)(136003)(230922051799003)(82310400011)(1800799012)(64100799003)(451199024)(186009)(46966006)(36840700001)(40470700004)(36756003)(921008)(316002)(83380400001)(426003)(336012)(70586007)(70206006)(30864003)(54906003)(110136005)(7416002)(40480700001)(2906002)(47076005)(8676002)(8936002)(4326008)(5660300002)(44832011)(36860700001)(6666004)(26005)(1076003)(478600001)(2616005)(86362001)(41300700001)(40460700003)(356005)(82740400003)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2023 09:44:40.2304 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd468f04-baf9-4c3b-d96e-08dbffadf4c4 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: MWH0EPF000989E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5483 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. --- 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);