All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] regulator: gpio: Reword the binding document
@ 2019-03-04 19:40 marek.vasut
  2019-03-04 22:20   ` Linus Walleij
  2019-03-05 10:07 ` Harald Geyer
  0 siblings, 2 replies; 14+ messages in thread
From: marek.vasut @ 2019-03-04 19:40 UTC (permalink / raw)
  To: devicetree
  Cc: Marek Vasut, Harald Geyer, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

From: Marek Vasut <marek.vasut+renesas@gmail.com>

Reword the binding document to make it clear how the propeties work
and which properties affect which other properties.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Harald Geyer <harald@ccbib.org>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Rob Herring <robh@kernel.org>
Cc: linux-renesas-soc@vger.kernel.org
To: devicetree@vger.kernel.org
---
V2: - Make "gpios" a mandatory property
    - Reword "gpio-states" property description
    - Change "enable-gpio" to "enable-gpios" to match modern DT rules
Note: The recent gpio-regulator rework caused breakage. While the
      changes in the gpio-regulator code were according to the DT
      binding document, they stopped working with older DTs. Make
      the binding document clearer to prevent such breakage in the
      future.
---
 .../bindings/regulator/gpio-regulator.txt     | 25 +++++++++++++------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
index 1f496159e2bb..d7f8c1b17db6 100644
--- a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
@@ -4,16 +4,25 @@ Required properties:
 - compatible		: Must be "regulator-gpio".
 - regulator-name	: Defined in regulator.txt as optional, but required
 			  here.
-- states		: Selection of available voltages and GPIO configs.
-                          if there are no states, then use a fixed regulator
+- gpios			: Array of one or more GPIO pins used to select the
+			  regulator voltage/current listed in "states".
+- states		: Selection of available voltages/currents provided by
+			  this regulator and matching GPIO configurations to
+			  achieve them. If there are no states in the "states"
+			  array, use a fixed regulator instead.
 
 Optional properties:
-- enable-gpio		: GPIO to use to enable/disable the regulator.
-- gpios			: GPIO group used to control voltage.
-- gpios-states		: gpios pin's initial states array. 0: LOW, 1: HIGH.
-			  defualt is LOW if nothing is specified.
+- enable-gpios		: GPIO used to enable/disable the regulator.
+			  Warning, the GPIO phandle flags are ignored and the
+			  GPIO polarity is controlled solely by the presence
+			  of "enable-active-high" DT property. This is due to
+			  compatibility with old DTs.
+- enable-active-high	: Polarity of "enable-gpio" GPIO is active HIGH.
+			  Default is active LOW.
+- gpios-states		: State of GPIO pins in "gpios" array that is set until
+			  changed by the first consumer. 0: LOW, 1: HIGH.
+			  Default is LOW if nothing else is specified.
 - startup-delay-us	: Startup time in microseconds.
-- enable-active-high	: Polarity of GPIO is active high (default is low).
 - regulator-type	: Specifies what is being regulated, must be either
 			  "voltage" or "current", defaults to voltage.
 
@@ -30,7 +39,7 @@ Example:
 		regulator-max-microvolt = <2600000>;
 		regulator-boot-on;
 
-		enable-gpio = <&gpio0 23 0x4>;
+		enable-gpios = <&gpio0 23 0x4>;
 		gpios = <&gpio0 24 0x4
 			 &gpio0 25 0x4>;
 		states = <1800000 0x3
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
  2019-03-04 19:40 [PATCH V2] regulator: gpio: Reword the binding document marek.vasut
@ 2019-03-04 22:20   ` Linus Walleij
  2019-03-05 10:07 ` Harald Geyer
  1 sibling, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2019-03-04 22:20 UTC (permalink / raw)
  To: Mark Vasut
  Cc: open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Marek Vasut, Harald Geyer, Kuninori Morimoto, Mark Brown,
	Rob Herring, Linux-Renesas

On Mon, Mar 4, 2019 at 8:40 PM <marek.vasut@gmail.com> wrote:

> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>
> Reword the binding document to make it clear how the propeties work
> and which properties affect which other properties.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Harald Geyer <harald@ccbib.org>
> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Rob Herring <robh@kernel.org>
> Cc: linux-renesas-soc@vger.kernel.org
> To: devicetree@vger.kernel.org
> ---
> V2: - Make "gpios" a mandatory property
>     - Reword "gpio-states" property description
>     - Change "enable-gpio" to "enable-gpios" to match modern DT rules
> Note: The recent gpio-regulator rework caused breakage. While the
>       changes in the gpio-regulator code were according to the DT
>       binding document, they stopped working with older DTs. Make
>       the binding document clearer to prevent such breakage in the
>       future.

Excellent work!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
@ 2019-03-04 22:20   ` Linus Walleij
  0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2019-03-04 22:20 UTC (permalink / raw)
  To: Mark Vasut
  Cc: open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Marek Vasut, Harald Geyer, Kuninori Morimoto, Mark Brown,
	Rob Herring, Linux-Renesas

On Mon, Mar 4, 2019 at 8:40 PM <marek.vasut@gmail.com> wrote:

> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>
> Reword the binding document to make it clear how the propeties work
> and which properties affect which other properties.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Harald Geyer <harald@ccbib.org>
> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Rob Herring <robh@kernel.org>
> Cc: linux-renesas-soc@vger.kernel.org
> To: devicetree@vger.kernel.org
> ---
> V2: - Make "gpios" a mandatory property
>     - Reword "gpio-states" property description
>     - Change "enable-gpio" to "enable-gpios" to match modern DT rules
> Note: The recent gpio-regulator rework caused breakage. While the
>       changes in the gpio-regulator code were according to the DT
>       binding document, they stopped working with older DTs. Make
>       the binding document clearer to prevent such breakage in the
>       future.

Excellent work!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
  2019-03-04 19:40 [PATCH V2] regulator: gpio: Reword the binding document marek.vasut
  2019-03-04 22:20   ` Linus Walleij
@ 2019-03-05 10:07 ` Harald Geyer
  2019-03-05 10:59   ` Marek Vasut
  1 sibling, 1 reply; 14+ messages in thread
From: Harald Geyer @ 2019-03-05 10:07 UTC (permalink / raw)
  To: marek.vasut
  Cc: devicetree, Marek Vasut, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

