The MCA LED controller implements a 9-channel LED driver with independent brightness and blink control. Each channel includes:
-
Brightness control (20 levels).
-
Blink control (configurable on/off periods).
-
Low-power operation with control of the LED state (on/off/blink).
The MCA LED controller is implemented on standard MCA IOs that can only drive up to 25 mA. For LEDs that require higher current, connect an external transistor driver. |
Kernel configuration
You can manage the MCA LED driver support through the following kernel configuration option:
-
MCA LED controller support (
CONFIG_LEDS_MCA
)
This option is enabled as built-in on the default ConnectCore 8M Mini kernel configuration file.
Kernel driver
File | Description |
---|---|
MCA LED controller driver |
Device tree bindings and customization
The MCA LED controller device tree binding is documented at Documentation/devicetree/bindings/leds/leds-mca.txt
.
LED controller inside the MCA
mca_cc8m: mca@63 {
...
mca_led: led {
compatible = "digi,mca-led";
status = "disabled";
};
};
Since the ConnectCore 8M Mini SOM does not contain an LED, the MCA LED controller is disabled by default in the device tree.
LEDs on the ConnectCore 8M Mini Development Kit
Power LED
/* Power LED on MCA_IO13 */
&mca_led {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
led@0 {
reg = <0>;
label = "power:green";
io = <13>;
linux,default-trigger = "default-on";
retain-state-suspended;
};
};
The ConnectCore 8M Mini Development Kit device tree assigns LED controller channel (0) to the power LED on the carrier board.
The initial configuration for the power LED is "default-on", which turns it solid-on while the device is in run mode.
When the system enters suspend state, the power LED is reconfigured to blink with a pattern.
When the system resumes operation, the power LED is configured back to its default-on state.
This is managed by the following entries on /lib/systemd/system-sleep/standby-actions
.
if [ "${1}" == "pre" ]; then
...
# Configure power LED for blinking in standby
if [ -d "/sys/class/leds/power:green" ]; then
# Configure LED for blinking
echo timer > /sys/class/leds/power\:green/trigger
# Turn LED on at max brightness
echo 19 > /sys/class/leds/power\:green/brightness
# Configure blink timing
echo 100 > /sys/class/leds/power\:green/delay_on
echo 1000 > /sys/class/leds/power\:green/delay_off
fi
elif [ "${1}" == "post" ]; then
...
# Configure power LED solid on after resume
if [ -d "/sys/class/leds/power:green" ]; then
# Reset LED settings by writing 0 to brightness descriptor
echo 0 > /sys/class/leds/power\:green/brightness
# Turn LED on at max brightness
echo 19 > /sys/class/leds/power\:green/brightness
fi
fi
User LEDs
The two user LEDs on the ConnectCore 8M Mini Development Kit are connected to MCA IOs and can be driven by the MCA LED driver.
The BSP contains an example device tree overlay called _ov_board_user-leds_ccimx8mmdvk.dts
that drives the two user LEDs with the MCA LED controller and configures them for blinking at different rates.
/* Enable USER_LED1 and USER_LED2 as mca-led */
fragment@1 {
target = <&mca_led>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
led@1 {
reg = <1>;
label = "USER_LED1:green";
io = <12>;
/* Configure LED to blink at boot */
linux,default-trigger = "timer";
led-pattern = <100>, <1000>;
retain-state-suspended;
};
led@2 {
reg = <2>;
label = "USER_LED2:orange";
io = <18>;
/* Configure LED to blink at boot */
linux,default-trigger = "timer";
led-pattern = <5000>, <5000>;
retain-state-suspended;
};
};
};
MCA IOs that are managed by the MCA LED driver cannot be used by other drivers.
The example user LEDs overlay conflicts with other functionality that tries to control the user LEDs, such as the apix-gpio-example .
|
See Device tree files and overlays for information on enabling a device tree overlay.
Using the LED controller
The Linux driver registers the MCA LED controller as a standard controller that can be accessed from the sysfs.
Sysfs access
The LED controller driver creates an entry in the /sys/class/led
sysfs directory for each enabled channel:
# ls /sys/class/leds/
USER_LED1:green USER_LED2:orange power:green
User LED entries only appear if you load the corresponding device tree overlay. |
You can use the sysfs entries associated with each LED label to configure that label:
# ls /sys/class/leds/power\:green
brightness consumers delay_off delay_on
device max_brightness power subsystem
suppliers trigger uevent
Examples
The following examples demonstrate different use cases of the LED controller:
# echo 0 > /sys/class/leds/power\:green/brightness
# echo 19 > /sys/class/leds/power\:green/brightness
# cat brightness.sh
#!/bin/sh
counter=0
while true; do
echo $counter > /sys/class/leds/power\:green/brightness
sleep 0.1
let counter++
if [[ "$counter" -gt 19 ]]; then
counter=0
fi
done
# echo timer > /sys/class/leds/power\:green/trigger # Configure LED for blinking
# echo 19 > /sys/class/leds/power\:green/brightness # Turn LED on at max brightness
# echo 100 > /sys/class/leds/power\:green/delay_on # Configure time on
# echo 1000 > /sys/class/leds/power\:green/delay_off # Configure time off
Power management
The retain-state-suspended
device tree entry configures the MCA LED channel to retain configuration while in suspend state.
The retain-state-suspended device tree entry only applies to solid-on and blinking LEDs.
Brightness control is not possible in standby state.
|
If the retain-state-suspended
device tree entry is not present, the Linux LED class driver sends a '0' to the brightness descriptor just before entering standby state.
This resets the LED settings, and they are not restored upon waking.
MCA standby power consumption will increase slightly if LEDs are configured to blink while in standby. This is because the MCA will wake periodically (microseconds) to handle the LED states. |