what is Gpio hog in device tree?
Asked Answered
W

2

9

I am trying to set a pin mode in device tree for am335. I change the pinmux node in device tree as below.

pinctrl_test: pinctrl_test_pins {
    pinctrl-single,pins = <
        0x078 0x07 /* P9_12 OUTPUT | MODE7 | PULLDOWN */
        0x048 0x07 /* P9_14 OUTPUT | MODE7 | PULLDOWN */
    >;
}

but I didn't see any changes in /sys/kernel/debug/pinctrl/44e10800.pinmux/pins .

I found some information about GPIO -HOG , but could not find good documentation.

The Kernel version I am using is 4.8.13

Withhold answered 28/8, 2017 at 4:57 Comment(2)
What is the kernel-image version ?Latterday
I am using 4.8.13 kernel version. I add above-mentioned code in device tree but the mode of GPIO doesn't seem to be changed. Is it necessary to define compatible filed for the node?Withhold
D
13

After configuring the pinmux to below:

pinctrl_test: pinctrl_test_pins {
    pinctrl-single,pins = <
        0x078 0x07 /* P9_12 OUTPUT | MODE7 | PULLDOWN */
        0x048 0x07 /* P9_14 OUTPUT | MODE7 | PULLDOWN */
    >;
}
  1. Did you recompile to dtb ?
  2. What is the value of 0x44E10848 and 0x44E10878 in this file /sys/kernel/debug/pinctrl/44e10800.pinmux/pins (should be 00000007 pinctrl-single)

gpio-hog is a gpio node property, which tell the gpio controller to either set the pin to high/low during boot up.

Example to hog a pin high:

    gpio@4805b000 {
        compatible = "ti,omap4-gpio";
        reg = <0x4805b000 0x200>;
        interrupts = <0x0 0x1c 0x4>;
        ti,hwmods = "gpio5";
        gpio-controller;
        #gpio-cells = <0x2>;
        interrupt-controller;
        #interrupt-cells = <0x2>;
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <0xaf>;

        p12 {
            gpio-hog;
            gpios = <0xc 0x0>;
            output-high;
            line-name = "vb4-gpio5-12-gpio";
        };
    };

Example to hog a pin low:

    gpio@48053000 {
        compatible = "ti,omap4-gpio";
        reg = <0x48053000 0x200>;
        interrupts = <0x0 0x74 0x4>;
        ti,hwmods = "gpio8";
        gpio-controller;
        #gpio-cells = <0x2>;
        interrupt-controller;
        #interrupt-cells = <0x2>;
        status = "okay";

        p0 {
            gpio-hog;
            gpios = <0x0 0x0>;
            output-low;
            line-name = "vb4-gpio8-0-gpio";
        };

    };

You can refer more about gpio-hog at [1].

[1] https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt

Devan answered 11/9, 2017 at 11:31 Comment(2)
Big ups! Been searching for this bit of info for quite a bit and you have put it quite elegantly here.Leptosome
Can this pin later be used by a mux? How to pass it to the "mux-gpios"?Tosha
L
1

Kernel version 4.8.13 is among the later ones where you dont need device-tree-overlays to change the configuration of a GPIO. You can simply use congif-pin utility.

Quoting from here :

Config-pin utility - To change the pinmux settings for a pin does not need device tree overlays now (4.4+ kernel), you can simply use ‘config-pin’ utility. To configure the pin you just need to know its position on the board, so to change mux settings of pin at , for example , P8_46

$ config-pin -l P8_46

The output shows space separated list of available pin-modes and will look like :

$ default gpio gpio_pu gpio_pd pruout pruin pwm

Now to change pinmode, to, for example, pruout

$ config-pin P8_46 pruout

This will configure pin at P8_46 to pru_output mode. Further status of the pin can be known using ‘config-pin -i’, which will give detailed output.

$ config-pin -i P8_46
Pin name: P8_46
Function if no cape loaded: hdmi
Function if cape loaded: default gpio gpio_pu gpio_pd pruout pruin pwm
Function information: lcd_data1 default gpio2_7 gpio2_7 gpio2_7 pr1_pru1_pru_r30_1 pr1_pru1_pru_r31_1 ehrpwm2B
Cape: cape-universala cape-univ-hdmi
Kernel GPIO id: 71
PRU GPIO id: 103
Latterday answered 1/9, 2017 at 9:25 Comment(2)
I want to configure pins during boot.Withhold
This is relevant only on beaglebone, this is not a standard ABI that the kernel provides to user-space.Cherish

© 2022 - 2024 — McMap. All rights reserved.