All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mehmet Fide <mehmet.fide@gmail.com>
To: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Peng Fan <peng.fan@nxp.com>, Vincent Jardin <vjardin@free.fr>,
	Ye Li <ye.li@nxp.com>, Michal Simek <michal.simek@amd.com>,
	Aristo Chen <aristo.chen@canonical.com>,
	u-boot@lists.u-boot-project.org,
	Mehmet Fide <mehmet.fide@screeningeagle.com>
Subject: [PATCH v2 0/4] dm: gpio: read GPIOs in of_to_plat(), request them in probe()
Date: Fri, 11 Sep 2026 00:08:14 +0200	[thread overview]
Message-ID: <20260910220818.3093364-1-mehmet.fide@gmail.com> (raw)

From: Mehmet Fide <mehmet.fide@screeningeagle.com>

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


             reply	other threads:[~2026-09-10 22:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 22:08 Mehmet Fide [this message]
2026-09-10 22:08 ` [PATCH v2 1/4] gpio: add a way to parse a GPIO now and request it later Mehmet Fide
2026-09-10 22:08 ` [PATCH v2 2/4] regulator: claim the enable GPIO at probe time, not in of_to_plat() Mehmet Fide
2026-09-10 22:08 ` [PATCH v2 3/4] doc: driver-model: state that of_to_plat() must not probe or claim Mehmet Fide
2026-09-10 22:08 ` [PATCH v2 4/4] test: dm: check the regulators claim their GPIOs at probe time Mehmet Fide

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=20260910220818.3093364-1-mehmet.fide@gmail.com \
    --to=mehmet.fide@gmail.com \
    --cc=aristo.chen@canonical.com \
    --cc=jh80.chung@samsung.com \
    --cc=mehmet.fide@screeningeagle.com \
    --cc=michal.simek@amd.com \
    --cc=peng.fan@nxp.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=vjardin@free.fr \
    --cc=ye.li@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.