Set default GPIO pin state while in sleep mode

Hi,

Is there a way to set the GPIO pins into a specific state before entering sleep mode on the BBB? I know you can set their configuration in the device tree e.g.:

wlan_pins_sleep: pinmux_wlan_pins_sleep {
pinctrl-single,pins = <
0x28 (PIN_OUTPUT_PULLUP | MUX_MODE7) /* gpmc_ad10.gpio0_26 WL_EN*/
0x2C (PIN_INPUT_PULLUP | MUX_MODE7) /* gpmc_ad11.gpio0_27 WL_IRQ*/
0x7C (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* gpmc_csn0.gpio1_29 BF_EN*/

;
};

But is there a way to set a default output state for certain pins upon entering sleep mode without involving the PRU?

Thank you,

-Eric

Yes. You can initially use universal IO to configure the pin(s), and then when it is time to sleep, use config-pin to change the pins direction, and / of value. There is also the /sys/class/gpio/* sysfs set of sub directories, but I’m unsure how one would use /sys/class/gpio/export, etc if the pin it already configured via a deice tree file. Perhaps the device tree file could take care of the mux mode only, and the sysfs gpio sub system could configure the rest ?

Thank you for the reply! The problem is that when I set the pin value/direction before entering sleep mode (using /sys/class/gpio…), it immediately returns to its initial state upon entering sleep mode. When I wake the BBB up it will return to the value I configured, however.

Where would I set the default sleep mode config for a pin in the device tree? Is there a spot in am335x-bone-common-pinmux.dtsi?

Thank you for the reply! The problem is that when I set the pin value/direction before entering sleep mode (using /sys/class/gpio…), it immediately returns to its initial state upon entering sleep mode. When I wake the BBB up it will return to the value I configured, however.

Where would I set the default sleep mode config for a pin in the device tree? Is there a spot in am335x-bone-common-pinmux.dtsi?

So I do not know exactly what happens when you put the board to “sleep”, but my guess would be that the processor is either completely shutting down. Or it is being put in a low enough power state that for all intents and purposes it may as well be shutting down.

So once we consider that. Each GPIO pin, has a default state that it comes up as when first powered on. You can not change this. You can only hope you can pick a pin, or set of pins that come up in the state that you need them to.