
I'm building u-boot for a mt7981a board, very similar to the in-tree mt7981-emmc-rfb. For reference, my device tree and output of make savedefconfig are here:
https://gist.github.com/arachsys/98048980728c652bea641b42cfd41a40
Everything boots fine, but I have a handful of gpios which need to be set to fixed values before booting the kernel to enable a 5g modem. I can do this with
gpio clear 10; gpio set 5; gpio set 9; gpio 11
which works fine, but I think the 'official' solution for this might be using u-boot's gpio-hog support?
With that in mind, I added
&gpio { hub_power { gpio-hog; gpios = <5 GPIO_ACTIVE_HIGH>; output-high; };
modem_control { gpio-hog; gpios = <9 GPIO_ACTIVE_HIGH>; output-high; };
modem_reset { gpio-hog; gpios = <10 GPIO_ACTIVE_HIGH>; output-low; };
modem_power { gpio-hog; gpios = <11 GPIO_ACTIVE_HIGH>; output-high; }; };
with CONFIG_GPIO_HOG=y, but this doesn't seem to work on either u-boot.git HEAD or 2024.07-rc.
To try to see what was going on better, I added some debug printfs:
--- a/u-boot/drivers/gpio/gpio-uclass.c +++ b/u-boot/drivers/gpio/gpio-uclass.c @@ -328,6 +330,8 @@ static int gpio_hog_of_to_plat(struct udevice *dev)
static int gpio_hog_probe(struct udevice *dev) { + printf("gpio_hog_probe called\n"); + struct gpio_hog_data *plat = dev_get_plat(dev); struct gpio_hog_priv *priv = dev_get_priv(dev); int ret; @@ -1518,6 +1523,8 @@ void devm_gpiod_put(struct udevice *dev, struct gpio_desc *desc)
static int gpio_post_bind(struct udevice *dev) { + printf("gpio_post_bind called\n"); + if (CONFIG_IS_ENABLED(GPIO_HOG) && dev_has_ofnode(dev)) { struct udevice *child; ofnode node; @@ -1539,6 +1546,7 @@ static int gpio_post_bind(struct udevice *dev) * since hogs can be essential to the hardware * system. */ + printf("found a gpio-hog\n"); dev_or_flags(child, DM_FLAG_PROBE_AFTER_BIND); } }
This shows gpio_post_bind being called, then the four gpio-hogs found and set to probe after bind, but the gpio_hog_probe function is never actually called. Presumably this is the problem - if they're not probed then they'll never take effect?
I enabled CONFIG_DM_WARN and CONFIG_DM_DEBUG, which confirm that nothing ever seems to be probing the gpio-hog children, but there aren't obviously any errors or warnings related to them either. Nothing relevant happens after gpio_post_bind is called.
Is this a bug or is there some basic config/dts mistake on my part here? Is there some other debug info I can get that might shed light on what's going on, or some config prerequisite for DM_FLAG_PROBE_AFTER_BIND to work that I'm likely to be missing?
Best wishes,
Chris.