regulator: fix: Move code to enable gpio regulator to pre_probe from ofdata_to_platdata
authorLukasz Majewski <lukma@denx.de>
Sat, 25 Jan 2020 08:00:58 +0000 (09:00 +0100)
committerTom Rini <trini@konsulko.com>
Mon, 10 Feb 2020 23:00:38 +0000 (18:00 -0500)
commitb7adcdd073c055b0e87a66b6a95fa42079fad7f7
treee41a6d20589f8fd079abcc1c5471995c6d1fedd1
parent4e5c4683b7a54090323043ab9a67772baeecb1b1
regulator: fix: Move code to enable gpio regulator to pre_probe from ofdata_to_platdata

The commit e8e9715df2d4 ("regulator: fixed: Modify enable-active-high behavior")
fixed the regulator driver behavior when 'enable-active-high' is defined.
Unfortunately, this patch used dm_regulator_platdata()'s "boot_on" member
to set GPIOD_IS_OUT_ACTIVE flag and enable the regulator.

The issue here is that regulator_common_ofdata_to_platdata() is called
_before_ regulator_pre_probe() function in which the 'regulator-boot-on'
property is asserted.

As a result the GPIOD_IS_OUT_ACTIVE flag is not set and gpio_request_by_name()
called in the former function is not enabling the regulator.
This is problematic for e.g. i.MX ethernet driver, which then tries to
perform initialization without power (and fails).

The solution here is to explicitly enable regulator in regulator_pre_probe()
callback only when 'regulator-boot-on' property is present in device tree.
The GPIOD_IS_OUT_ACTIVE flag is not set at all, but relevant gpio is
requested.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Tested-by: Patrice Chotard <patrice.chotard@st.com>
drivers/power/regulator/regulator-uclass.c
drivers/power/regulator/regulator_common.c