From patchwork Tue Jan 31 13:49:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niall Leonard via B4 Submission Endpoint X-Patchwork-Id: 1734900 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=J7a8fZSU; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4P5mdK2DSvz23gY for ; Wed, 1 Feb 2023 00:49:57 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232394AbjAaNtq (ORCPT ); Tue, 31 Jan 2023 08:49:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232358AbjAaNto (ORCPT ); Tue, 31 Jan 2023 08:49:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74F874DBEA; Tue, 31 Jan 2023 05:49:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2CC1EB81CD8; Tue, 31 Jan 2023 13:49:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id C7415C433EF; Tue, 31 Jan 2023 13:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675172980; bh=7uS99guVEB4XU7LjGkPqNw0LUaTw0sbs4tjMoJ9K564=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=J7a8fZSUs+lYf7LZMmzS7MATftH5bDlUCXYiECSixOaqU0b9AvY+pxzTcMUfnKIkH 4YY/2PBV5lSOY2Glx3xPRLFjLwz+hup2gXXRFsyrduoxqigHVuG1ltV7DB5fhX0v4B w6Mc6agHugLUXU/zfs6zrd/DxZwB0QDHRSe9M3TAKm8RZjdY4xsuyedZMjofzkToYx nvj7ww2Mv9pPF80wUDofgDQaq6OFniPGE/k9l+zZR19X6ArIuS7QLTH8SgHrCZrGjC AP3px/o7EIjrdapKJ29a4kw6d3+QtFiQbsBaIwCBtFj1n28uhJ9QBRvlH3qQlyaCgQ SKI8PQcI7fO3Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7E7CC636D7; Tue, 31 Jan 2023 13:49:40 +0000 (UTC) From: Niall Leonard via B4 Submission Endpoint Date: Tue, 31 Jan 2023 13:49:37 +0000 Subject: [PATCH v2 1/2] dt-bindings: improve wb,mbl-gpio binding documentation. MIME-Version: 1.0 Message-Id: <20230126-gpio-mmio-fix-v2-1-38397aace340@ncr.com> References: <20230126-gpio-mmio-fix-v2-0-38397aace340@ncr.com> In-Reply-To: <20230126-gpio-mmio-fix-v2-0-38397aace340@ncr.com> To: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Niall Leonard X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3862; i=nl250060@ncr.com; h=from:subject:message-id; bh=142m7Aqg9vw0k6ow9nta9rhrZ0z5xj3jNyxgUalZmSE=; =?utf-8?q?b=3D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Received: by B4 Submission Endpoint for nl250060@ncr.com/default with auth_id=26 X-Original-From: Niall Leonard Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Niall Leonard Convert existing wd,mbl-gpio binding documentation to YAML and add new optional propery "no-input". Signed-off-by: Niall Leonard --- .../devicetree/bindings/gpio/wd,mbl-gpio.txt | 38 ----------- .../devicetree/bindings/gpio/wd,mbl-gpio.yaml | 78 ++++++++++++++++++++++ 2 files changed, 78 insertions(+), 38 deletions(-) diff --git a/Documentation/devicetree/bindings/gpio/wd,mbl-gpio.txt b/Documentation/devicetree/bindings/gpio/wd,mbl-gpio.txt deleted file mode 100644 index 038c3a6a1f4d..000000000000 --- a/Documentation/devicetree/bindings/gpio/wd,mbl-gpio.txt +++ /dev/null @@ -1,38 +0,0 @@ -Bindings for the Western Digital's MyBook Live memory-mapped GPIO controllers. - -The Western Digital MyBook Live has two memory-mapped GPIO controllers. -Both GPIO controller only have a single 8-bit data register, where GPIO -state can be read and/or written. - -Required properties: - - compatible: should be "wd,mbl-gpio" - - reg-names: must contain - "dat" - data register - - reg: address + size pairs describing the GPIO register sets; - order must correspond with the order of entries in reg-names - - #gpio-cells: must be set to 2. The first cell is the pin number and - the second cell is used to specify the gpio polarity: - 0 = active high - 1 = active low - - gpio-controller: Marks the device node as a gpio controller. - -Optional properties: - - no-output: GPIOs are read-only. - -Examples: - gpio0: gpio0@e0000000 { - compatible = "wd,mbl-gpio"; - reg-names = "dat"; - reg = <0xe0000000 0x1>; - #gpio-cells = <2>; - gpio-controller; - }; - - gpio1: gpio1@e0100000 { - compatible = "wd,mbl-gpio"; - reg-names = "dat"; - reg = <0xe0100000 0x1>; - #gpio-cells = <2>; - gpio-controller; - no-output; - }; diff --git a/Documentation/devicetree/bindings/gpio/wd,mbl-gpio.yaml b/Documentation/devicetree/bindings/gpio/wd,mbl-gpio.yaml new file mode 100644 index 000000000000..d1c72a42c5bc --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/wd,mbl-gpio.yaml @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/wd,mbl-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Western Digital's MyBook Live memory-mapped GPIO controllers. + +maintainers: + - Niall Leonard + +description: |+ + Bindings for the Western Digital's MyBook Live memory-mapped GPIO controllers. + + The Western Digital MyBook Live has two memory-mapped GPIO controllers. + Both GPIO controller only have a single 8-bit data register, where GPIO + state can be read and/or written. + +properties: + compatible: + enum: + - wd,mbl-gpio + + reg-names: + items: + - const: dat + + reg: + maxItems: 1 + + "#gpio-cells": + const: 2 + + gpio-controller: true + + no-output: + description: GPIOs are read-only. + + no-input: + description: GPIOs are write-only. + +required: + - compatible + - reg-names + - reg + - '#gpio-cells' + - gpio-controller + +additionalProperties: false + +examples: + - | + gpio0: gpio0@e0000000 { + compatible = "wd,mbl-gpio"; + reg-names = "dat"; + reg = <0xe0000000 0x1>; + #gpio-cells = <2>; + gpio-controller; + }; + + gpio1: gpio1@e0100000 { + compatible = "wd,mbl-gpio"; + reg-names = "dat"; + reg = <0xe0100000 0x1>; + #gpio-cells = <2>; + gpio-controller; + no-output; + }; + + gpio2: gpio1@e0200000 { + compatible = "wd,mbl-gpio"; + reg-names = "dat"; + reg = <0xe0200000 0x1>; + #gpio-cells = <2>; + gpio-controller; + no-input; + }; + From patchwork Tue Jan 31 13:49:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niall Leonard via B4 Submission Endpoint X-Patchwork-Id: 1734899 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=UJ27/uL/; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4P5mdJ3NhWz23gY for ; Wed, 1 Feb 2023 00:49:56 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232403AbjAaNtq (ORCPT ); Tue, 31 Jan 2023 08:49:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232347AbjAaNto (ORCPT ); Tue, 31 Jan 2023 08:49:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 960254B483; Tue, 31 Jan 2023 05:49:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 429FFB81CDF; Tue, 31 Jan 2023 13:49:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id D826CC4339B; Tue, 31 Jan 2023 13:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675172980; bh=2a2lkU6K2uCveC71ivewBVMghpO7dbUOieeM5PNFeK0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=UJ27/uL/1ZBdH5Mqb5dOkVjo9goPIMc2eIY3HzDvbHDt1OtdwdIdOfwxgFoFAFCML uam8JgupPWFGTOfIPsTFZmUapQR9OZxAbaLG1QbeYWmVK7AI5FiSlIDqGza2HO/iUH G433WFLpod+UN0FpKctwiytA4VrWQQIN7RMYWo7om6p2m8UQTS/6fa2aYc2zjCDbsH 1XLEzeDusOOqUpRCZOKvGLYLflt3GUIOcsFVZq18YF92siLjn2NZukr4qFD/mpzihR 9x7pTDQZxlozu5aDeiMu3+g5oXFnt9hukwAzdDJJ7MTj8ddYElEPzGs0l8Q/WG43+V QYTqgL6P3r6bg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4E43C64EC3; Tue, 31 Jan 2023 13:49:40 +0000 (UTC) From: Niall Leonard via B4 Submission Endpoint Date: Tue, 31 Jan 2023 13:49:38 +0000 Subject: [PATCH v2 2/2] gpio: mmio: Use new flag BGPIOF_NO_INPUT. MIME-Version: 1.0 Message-Id: <20230126-gpio-mmio-fix-v2-2-38397aace340@ncr.com> References: <20230126-gpio-mmio-fix-v2-0-38397aace340@ncr.com> In-Reply-To: <20230126-gpio-mmio-fix-v2-0-38397aace340@ncr.com> To: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Niall Leonard X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3171; i=nl250060@ncr.com; h=from:subject:message-id; bh=qw+ukSOOr1LL8jakS9qqqS7Ifx1mSYww3yijW1VYn/c=; =?utf-8?q?b=3DowEBbQKS/ZANAwAKAVGiIrYFD2P/AcsmYgBj2RxzG8Rs4mvsqSBm+6z29boec?= =?utf-8?q?XRRXeqa8Uuy4anQ_ehqbzcSJAjMEAAEKAB0WIQSha1EPjh6hUqdtwZNRoiK2BQ9j/?= =?utf-8?q?wUCY9kccwAKCRBRoiK2BQ9j/9FKEA_DNju1HJb+AUeRe9LgvDDLjnqhfbAV0+NsnU?= =?utf-8?q?co9AgeNNsZ87CaMOIThcNTLH6kLkwxeeMb7XuWieLMe_x6CDnp9Gj2PUsvqJZBSuN?= =?utf-8?q?w9oX2DnxytOxXB8je/3fzhDvDTUAo4caKnXA7pna8rQbeY7NxbsItkBqy_vpRYD3L?= =?utf-8?q?oKFXsIrVPsvUbn7/wkW4flcjhuY5AcwCGHIzOUsiAxKqYRVhAl8oX+g7PT6xH0BeL?= =?utf-8?q?g6xX9x_Fldqj93K4zJXEFypyYcrwVzzWEpHE3sWPPazVYBv+0D2TJIFWaVIwgCDln?= =?utf-8?q?oNgbvCB7grUaeskAmrCS_Gr6val+X4RZmUcv7iQua+13bzeLWeZ9Q1yYffKpdWBB7?= =?utf-8?q?vJnYQIDHqQ3nkNC6Azgx8msVcSPdTDsF8Q_EvqPLSB8RvkQ73JKHwfx0R/ROdSfqN?= =?utf-8?q?GS9Znzbr9Qh4pLvq4OLz1F8Ao1dLlQ4XTNTBNAczNk+MOw3x_8e2LAmLv0x6CYMnP?= =?utf-8?q?HC3VWZ3KKOepEKneoLJ3ec0PykAkMt1GVhAskcopvCUXaWKik2dogK0nZd0aAh_RX?= =?utf-8?q?1R42naQaNEK0fE/tw6iZLlJz0t/UU1ZiMb87edPInPTW+wYjSsmRij1JGaoPNEskw?= =?utf-8?q?jZ1qgNRWcqm?= 5VdwCAqUsIc/ocBhTdEjer4JBiYr01gvxrJginHJNWG8OcrfN+IIfg6UPiAw== X-Developer-Key: i=nl250060@ncr.com; a=openpgp; fpr=A16B510F8E1EA152A76DC19351A222B6050F63FF X-Endpoint-Received: by B4 Submission Endpoint for nl250060@ncr.com/default with auth_id=26 X-Original-From: Niall Leonard Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Niall Leonard Add new flag BGPIOF_NO_INPUT to header file. Use the existing shadow data register 'bgpio_data' to allow the last written value to be returned by the read operation when BGPIOF_NO_INPUT flag is set. Ensure this change only applies to the specific binding "wd,mbl-gpio". Signed-off-by: Niall Leonard --- drivers/gpio/gpio-mmio.c | 24 +++++++++++++++++++++--- include/linux/gpio/driver.h | 1 + 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c index d9dff3dc92ae..9939fdbf6345 100644 --- a/drivers/gpio/gpio-mmio.c +++ b/drivers/gpio/gpio-mmio.c @@ -164,6 +164,11 @@ static int bgpio_get_set_multiple(struct gpio_chip *gc, unsigned long *mask, return 0; } +static int bgpio_get_shadow(struct gpio_chip *gc, unsigned int gpio) +{ + return !!(gc->bgpio_data & bgpio_line2mask(gc, gpio)); +} + static int bgpio_get(struct gpio_chip *gc, unsigned int gpio) { return !!(gc->read_reg(gc->reg_dat) & bgpio_line2mask(gc, gpio)); @@ -526,7 +531,10 @@ static int bgpio_setup_io(struct gpio_chip *gc, * reading each line individually in that fringe case. */ } else { - gc->get = bgpio_get; + if (flags & BGPIOF_NO_INPUT) + gc->get = bgpio_get_shadow; + else + gc->get = bgpio_get; if (gc->be_bits) gc->get_multiple = bgpio_get_multiple_be; else @@ -630,7 +638,11 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev, if (ret) return ret; - gc->bgpio_data = gc->read_reg(gc->reg_dat); + if (flags & BGPIOF_NO_INPUT) + gc->bgpio_data = 0; + else + gc->bgpio_data = gc->read_reg(gc->reg_dat); + if (gc->set == bgpio_set_set && !(flags & BGPIOF_UNREADABLE_REG_SET)) gc->bgpio_data = gc->read_reg(gc->reg_set); @@ -694,8 +706,9 @@ static struct bgpio_pdata *bgpio_parse_dt(struct platform_device *pdev, unsigned long *flags) { struct bgpio_pdata *pdata; + const struct of_device_id *of_id; - if (!of_match_device(bgpio_of_match, &pdev->dev)) + if (!(of_id = of_match_device(bgpio_of_match, &pdev->dev))) return NULL; pdata = devm_kzalloc(&pdev->dev, sizeof(struct bgpio_pdata), @@ -711,6 +724,11 @@ static struct bgpio_pdata *bgpio_parse_dt(struct platform_device *pdev, if (of_property_read_bool(pdev->dev.of_node, "no-output")) *flags |= BGPIOF_NO_OUTPUT; + if (!strcmp(of_id->compatible, "wd,mbl-gpio")) { + if (of_property_read_bool(pdev->dev.of_node, "no-input")) + *flags |= BGPIOF_NO_INPUT; + } + return pdata; } #else diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 44783fc16125..e8e57310e3b8 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -682,6 +682,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev, #define BGPIOF_READ_OUTPUT_REG_SET BIT(4) /* reg_set stores output value */ #define BGPIOF_NO_OUTPUT BIT(5) /* only input */ #define BGPIOF_NO_SET_ON_INPUT BIT(6) +#define BGPIOF_NO_INPUT BIT(7) /* only output */ int gpiochip_irq_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hwirq);