diff mbox

[v5,2/2] gpio: Document GPIO hogging mechanism

Message ID 1419019671-25377-3-git-send-email-bparrot@ti.com
State New, archived
Headers show

Commit Message

Benoit Parrot Dec. 19, 2014, 8:07 p.m. UTC
Add GPIO hogging documentation to gpio.txt

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
---
 Documentation/devicetree/bindings/gpio/gpio.txt | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Linus Walleij Jan. 12, 2015, 10:20 a.m. UTC | #1
On Fri, Dec 19, 2014 at 9:07 PM, Benoit Parrot <bparrot@ti.com> wrote:

> Add GPIO hogging documentation to gpio.txt
>
> Signed-off-by: Benoit Parrot <bparrot@ti.com>
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

This is starting to look good ...

> +               line_b {
> +                       gpio-hog;
> +                       gpios = <6 0>;
> +                       state = "output-low";

I don't like the state string.

Instead have boolean properties for all states.

line_b {
    gpio-hog;
    gpios = <6 0>;
    output-low;
    line-name = "foo-bar-gpio";
}

Then use of_property_read_bool() in the code to check which
state is to be selected intially. You can check that no mutually
exclusive state are selected, I don't like that an arbitrary string
select the state like that, if we do it that way an enumerator would
be better, I prefer bools.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arend van Spriel Jan. 12, 2015, 10:28 a.m. UTC | #2
On 01/12/15 11:20, Linus Walleij wrote:
> On Fri, Dec 19, 2014 at 9:07 PM, Benoit Parrot<bparrot@ti.com>  wrote:
>
>> Add GPIO hogging documentation to gpio.txt
>>
>> Signed-off-by: Benoit Parrot<bparrot@ti.com>
>> Reviewed-by: Alexandre Courbot<acourbot@nvidia.com>
>
> This is starting to look good ...
>
>> +               line_b {
>> +                       gpio-hog;
>> +                       gpios =<6 0>;
>> +                       state = "output-low";
>
> I don't like the state string.
>
> Instead have boolean properties for all states.
>
> line_b {
>      gpio-hog;
>      gpios =<6 0>;
>      output-low;
>      line-name = "foo-bar-gpio";
> }
>
> Then use of_property_read_bool() in the code to check which
> state is to be selected intially. You can check that no mutually
> exclusive state are selected, I don't like that an arbitrary string
> select the state like that, if we do it that way an enumerator would
> be better, I prefer bools.

To avoid the mutual exclusive state checking, would it not be more 
straightforward to use numeric enum values defined in boot/dts/include.

Regards,
Arend

> Yours,
> Linus Walleij
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Benoit Parrot Jan. 12, 2015, 4:39 p.m. UTC | #3
Linus Walleij <linus.walleij@linaro.org> wrote on Mon [2015-Jan-12 11:20:14 +0100]:
> On Fri, Dec 19, 2014 at 9:07 PM, Benoit Parrot <bparrot@ti.com> wrote:
> 
> > Add GPIO hogging documentation to gpio.txt
> >
> > Signed-off-by: Benoit Parrot <bparrot@ti.com>
> > Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
> 
> This is starting to look good ...
> 
> > +               line_b {
> > +                       gpio-hog;
> > +                       gpios = <6 0>;
> > +                       state = "output-low";
> 
> I don't like the state string.
> 
> Instead have boolean properties for all states.
> 
> line_b {
>     gpio-hog;
>     gpios = <6 0>;
>     output-low;
>     line-name = "foo-bar-gpio";
> }
> 
> Then use of_property_read_bool() in the code to check which
> state is to be selected intially. You can check that no mutually
> exclusive state are selected, I don't like that an arbitrary string
> select the state like that, if we do it that way an enumerator would
> be better, I prefer bools.

I am sorry but that is how it was originally in the first patch.
Alexandre's review comment suggested this method in [1] and [2] (below).

Alexandre, any comments?

[1] http://marc.info/?l=linux-gpio&m=141456662426151&w=2

[2] http://marc.info/?l=linux-gpio&m=141715982424744&w=2

> 
> Yours,
> Linus Walleij
> --
> To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexandre Courbot Jan. 12, 2015, 9:43 p.m. UTC | #4
On Tue, Jan 13, 2015 at 1:39 AM, Benoit Parrot <bparrot@ti.com> wrote:
> Linus Walleij <linus.walleij@linaro.org> wrote on Mon [2015-Jan-12 11:20:14 +0100]:
>> On Fri, Dec 19, 2014 at 9:07 PM, Benoit Parrot <bparrot@ti.com> wrote:
>>
>> > Add GPIO hogging documentation to gpio.txt
>> >
>> > Signed-off-by: Benoit Parrot <bparrot@ti.com>
>> > Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
>>
>> This is starting to look good ...
>>
>> > +               line_b {
>> > +                       gpio-hog;
>> > +                       gpios = <6 0>;
>> > +                       state = "output-low";
>>
>> I don't like the state string.
>>
>> Instead have boolean properties for all states.
>>
>> line_b {
>>     gpio-hog;
>>     gpios = <6 0>;
>>     output-low;
>>     line-name = "foo-bar-gpio";
>> }
>>
>> Then use of_property_read_bool() in the code to check which
>> state is to be selected intially. You can check that no mutually
>> exclusive state are selected, I don't like that an arbitrary string
>> select the state like that, if we do it that way an enumerator would
>> be better, I prefer bools.
>
> I am sorry but that is how it was originally in the first patch.
> Alexandre's review comment suggested this method in [1] and [2] (below).
>
> Alexandre, any comments?
>
> [1] http://marc.info/?l=linux-gpio&m=141456662426151&w=2
>
> [2] http://marc.info/?l=linux-gpio&m=141715982424744&w=2

When Linus and I are in conflict, follow Linus. Arnd's suggestion of
having enums defined in (IIUC) include/dt-bindings/gpio and using them
sounds good to me too and might make everyone happy (no possibility of
conflicting definitions + no strings). Linus, could you comment on it?
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Benoit Parrot Jan. 13, 2015, 6:38 p.m. UTC | #5
Alexandre Courbot <gnurou@gmail.com> wrote on Tue [2015-Jan-13 06:43:33 +0900]:
> On Tue, Jan 13, 2015 at 1:39 AM, Benoit Parrot <bparrot@ti.com> wrote:
> > Linus Walleij <linus.walleij@linaro.org> wrote on Mon [2015-Jan-12 11:20:14 +0100]:
> >> On Fri, Dec 19, 2014 at 9:07 PM, Benoit Parrot <bparrot@ti.com> wrote:
> >>
> >> > Add GPIO hogging documentation to gpio.txt
> >> >
> >> > Signed-off-by: Benoit Parrot <bparrot@ti.com>
> >> > Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
> >>
> >> This is starting to look good ...
> >>
> >> > +               line_b {
> >> > +                       gpio-hog;
> >> > +                       gpios = <6 0>;
> >> > +                       state = "output-low";
> >>
> >> I don't like the state string.
> >>
> >> Instead have boolean properties for all states.
> >>
> >> line_b {
> >>     gpio-hog;
> >>     gpios = <6 0>;
> >>     output-low;
> >>     line-name = "foo-bar-gpio";
> >> }
> >>
> >> Then use of_property_read_bool() in the code to check which
> >> state is to be selected intially. You can check that no mutually
> >> exclusive state are selected, I don't like that an arbitrary string
> >> select the state like that, if we do it that way an enumerator would
> >> be better, I prefer bools.
> >
> > I am sorry but that is how it was originally in the first patch.
> > Alexandre's review comment suggested this method in [1] and [2] (below).
> >
> > Alexandre, any comments?
> >
> > [1] http://marc.info/?l=linux-gpio&m=141456662426151&w=2
> >
> > [2] http://marc.info/?l=linux-gpio&m=141715982424744&w=2
> 
> When Linus and I are in conflict, follow Linus. Arnd's suggestion of
> having enums defined in (IIUC) include/dt-bindings/gpio and using them
> sounds good to me too and might make everyone happy (no possibility of
> conflicting definitions + no strings). Linus, could you comment on it?

Understood.
Now given Linus prefers the bools that is the direction I am going to follow.
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Jan. 16, 2015, 10:20 a.m. UTC | #6
On Mon, Jan 12, 2015 at 10:43 PM, Alexandre Courbot <gnurou@gmail.com> wrote:
> On Tue, Jan 13, 2015 at 1:39 AM, Benoit Parrot <bparrot@ti.com> wrote:
>> Linus Walleij <linus.walleij@linaro.org> wrote on Mon [2015-Jan-12 11:20:14 +0100]:

>>> line_b {
>>>     gpio-hog;
>>>     gpios = <6 0>;
>>>     output-low;
>>>     line-name = "foo-bar-gpio";
>>> }
>>>
>>> Then use of_property_read_bool() in the code to check which
>>> state is to be selected intially. You can check that no mutually
>>> exclusive state are selected, I don't like that an arbitrary string
>>> select the state like that, if we do it that way an enumerator would
>>> be better, I prefer bools.
>>
>> I am sorry but that is how it was originally in the first patch.
>> Alexandre's review comment suggested this method in [1] and [2] (below).
>>
>> Alexandre, any comments?
>>
>> [1] http://marc.info/?l=linux-gpio&m=141456662426151&w=2
>>
>> [2] http://marc.info/?l=linux-gpio&m=141715982424744&w=2
>
> When Linus and I are in conflict, follow Linus. Arnd's suggestion of
> having enums defined in (IIUC) include/dt-bindings/gpio and using them
> sounds good to me too and might make everyone happy (no possibility of
> conflicting definitions + no strings). Linus, could you comment on it?

I'm fine with bools or enums, just not strings, sorry for the mess.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/gpio/gpio.txt b/Documentation/devicetree/bindings/gpio/gpio.txt
index b9bd1d6..f5d2717 100644
--- a/Documentation/devicetree/bindings/gpio/gpio.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio.txt
@@ -115,6 +115,22 @@  Every GPIO controller node must contain both an empty "gpio-controller"
 property, and a #gpio-cells integer property, which indicates the number of
 cells in a gpio-specifier.
 
+The GPIO chip may contain GPIO hog definitions. GPIO hogging is a mechanism
+providing automatic GPIO request and configuration as part of the
+gpio-controller's driver probe function.
+
+Each GPIO hog definition is represented as a child node of the GPIO controller.
+Required properties:
+- gpio-hog:  A property specifying that this child node represent a GPIO hog.
+- gpios:     Store the GPIO information (id, flags, ...). Shall contain the
+	     number of cells specified in its parent node (GPIO controller
+	     node).
+- state:     A property specifying the direction/value needed. This property
+	     can take the following values: input, output-high, output-low.
+
+Optional properties:
+- line-name: The GPIO label name. If not present the node name is used.
+
 Example of two SOC GPIO banks defined as gpio-controller nodes:
 
 	qe_pio_a: gpio-controller@1400 {
@@ -122,6 +138,13 @@  Example of two SOC GPIO banks defined as gpio-controller nodes:
 		reg = <0x1400 0x18>;
 		gpio-controller;
 		#gpio-cells = <2>;
+
+		line_b {
+			gpio-hog;
+			gpios = <6 0>;
+			state = "output-low";
+			line-name = "foo-bar-gpio";
+		};
 	};
 
 	qe_pio_e: gpio-controller@1460 {