Backlight control signal
The ConnectCore MP25 Development Kit uses signal TIM20_CH4 of the SOM as the LCD backlight. This line is routed to the parallel LCD and LVDS connectors and can be configured as PWM2, allowing you to adjust the backlight brightness.
Kernel configuration
You can manage the backlight support through the following kernel configuration options:
-
Low-level backlight controls (
CONFIG_BACKLIGHT_CLASS_DEVICE
) -
Generic PWM-based backlight driver (
CONFIG_BACKLIGHT_PWM
)
These options are enabled as built-in on the default ConnectCore MP25 kernel configuration file.
Besides these, you must also enable support for the PWM. See Pulse-width Modulation (PWM).
Device tree bindings and customization
The PWM backlight interface bindings is documented at
Documentation/devicetree/bindings/leds/backlight/pwm-backlight.yaml
.
PWM2 as backlight on ConnectCore MP25 Development Kit
This device tree excerpt shows the blocks that configure the backlight signal:
-
A backlight entry that:
-
uses the generic PWM backlight driver
-
defines the period for the PWM signal
-
defines a list of ten brightness levels from 0 (off) to 255 (fully on)
-
defines a default brightness (with an index to the list of brightness levels)
-
-
The TIMER2 signal from the STM32MP25, with the clocks it is sourced from.
-
The port B GPIO pad 0, to behave as PWM2.
/ {
panel_lvds_pwm_backlight: panel-lvds-pwm-backlight {
compatible = "pwm-backlight";
/* node TIM20_CH4 period (ns) */
pwms = <&pwm_lvds_bckl 3 500000 PWM_POLARITY_INVERTED>;
brightness-levels = <0 16 22 30 40 55 75 102 138 188 255>;
default-brightness-level = <8>;
power-supply = <®_5v_board>;
status = "disabled";
};
};
&timers20 {
/delete-property/dmas;
/delete-property/dma-names;
status = "okay";
pwm_lvds_bckl: pwm {
pinctrl-0 = <&ccmp25_pwm2_pins>;
pinctrl-1 = <&ccmp25_pwm2_sleep_pins>;
pinctrl-names = "default", "sleep";
status = "okay";
};
timer@19 {
status = "okay";
};
};
&pinctrl {
ccmp25_pwm2_pins: ccmp25-pwm2-0 {
pins {
pinmux = <STM32_PINMUX('B', 0, AF8)>; /* TIM20_CH4N */
bias-disable;
drive-push-pull;
slew-rate = <0>;
};
};
ccmp25_pwm2_sleep_pins: ccmp25-pwm2-sleep-0 {
pins {
pinmux = <STM32_PINMUX('B', 0, ANALOG)>; /* TIM20_CH4N */
};
};
};
Using the backlight
Backlight PWM control is managed through backlight sysfs entries.
To read the maximum allowed brightness level of the backlight:
# cat /sys/class/backlight/backlight/max_brightness
9
The returned value is the index to the predefined values array in the device tree (starting at zero).
In the example, the 9 equates to the tenth element in the brightness-levels
array (188).
To set a certain brightness value, use another index to the predefined values array in the device tree:
# echo 4 > /sys/class/backlight/backlight/brightness
In this example, index 4 equates to the fifth element in the brightness-levels
array (40).
The polarity of the backlight signal may be different among displays. In some displays the backlight may be active at high level, while in others the backlight is active at low level. On the ConnectCore MP25 Development Kit and for the supported displays, the backlight is active at high level.