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

1,380 views
Skip to first unread message

smith.wi...@gmail.com

unread,
Oct 10, 2013, 2:55:02 PM10/10/13
to beagl...@googlegroups.com

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

Nicolas V

unread,
Nov 13, 2013, 12:32:11 PM11/13/13
to beagl...@googlegroups.com
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.

2p.pl...@gmail.com

unread,
Apr 10, 2014, 4:50:04 PM4/10/14
to beagl...@googlegroups.com
I can see gpio-name in /sys/devices/ocp.3/*/status file. init-high hopefully works in 3.8.13-bone45 kernel.

- Tomas

Nicolas Vansnick

unread,
Apr 11, 2014, 10:49:36 AM4/11/14
to beagl...@googlegroups.com
Thx for the update. I will try updating the kernel


On Thu, Apr 10, 2014 at 4:50 PM, <2p.pl...@gmail.com> wrote:
I can see gpio-name in /sys/devices/ocp.3/*/status file. init-high hopefully works in 3.8.13-bone45 kernel.

- Tomas

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Pc51tQSw8Jo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages