From: Alexandre Courbot <gnurou@gmail.com>
To: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Javier Martinez Canillas <javier.martinez@collabora.co.uk>,
Samuel Ortiz <sameo@linux.intel.com>,
Lee Jones <lee.jones@linaro.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Ben Dooks <ben-linux@fluff.org>,
Kukjin Kim <kgene.kim@samsung.com>,
Russell King <linux@arm.linux.org.uk>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-samsung-soc@vger.kernel.org"
<linux-samsung-soc@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Kyungmin Park <kyungmin.park@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH 6/8] regulator: max77686: Add external GPIO control
Date: Sat, 1 Nov 2014 14:47:29 +0900 [thread overview]
Message-ID: <CAAVeFuL7XiP3e4+pQt_asL+0f-UpffTvj0Mt=D0TPevW4hT=zA@mail.gmail.com> (raw)
In-Reply-To: <1414741898.20071.8.camel@AMDC1943>
On Fri, Oct 31, 2014 at 4:51 PM, Krzysztof Kozlowski
<k.kozlowski@samsung.com> wrote:
> On pią, 2014-10-31 at 12:31 +0900, Alexandre Courbot wrote:
>> On Fri, Oct 31, 2014 at 12:03 AM, Krzysztof Kozlowski
>> <k.kozlowski@samsung.com> wrote:
>> > On czw, 2014-10-30 at 22:56 +0900, Alexandre Courbot wrote:
>> >> Hi, and thanks for bringing this issue to us!
>> >>
>> >> On Wed, Oct 29, 2014 at 7:49 PM, Javier Martinez Canillas
>> >> <javier.martinez@collabora.co.uk> wrote:
>> >> > [adding Linus and Alexandre to the cc list]
>> >> >
>> >> > Hello Krzysztof,
>> >> >
>> >> > On 10/29/2014 11:42 AM, Krzysztof Kozlowski wrote:
>> >> >> On wto, 2014-10-28 at 13:11 +0100, Krzysztof Kozlowski wrote:
>> >> >>> On wto, 2014-10-28 at 09:52 +0100, Krzysztof Kozlowski wrote:
>> >> >>> > On pon, 2014-10-27 at 21:03 +0100, Javier Martinez Canillas wrote:
>> >> >>> > > Hello Krzysztof,
>> >> >>> > >
>> >> >>> > > On 10/27/2014 04:03 PM, Krzysztof Kozlowski wrote:
>> >> >>> > > > @@ -85,6 +91,9 @@ struct max77686_data {
>> >> >>> > > > struct max77686_regulator_data *regulators;
>> >> >>> > > > int num_regulators;
>> >> >>> > > >
>> >> >>> > > > + /* Array of size num_regulators with GPIOs for external control. */
>> >> >>> > > > + int *ext_control_gpio;
>> >> >>> > > > +
>> >> >>> > >
>> >> >>> > > The integer-based GPIO API is deprecated in favor of the descriptor-based GPIO
>> >> >>> > > interface (Documentation/gpio/consumer.txt). Could you please use the later?
>> >> >>> >
>> >> >>> > Sure, I can. Please have in mind that regulator core still accepts old
>> >> >>> > GPIO so I will have to use desc_to_gpio(). That should work... and
>> >> >>> > should be future-ready.
>> >> >>>
>> >> >>> It seems I was too hasty... I think usage of the new gpiod API implies
>> >> >>> completely different bindings.
>> >> >>>
>> >> >>> The gpiod_get() gets GPIO from a device level, not from given sub-node
>> >> >>> pointer. This means that you cannot have DTS like this:
>> >> >>> ldo21_reg: ldo21 {
>> >> >>> regulator-compatible = "LDO21";
>> >> >>> regulator-name = "VTF_2.8V";
>> >> >>> regulator-min-microvolt = <2800000>;
>> >> >>> regulator-max-microvolt = <2800000>;
>> >> >>> ec-gpio = <&gpy2 0 0>;
>> >> >>> };
>> >> >>>
>> >> >>> ldo22_reg: ldo22 {
>> >> >>> regulator-compatible = "LDO22";
>> >> >>> regulator-name = "VMEM_VDD_2.8V";
>> >> >>> regulator-min-microvolt = <2800000>;
>> >> >>> regulator-max-microvolt = <2800000>;
>> >> >>> ec-gpio = <&gpk0 2 0>;
>> >> >>> };
>> >> >>>
>> >> >>>
>> >> >>> I could put GPIOs in device node:
>> >> >>>
>> >> >>> max77686_pmic@09 {
>> >> >>> compatible = "maxim,max77686";
>> >> >>> interrupt-parent = <&gpx0>;
>> >> >>> interrupts = <7 0>;
>> >> >>> reg = <0x09>;
>> >> >>> #clock-cells = <1>;
>> >> >>> ldo21-gpio = <&gpy2 0 0>;
>> >> >>> ldo22-gpio = <&gpk0 2 0>;
>> >> >>>
>> >> >>> ldo21_reg: ldo21 {
>> >> >>> regulator-compatible = "LDO21";
>> >> >>> regulator-name = "VTF_2.8V";
>> >> >>> regulator-min-microvolt = <2800000>;
>> >> >>> regulator-max-microvolt = <2800000>;
>> >> >>> };
>> >> >>>
>> >> >>> ldo22_reg: ldo22 {
>> >> >>> regulator-compatible = "LDO22";
>> >> >>> regulator-name = "VMEM_VDD_2.8V";
>> >> >>> regulator-min-microvolt = <2800000>;
>> >> >>> regulator-max-microvolt = <2800000>;
>> >> >>> };
>> >> >>>
>> >> >>> This would work but I don't like it. The properties of a regulator are
>> >> >>> above the node configuring that regulator.
>> >> >>>
>> >> >>> Any ideas?
>> >> >>>
>> >> >>
>> >> >> Continuing talking to myself... I found another problem - GPIO cannot be
>> >> >> requested more than once (-EBUSY). In case of this driver (and board:
>> >> >> Trats2) one GPIO is connected to regulators. The legacy GPIO API and
>> >> >> regulator core handle this.
>> >> >>
>> >> >> With new GPIO API I would have to implement some additional steps in
>> >> >> such case...
>> >> >>
>> >> >> So there are 2 issues:
>> >> >> 1. Cannot put GPIO property in regulator node.
>> >>
>> >> For this problem you will probably want to use the
>> >> dev(m)_get_named_gpiod_from_child() function from the following patch:
>> >>
>> >> https://lkml.org/lkml/2014/10/6/529
>> >>
>> >> It should reach -next soon now.
>> >
>> > Thanks! Probably I would switch to "top" level gpios property anyway
>> > (other reasons) but it would be valuable in some cases to specify them
>> > per child node.
>>
>> Mmm, but doesn't it make more sense to have them in the child nodes?
>
> Yes, it makes more sense. Using old way of parsing regulators from DT it
> was straightforward.
>
> However new DT style parsing (regulator_of_get_init_data()) does the
> basic parsing stuff and this removes a lot of code from driver. The
> driver no longer parses all regulaotrs but the regulator core does it.
> Unfortunately regulator core does not parse custom bindings (like such
> GPIOs) so I would have to iterate once again through all regulators just
> to find "gpios" property.
>
> It is simpler just to do something like (5 regulators can be controlled
> by GPIO):
>
> max77686_pmic_dt_parse_gpio_control(struct platform_device *pdev, *gpio)
> {
> gpio[MAX77686_LDO20] = of_get_named_gpio(np, "ldo20-gpios", 0);
> gpio[MAX77686_LDO21] = of_get_named_gpio(np, "ldo21-gpios", 0);
> gpio[MAX77686_LDO22] = of_get_named_gpio(np, "ldo22-gpios", 0);
> gpio[MAX77686_BUCK8] = of_get_named_gpio(np, "buck8-gpios", 0);
> gpio[MAX77686_BUCK9] = of_get_named_gpio(np, "buck9-gpios", 0);
> }
It is simpler from the driver's perspective, but if I understand
correctly DT bindings are not supposed to be adapted to make life
easier for a particular implementation. If the driver needs to make an
additional pass into the child nodes, then so be it, as long as the
nodes describe the hardware accurately and in a way that is easy to
understand. You can always adapt the driver core to handle your
use-case better, but once DT bindings are published, they are set in
stone.
next prev parent reply other threads:[~2014-11-01 5:47 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-27 15:03 [PATCH 0/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
2014-10-27 15:03 ` [PATCH 1/8] regulator: max77802: Remove support for board files Krzysztof Kozlowski
2014-10-27 19:36 ` Javier Martinez Canillas
2014-10-28 8:45 ` Krzysztof Kozlowski
2014-10-28 8:50 ` Javier Martinez Canillas
2014-10-27 15:03 ` [PATCH 2/8] regulator: max77686: " Krzysztof Kozlowski
2014-10-27 19:41 ` Javier Martinez Canillas
2014-10-28 0:37 ` Mark Brown
2014-10-28 8:40 ` Krzysztof Kozlowski
2014-10-27 15:03 ` [PATCH 3/8] mfd: max77686/802: " Krzysztof Kozlowski
2014-10-27 19:48 ` Javier Martinez Canillas
2014-10-28 9:11 ` Krzysztof Kozlowski
2014-10-27 15:03 ` [PATCH 4/8] regulator: max77686: Make regulator_desc array const Krzysztof Kozlowski
2014-10-27 19:50 ` Javier Martinez Canillas
2014-10-28 0:38 ` Mark Brown
2014-10-27 15:03 ` [PATCH 5/8] regulator: max77686: Initialize opmode explicitly to normal mode Krzysztof Kozlowski
2014-10-27 19:51 ` Javier Martinez Canillas
2014-10-27 15:03 ` [PATCH 6/8] regulator: max77686: Add external GPIO control Krzysztof Kozlowski
2014-10-27 20:03 ` Javier Martinez Canillas
2014-10-28 8:52 ` Krzysztof Kozlowski
2014-10-28 12:11 ` Krzysztof Kozlowski
2014-10-29 10:42 ` Krzysztof Kozlowski
2014-10-29 10:49 ` Javier Martinez Canillas
2014-10-30 13:56 ` Alexandre Courbot
2014-10-30 15:03 ` Krzysztof Kozlowski
2014-10-31 3:31 ` Alexandre Courbot
2014-10-31 7:51 ` Krzysztof Kozlowski
2014-10-31 10:32 ` Mark Brown
2014-10-31 11:45 ` Krzysztof Kozlowski
2014-10-31 11:54 ` Mark Brown
2014-11-03 12:07 ` Krzysztof Kozlowski
2014-11-03 13:23 ` Mark Brown
2014-11-01 5:47 ` Alexandre Courbot [this message]
2014-10-27 15:03 ` [PATCH 7/8] mfd/regulator: dt-bindings: max77686: Document gpio property Krzysztof Kozlowski
2014-10-27 20:15 ` Javier Martinez Canillas
2014-10-28 8:53 ` Krzysztof Kozlowski
2014-10-27 15:03 ` [PATCH 8/8] ARM: dts: exynos4412-trats: Switch max77686 regulators to GPIO control Krzysztof Kozlowski
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='CAAVeFuL7XiP3e4+pQt_asL+0f-UpffTvj0Mt=D0TPevW4hT=zA@mail.gmail.com' \
--to=gnurou@gmail.com \
--cc=b.zolnierkie@samsung.com \
--cc=ben-linux@fluff.org \
--cc=broonie@kernel.org \
--cc=cw00.choi@samsung.com \
--cc=devicetree@vger.kernel.org \
--cc=javier.martinez@collabora.co.uk \
--cc=k.kozlowski@samsung.com \
--cc=kgene.kim@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=m.szyprowski@samsung.com \
--cc=sameo@linux.intel.com \
/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).