From patchwork Fri Sep 22 20:41:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 817696 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xzQPp1WFbz9t38 for ; Sat, 23 Sep 2017 06:41:50 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751871AbdIVUlt (ORCPT ); Fri, 22 Sep 2017 16:41:49 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:45235 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751974AbdIVUls (ORCPT ); Fri, 22 Sep 2017 16:41:48 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dvUlc-0006mj-FA; Fri, 22 Sep 2017 22:41:44 +0200 Received: from ukl by dude.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1dvUlb-0007nm-BK; Fri, 22 Sep 2017 22:41:43 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Linus Walleij , Rob Herring Cc: Mark Rutland , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH RFC] gpio: of: document gpio-init nodes Date: Fri, 22 Sep 2017 22:41:38 +0200 Message-Id: <20170922204138.29951-1-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: devicetree@vger.kernel.org Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Sometimes it is desirable to define a "safe" configuration for a GPIO in the device tree but let the operating system later still make use of this pin. This might for example be useful to initially configure a debug pin that is usually unconnected as output to prevent floating until it is used later. Signed-off-by: Uwe Kleine-König --- Hello, this picks up a discussion that pops up now and then with our customers. Last time I discussed this topic with Linus Walleij my suggestion was to merge this usecase with gpio-hogs, but he wasn't happy with it because hogging implies that the pin is not free for other usage and he suggested to use "gpio-init" instead. Maybe it's arguable if this "initial configuration" belongs into the device tree, but IMHO defining a "safe configuration" should have a place and the requirements are identical. This isn't implied by the name however, but I don't have a better idea for a different name. Thinking further (which was also discussed last time) it would also be nice to restrict usage. For example that a given pin that has "output-low" as its safe setting might be configured later als high output but not as input. Maybe: companion-reset { gpio-somethingwithsafe; gpios = <12 0>; output-low; fixed-direction; }; (Conceptually we would have a hog then when also adding "fixed-value".) I'm not sure the early configuration should be implemented in Linux. I'd target the bootloader for that instead, still having the blessing of a binding document would be great. I look forward to your comments and ideas. Best regards Uwe Documentation/devicetree/bindings/gpio/gpio.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/gpio/gpio.txt b/Documentation/devicetree/bindings/gpio/gpio.txt index 802402f6cc5d..849d620cee4d 100644 --- a/Documentation/devicetree/bindings/gpio/gpio.txt +++ b/Documentation/devicetree/bindings/gpio/gpio.txt @@ -207,6 +207,11 @@ configuration. Optional properties: - line-name: The GPIO label name. If not present the node name is used. +Similar to hogging above GPIOs can be initialized to a certain configuration +only which compared to hogs doesn't prevent the operating system to change the +pin later. The syntax is similar to hog definitons, the difference is only that +the identifying property is "gpio-init" instead of "gpio-hog". + Example of two SOC GPIO banks defined as gpio-controller nodes: qe_pio_a: gpio-controller@1400 { @@ -221,6 +226,12 @@ Example of two SOC GPIO banks defined as gpio-controller nodes: output-low; line-name = "foo-bar-gpio"; }; + + companion-reset { + gpio-init; + gpios = <12 0>; + output-low; + }; }; qe_pio_e: gpio-controller@1460 {