Last edited 3 months ago

LTDC device tree configuration: Difference between revisions


Latest revision as of 14:48, 14 October 2024



1. Article purpose[edit | edit source]

This article explains how to configure the LTDC [1] when the peripheral is assigned to the Linux® OS.

The configuration is performed using the device tree mechanism [2].

The Device tree provides a hardware description of the LTDC [1] used by the STM32 LTDC Linux driver.

2. DT bindings documentation[edit | edit source]

The LTDC is represented by the STM32 LTDC device tree bindings [3].

3. DT configuration[edit | edit source]

This hardware description is a combination of the STM32 microprocessor device tree files (.dtsi extension) and board device tree files (.dts extension). See the Device tree for an explanation of the device tree file split.

STM32CubeMX can be used to generate the board device tree. Refer to How to configure the DT using STM32CubeMX for more details.

3.1. DT configuration (STM32/SoC level)[edit | edit source]

The LTDC device tree node is declared in:

The declaration (shown above) provides the hardware registers base address, the clocks, the interrupts and the reset. The port may be pre-populated to facilitate its use in the many other device tree files.

3.2. DT configuration (board level)[edit | edit source]

The LTDC device tree related to a particular board may have the following nodes, depending on the board hardware:

  • ltdc node: containing the LTDC pinctrl references and the in/out port descriptions
  • panel or i2cx bridge rgb node (depending of the board hardware): containing the in/out port descriptions related to the LTDC node
  • panel_backlight node (depending of the board hardware): related to the panel or bridge node

Full examples:

3.3. LTDC output rotation[edit | edit source]

Depending on the LTDC internal peripheral version, it is possible to rotate the display output.

3.3.1. 180 degree rotation (only STM32MP13x lines More info.png and STM32MP2 series)[edit | edit source]

Add a rotation property in the board panel device tree node like in STM32MP257 Evaluation board device tree arch/arm64/boot/dts/st/stm32mp257f-ev1.dts

...
	panel_lvds: panel-lvds {
		compatible = "edt,etml0700z9ndha", "panel-lvds";
		enable-gpios = <&gpiog 15 GPIO_ACTIVE_HIGH>;
		backlight = <&panel_lvds_backlight>;
		status = "okay";

		rotation = <180>;
...

3.3.2. 90 or 270 degree rotation (only STM32MP23x lines More info.png and STM32MP25x lines More info.png)[edit | edit source]

On STM32MP23x lines More info.png and STM32MP25x lines More info.png, it is possible to use the 90 or 270 degree LTDC output rotation.

1. The 90 or 270 degree rotation requires additional memory area, defined in the ltdc_sec_rotation device tree node located in arch/arm64/boot/dts/st/stm32mp257f-ev1-ca35tdcid-resmem.dtsi :

/ {
	reserved-memory {
		#address-cells = <2>;
		#size-cells = <2>;
		ranges;
...
		ltdc_sec_rotation: ltdc-sec-rotation@ff000000 {
			reg = <0x0 0xff000000 0x0 0x1000000>;
			no-map;
		};


2. The rotation property needs to be added in the board panel device tree node like in STM32MP257 Evaluation board device tree arch/arm64/boot/dts/st/stm32mp257f-ev1.dts

...
	panel_lvds: panel-lvds {
		compatible = "edt,etml0700z9ndha", "panel-lvds";
		enable-gpios = <&gpiog 15 GPIO_ACTIVE_HIGH>;
		backlight = <&panel_lvds_backlight>;
		status = "okay";

		rotation = <90>;
...


3. The horizontal and vertical panel timings and dimensions need to be permuted in the board panel device tree node like in STM32MP257 Evaluation board device tree arch/arm64/boot/dts/st/stm32mp257f-ev1.dts

...
	panel_lvds: panel-lvds {
		compatible = "edt,etml0700z9ndha", "panel-lvds";
		enable-gpios = <&gpiog 15 GPIO_ACTIVE_HIGH>;
		backlight = <&panel_lvds_backlight>;
		status = "okay";

		rotation = <90>;

		width-mm = <92>; /* width-mm & height-mm are permuted for 90° rotation */
		height-mm = <156>;
		data-mapping = "vesa-24";

/* Find below timings for the 90° rotation ("h" & "v" timings are permuted) */
		panel-timing {
			clock-frequency = <54000000>;
			hactive = <600>;
			vactive = <1024>;
			hfront-porch = <24>;
			hback-porch = <24>;
			hsync-len = <21>;
			vfront-porch = <150>;
			vback-porch = <150>;
			vsync-len = <21>;
		};

/* Find below original values for 0° rotation */
/*
		panel-timing {
			clock-frequency = <54000000>;
			hactive = <1024>;
			vactive = <600>;
			hfront-porch = <150>;
			hback-porch = <150>;
			hsync-len = <21>;
			vfront-porch = <24>;
			vback-porch = <24>;
			vsync-len = <21>;
		};
*/
		port {
			lvds_panel_in: endpoint {
				remote-endpoint = <&lvds_out0>;
			};
		};
	};
...

4. Find below some attention points:

  • Touchscreen: The LTDC rotation does not modify the touchscreen orientation. Refer to the panel touchscreen documentation to adjust its orientation, most of time thanks to dedicated device tree properties.
  • Performances: The 90 or 270 degree rotation requires additional memory area used by the LTDC internal peripheral. It means that the overall memory bandwidth used during a use case with rotation is bigger than without the rotation. Depending on the system load, some LTDC fifo issues may appears.


4. How to configure the DT using STM32CubeMX[edit | edit source]

The STM32CubeMX tool can be used to configure the STM32MPU device and get the corresponding platform configuration device tree files.
The STM32CubeMX may not support all the properties described in the above DT bindings documentation paragraph. If so, the tool inserts user sections in the generated device tree. These sections can then be edited to add some properties and they are preserved from one generation to another. Refer to STM32CubeMX user manual for further information.

5. References[edit | edit source]

Please refer to the following links for additional information: