LEDS¶
Objective¶
The SOM has 2 green LEDS installed.- D1 is a debug LED connected to the GPIO pin on the PMIC. D1 is exposed in the device tree as
/sys/class/leds/som-d1
. - D2 is the "power good" led driven by the PMIC via the LED_RTN pin on the edge connector (pin 2). This pin is normally connected to ground, but if you are using the SoM in a light or power sensitive application, leave this pin disconnected and LED D2 will stay OFF.
Additionally, the Development Kit has an LED (D1) attached directly to a GPIO (GPIO1_49 - pin 194 on the SoM)
Controlling the SoM Debug LED (D1)¶
The SoM debug led is accessible via the sysfs interface. As this LED is controlled via I2C commands to the PMIC and not directly from a GPIO on the CPU, there is more overhead required to control it. For this reason, it its not recommended to use this LED in a means that requires constant/frequent updates.
The LED intensity is controlled via the brightness
file. As this is strictly an ON/OFF LED, the LED will be OFF when brightness is 0 and on if brightness > 0; The /sys/class/leds/som-d1/max_brightness
value is effectively ignored.
- Turn LED ON
root@mitysom-am62x:~# echo 1 > /sys/class/leds/som-d1/brightness
- Turn LED OFF
root@mitysom-am62x:~# echo 0 > /sys/class/leds/som-d1/brightness
Device tree entry (in arch/arm64/boot/dts/ti/k3-am62x-mitysom-som.dtsi)¶
som_led { compatible = "gpio-leds"; led-0 { label = "som-d1"; function = LED_FUNCTION_DEBUG; color = <LED_COLOR_ID_GREEN>; gpios = <&tps65219 2 GPIO_ACTIVE_LOW>; linux,default-trigger = "none"; default-state = "off"; }; };
Controlling the Devkit Debug LED (D1)¶
The devkit debug led is accessible via the sysfs interface under /sys/class/leds/devkit-d1
. This LED is connected directly to a GPIO on the CPU, and can be PWM controlled using the TI supplied pwm driver.
The LED intensity is controlled via the brightness
file. The range is from 0 (off) to 255 ( max_brighness
). As this is a PWM controllable LED it can be connected via the led subsystem in the kernel to provide user feedback of system events. The system configuration provided by Critical Link has this LED set to the "heatbeat" mode, which blinks twice periodically in relation to the system load.
- Show trigger
root@mitysom-am62x:~# cat /sys/class/leds/devkit-d1/trigger
none kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock timer disk-activity disk-read disk-write ide-disk [heartbeat] cpu cpu0 cpu1 cpu2 cpu3 default-on panic mmc0 mmc2 mmc1 usb-charger-online
- Disable trigger
root@mitysom-am62x:~# echo none > /sys/class/leds/devkit-d1/trigger
- Turn LED ON dim
root@mitysom-am62x:~# echo 30 > /sys/class/leds/devkit-d1/brightness
- Turn LED ON full
root@mitysom-am62x:~# echo 255 > /sys/class/leds/devkit-d1/brightness
- Turn LED OFF
root@mitysom-am62x:~# echo 0 > /sys/class/leds/devkit-d1/brightness
- Set heartbeat trigger
root@mitysom-am62x:~# echo heartbeat > /sys/class/leds/devkit-d1/trigger
Device tree entry (in arch/arm64/boot/dts/ti/k3-am62x-mitysom-devkit.dts)¶
leds { compatible = "pwm-leds"; led-0 { label = "devkit-d1"; pwms = <&main_pwm7 0 7812500 0>; max-brightness = <255>; color = <LED_COLOR_ID_GREEN>; linux,default-trigger = "heartbeat"; function = LED_FUNCTION_HEARTBEAT; default-state = "off"; active-low; }; };
Conclusion¶
There are a variety of ways to use the LED on the AM62X platform and you can extend any of the GPIOs available to do so. See https://docs.kernel.org/leds/leds-class.html for the official documentation regarding the linux LED subsystem
Go to top