Re: [PATCH] regulator: fixed: Default enable high on DT regulators

From: Leonard Crestez
Date: Tue Oct 02 2018 - 09:42:48 EST


On Mon, 2018-10-01 at 22:43 +0200, Linus Walleij wrote:
> commit efdfeb079cc3
> ("regulator: fixed: Convert to use GPIO descriptor only")
> switched to use gpiod_get() to look up the regulator from the
> gpiolib core whether that is device tree or boardfile.
>
> This meant that we activate the code in
> a603a2b8d86e ("gpio: of: Add special quirk to parse regulator flags")
> which means the descriptors coming from the device tree already
> have the right inversion and open drain semantics set up from
> the gpiolib core.
>
> As the fixed regulator was inspected again we got the
> inverted inversion and things broke.
>
> Fix it by ignoring the config in the device tree for now: the
> later patches in the series will push all inversion handling
> over to the gpiolib core and set it up properly in the
> boardfiles for legacy devices, but I did not finish that
> for this kernel cycle.
>
> Fixes: commit efdfeb079cc3 ("regulator: fixed: Convert to use GPIO descriptor only")
> Reported-by: Leonard Crestez <leonard.crestez@xxxxxxx>
> Reported-by: Fabio Estevam <festevam@xxxxxxxxx>
> Reported-by: John Stultz <john.stultz@xxxxxxxxxx>
> Reported-by: Anders Roxell <anders.roxell@xxxxxxxxxx>
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

This doesn't work for imx6sx-sdb but I suspect an imx issue. Log:

[ 0.150198] regulator-enet-3v3 GPIO handle specifies active low - ignored
[ 0.150258] gpio_value: 38 set 1
[ 0.150283] gpio_direction: 38 out (0)
...
[ 1.962493] regulator_enable: name=enet_3v3
[ 1.966709] gpio_value: 38 set 0
[ 1.970005] regulator_enable_delay: name=enet_3v3
[ 1.974730] regulator_enable_complete: name=enet_3v3
...
[ 4.097077] fec 2188000.ethernet eth0: Unable to connect to phy
[ 4.109219] IP-Config: Failed to open eth0
[ 4.115557] fec 21b4000.ethernet eth1: Unable to connect to phy
[ 4.123690] IP-Config: Failed to open eth1

This turns the phy off and on again instead of leaving it up from uboot
and it doesn't work for some reason. However looking at
reg_fixed_voltage_probe introducing an edge seems to be intentional for
regulators which are not marked with "enabled-at-boot". Right?

It's possible that you exposed an imx board-specific bug: maybe power
cycling the phy after uboot needs some missing fixup?

Apparently if I revert your patch the old behavior is to never touch
this GPIO. I spent a while debugging this and the cause seems to be
that this regulator has the "gpios" property instead of "gpio".

The "gpios" property is not actually handled by old regulator-fixed
of_get_named_gpio(np, "gpio", 0) call but only by the new path going
through of_find_gpio.

I can also break boot by fixing the gpios property on stable 4.18:

reg_enet_3v3: regulator-enet-3v3 {
compatible = "regulator-fixed";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet_3v3>;
regulator-name = "enet_3v3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
- gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
+ gpio = <&gpio2 6 GPIO_ACTIVE_LOW>;
};

Any suggestions? This turned out to be quite messy.

--
Regards,
Leonard