what is Gpio hog in device tree?

Daniel picture Daniel · Aug 28, 2017 · Viewed 8.3k times · Source

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

Answer

Prabhakar Lad picture Prabhakar Lad · Sep 11, 2017

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