uboot/doc/README.gpio
<<
>>
Prefs
   1
   2GPIO hog (CONFIG_GPIO_HOG)
   3--------
   4
   5All the GPIO hog are initialized in gpio_hog_probe_all() function called in
   6board_r.c just before board_late_init() but you can also acces directly to
   7the gpio with gpio_hog_lookup_name().
   8
   9
  10Example, for the device tree:
  11
  12        tca6416@20 {
  13                compatible = "ti,tca6416";
  14                reg = <0x20>;
  15                #gpio-cells = <2>;
  16                gpio-controller;
  17
  18                env_reset {
  19                        gpio-hog;
  20                        input;
  21                        gpios = <6 GPIO_ACTIVE_LOW>;
  22                };
  23                boot_rescue {
  24                        gpio-hog;
  25                        input;
  26                        line-name = "foo-bar-gpio";
  27                        gpios = <7 GPIO_ACTIVE_LOW>;
  28                };
  29        };
  30
  31You can than access the gpio in your board code with:
  32
  33        struct gpio_desc *desc;
  34        int ret;
  35
  36        ret = gpio_hog_lookup_name("boot_rescue", &desc);
  37        if (ret)
  38                return;
  39        if (dm_gpio_get_value(desc) == 1)
  40                printf("\nBooting into Rescue System\n");
  41        else if (dm_gpio_get_value(desc) == 0)
  42                printf("\nBoot normal\n");
  43