blob: d253f654fadd16810b78503f23e913a4b1a9d019 [file] [log] [blame]
Patrick Delaunay6a0388c2020-01-13 11:35:10 +01001
2GPIO hog (CONFIG_GPIO_HOG)
3--------
4
Marek Vasut48b3ecb2022-09-22 17:53:26 +02005All the GPIO hog are initialized using DM_FLAG_PROBE_AFTER_BIND DM flag
6after bind().
Patrick Delaunay6a0388c2020-01-13 11:35:10 +01007
8Example, for the device tree:
9
10 tca6416@20 {
11 compatible = "ti,tca6416";
12 reg = <0x20>;
13 #gpio-cells = <2>;
14 gpio-controller;
15
16 env_reset {
17 gpio-hog;
18 input;
19 gpios = <6 GPIO_ACTIVE_LOW>;
20 };
21 boot_rescue {
22 gpio-hog;
23 input;
24 line-name = "foo-bar-gpio";
25 gpios = <7 GPIO_ACTIVE_LOW>;
26 };
27 };
28
29You can than access the gpio in your board code with:
30
31 struct gpio_desc *desc;
32 int ret;
33
34 ret = gpio_hog_lookup_name("boot_rescue", &desc);
35 if (ret)
36 return;
37 if (dm_gpio_get_value(desc) == 1)
38 printf("\nBooting into Rescue System\n");
39 else if (dm_gpio_get_value(desc) == 0)
40 printf("\nBoot normal\n");