Last edited 2 weeks ago

LTDC device tree configuration

Applicable for STM32MP13x lines, STM32MP15x lines, STM32MP25x lines


1. Article purpose[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 source]

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

3. DT configuration[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 source]

The LTDC device tree node is declared in:

...
/ {
	soc {
		etzpc: etzpc@5c007000 {
...
			ltdc: display-controller@5a001000 {
				compatible = "st,stm32-ltdc";
				reg = <0x5a001000 0x400>;
				interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>,
					     <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
				clocks = <&rcc LTDC_PX>;
				clock-names = "lcd";
				resets = <&scmi_reset RST_SCMI_LTDC>;
				feature-domains = <&etzpc STM32MP1_ETZPC_LTDC_ID>;
				status = "disabled";
			};
		};
	};
};
/ {
	#address-cells = <1>;
	#size-cells = <1>;
...
	soc {
...
		ltdc: display-controller@5a001000 {
			compatible = "st,stm32-ltdc";
			reg = <0x5a001000 0x400>;
			interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&rcc LTDC_PX>;
			clock-names = "lcd";
			resets = <&rcc LTDC_R>;
			status = "disabled";
		};
...
...
		rifsc: rifsc@42080000 {
			compatible = "st,stm32mp25-sys-bus";
			reg = <0x42080000 0x1000>;
			#address-cells = <1>;
			#size-cells = <1>;
			ranges;
			feature-domain-controller;
			#feature-domain-cells = <1>;
...
			ltdc: display-controller@48010000 {
				compatible = "st,stm32mp25-ltdc";
				reg = <0x48010000 0x400>;
				st,syscon = <&syscfg>;
				interrupts = <GIC_SPI 158 IRQ_TYPE_LEVEL_HIGH>,
					<GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>;
				clocks = <&rcc CK_BUS_LTDC>, <&rcc CK_KER_LTDC>;
				clock-names = "bus", "lcd";
				resets = <&rcc LTDC_R>;
				feature-domains = <&rifsc STM32MP25_RIFSC_LTDC_CMN_ID>;
				power-domains = <&CLUSTER_PD>;
				status = "disabled";
			};
...

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.

Warning white.png Warning
This device tree part is related to STM32 microprocessors. It must be kept as is, without being modified by the end-user.



3.2. DT configuration (board level)[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
Info white.png Information
When the LTDC is directly connected to an external display panel or a bridge thanks to GPIO, a LTDC Pinctrl [4] configuration is required:

Full examples:

/ {
...
	panel_rgb: panel-rgb {
		compatible = "rocktech,rk043fn48h", "panel-dpi";
		enable-gpios = <&gpioi 7 GPIO_ACTIVE_HIGH>;
		backlight = <&panel_backlight>;
		power-supply = <&scmi_v3v3_sw>;
		status = "okay";

		width-mm = <105>;
		height-mm = <67>;

		port {
			panel_in_rgb: endpoint {
				remote-endpoint = <&ltdc_out_rgb>;
			};
		};

		panel-timing {
			clock-frequency = <10000000>;
			hactive = <480>;
			vactive = <272>;
			hsync-len = <52>;
			hfront-porch = <10>;
			hback-porch = <10>;
			vsync-len = <10>;
			vfront-porch = <10>;
			vback-porch = <10>;
		};
	};
...
};
...
&ltdc {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&ltdc_pins_a>;
	pinctrl-1 = <&ltdc_sleep_pins_a>;
	status = "okay";

	port {
		#address-cells = <1>;
		#size-cells = <0>;

		ltdc_out_rgb: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&panel_in_rgb>;
		};
	};
};
...
&i2c1 {
...
	hdmi-transmitter@39 {
		compatible = "sil,sii9022";
		reg = <0x39>;
		iovcc-supply = <&v3v3_hdmi>;
		cvcc12-supply = <&v1v2_hdmi>;
		reset-gpios = <&gpioa 10 GPIO_ACTIVE_LOW>;
		interrupts = <1 IRQ_TYPE_EDGE_FALLING>;
		interrupt-parent = <&gpiog>;
		#sound-dai-cells = <0>;
		status = "okay";

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;
				sii9022_in: endpoint {
					remote-endpoint = <&ltdc_ep0_out>;
				};
			};

			port@3 {
				reg = <3>;
				sii9022_tx_endpoint: endpoint {
					remote-endpoint = <&i2s2_endpoint>;
				};
			};
		};
	};
...
};
&ltdc {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&ltdc_pins_a>;
	pinctrl-1 = <&ltdc_sleep_pins_a>;
	status = "okay";

	port {
		ltdc_ep0_out: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&sii9022_in>;
		};
	};
};
...
/ {
	model = "STMicroelectronics STM32MP257F-EV1 Evaluation Board";
	compatible = "st,stm32mp257f-ev1", "st,stm32mp257";
...
	hdmi: connector {
		compatible = "hdmi-connector";
		label = "hdmi";
		type = "a";

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

		width-mm = <156>;
		height-mm = <92>;
		data-mapping = "vesa-24";

		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>;
			};
		};
	};

	panel_lvds_backlight: panel-lvds-backlight {
		compatible = "gpio-backlight";
		gpios = <&gpioi 5 GPIO_ACTIVE_HIGH>;
		default-on;
		default-brightness-level = <1>;
		status = "okay";
	};
