Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is Gpio hog in device tree?

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

like image 660
Daniel Avatar asked Aug 28 '17 04:08

Daniel


People also ask

How do I add GPIO to device tree?

In order to add a GPIO on the NXP device tree, the relative PAD should be added to the GPIO hog pin control in the iomux node.

What is Pinctrl in device tree?

The pinctrl subsystem is nothing but a way to gather pins (not only GPIO), and pass them to the driver. The pin controller driver is responsible for parsing pin descriptions in the DT and applying their configuration in the chip.

What is GPIO mapping?

A general-purpose input/output (GPIO) is an uncommitted digital signal pin on an integrated circuit or electronic circuit board which may be used as an input or output, or both, and is controllable by software. GPIOs have no predefined purpose and are unused by default.


2 Answers

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

like image 196
Prabhakar Lad Avatar answered Nov 14 '22 22:11

Prabhakar Lad


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
like image 22
zeekhuge Avatar answered Nov 14 '22 21:11

zeekhuge