Is it possible to configure a GPIO for both input and output in the Device Tree Overlay

Hello all,
I was wondering if it’s possible to configure a GPIO pin on the Beaglebone black as a bidirectional GPIO via device tree overlays. Essentially allowing the developer to control the pins direction via the /sys/class/gpio/gpioxx/direction file in sysfs.

A close look at the pinmux table/registers in the TRM reveals that setting bit 5 enables the receiver (input) and clearing bit 5 disables the receiver (input). If I enable the receiver can I use the GPIO pin as both input and output or would it have to be input only ?

And if that isn’t possible is there any other way to use the GPIO pins bidirectionally without having to dynamically load device tree overlays every time we need to change the direction of a GPIO ?


Bit 5 in the control module register controls whether the pin can be used as a input as well as an output.
Its the GPIO_OE register that controls whether it is configured as an input or an output.

thanks for the reply briselec! so setting bit 5 enables the pin to be both an output pin and an input pin. The pins themselves could obviously only be either an input or output pin at any one time depending on the value in the GPIO_OE reg.

And the sysfs interface likely sets/clears the GPIO_OE register depending on what value (“out” or “in”) is written in the GPIO’s ‘direction’ file.

Does this sound about right ?

For generic GPIO, does that mean that writing a value of 0x2F in the GPIO’s control module register via device tree overlays will enable the GPIO as a bidirectional pin? Are there any recommendations for the pull-up/down settings for bi-directional I/Os? I know that they come in handy for inputs configurations, not sure about the bidirectional/output configurations though.

0x2F => 0010 1111

bits 0-2 (111) Mode 7

bit 3 (1) Pull up/down Disabled

bit 4 (x) Pull up/down type (bit 3 is disabled hence this doesn’t matter)

bit 5 (1) Receiver enabled

bit 6 (0) Fast slew rate