...
};
...
&dsi {
	vdd-supply =  <&scmi_vddcore>;
	vdda18-supply = <&scmi_v1v8>;
	status = "disabled";

	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			dsi_in: endpoint {
				remote-endpoint = <&ltdc_ep0_out>;
			};
		};

		port@1 {
			reg = <1>;
			dsi_out1: endpoint {
				remote-endpoint = <&adv753x_in>;
			};
		};
	};
};

...
&i2c2 {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&i2c2_pins_a>;
	pinctrl-1 = <&i2c2_sleep_pins_a>;
	i2c-scl-rising-time-ns = <100>;
	i2c-scl-falling-time-ns = <13>;
	clock-frequency = <400000>;
	status = "okay";
	/* spare dmas for other usage */
	/delete-property/dmas;
	/delete-property/dma-names;
...
	adv753x: hdmi@3d {
		/*
		 * With MB1232 board, use "adi,adv7533" (1080p30)
		 * With MB1752 board, use "adi,adv7535" (1080p60)
		 */
		compatible = "adi,adv7533";
		reg = <0x3d>, <0x3c>, <0x3f>, <0x38>;
		reg-names = "main", "cec", "edid", "packet";
		clocks = <&cec_clock>;
		clock-names = "cec";
		interrupt-parent = <&gpiod>;
		interrupts = <10 IRQ_TYPE_EDGE_FALLING>;
		status = "disabled";
		adi,dsi-lanes = <4>;
		reset-gpios = <&gpiog 14 GPIO_ACTIVE_LOW>;
		avdd-supply = <&scmi_v1v8>;
		dvdd-supply = <&scmi_v1v8>;
		pvdd-supply = <&scmi_v1v8>;
		a2vdd-supply = <&scmi_v1v8>;
		v3p3-supply = <&scmi_v3v3>;
		v1p2-supply = <&scmi_v1v8>;

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;
				adv753x_in: endpoint {
					remote-endpoint = <&dsi_out1>;
				};
			};

			port@1 {
				reg = <1>;
				adv753x_out: endpoint {
					remote-endpoint = <&hdmi_connector_in>;
				};
			};

			port@2 {
				reg = <2>;
				adv753x_tx_endpoint: endpoint {
					remote-endpoint = <&i2s2_endpoint>;
				};
			};
		};
	};

	ili2511: ili2511@41 {
		compatible = "ilitek,ili251x";
		reg = <0x41>;
		interrupt-parent = <&gpioi>;
		interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
		reset-gpios = <&gpiog 14 GPIO_ACTIVE_LOW>;
		status = "okay";
	};
};
...
&ltdc {
	default-on;
	rotation-memory = <&ltdc_sec_rotation>;
	status = "okay";

	port {
		#address-cells = <1>;
		#size-cells = <0>;

		ltdc_ep0_out: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&dsi_in>;
		};

		ltdc_ep1_out: endpoint@1 {
			reg = <1>;
			remote-endpoint = <&lvds_in>;
		};
	};
};

&lvds {
	default-on;
	vdd-supply =  <&scmi_vddcore>;
	vdda18-supply = <&scmi_v1v8>;
	status = "okay";

	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			lvds_in: endpoint {
				remote-endpoint = <&ltdc_ep1_out>;
			};
		};

		port@1 {
			reg = <1>;
			lvds_out0: endpoint {
				remote-endpoint = <&lvds_panel_in>;
			};
		};
	};
};
...

3.3. LTDC output rotation[edit source]

3.3.1. 180 degree rotation[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>;
...
Info white.png Information
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.


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

On 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;
		};
Info white.png Information
The 16Mbytes default value is perfect for a 1080p resolution and for a good memory alignment. If this memory area size needs to be adjusted, please refer to the LTDC Rotation chapter in the related STM32 MPU reference manual for computation details.


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>;
			};
		};
	};
...
Info white.png Information
In the above example, the panel timings are located in the panel device tree node. Depending on the panel driver, the panel timings may be located in the panel driver file.

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 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 source]

Please refer to the following links for additional information: