GPIO
General-Purpose Input/Output (GPIO) pins can be configured as either inputs or outputs. Many signals on the phyCORE-Connector can be used as GPIOs through multiplexing. The AM62x processor features five independent GPIO modules. For detailed information about the phyCORE-AM62x GPIO interface, please refer to the GPIO section in the Hardware Manual
GPIO Signal Names and Chip Mapping
GPIOn_x is generic name used to describe a GPIO signal, where n represents the specific GPIO module and x represents one of the input/output signals associated with the module. Usually you find this names in the schematics and in comments in our device trees in the muxing section.
The AM62x provides three GPIO modules:
GPIO0
GPIO1
MCU_GPIO0
Linux represents these modules as gpiochips. You can list them using the gpiodetect command:
phyboard-lyra-am62xx-3:~# gpiodetect
gpiochip0 [tps65219-gpio] (3 lines)
gpiochip1 [4201000.gpio] (24 lines) # MCU_GPIO0
gpiochip2 [600000.gpio] (92 lines) # GPIO0
gpiochip3 [601000.gpio] (52 lines) # GPIO1
gpiochip4 [pcf8574] (8 lines)
The second column shows the hardware address of each GPIO module. In the device tree, these GPIOs are accessed using node labels:
main_gpio0 (gpio@600000)
main_gpio1 (gpio@601000)
mcu_gpio0 (gpio@4201000)
gpio_exp
Note
GPIO chip numbers may change between system boots. For consistent numbering, configure udev rules.
Active GPIO Signals
The following command shows GPIO signals that are currently allocated by kernel drivers. These GPIOs are already in use and attempting to access them with gpioget or gpioset will result in a “Device or resource busy” error.
See the allocated GPIO signals by running:
phyboard-lyra-am62xx-3:~# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 512-514, parent: i2c/0-0030, tps65219-gpio, can sleep:
gpiochip1: GPIOs 515-538, parent: platform/4201000.gpio, 4201000.gpio:
gpiochip2: GPIOs 539-630, parent: platform/600000.gpio, 600000.gpio:
gpio-552 ( |green:heartbeat ) out lo
gpio-571 ( |led-1 ) out lo
gpiochip3: GPIOs 631-682, parent: platform/601000.gpio, 601000.gpio:
gpio-654 ( |home ) in lo
gpiochip4: GPIOs 683-690, parent: i2c/1-0021, pcf8574, can sleep:
gpio-684 (GPIO1_CAN0_nEN |standby ) out lo
gpio-685 (GPIO2_LED2 |led-2 ) out lo
gpio-686 (GPIO3_LVDS_GPIO )
gpio-687 (GPIO4_BUT2 |menu ) in lo IRQ
gpio-688 (GPIO5_LVDS_BKLT_EN )
gpio-689 (GPIO6_ETH1_USER_RESE)
gpio-690 (GPIO7_AUDIO_USER_RES)
Using GPIOs
To access GPIOs from userspace applications, use the libgpiod library. This library provides tools for interacting with Linux GPIO devices. Here are some common usage examples:
List all available GPIO chips:
phyboard-lyra-am62xx-3:~# gpiodetect
gpiochip0 [tps65219-gpio] (3 lines)
gpiochip1 [4201000.gpio] (24 lines) # MCU_GPIO0
gpiochip2 [600000.gpio] (92 lines) # GPIO0
gpiochip3 [601000.gpio] (52 lines) # GPIO1
gpiochip4 [pcf8574] (8 lines)
Display detailed GPIO chip information (names, consumers, direction, active state, and flags):
phyboard-lyra-am62xx-3:~# gpioinfo -c gpiochip2
Read the value of a GPIO (e.g GPIO 36 from chip2):
phyboard-lyra-am62xx-3:~# gpioget -c gpiochip2 36
Set the value of GPIO 36 on chip2 to 0 and exit tool:
phyboard-lyra-am62xx-3:~# gpioset -z -c gpiochip2 36=0
Note
Interacting with a Signal as GPIO requires a proper muxing. The signal needs to be muxed in mux mode 7 (GPIO).
GPIOs via sysfs
Warning
Accessing GPIOs via sysfs is deprecated. We strongly encourage using libgpiod instead.
Sysfs GPIO access is no longer enabled by default. To enable it, enable CONFIG_EXPERT & CONFIG_GPIO_SYSFS in the kernel configuration.
Using LEDs
The phyBOARD-Lyra AM62x features several user-controllable LEDs that are connected to GPIO pins. While these LEDs can be controlled through the standard GPIO interface, Linux provides a dedicated LED subsystem that offers a more convenient way to manage them.
![phyCORE-AM62x UI](../_images/pb-07124_gpio.webp)
LED Control Interface
The LED subsystem is accessible through the sysfs interface at /sys/class/leds/. Each LED has its own directory containing control files:
brightness
: Write values to control the LED state0
turns the LED offAny non-zero value turns the LED on
max_brightness
: Read-only file showing the maximum brightness valuetrigger
: Allows setting automatic triggers (e.g., heartbeat, disk activity)
Note
While the interface supports brightness levels, most onboard LEDs are simple on/off LEDs without hardware brightness control. Any non-zero brightness value will simply turn them on.
Available LEDs
To list all available LEDs on your system:
phyboard-lyra-am62xx-3:~# ls /sys/class/leds/
green:heartbeat@ led-1@ led-2@ mmc0::@ mmc1::@
Controlling LEDs
You can control LEDs using simple shell commands:
To toggle the LEDs ON:
phyboard-lyra-am62xx-3:~# echo 255 > /sys/class/leds/led-1/brightness
To toggle the LEDs OFF:
phyboard-lyra-am62xx-3:~# echo 0 > /sys/class/leds/led-1/brightness
Advanced Usage
For more details about LED configuration, refer to the Linux kernel documentation at https://www.kernel.org/doc/Documentation/leds/leds-class.txt
Set LED triggers (e.g., for heartbeat effect):
phyboard-lyra-am62xx-3:~# echo heartbeat > /sys/class/leds/green\:heartbeat/trigger
Disable LED trigger:
phyboard-lyra-am62xx-3:~# echo none > /sys/class/leds/green\:heartbeat/trigger