Re: Question: what is the best way to use gpio-syscon driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 12, 2018 at 11:59 AM, Levin Du <zslevin@xxxxxxxxx> wrote:

> Hi all,
>
>    I'd like to use a special pin to control the voltage io of the SD card.
> This pin is set by bit 1 of GRF_SOC_CON10 register in Rockchip RK3328),
> which is not a simple gpio.
>
> I have found out the gpio-syscon, which should fit my need. But after reading
> the source code, it seems that I have to add a ton of stuff to control
> this little bit.
>
> This is my regulator:
>
> vcc_sdio: sdmmcio-regulator {
>   compatible = "regulator-gpio";
>   gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
>   states = <1800000 0x1
>                  3300000 0x0>;
>   regulator-name = "vcc_sdio";
>   regulator-type = "voltage";
>   regulator-min-microvolt = <1800000>;
>   regulator-max-microvolt = <3300000>;
> };
>
> <&gpio0 25> is a special gpio which will not be accessed by the pinctrl.
>
> I need to relace it with:
>
>   gpios = <&special_gpio 0 GPIO_ACTIVE_HIGH>;
>
> and defines it as:
>   special_gpio: special-gpio {
>       compatible = "gpio-syscon";
>       gpio-controller;
>       #gpio-cells = <2>;
>   }
>
> The question is, there's no "gpio-syscon" driver id in gpio-syscon.
> I'll have to modify that driver to add another "rockchip,rk3328-special-gpio"
> and related configuration.
>
> Is there any common solution to this practice? Please shed some light on this.
> Thanks in advance.

Yeah it is a bit complex for a simple thing isn't it?

Notice that for LEDs we have:

drivers/leds/leds-gpio.c
drivers/leds/leds-syscon.c

Corresponding bindings:
Documentation/devicetree/bindings/leds/leds-gpio.txt
Documentation/devicetree/bindings/leds/register-bit-led.txt

What people were doing in the past was to create a syscon GPIO and
put the GPIO leds driver on top.

That made me crazy, so by defining a syscon LED they can skip
one layer of pointless indirection and get to the LED business
directly on syscon.

If Mark doesn't say otherwise I think it would be wise to also skip
the indirection for random syscon regulators, and go for a
drivers/regulators/syscon-regulator.c
based on the LEDs approach.

At least it shaves off a layer of indirection and gets down
to business.

Just using the LED examples for inspiration should work.

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



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux