summaryrefslogtreecommitdiff
path: root/doc/README.gpio
blob: 548ff37b8cc719211b6a8e4732c22bff3b2fdbdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

GPIO hog (CONFIG_GPIO_HOG)
--------

All the GPIO hog are initialized in gpio_hog_probe_all() function called in
board_r.c just before board_late_init() but you can also acces directly to
the gpio with gpio_hog_lookup_name().


Example, for the device tree:

        tca6416@20 {
                compatible = "ti,tca6416";
                reg = <0x20>;
                #gpio-cells = <2>;
                gpio-controller;

                env_reset {
                        gpio-hog;
                        input;
                        gpios = <6 GPIO_ACTIVE_LOW>;
                };
                boot_rescue {
                        gpio-hog;
                        input;
                        line-name = "foo-bar-gpio";
                        gpios = <7 GPIO_ACTIVE_LOW>;
                };
        };

You can than access the gpio in your board code with:

	struct gpio_desc *desc;
	int ret;

	ret = gpio_hog_lookup_name("boot_rescue", &desc);
	if (ret)
		return;
	if (dm_gpio_get_value(desc) == 1)
		printf("\nBooting into Rescue System\n");
	else if (dm_gpio_get_value(desc) == 0)
		printf("\nBoot normal\n");