marek.vasut@gmail.com writes:
> From: Marek Vasut <marek.vasut+renesas@gmail.com>
> 
> Reword the binding document to make it clear how the propeties work
> and which properties affect which other properties.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Harald Geyer <harald@ccbib.org>
> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Rob Herring <robh@kernel.org>
> Cc: linux-renesas-soc@vger.kernel.org
> To: devicetree@vger.kernel.org
> ---
> V2: - Make "gpios" a mandatory property
>     - Reword "gpio-states" property description
>     - Change "enable-gpio" to "enable-gpios" to match modern DT rules
> Note: The recent gpio-regulator rework caused breakage. While the
>       changes in the gpio-regulator code were according to the DT
>       binding document, they stopped working with older DTs. Make
>       the binding document clearer to prevent such breakage in the
>       future.

Thanks for the update. I think it addresses all my concerns except for
one:

> +- gpios-states	: State of GPIO pins in "gpios" array that is set until
> +			  changed by the first consumer. 0: LOW, 1: HIGH.
> +			  Default is LOW if nothing else is specified.

I still believe this not true: There is no guarantee that the regulator
core won't change the state of GPIO pins before the first consumer comes
up.

I still think my proposal describes the property more acurately:
gpios-states : On operating systems, that don't support reading back gpio
               values in output mode (most notably linux), this array
               provides the state of GPIO pins set when requesting them
               from the gpio controller. Systems, that are capable of
               preserving state when requesting the lines, are free to
               ignore this property. 0: LOW, 1: HIGH. Default is LOW if
               nothing else is specified.

Since we had this discussion already in the V1 thread and you clearly don't
agree with me, the maintainers will need to decide. You can add 
Reviewed-by: Harald Geyer <harald@ccbib.org>
once Rob and/or Mark have addressed this issue.

Thanks for your work!
Harald

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
  2019-03-05 10:07 ` Harald Geyer
@ 2019-03-05 10:59   ` Marek Vasut
  2019-03-05 16:10     ` Harald Geyer
  0 siblings, 1 reply; 14+ messages in thread
From: Marek Vasut @ 2019-03-05 10:59 UTC (permalink / raw)
  To: Harald Geyer
  Cc: devicetree, Marek Vasut, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

On 3/5/19 11:07 AM, Harald Geyer wrote:
> marek.vasut@gmail.com writes:
>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>>
>> Reword the binding document to make it clear how the propeties work
>> and which properties affect which other properties.
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>> Cc: Harald Geyer <harald@ccbib.org>
>> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>> Cc: Linus Walleij <linus.walleij@linaro.org>
>> Cc: Mark Brown <broonie@kernel.org>
>> Cc: Rob Herring <robh@kernel.org>
>> Cc: linux-renesas-soc@vger.kernel.org
>> To: devicetree@vger.kernel.org
>> ---
>> V2: - Make "gpios" a mandatory property
>>     - Reword "gpio-states" property description
>>     - Change "enable-gpio" to "enable-gpios" to match modern DT rules
>> Note: The recent gpio-regulator rework caused breakage. While the
>>       changes in the gpio-regulator code were according to the DT
>>       binding document, they stopped working with older DTs. Make
>>       the binding document clearer to prevent such breakage in the
>>       future.
> 
> Thanks for the update. I think it addresses all my concerns except for
> one:
> 
>> +- gpios-states	: State of GPIO pins in "gpios" array that is set until
>> +			  changed by the first consumer. 0: LOW, 1: HIGH.
>> +			  Default is LOW if nothing else is specified.
> 
> I still believe this not true: There is no guarantee that the regulator
> core won't change the state of GPIO pins before the first consumer comes
> up.

Why would it do that ? That would completely invalidate any remaining
useful-ness of this property.

> I still think my proposal describes the property more acurately:
> gpios-states : On operating systems, that don't support reading back gpio
>                values in output mode (most notably linux), this array
>                provides the state of GPIO pins set when requesting them
>                from the gpio controller. Systems, that are capable of
>                preserving state when requesting the lines, are free to
>                ignore this property. 0: LOW, 1: HIGH. Default is LOW if
>                nothing else is specified.
> 
> Since we had this discussion already in the V1 thread and you clearly don't
> agree with me, the maintainers will need to decide. You can add 
> Reviewed-by: Harald Geyer <harald@ccbib.org>
> once Rob and/or Mark have addressed this issue.

I think we're just looking at this from two different perspectives and
for whatever reason can't reconcile them.

> Thanks for your work!
> Harald
> 


-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
  2019-03-05 10:59   ` Marek Vasut
@ 2019-03-05 16:10     ` Harald Geyer
  2019-03-05 19:01       ` Marek Vasut
  0 siblings, 1 reply; 14+ messages in thread
From: Harald Geyer @ 2019-03-05 16:10 UTC (permalink / raw)
  To: Marek Vasut
  Cc: devicetree, Marek Vasut, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

Marek Vasut writes:
> On 3/5/19 11:07 AM, Harald Geyer wrote:
> > marek.vasut@gmail.com writes:
> >> From: Marek Vasut <marek.vasut+renesas@gmail.com>
> >>
> >> Reword the binding document to make it clear how the propeties work
> >> and which properties affect which other properties.
> >>
> >> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> >> Cc: Harald Geyer <harald@ccbib.org>
> >> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> >> Cc: Linus Walleij <linus.walleij@linaro.org>
> >> Cc: Mark Brown <broonie@kernel.org>
> >> Cc: Rob Herring <robh@kernel.org>
> >> Cc: linux-renesas-soc@vger.kernel.org
> >> To: devicetree@vger.kernel.org
> >> ---
> >> V2: - Make "gpios" a mandatory property
> >>     - Reword "gpio-states" property description
> >>     - Change "enable-gpio" to "enable-gpios" to match modern DT rules
> >> Note: The recent gpio-regulator rework caused breakage. While the
> >>       changes in the gpio-regulator code were according to the DT
> >>       binding document, they stopped working with older DTs. Make
> >>       the binding document clearer to prevent such breakage in the
> >>       future.
> > 
> > Thanks for the update. I think it addresses all my concerns except for
> > one:
> > 
> >> +- gpios-states	: State of GPIO pins in "gpios" array that is set until
> >> +			  changed by the first consumer. 0: LOW, 1: HIGH.
> >> +			  Default is LOW if nothing else is specified.
> > 
> > I still believe this not true: There is no guarantee that the regulator
> > core won't change the state of GPIO pins before the first consumer comes
> > up.
> 
> Why would it do that ?

Because the regulator core doesn't know about this driver specific
property at all. And without any constraints placed by consumers, the
core is free to choose any state whatsoever at any point in time.

> That would completely invalidate any remaining
> useful-ness of this property.

