devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Linus Walleij <linus.walleij@linaro.org>,
	Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	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	[thread overview]
Message-ID: <20170922204138.29951-1-u.kleine-koenig@pengutronix.de> (raw)

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 <u.kleine-koenig@pengutronix.de>
---
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 {
-- 
2.11.0


             reply	other threads:[~2017-09-22 20:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-22 20:41 Uwe Kleine-König [this message]
2017-09-26 23:57 ` [PATCH RFC] gpio: of: document gpio-init nodes Linus Walleij
2017-10-04 20:53 ` Rob Herring
2017-10-04 22:00   ` Uwe Kleine-König
2017-10-05 14:01     ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170922204138.29951-1-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).