DT overlay for GPIO output pin -- default state="on" / init-high

I have created a device tree (DT) overlay file based on the examples in /lib/firmware for a GPIO pin to be used to control a relay that powers a peripheral. As long as the GPIO is output/high the relay is closed and the peripheral has power, So consequentially, I need the GPIO pin to have a default state of “high” as soon as possible after BBB is powered up.

Everything seems to work (after disabling HDMI!), but I don’t seem to be able to get it to set the pin state to high by default. I’m loading the DT overlay via the uEnv command line, but it seems that until I manually go and export the GPIO pin and set the direction to “high” in /sys/class/gpio, the initial state of the pin stays low until explicitly set high.

I handle the pinmux as follows:

fragment@0 {
target = <&am33xx_pinmux>;
overlay {

my_gpio_pins: pinmux_my_gpio_pins {
pinctrl-single,pins = <
/* the gpio pin(s) /
0x0B4 0x0F /
P8 42 GPIO2_11: lcd_data5.gpio2_11 | MODE7 | OUTPUT */

;
};

};
};

And add it as an OCP as follows:

fragment@2 {
target = <&ocp>;
overlay {

my_gpio {
compatible = “gpio-of-helper”;
status = “okay”;
pinctrl-names = “default”;
pinctrl-0 = <&my_gpio_pins>;

/* declare your gpios /
my_relay {
gpio-name = “my_relay”;
gpio = <&gpio3 11 0x00>; /
gpio3 is gpio2 */
output;
init-high;
};
};
};
};

Shouldn’t the “init-high” cause the pin to go high as soon as the DT overlay is loaded? If not, how do I accomplish this? I realize I can write an rc script to export the gpio and set direction=high, but we’re probably talking 10 seconds after power up before that happens.

I have also tried using default-state=“on” in the my_relay{} section which doesn’t do anything either.

Finally, a question – the gpio-name of “my_relay”, what is this for? I kind of assumed it would be an alias in the /sys/class/gpio tree to gpio75, but I don’t find any references to “my_relay” anywhere in the /sys/class tree (or even in dmesg output for that matter).

Thanks!

-W

I am also having problems setting an outpit pin HIGH, even though everything else is working.

Here is an extract of my DT overlay:

fragment@1{
target = <&pruss>;
overlay{
status = “okay”;
pinctrl-names = “default”;
pinctrl-0 = <&pruicss_pins>;

pins_1{
pin-names = “PRU:pin_11”, “PRU:pin_12”, “PRU:pin_13”;
gpios = <&gpio2 13 0
&gpio1 23 0
&gpio3 4 0>;
};

You will notice I have pin-names instead of gpio-name. It all appear correctly when I am printing the /sys/class/gpio. However, nothing changes when I try adding init-high;

Please let me know if you have found a solution.

I can see gpio-name in /sys/devices/ocp.3/*/status file. init-high hopefully works in 3.8.13-bone45 kernel.

  • Tomas

Thx for the update. I will try updating the kernel