From patchwork Fri Jan 26 14:55:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Farouk Bouabid X-Patchwork-Id: 767175 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2083.outbound.protection.outlook.com [40.107.6.83]) (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 5DA651B963; Fri, 26 Jan 2024 14:58:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706281108; cv=fail; b=l2g/QPhux9zd9DsfJGoezinydVgHQonJF16WdX6XkKckbj379CYQsH/M97ZJixX4m/D6di5YlqX3/9nBTbhemU2IL6HbPMUZkVjAcdEspJbXKWQx03OojXVuLAlIygxHVTJTejK+HAPvTE9GblkxY6NY7cmn6Pa4giArz0WXM18= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706281108; c=relaxed/simple; bh=0IrMSMvFKpqj1lAwdLsZodaIV5l/8Q8O27U8dq1joso=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=s/bd4Tln+dfnLHA3FB2JlmEkWw9DHM49WXxuHsNlzlOLq4Fz2/aNnDMtkzy45y2z+kMWc4YAumWN7Rhopa1bC3cm+BiSuXfuXyTslUvD7P6s1grl6Li+wrksZ2J3FPEK74Zf4TkwUWJwYm1cNPf7K5WgbDgNwxVXTGEZMGCt/ak= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=theobroma-systems.com; spf=pass smtp.mailfrom=theobroma-systems.com; dkim=pass (2048-bit key) header.d=theobroma-systems.com header.i=@theobroma-systems.com header.b=E/fPac+X; arc=fail smtp.client-ip=40.107.6.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=theobroma-systems.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=theobroma-systems.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=theobroma-systems.com header.i=@theobroma-systems.com header.b="E/fPac+X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ia6aSDTVy/sjv9eWQRouY9WVtQaUXSNbfuObYu8b5QTKDJwrmzDfXlCWOF23IjYylSdPh0U/X/ZzckWv5aYFaRY1qmpsn4G8quiWVDzuQ5F8mdfPupMoVhy1q0taD7++cnPXcmHDABHBIEuGqCPjteYhn7/H2l2VgJJDMNZnMrG0sxpVvPtKLe5f5yTczsKhK88x0uA9qrP7kytVOMpqjIxeoVB5iLFv8ZpHPZyQqRCI54hPlg9oxNu/gkcWNTk/IPGqDp4dv6xXgh37g4xDj1fFKy/vhRA5t5htLicIg5MI6fuNwlDKMQtvQ8NTFWvvww14ryow8mVC7eC+Gx2new== 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=fSCKe2OcTqJsvI3kD+f+eWX2tw7eVNsZl5iY1pZu8Gg=; b=K/w/a+0JuETUIGrWN5JsBGeTQLgUaF0NXINl+HPPDzrSGwIj2aVaY3IN9b+QHDPpx1PspBezt+3f45BVZWwYqcYO7oNBF0K3s1+ZQewg/TpfgFYyiftuBk4UMxrEIn0/JTSDX60DSXn580jcpmzPESju+THaN6sNGo1haRWlGh6nawwRWDXQaS/FOOHSnrfETqLYdvv0gsByPXoHvFAjeXM9vC6jL7RRo7xQvGnf2vldh2OXZNvIZ3Tbb776SN4wH+6tXyazUA4yF/muv2MQyKav4fNAZa8KutxZkxNVA+mTTxhjIQZgXKyqeO2hRLkewaOcz3nFlYu1iDUHeF/6rA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=theobroma-systems.com; dmarc=pass action=none header.from=theobroma-systems.com; dkim=pass header.d=theobroma-systems.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=theobroma-systems.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fSCKe2OcTqJsvI3kD+f+eWX2tw7eVNsZl5iY1pZu8Gg=; b=E/fPac+X+mn1O7iiiRkN8vNmUp4bVUKFnXhxGsAXZwZoBTBcqMjq0Y1OjsWPtXWAXzb0fBxN3Bry0B1sj2iu/S6gfZcdKfwBAUMtZmtVx3bk3MZL9WYzI5yrmbSe42tjxo3sEJZ7fjEWDAdaNrx2KM3g660hkGjFlB8ARFVmoOl3gySp/YqL8zSvaHXHcm9vXkypJDJY6VEzbLucB9fOG/PPssn6CdjQnsocHnlzdQi1Hb60ssGEFBKLHOryU6zLr5xixrWApzyEmas5LtPRv/uctC2b4Tve0Zag9/HQcGGD3TatoDLBdfQ1lZ2X/kWVJ4XCyHq8p79QPwFm4sNW4w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=theobroma-systems.com; Received: from AM0PR04MB6371.eurprd04.prod.outlook.com (2603:10a6:208:178::19) by AS4PR04MB9435.eurprd04.prod.outlook.com (2603:10a6:20b:4eb::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Fri, 26 Jan 2024 14:58:22 +0000 Received: from AM0PR04MB6371.eurprd04.prod.outlook.com ([fe80::e130:6c40:23e5:9a8f]) by AM0PR04MB6371.eurprd04.prod.outlook.com ([fe80::e130:6c40:23e5:9a8f%5]) with mapi id 15.20.7228.022; Fri, 26 Jan 2024 14:58:22 +0000 From: Farouk Bouabid Subject: [PATCH v4 0/6] serial: 8250: Add support for rs485 half/full duplex on puma/ringneck-haikou Date: Fri, 26 Jan 2024 15:55:09 +0100 Message-Id: <20240126-dev-rx-enable-v4-0-45aaf4d96328@theobroma-systems.com> X-B4-Tracking: v=1; b=H4sIAM3Hs2UC/53PsQ7CIBDG8VcxzGLKlSJ18j2MA+UOS2KLgYZom r676OBkHRz/l9wv+WaWKHpK7LCZWaTskw9jCbndMNub8ULcY2kGFchKQMORMo93TqPprsRRa6G xc3sLmpWfWyTn72/vdC7d+zSF+HjzWbyua1IWvOKN0miNMRYsHKeeQhfDYHh6pImGtLNhYC81y 5+SLJKrW3BWSOmEXpG2n1Xqm1BLQFTUSRTtf4IyAI1ygNCatTXLsjwB9DVon4QBAAA= To: Greg Kroah-Hartman , Jiri Slaby , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner Cc: Rob Herring , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, quentin.schulz@theobroma-systems.com, Heiko Stuebner , Farouk Bouabid X-Mailer: b4 0.12.3 X-ClientProxiedBy: VI1PR06CA0114.eurprd06.prod.outlook.com (2603:10a6:803:8c::43) To AM0PR04MB6371.eurprd04.prod.outlook.com (2603:10a6:208:178::19) Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6371:EE_|AS4PR04MB9435:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ab26628-c2c4-4f1b-9d96-08dc1e7f3dc0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mFNN40mHUbva29mEbqYnAVwUqv9z1GZr2ftvEBBCP0k3BbiCRidSPXyg7xoUkNF5p9kjvGl4OHIOV+TU6D4jFNNjZebss8UlRLavWn0y8024s7CXAknoaGrFFxmMpCT31kTSjJuMZMcBuyFoum+Tljs9GJZ5OTFNwWbfgLv4OybDb3Sd60rpfTsKziuT2dZ7RRWyb82b/LuYcBPi7Ro9w1iIJj2/Itry4UC1CbDdrcjsWOTRqkqhPAZgj6hha/RgULrUp0eHKVVQLd+iY4LUOMx5eXxs5+Le+LDbnHTUTzizIXJNbXRVAZu7/aTkepmnmnfvfNnLIcLliVHolx0w3ZQHPLAT6TRg+QT3uXcxx1hBf+BQm/2ehhRlXxvAJKnZdv/bWA1Nxjg3C+RyHIhUrZfzpNDevw5HamjvZ4rdtLvgDU5buN0lDdaXDm416zf1r2LhpwpjLIaBe3cGtKylRR6DTIet+1BqBpJ8SHYzsSL9y8K658kq6OlipzFexpf+tlCSLbd68xrvG/P3lBl2usragY6buOW8J5Htl+9B3v17BP0Ezqk63mEduVswOzJh+/8r6nCqObguzOwNGG2amvsRGMeeZ0G0l+T2e2HMNjDh4zkuy1NWr45eHLGyyMet7tZtltqlHmUBFuwqL+D+fA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6371.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39850400004)(376002)(366004)(346002)(396003)(136003)(230273577357003)(230922051799003)(230173577357003)(451199024)(64100799003)(1800799012)(186009)(38100700002)(2906002)(41300700001)(36756003)(86362001)(54906003)(66476007)(66556008)(6512007)(52116002)(6506007)(66946007)(7416002)(316002)(478600001)(966005)(6486002)(6666004)(110136005)(5660300002)(83380400001)(4326008)(26005)(2616005)(8676002)(44832011)(8936002)(107886003)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?PkuWjDbj4Qp0DYT3myWDWQ7v3K+u?= =?utf-8?q?KFVul1OaHg9qgquOFrSFC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I2pnBlXcHVkH8aa3kBKa92+bZyyxf06ImrF8rbL1c?= =?utf-8?q?38oBzEMgl6RkwsY4aRYefE+XLxtxF+oYOkf97vGM9vbeaYwS+Yw7uHhquZVqua60w?= =?utf-8?q?LbbrHycIHp2PEKdBpi+eJwoHa7t+7RE1p8mXSYAMS6FUfV3WKeG1LbfSnQj9pNQlz?= =?utf-8?q?x6zV9qFSv+x4DjYW7NZnDgF8mssegT+xwVP8nM0at+LZiuoHrAevY5xKcnWIfrvUE?= =?utf-8?q?oe0JZFBvvQ3Ct8hNMnq7cNl3LOkuUKMbCvsMCTgRT9XRvfuRf3qZC92CpbdReUSqs?= =?utf-8?q?AeHr6mBRgycPjb/VoxHgJ3oiOIk7Qg5ASJ87b3391izfvOrQtbRM3Ih//E1gLlm61?= =?utf-8?q?jjdwiWioNKrptYgp9tKzE6/92o2iQG8HA/yqVPUTVWRchuaHT7iw+ccyPQSzOU5xR?= =?utf-8?q?1P+DPCABvcQKAsRhMG3hUDkJ2Zy2cXDnZRzsrkIsP1ceeBB/aUeayCjEkdMsZelab?= =?utf-8?q?YW02VAewUCkDxgxdOKhgFdbE5H4KaaxdaiaZotvXmJuX1m8u5rc9vl1g224NU1Ft9?= =?utf-8?q?Kzc1rFayezM70tzwDfrrumZj0Yo90COxaR3AEE3S9L8ZbW5MQEwtOkyUe/putuAi1?= =?utf-8?q?90JUbtzmgu7iBFO8zxWhO6fS36//NxuvUVwOJKgCqzjlLH9dYJv9zvI=3D?= X-OriginatorOrg: theobroma-systems.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ab26628-c2c4-4f1b-9d96-08dc1e7f3dc0 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6371.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 14:58:22.7613 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5e0e1b52-21b5-4e7b-83bb-514ec460677e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qeSGuZmu9qCPFvvOIpSNzVCfGrZN0oizEye4J68g6kGtKTKk8Z88apKkHfszdHgjgQqW++xZ/ukhxMCLslS0MIrkG8v/MdAlbESHyXhcgD+zei6ZCkERm4l116zDpfpp X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9435 This series tries to revive the work of Heiko Stuebner from 2020 On the boards that we are using (ringneck/puma-haikou) a hardware switch can set the rs485 transceiver into half or full duplex mode. In half-duplex mode the DE/RE signal of the rs485 transceiver is not connected to an RTS signal whose control is already handled in the rs485 emulation (start/stop callbacks), but rather to a gpio. And since enabling the receiver requires setting this gpio active we need to do that in em485 while receiving and disable it while sending to enable the driver mode. In full-duplex mode RE is grounded and separated from DE. Meanwhile the rx-enable gpio remains connected to the DE pin. In this case the receiver-enable gpio should be disabled to enable driver mode in parallel to the enabled receiver. This patch-series adds support for controlling the receiver mode using a gpio in em485 for half-duplex mode while allowing users to keep using the full-duplex feature if em485 is disabled. Changes in v4: - define the state of rx-enable gpio when em485 is disabled - add rs485 half/full duplex support to ringneck/puma-haikou - use dev_err_probe instead of dev_err if error is -EPROBE_DEFER Changes from the 2020 submission include: - external gpio for optional receiver-enable handling Link: https://lore.kernel.org/all/20200517215610.2131618-1-heiko@sntech.de/ --- Farouk Bouabid (4): dt-bindings: serial: add binding for rs485 rx-enable state when rs485 is disabled serial: 8250: set rx-enable gpio state when rs485 is disabled arm64: dts: rockchip: rk3399-puma-haikou: add rs485 support on uart2 arm64: dts: rockchip: px30-ringneck-haikou: add rs485 support on uart5 Heiko Stuebner (2): dt-bindings: serial: Add binding for rs485 receiver enable GPIO serial: 8250: Support separate rs485 rx-enable GPIO Documentation/devicetree/bindings/serial/rs485.yaml | 9 +++++++++ arch/arm64/boot/dts/rockchip/px30-ringneck-haikou.dts | 2 ++ arch/arm64/boot/dts/rockchip/rk3399-puma-haikou.dts | 4 +++- drivers/tty/serial/8250/8250_port.c | 11 ++++++++++- drivers/tty/serial/serial_core.c | 12 ++++++++++++ include/linux/serial_core.h | 2 ++ 6 files changed, 38 insertions(+), 2 deletions(-) --- base-commit: 5ebe731c2a586b379103f736cd498bcca3cf1ea9 change-id: 20240125-dev-rx-enable-d8818dbf7c28 Best regards,