8

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

Claudio
  • 10,614
  • 4
  • 31
  • 71
Daniel
  • 121
  • 1
  • 1
  • 7
  • What is the kernel-image version ? – zeekhuge Aug 30 '17 at 12:04
  • 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? – Daniel Sep 01 '17 at 05:01

2 Answers2

12

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

Prabhakar Lad
  • 1,248
  • 1
  • 8
  • 12
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
zeekhuge
  • 1,594
  • 1
  • 13
  • 23