Backlight control signal

The ConnectCore MP15 Development Kit uses signal TIM2_CH1 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 MP15 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 MP15 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 STM32MP15, with the clocks it is sourced from.

  • The port A GPIO pad 15, to behave as PWM2.

ConnectCore MP15 Development Kit device tree
/ {
	display_bl: display-bl {
		compatible = "pwm-backlight";
		/* node TIM2_CH1 period (ns) */
		pwms = <&pwm2 0 500000 PWM_POLARITY_INVERTED>;
		brightness-levels = <0 16 22 30 40 55 75 102 138 188 255>;
		default-brightness-level = <8>;
		power-supply = <&reg_5v_board>;
		status = "disabled";
	};
};

&timers2 {
        /delete-property/dmas;
        /delete-property/dma-names;
        status = "okay";
        pwm2: pwm {
                pinctrl-0 = <&ccmp15_pwm2_pins>;
                pinctrl-1 = <&ccmp15_pwm2_sleep_pins>;
                pinctrl-names = "default", "sleep";
                status = "okay";
        };
        timer@1 {
                status = "okay";
        };
};

&pinctrl {
	ccmp15_pwm2_pins: pwm2-0 {
		pins {
			pinmux = <STM32_PINMUX('A', 15, AF1)>; /* TIM2_CH1 */
			bias-disable;
			drive-push-pull;
			slew-rate = <0>;
		};
	};

	ccmp15_pwm2_sleep_pins: pwm2-sleep-0 {
		pins {
			pinmux = <STM32_PINMUX('A', 15, ANALOG)>; /* TIM2_CH1 */
		};
	};
};

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 MP15 Development Kit and for the supported displays, the backlight is active at high level.