Yes, I believe this property is mostly useless. That's what I want to
get across with my wording proposal. The remaining usecase, that I can see,
is when the GPIOs have been setup by the bootloader and we don't want
to reset them to low during probing (which some OSes might be capable
of, but linux currently doesn't). Also a state of all GPIOs low might
be invalid (not in the "states" property), so we shouldn't set all GPIOs
to low during probing in that case.

HTH,
Harald

> > I still think my proposal describes the property more acurately:
> > gpios-states : On operating systems, that don't support reading back gpio
> >                values in output mode (most notably linux), this array
> >                provides the state of GPIO pins set when requesting them
> >                from the gpio controller. Systems, that are capable of
> >                preserving state when requesting the lines, are free to
> >                ignore this property. 0: LOW, 1: HIGH. Default is LOW if
> >                nothing else is specified.
> > 
> > Since we had this discussion already in the V1 thread and you clearly don't
> > agree with me, the maintainers will need to decide. You can add 
> > Reviewed-by: Harald Geyer <harald@ccbib.org>
> > once Rob and/or Mark have addressed this issue.
> 
> I think we're just looking at this from two different perspectives and
> for whatever reason can't reconcile them.
> 
> > Thanks for your work!
> > Harald
> > 
> 
> 
> -- 
> Best regards,
> Marek Vasut

-- 
If you want to support my work:
see http://friends.ccbib.org/harald/supporting/
or donate via CLAM to xASPBtezLNqj4cUe8MT5nZjthRSEjrRQXN
or via peercoin to P98LRdhit3gZbHDBe7ta5jtXrMJUms4p7w

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
  2019-03-05 16:10     ` Harald Geyer
@ 2019-03-05 19:01       ` Marek Vasut
  2019-03-05 21:36         ` Harald Geyer
  0 siblings, 1 reply; 14+ messages in thread
From: Marek Vasut @ 2019-03-05 19:01 UTC (permalink / raw)
  To: Harald Geyer
  Cc: devicetree, Marek Vasut, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

On 3/5/19 5:10 PM, Harald Geyer wrote:
> Marek Vasut writes:
>> On 3/5/19 11:07 AM, Harald Geyer wrote:
>>> marek.vasut@gmail.com writes:
>>>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>
>>>> Reword the binding document to make it clear how the propeties work
>>>> and which properties affect which other properties.
>>>>
>>>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>> Cc: Harald Geyer <harald@ccbib.org>
>>>> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>>>> Cc: Linus Walleij <linus.walleij@linaro.org>
>>>> Cc: Mark Brown <broonie@kernel.org>
>>>> Cc: Rob Herring <robh@kernel.org>
>>>> Cc: linux-renesas-soc@vger.kernel.org
>>>> To: devicetree@vger.kernel.org
>>>> ---
>>>> V2: - Make "gpios" a mandatory property
>>>>     - Reword "gpio-states" property description
>>>>     - Change "enable-gpio" to "enable-gpios" to match modern DT rules
>>>> Note: The recent gpio-regulator rework caused breakage. While the
>>>>       changes in the gpio-regulator code were according to the DT
>>>>       binding document, they stopped working with older DTs. Make
>>>>       the binding document clearer to prevent such breakage in the
>>>>       future.
>>>
>>> Thanks for the update. I think it addresses all my concerns except for
>>> one:
>>>
>>>> +- gpios-states	: State of GPIO pins in "gpios" array that is set until
>>>> +			  changed by the first consumer. 0: LOW, 1: HIGH.
>>>> +			  Default is LOW if nothing else is specified.
>>>
>>> I still believe this not true: There is no guarantee that the regulator
>>> core won't change the state of GPIO pins before the first consumer comes
>>> up.
>>
>> Why would it do that ?
> 
> Because the regulator core doesn't know about this driver specific
> property at all. And without any constraints placed by consumers, the
> core is free to choose any state whatsoever at any point in time.

But git grep seems to disagree, see drivers/regulator/gpio-regulator.c:
                    ret = of_property_read_u32_index(np, "gpios-states", i,

The core sets the pins to such a value until the consumer takes over.

>> That would completely invalidate any remaining
>> useful-ness of this property.
> 
> Yes, I believe this property is mostly useless. That's what I want to
> get across with my wording proposal. The remaining usecase, that I can see,
> is when the GPIOs have been setup by the bootloader and we don't want
> to reset them to low during probing (which some OSes might be capable
> of, but linux currently doesn't). Also a state of all GPIOs low might
> be invalid (not in the "states" property), so we shouldn't set all GPIOs
> to low during probing in that case.

I presume the bootloader might even add this property to DT based on the
state in which it leaves the GPIOs in.

> HTH,
> Harald
> 
>>> I still think my proposal describes the property more acurately:
>>> gpios-states : On operating systems, that don't support reading back gpio
>>>                values in output mode (most notably linux), this array
>>>                provides the state of GPIO pins set when requesting them
>>>                from the gpio controller. Systems, that are capable of
>>>                preserving state when requesting the lines, are free to
>>>                ignore this property. 0: LOW, 1: HIGH. Default is LOW if
>>>                nothing else is specified.
>>>
>>> Since we had this discussion already in the V1 thread and you clearly don't
>>> agree with me, the maintainers will need to decide. You can add 
>>> Reviewed-by: Harald Geyer <harald@ccbib.org>
>>> once Rob and/or Mark have addressed this issue.
>>
>> I think we're just looking at this from two different perspectives and
>> for whatever reason can't reconcile them.
>>
>>> Thanks for your work!
>>> Harald
>>>
>>
>>
>> -- 
>> Best regards,
>> Marek Vasut
> 


-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
  2019-03-05 19:01       ` Marek Vasut
@ 2019-03-05 21:36         ` Harald Geyer
  2019-03-05 22:23           ` Marek Vasut
  0 siblings, 1 reply; 14+ messages in thread
From: Harald Geyer @ 2019-03-05 21:36 UTC (permalink / raw)
  To: Marek Vasut
  Cc: devicetree, Marek Vasut, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

Marek Vasut writes:
> On 3/5/19 5:10 PM, Harald Geyer wrote:
> > Marek Vasut writes:
> >> On 3/5/19 11:07 AM, Harald Geyer wrote:
> >>> marek.vasut@gmail.com writes:
> >>>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
> >>>>
> >>>> Reword the binding document to make it clear how the propeties work
> >>>> and which properties affect which other properties.
> >>>>
> >>>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> >>>> Cc: Harald Geyer <harald@ccbib.org>
> >>>> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> >>>> Cc: Linus Walleij <linus.walleij@linaro.org>
> >>>> Cc: Mark Brown <broonie@kernel.org>
> >>>> Cc: Rob Herring <robh@kernel.org>
> >>>> Cc: linux-renesas-soc@vger.kernel.org
> >>>> To: devicetree@vger.kernel.org
> >>>> ---
> >>>> V2: - Make "gpios" a mandatory property
> >>>>     - Reword "gpio-states" property description
> >>>>     - Change "enable-gpio" to "enable-gpios" to match modern DT rules
> >>>> Note: The recent gpio-regulator rework caused breakage. While the
> >>>>       changes in the gpio-regulator code were according to the DT
> >>>>       binding document, they stopped working with older DTs. Make
> >>>>       the binding document clearer to prevent such breakage in the
> >>>>       future.
> >>>
> >>> Thanks for the update. I think it addresses all my concerns except for
> >>> one:
> >>>
> >>>> +- gpios-states	: State of GPIO pins in "gpios" array that is set until
> >>>> +			  changed by the first consumer. 0: LOW, 1: HIGH.
> >>>> +			  Default is LOW if nothing else is specified.
> >>>
> >>> I still believe this not true: There is no guarantee that the regulator
> >>> core won't change the state of GPIO pins before the first consumer comes
> >>> up.
> >>
> >> Why would it do that ?
> > 
> > Because the regulator core doesn't know about this driver specific
> > property at all. And without any constraints placed by consumers, the
> > core is free to choose any state whatsoever at any point in time.
> 
> But git grep seems to disagree, see drivers/regulator/gpio-regulator.c:
>                     ret = of_property_read_u32_index(np, "gpios-states", i,
> 
> The core sets the pins to such a value until the consumer takes over.

I think we have a misunderstanding of terminology. When I write "regulator
core", I mean the driver independent regulator code. The line you quote
above is part of the gpio-regulator driver and thus not part of what
I call the "regulator core".

AFAICS the data from the property is only stored in a driver specific
data structure (and not used at all outside of probe) but never passed
to what I call the regulator core.

Why do you believe there is a guarantee that the value set during
probeing is preserved until a consumer takes over?

Harald

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
  2019-03-05 21:36         ` Harald Geyer
@ 2019-03-05 22:23           ` Marek Vasut
  2019-03-06  8:17             ` Harald Geyer
  0 siblings, 1 reply; 14+ messages in thread
From: Marek Vasut @ 2019-03-05 22:23 UTC (permalink / raw)
  To: Harald Geyer
  Cc: devicetree, Marek Vasut, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

On 3/5/19 10:36 PM, Harald Geyer wrote:
> Marek Vasut writes:
>> On 3/5/19 5:10 PM, Harald Geyer wrote:
>>> Marek Vasut writes:
>>>> On 3/5/19 11:07 AM, Harald Geyer wrote:
>>>>> marek.vasut@gmail.com writes:
>>>>>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>>>
>>>>>> Reword the binding document to make it clear how the propeties work
>>>>>> and which properties affect which other properties.
>>>>>>
>>>>>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>>> Cc: Harald Geyer <harald@ccbib.org>
>>>>>> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>>>>>> Cc: Linus Walleij <linus.walleij@linaro.org>
>>>>>> Cc: Mark Brown <broonie@kernel.org>
>>>>>> Cc: Rob Herring <robh@kernel.org>
>>>>>> Cc: linux-renesas-soc@vger.kernel.org
>>>>>> To: devicetree@vger.kernel.org
>>>>>> ---
>>>>>> V2: - Make "gpios" a mandatory property
>>>>>>     - Reword "gpio-states" property description
>>>>>>     - Change "enable-gpio" to "enable-gpios" to match modern DT rules
>>>>>> Note: The recent gpio-regulator rework caused breakage. While the
>>>>>>       changes in the gpio-regulator code were according to the DT
>>>>>>       binding document, they stopped working with older DTs. Make
>>>>>>       the binding document clearer to prevent such breakage in the
>>>>>>       future.
>>>>>
>>>>> Thanks for the update. I think it addresses all my concerns except for
>>>>> one:
>>>>>
>>>>>> +- gpios-states	: State of GPIO pins in "gpios" array that is set until
>>>>>> +			  changed by the first consumer. 0: LOW, 1: HIGH.
>>>>>> +			  Default is LOW if nothing else is specified.
>>>>>
>>>>> I still believe this not true: There is no guarantee that the regulator
>>>>> core won't change the state of GPIO pins before the first consumer comes
>>>>> up.
>>>>
>>>> Why would it do that ?
>>>
>>> Because the regulator core doesn't know about this driver specific
>>> property at all. And without any constraints placed by consumers, the
>>> core is free to choose any state whatsoever at any point in time.
>>
>> But git grep seems to disagree, see drivers/regulator/gpio-regulator.c:
>>                     ret = of_property_read_u32_index(np, "gpios-states", i,
>>
>> The core sets the pins to such a value until the consumer takes over.
> 
> I think we have a misunderstanding of terminology. When I write "regulator
> core", I mean the driver independent regulator code. The line you quote
> above is part of the gpio-regulator driver and thus not part of what
> I call the "regulator core".
> 
> AFAICS the data from the property is only stored in a driver specific
> data structure (and not used at all outside of probe) but never passed
> to what I call the regulator core.
> 
> Why do you believe there is a guarantee that the value set during
> probeing is preserved until a consumer takes over?

It is the only sensible behavior and the behavior I see people expect
from this property. I presume it solidified in this sort of semi-defined
state, so we're stuck with assuming it behaves this way to maintain
compatibility.

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
  2019-03-05 22:23           ` Marek Vasut
@ 2019-03-06  8:17             ` Harald Geyer
  2019-03-06 21:56               ` Marek Vasut
  0 siblings, 1 reply; 14+ messages in thread
From: Harald Geyer @ 2019-03-06  8:17 UTC (permalink / raw)
  To: Marek Vasut
  Cc: devicetree, Marek Vasut, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

Marek Vasut writes:
> On 3/5/19 10:36 PM, Harald Geyer wrote:
> > Marek Vasut writes:
> >> On 3/5/19 5:10 PM, Harald Geyer wrote:
> >>> Marek Vasut writes:
> >>>> On 3/5/19 11:07 AM, Harald Geyer wrote:
> >>>>> marek.vasut@gmail.com writes:
> >>>>>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
> >>>>>>
> >>>>>> Reword the binding document to make it clear how the propeties work
> >>>>>> and which properties affect which other properties.
> >>>>>>
> >>>>>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> >>>>>> Cc: Harald Geyer <harald@ccbib.org>
> >>>>>> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> >>>>>> Cc: Linus Walleij <linus.walleij@linaro.org>
> >>>>>> Cc: Mark Brown <broonie@kernel.org>
> >>>>>> Cc: Rob Herring <robh@kernel.org>
> >>>>>> Cc: linux-renesas-soc@vger.kernel.org
> >>>>>> To: devicetree@vger.kernel.org
> >>>>>> ---
> >>>>>> V2: - Make "gpios" a mandatory property
> >>>>>>     - Reword "gpio-states" property description
> >>>>>>     - Change "enable-gpio" to "enable-gpios" to match modern DT rules
> >>>>>> Note: The recent gpio-regulator rework caused breakage. While the
> >>>>>>       changes in the gpio-regulator code were according to the DT
> >>>>>>       binding document, they stopped working with older DTs. Make
> >>>>>>       the binding document clearer to prevent such breakage in the
> >>>>>>       future.
> >>>>>
> >>>>> Thanks for the update. I think it addresses all my concerns except for
> >>>>> one:
> >>>>>
> >>>>>> +- gpios-states	: State of GPIO pins in "gpios" array that is set until
> >>>>>> +			  changed by the first consumer. 0: LOW, 1: HIGH.
> >>>>>> +			  Default is LOW if nothing else is specified.
> >>>>>
> >>>>> I still believe this not true: There is no guarantee that the regulator
> >>>>> core won't change the state of GPIO pins before the first consumer comes
> >>>>> up.
> >>>>
> >>>> Why would it do that ?
> >>>
> >>> Because the regulator core doesn't know about this driver specific
> >>> property at all. And without any constraints placed by consumers, the
> >>> core is free to choose any state whatsoever at any point in time.
> >>
> >> But git grep seems to disagree, see drivers/regulator/gpio-regulator.c:
> >>                     ret = of_property_read_u32_index(np, "gpios-states", i,
> >>
> >> The core sets the pins to such a value until the consumer takes over.
> > 
> > I think we have a misunderstanding of terminology. When I write "regulator
> > core", I mean the driver independent regulator code. The line you quote
> > above is part of the gpio-regulator driver and thus not part of what
> > I call the "regulator core".
> > 
> > AFAICS the data from the property is only stored in a driver specific
> > data structure (and not used at all outside of probe) but never passed
> > to what I call the regulator core.
> > 
> > Why do you believe there is a guarantee that the value set during
> > probeing is preserved until a consumer takes over?
> 
> It is the only sensible behavior and the behavior I see people expect
> from this property. I presume it solidified in this sort of semi-defined
> state, so we're stuck with assuming it behaves this way to maintain
> compatibility.

Maybe the behaviour you want would be more sensible, but AFAIK it just
isn't true in general (it might work that way by chance in many cases).
If people expect this behaviour, it is a misunderstanding of the old wording.
I'd prefer we don't have to add a quirk to the regulator subsystem to
cater for a misunderstanding.

I think, if you really want to go forward with making this behaviour
officially maintained, then we should first add the code to linux and
only then add the promise to the binding document. This isn't the scope
of this patch, so I guess we would need to keep the ambiguous wording as
it is for now. I believe it is more important for a binding document
to be correct than to be sensible.

However I don't think we actually need to go to such extremes: In linux
we currently have (arm/boot/dts and arm64/boot/dts) 38 uses of this
property in 29 DTs. All the examples, that I studied in some detail,
seem to either don't need this property at all or have a usecase that is
supported by my proposed wording. I don't expect any problems if we just
document the status quo clearly.

Harald

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
  2019-03-06  8:17             ` Harald Geyer
@ 2019-03-06 21:56               ` Marek Vasut
  2019-03-07  9:12                   ` Harald Geyer
  0 siblings, 1 reply; 14+ messages in thread
From: Marek Vasut @ 2019-03-06 21:56 UTC (permalink / raw)
  To: Harald Geyer
  Cc: devicetree, Marek Vasut, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

On 3/6/19 9:17 AM, Harald Geyer wrote:
> Marek Vasut writes:
>> On 3/5/19 10:36 PM, Harald Geyer wrote:
>>> Marek Vasut writes:
>>>> On 3/5/19 5:10 PM, Harald Geyer wrote:
>>>>> Marek Vasut writes:
>>>>>> On 3/5/19 11:07 AM, Harald Geyer wrote:
>>>>>>> marek.vasut@gmail.com writes:
>>>>>>>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>>>>>
>>>>>>>> Reword the binding document to make it clear how the propeties work
>>>>>>>> and which properties affect which other properties.
>>>>>>>>
>>>>>>>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>>>>> Cc: Harald Geyer <harald@ccbib.org>
>>>>>>>> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>>>>>>>> Cc: Linus Walleij <linus.walleij@linaro.org>
>>>>>>>> Cc: Mark Brown <broonie@kernel.org>
>>>>>>>> Cc: Rob Herring <robh@kernel.org>
>>>>>>>> Cc: linux-renesas-soc@vger.kernel.org
>>>>>>>> To: devicetree@vger.kernel.org
>>>>>>>> ---
>>>>>>>> V2: - Make "gpios" a mandatory property
>>>>>>>>     - Reword "gpio-states" property description
>>>>>>>>     - Change "enable-gpio" to "enable-gpios" to match modern DT rules
>>>>>>>> Note: The recent gpio-regulator rework caused breakage. While the
>>>>>>>>       changes in the gpio-regulator code were according to the DT
>>>>>>>>       binding document, they stopped working with older DTs. Make
>>>>>>>>       the binding document clearer to prevent such breakage in the
>>>>>>>>       future.
>>>>>>>
>>>>>>> Thanks for the update. I think it addresses all my concerns except for
>>>>>>> one:
>>>>>>>
>>>>>>>> +- gpios-states	: State of GPIO pins in "gpios" array that is set until
>>>>>>>> +			  changed by the first consumer. 0: LOW, 1: HIGH.
>>>>>>>> +			  Default is LOW if nothing else is specified.
>>>>>>>
>>>>>>> I still believe this not true: There is no guarantee that the regulator
>>>>>>> core won't change the state of GPIO pins before the first consumer comes
>>>>>>> up.
>>>>>>
>>>>>> Why would it do that ?
>>>>>
>>>>> Because the regulator core doesn't know about this driver specific
>>>>> property at all. And without any constraints placed by consumers, the
>>>>> core is free to choose any state whatsoever at any point in time.
>>>>
>>>> But git grep seems to disagree, see drivers/regulator/gpio-regulator.c:
>>>>                     ret = of_property_read_u32_index(np, "gpios-states", i,
>>>>
>>>> The core sets the pins to such a value until the consumer takes over.
>>>
>>> I think we have a misunderstanding of terminology. When I write "regulator
>>> core", I mean the driver independent regulator code. The line you quote
>>> above is part of the gpio-regulator driver and thus not part of what
>>> I call the "regulator core".
>>>
>>> AFAICS the data from the property is only stored in a driver specific
>>> data structure (and not used at all outside of probe) but never passed
>>> to what I call the regulator core.
>>>
>>> Why do you believe there is a guarantee that the value set during
>>> probeing is preserved until a consumer takes over?
>>
>> It is the only sensible behavior and the behavior I see people expect
>> from this property. I presume it solidified in this sort of semi-defined
>> state, so we're stuck with assuming it behaves this way to maintain
>> compatibility.
> 
> Maybe the behaviour you want would be more sensible, but AFAIK it just
> isn't true in general (it might work that way by chance in many cases).
> If people expect this behaviour, it is a misunderstanding of the old wording.
> I'd prefer we don't have to add a quirk to the regulator subsystem to
> cater for a misunderstanding.
> 
> I think, if you really want to go forward with making this behaviour
> officially maintained, then we should first add the code to linux and
> only then add the promise to the binding document. This isn't the scope
> of this patch, so I guess we would need to keep the ambiguous wording as
> it is for now. I believe it is more important for a binding document
> to be correct than to be sensible.
> 
> However I don't think we actually need to go to such extremes: In linux
> we currently have (arm/boot/dts and arm64/boot/dts) 38 uses of this
> property in 29 DTs. All the examples, that I studied in some detail,
> seem to either don't need this property at all or have a usecase that is
> supported by my proposed wording. I don't expect any problems if we just
> document the status quo clearly.

In that case, provide a suggestion how to document this property better?

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
  2019-03-06 21:56               ` Marek Vasut
@ 2019-03-07  9:12                   ` Harald Geyer
  0 siblings, 0 replies; 14+ messages in thread
From: Harald Geyer @ 2019-03-07  9:12 UTC (permalink / raw)
  To: Marek Vasut
  Cc: devicetree, Marek Vasut, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

On 06.03.2019 22:56, Marek Vasut wrote:
> On 3/6/19 9:17 AM, Harald Geyer wrote:
>> Marek Vasut writes:
>>> On 3/5/19 10:36 PM, Harald Geyer wrote:
>>>> Marek Vasut writes:
>>>>> On 3/5/19 5:10 PM, Harald Geyer wrote:
>>>>>> Marek Vasut writes:
>>>>>>> On 3/5/19 11:07 AM, Harald Geyer wrote:
>>>>>>>> marek.vasut@gmail.com writes:
>>>>>>>>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>>>>>>
>>>>>>>>> Reword the binding document to make it clear how the 
>>>>>>>>> propeties work
>>>>>>>>> and which properties affect which other properties.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>>>>>> Cc: Harald Geyer <harald@ccbib.org>
>>>>>>>>> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>>>>>>>>> Cc: Linus Walleij <linus.walleij@linaro.org>
>>>>>>>>> Cc: Mark Brown <broonie@kernel.org>
>>>>>>>>> Cc: Rob Herring <robh@kernel.org>
>>>>>>>>> Cc: linux-renesas-soc@vger.kernel.org
>>>>>>>>> To: devicetree@vger.kernel.org
>>>>>>>>> ---
>>>>>>>>> V2: - Make "gpios" a mandatory property
>>>>>>>>>     - Reword "gpio-states" property description
>>>>>>>>>     - Change "enable-gpio" to "enable-gpios" to match modern 
>>>>>>>>> DT rules
>>>>>>>>> Note: The recent gpio-regulator rework caused breakage. While 
>>>>>>>>> the
>>>>>>>>>       changes in the gpio-regulator code were according to 
>>>>>>>>> the DT
>>>>>>>>>       binding document, they stopped working with older DTs. 
>>>>>>>>> Make
>>>>>>>>>       the binding document clearer to prevent such breakage 
>>>>>>>>> in the
>>>>>>>>>       future.
>>>>>>>>
>>>>>>>> Thanks for the update. I think it addresses all my concerns 
>>>>>>>> except for
>>>>>>>> one:
>>>>>>>>
>>>>>>>>> +- gpios-states	: State of GPIO pins in "gpios" array that is 
>>>>>>>>> set until
>>>>>>>>> +			  changed by the first consumer. 0: LOW, 1: HIGH.
>>>>>>>>> +			  Default is LOW if nothing else is specified.
>>>>>>>>
>>>>>>>> I still believe this not true: There is no guarantee that the 
>>>>>>>> regulator
>>>>>>>> core won't change the state of GPIO pins before the first 
>>>>>>>> consumer comes
>>>>>>>> up.
>>>>>>>
>>>>>>> Why would it do that ?
>>>>>>
>>>>>> Because the regulator core doesn't know about this driver 
>>>>>> specific
>>>>>> property at all. And without any constraints placed by 
>>>>>> consumers, the
>>>>>> core is free to choose any state whatsoever at any point in 
>>>>>> time.
>>>>>
>>>>> But git grep seems to disagree, see 
>>>>> drivers/regulator/gpio-regulator.c:
>>>>>                     ret = of_property_read_u32_index(np, 
>>>>> "gpios-states", i,
>>>>>
>>>>> The core sets the pins to such a value until the consumer takes 
>>>>> over.
>>>>
>>>> I think we have a misunderstanding of terminology. When I write 
>>>> "regulator
>>>> core", I mean the driver independent regulator code. The line you 
>>>> quote
>>>> above is part of the gpio-regulator driver and thus not part of 
>>>> what
>>>> I call the "regulator core".
>>>>
>>>> AFAICS the data from the property is only stored in a driver 
>>>> specific
>>>> data structure (and not used at all outside of probe) but never 
>>>> passed
>>>> to what I call the regulator core.
>>>>
>>>> Why do you believe there is a guarantee that the value set during
>>>> probeing is preserved until a consumer takes over?
>>>
>>> It is the only sensible behavior and the behavior I see people 
>>> expect
>>> from this property. I presume it solidified in this sort of 
>>> semi-defined
>>> state, so we're stuck with assuming it behaves this way to maintain
>>> compatibility.
>>
>> Maybe the behaviour you want would be more sensible, but AFAIK it 
>> just
>> isn't true in general (it might work that way by chance in many 
>> cases).
>> If people expect this behaviour, it is a misunderstanding of the old 
>> wording.
>> I'd prefer we don't have to add a quirk to the regulator subsystem 
>> to
>> cater for a misunderstanding.
>>
>> I think, if you really want to go forward with making this behaviour
>> officially maintained, then we should first add the code to linux 
>> and
>> only then add the promise to the binding document. This isn't the 
>> scope
>> of this patch, so I guess we would need to keep the ambiguous 
>> wording as
>> it is for now. I believe it is more important for a binding document
>> to be correct than to be sensible.
>>
>> However I don't think we actually need to go to such extremes: In 
>> linux
>> we currently have (arm/boot/dts and arm64/boot/dts) 38 uses of this
>> property in 29 DTs. All the examples, that I studied in some detail,
>> seem to either don't need this property at all or have a usecase 
>> that is
>> supported by my proposed wording. I don't expect any problems if we 
>> just
>> document the status quo clearly.
>
> In that case, provide a suggestion how to document this property 
> better?

I did: https://www.spinics.net/lists/devicetree/msg275050.html

HTH,
Harald

-- 
If you want to support my work:
see http://friends.ccbib.org/harald/supporting/
or donate via peercoin to P98LRdhit3gZbHDBe7ta5jtXrMJUms4p7w
or CLAM xASPBtezLNqj4cUe8MT5nZjthRSEjrRQXN

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
@ 2019-03-07  9:12                   ` Harald Geyer
  0 siblings, 0 replies; 14+ messages in thread
From: Harald Geyer @ 2019-03-07  9:12 UTC (permalink / raw)
  To: Marek Vasut
  Cc: devicetree, Marek Vasut, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

On 06.03.2019 22:56, Marek Vasut wrote:
> On 3/6/19 9:17 AM, Harald Geyer wrote:
>> Marek Vasut writes:
>>> On 3/5/19 10:36 PM, Harald Geyer wrote:
>>>> Marek Vasut writes:
>>>>> On 3/5/19 5:10 PM, Harald Geyer wrote:
>>>>>> Marek Vasut writes:
>>>>>>> On 3/5/19 11:07 AM, Harald Geyer wrote:
>>>>>>>> marek.vasut@gmail.com writes:
>>>>>>>>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>>>>>>
>>>>>>>>> Reword the binding document to make it clear how the 
>>>>>>>>> propeties work
>>>>>>>>> and which properties affect which other properties.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>>>>>> Cc: Harald Geyer <harald@ccbib.org>
>>>>>>>>> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>>>>>>>>> Cc: Linus Walleij <linus.walleij@linaro.org>
>>>>>>>>> Cc: Mark Brown <broonie@kernel.org>
>>>>>>>>> Cc: Rob Herring <robh@kernel.org>
>>>>>>>>> Cc: linux-renesas-soc@vger.kernel.org
>>>>>>>>> To: devicetree@vger.kernel.org
>>>>>>>>> ---
>>>>>>>>> V2: - Make "gpios" a mandatory property
>>>>>>>>>     - Reword "gpio-states" property description
>>>>>>>>>     - Change "enable-gpio" to "enable-gpios" to match modern 
>>>>>>>>> DT rules
>>>>>>>>> Note: The recent gpio-regulator rework caused breakage. While 
>>>>>>>>> the
>>>>>>>>>       changes in the gpio-regulator code were according to 
>>>>>>>>> the DT
>>>>>>>>>       binding document, they stopped working with older DTs. 
>>>>>>>>> Make
>>>>>>>>>       the binding document clearer to prevent such breakage 
>>>>>>>>> in the
>>>>>>>>>       future.
>>>>>>>>
>>>>>>>> Thanks for the update. I think it addresses all my concerns 
>>>>>>>> except for
>>>>>>>> one:
>>>>>>>>
>>>>>>>>> +- gpios-states	: State of GPIO pins in "gpios" array that is 
>>>>>>>>> set until
>>>>>>>>> +			  changed by the first consumer. 0: LOW, 1: HIGH.
>>>>>>>>> +			  Default is LOW if nothing else is specified.
>>>>>>>>
>>>>>>>> I still believe this not true: There is no guarantee that the 
>>>>>>>> regulator
>>>>>>>> core won't change the state of GPIO pins before the first 
>>>>>>>> consumer comes
>>>>>>>> up.
>>>>>>>
>>>>>>> Why would it do that ?
>>>>>>
>>>>>> Because the regulator core doesn't know about this driver 
>>>>>> specific
>>>>>> property at all. And without any constraints placed by 
>>>>>> consumers, the
>>>>>> core is free to choose any state whatsoever at any point in 
>>>>>> time.
>>>>>
>>>>> But git grep seems to disagree, see 
>>>>> drivers/regulator/gpio-regulator.c:
>>>>>                     ret = of_property_read_u32_index(np, 
>>>>> "gpios-states", i,
>>>>>
>>>>> The core sets the pins to such a value until the consumer takes 
>>>>> over.
>>>>
>>>> I think we have a misunderstanding of terminology. When I write 
>>>> "regulator
>>>> core", I mean the driver independent regulator code. The line you 
>>>> quote
>>>> above is part of the gpio-regulator driver and thus not part of 
>>>> what
>>>> I call the "regulator core".
>>>>
>>>> AFAICS the data from the property is only stored in a driver 
>>>> specific
>>>> data structure (and not used at all outside of probe) but never 
>>>> passed
>>>> to what I call the regulator core.
>>>>
>>>> Why do you believe there is a guarantee that the value set during
>>>> probeing is preserved until a consumer takes over?
>>>
>>> It is the only sensible behavior and the behavior I see people 
>>> expect
>>> from this property. I presume it solidified in this sort of 
>>> semi-defined
>>> state, so we're stuck with assuming it behaves this way to maintain
>>> compatibility.
>>
>> Maybe the behaviour you want would be more sensible, but AFAIK it 
>> just
>> isn't true in general (it might work that way by chance in many 
>> cases).
>> If people expect this behaviour, it is a misunderstanding of the old 
>> wording.
>> I'd prefer we don't have to add a quirk to the regulator subsystem 
>> to
>> cater for a misunderstanding.
>>
>> I think, if you really want to go forward with making this behaviour
>> officially maintained, then we should first add the code to linux 
>> and
>> only then add the promise to the binding document. This isn't the 
>> scope
>> of this patch, so I guess we would need to keep the ambiguous 
>> wording as
>> it is for now. I believe it is more important for a binding document
>> to be correct than to be sensible.
>>
>> However I don't think we actually need to go to such extremes: In 
>> linux
>> we currently have (arm/boot/dts and arm64/boot/dts) 38 uses of this
>> property in 29 DTs. All the examples, that I studied in some detail,
>> seem to either don't need this property at all or have a usecase 
>> that is
>> supported by my proposed wording. I don't expect any problems if we 
>> just
>> document the status quo clearly.
>
> In that case, provide a suggestion how to document this property 
> better?

I did: https://www.spinics.net/lists/devicetree/msg275050.html

HTH,
Harald

-- 
If you want to support my work:
see http://friends.ccbib.org/harald/supporting/
or donate via peercoin to P98LRdhit3gZbHDBe7ta5jtXrMJUms4p7w
or CLAM xASPBtezLNqj4cUe8MT5nZjthRSEjrRQXN

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH V2] regulator: gpio: Reword the binding document
  2019-03-07  9:12                   ` Harald Geyer
  (?)
@ 2019-03-16 20:26                   ` Marek Vasut
  -1 siblings, 0 replies; 14+ messages in thread
From: Marek Vasut @ 2019-03-16 20:26 UTC (permalink / raw)
  To: Harald Geyer
  Cc: devicetree, Marek Vasut, Kuninori Morimoto, Linus Walleij,
	Mark Brown, Rob Herring, linux-renesas-soc

On 3/7/19 10:12 AM, Harald Geyer wrote:
> On 06.03.2019 22:56, Marek Vasut wrote:
>> On 3/6/19 9:17 AM, Harald Geyer wrote:
>>> Marek Vasut writes:
>>>> On 3/5/19 10:36 PM, Harald Geyer wrote:
>>>>> Marek Vasut writes:
>>>>>> On 3/5/19 5:10 PM, Harald Geyer wrote:
>>>>>>> Marek Vasut writes:
>>>>>>>> On 3/5/19 11:07 AM, Harald Geyer wrote:
>>>>>>>>> marek.vasut@gmail.com writes:
>>>>>>>>>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>>>>>>>
>>>>>>>>>> Reword the binding document to make it clear how the propeties
>>>>>>>>>> work
>>>>>>>>>> and which properties affect which other properties.
>>>>>>>>>>
>>>>>>>>>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>>>>>>>> Cc: Harald Geyer <harald@ccbib.org>
>>>>>>>>>> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>>>>>>>>>> Cc: Linus Walleij <linus.walleij@linaro.org>
>>>>>>>>>> Cc: Mark Brown <broonie@kernel.org>
>>>>>>>>>> Cc: Rob Herring <robh@kernel.org>
>>>>>>>>>> Cc: linux-renesas-soc@vger.kernel.org
>>>>>>>>>> To: devicetree@vger.kernel.org
>>>>>>>>>> ---
>>>>>>>>>> V2: - Make "gpios" a mandatory property
>>>>>>>>>>     - Reword "gpio-states" property description
>>>>>>>>>>     - Change "enable-gpio" to "enable-gpios" to match modern
>>>>>>>>>> DT rules
>>>>>>>>>> Note: The recent gpio-regulator rework caused breakage. While the
>>>>>>>>>>       changes in the gpio-regulator code were according to the DT
>>>>>>>>>>       binding document, they stopped working with older DTs. Make
>>>>>>>>>>       the binding document clearer to prevent such breakage in
>>>>>>>>>> the
>>>>>>>>>>       future.
>>>>>>>>>
>>>>>>>>> Thanks for the update. I think it addresses all my concerns
>>>>>>>>> except for
>>>>>>>>> one:
>>>>>>>>>
>>>>>>>>>> +- gpios-states    : State of GPIO pins in "gpios" array that
>>>>>>>>>> is set until
>>>>>>>>>> +              changed by the first consumer. 0: LOW, 1: HIGH.
>>>>>>>>>> +              Default is LOW if nothing else is specified.
>>>>>>>>>
>>>>>>>>> I still believe this not true: There is no guarantee that the
>>>>>>>>> regulator
>>>>>>>>> core won't change the state of GPIO pins before the first
>>>>>>>>> consumer comes
>>>>>>>>> up.
>>>>>>>>
>>>>>>>> Why would it do that ?
>>>>>>>
>>>>>>> Because the regulator core doesn't know about this driver specific
>>>>>>> property at all. And without any constraints placed by consumers,
>>>>>>> the
>>>>>>> core is free to choose any state whatsoever at any point in time.
>>>>>>
>>>>>> But git grep seems to disagree, see
>>>>>> drivers/regulator/gpio-regulator.c:
>>>>>>                     ret = of_property_read_u32_index(np,
>>>>>> "gpios-states", i,
>>>>>>
>>>>>> The core sets the pins to such a value until the consumer takes over.
>>>>>
>>>>> I think we have a misunderstanding of terminology. When I write
>>>>> "regulator
>>>>> core", I mean the driver independent regulator code. The line you
>>>>> quote
>>>>> above is part of the gpio-regulator driver and thus not part of what
>>>>> I call the "regulator core".
>>>>>
>>>>> AFAICS the data from the property is only stored in a driver specific
>>>>> data structure (and not used at all outside of probe) but never passed
>>>>> to what I call the regulator core.
>>>>>
>>>>> Why do you believe there is a guarantee that the value set during
>>>>> probeing is preserved until a consumer takes over?
>>>>
>>>> It is the only sensible behavior and the behavior I see people expect
>>>> from this property. I presume it solidified in this sort of
>>>> semi-defined
>>>> state, so we're stuck with assuming it behaves this way to maintain
>>>> compatibility.
>>>
>>> Maybe the behaviour you want would be more sensible, but AFAIK it just
>>> isn't true in general (it might work that way by chance in many cases).
>>> If people expect this behaviour, it is a misunderstanding of the old
>>> wording.
>>> I'd prefer we don't have to add a quirk to the regulator subsystem to
>>> cater for a misunderstanding.
>>>
>>> I think, if you really want to go forward with making this behaviour
>>> officially maintained, then we should first add the code to linux and
>>> only then add the promise to the binding document. This isn't the scope
>>> of this patch, so I guess we would need to keep the ambiguous wording as
>>> it is for now. I believe it is more important for a binding document
>>> to be correct than to be sensible.
>>>
>>> However I don't think we actually need to go to such extremes: In linux
>>> we currently have (arm/boot/dts and arm64/boot/dts) 38 uses of this
>>> property in 29 DTs. All the examples, that I studied in some detail,
>>> seem to either don't need this property at all or have a usecase that is
>>> supported by my proposed wording. I don't expect any problems if we just
>>> document the status quo clearly.
>>
>> In that case, provide a suggestion how to document this property better?
> 
> I did: https://www.spinics.net/lists/devicetree/msg275050.html

I don't like it, but I added it there and sent V3, let's see what others
think.

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-03-16 20:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-04 19:40 [PATCH V2] regulator: gpio: Reword the binding document marek.vasut
2019-03-04 22:20 ` Linus Walleij
2019-03-04 22:20   ` Linus Walleij
2019-03-05 10:07 ` Harald Geyer
2019-03-05 10:59   ` Marek Vasut
2019-03-05 16:10     ` Harald Geyer
2019-03-05 19:01       ` Marek Vasut
2019-03-05 21:36         ` Harald Geyer
2019-03-05 22:23           ` Marek Vasut
2019-03-06  8:17             ` Harald Geyer
2019-03-06 21:56               ` Marek Vasut
2019-03-07  9:12                 ` Harald Geyer
2019-03-07  9:12                   ` Harald Geyer
2019-03-16 20:26                   ` Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.