From: Mehmet Fide <[email protected]> A driver's of_to_plat() method must only read the devicetree, but the only way to pick a GPIO out of it, gpio_request_by_name(), also probes the controller and claims the pin. Several drivers therefore claim GPIOs while their platform data is being read, before their own pinctrl state is applied. On SoCs where the direction lives in the pad register the pinctrl then undoes the direction the early claim set; on Vybrid this leaves a fixed regulator configured as always-on powering nothing, which is where this started (the ehci-vf VBUS supply).
Patch 1 splits gpio_request_by_name() in two: gpio_parse_by_name() reads the phandle into a struct gpio_dt_spec that can live in the platform data, gpio_request_parsed() claims it later from probe(). Patch 2 converts the fixed and gpio regulators, the two drivers that share regulator_common, patch 3 writes the rule into the driver model design document, and patch 4 checks the two phases in sandbox for both regulators. The remaining drivers that claim GPIOs from of_to_plat() (about fifty, mostly panels and backlights) are left for their owners once the shape is settled; I will convert fec_mxc and fsl_esdhc_imx, which I can test on a Colibri VF50, in a follow-up. Tested with 'ut dm' on sandbox against the same tree without the series (the three new tests pass, the pre-existing failures are unchanged), built for colibri_vf, evb-rk3399 and the sandbox variants, and booted on a Colibri VF61 from NAND. There the VBUS regulator's pad register (0x4004814c) reads 0x60 until the regulator probes and 0x22ef after, the pin shows up as 'regulator-usbh-vbus.gpio' in 'gpio status', and Linux boots from the same U-Boot. Changes in v2: - keep the list index in the spec so the request label matches gpio_request_by_name(); rename gpio_dt_desc to gpio_dt_spec; document the list_name lifetime and the -ENOENT contract, and use it instead of present-flag guards in the regulators (Simon Glass) - drop the GPIO request from the fixed-clock regulator (Simon Glass) - doc: reword the helper sentence and remove the paragraph that allowed probing providers from of_to_plat() (Simon Glass) - test: move to the pinmux-gpios bank (a10 is a hog pin), name the node fixed-gpio-reg, add a gpio regulator test, check the simulated pad direction as well as the name table (Simon Glass) Mehmet Fide (4): gpio: add a way to parse a GPIO now and request it later regulator: claim the enable GPIO at probe time, not in of_to_plat() doc: driver-model: state that of_to_plat() must not probe or claim test: dm: check the regulators claim their GPIOs at probe time arch/sandbox/dts/test.dts | 18 +++++++ configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + configs/sandbox_noinst_defconfig | 1 + configs/sandbox_spl_defconfig | 1 + configs/sandbox_vpl_defconfig | 1 + doc/develop/driver-model/design.rst | 16 ++++-- drivers/gpio/gpio-uclass.c | 34 ++++++++++++ drivers/power/regulator/fixed.c | 6 +++ drivers/power/regulator/gpio-regulator.c | 21 ++++++-- drivers/power/regulator/regulator_common.c | 26 ++++++++-- drivers/power/regulator/regulator_common.h | 3 ++ include/asm-generic/gpio.h | 60 ++++++++++++++++++++++ test/dm/gpio.c | 39 ++++++++++++++ test/dm/regulator.c | 58 +++++++++++++++++++++ 16 files changed, 274 insertions(+), 13 deletions(-) base-commit: d4152edb50356338af994d1c0483f65b717b4c15 -- 2.55.0
