Last edited one month ago

LVDS device tree configuration

Applicable for STM32MP23x lines  STM32MP25x lines


1. Article purpose[edit | edit source]

The purpose of this article is to explain how to configure the LVDS internal peripheral using the device tree mechanism, relying on the bindings documentation. The latter corresponds to the description of the required and optional device-tree properties.

2. DT bindings documentation[edit | edit source]

The device tree binding documents are stored, either in the given applicable components listed below, or in the Linux kernel repository:

  • Linux® OS :
    • st,stm32-lvds.yaml : STM32 LVDS device tree bindings.
    • panel/panel-lvds.yaml : Description of properties for a panel-lvds: data-mapping, width-mm, height-mm, panel-timing, port...
    • panel/panel-simple-lvds-dual-ports.yaml: Description of the dual-lvds-odd-pixels and dual-lvds-even-pixels properties for "dual ports" (also named "dual links" or "dual channels") LVDS display panel.
    • lvds-data-mapping.yaml: Description of the data-mapping property with the following possible values: jeida-18, jeida-24 and vesa-24.
    • lvds.yaml : Description of the data-mirror property. If set, reverse the bit order described in the data mappings on all data lanes, transmitting bits for slots 6 to 0 instead of 0 to 6.
Warning white.png Warning
The data-mirror and jeida-18 properties are not yet available in current ecosystem release v6.0.0 More info.png .

3. DT configuration[edit | edit source]

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

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 LVDS node is located in the device tree file for the software components, supporting the peripheral and listed in the above DT bindings documentation paragraph.

The LVDSdevice tree node is declared in:

The declaration (shown below) defines the hardware register base address, the clocks, and the reset.

...
&rifsc {
...
	lvds: lvds@48060000 {
		#clock-cells = <0>;
		compatible = "st,stm32mp25-lvds";
		reg = <0x48060000 0x2000>;
		clocks = <&rcc CK_BUS_LVDS>, <&rcc CK_KER_LVDSPHY>, <&syscfg 0>;
		clock-names = "pclk", "ref", "pixclk";
		resets = <&rcc LVDS_R>;
		access-controllers = <&rifsc 84>;
		power-domains = <&CLUSTER_PD>;
		status = "disabled";
	};
...

The declaration (shown below) defines the hardware register base address, the clocks, and the reset.

...
&rifsc {
...
	lvds: lvds@48060000 {
		#clock-cells = <0>;
		compatible = "st,stm32mp25-lvds";
		reg = <0x48060000 0x2000>;
		clocks = <&rcc CK_BUS_LVDS>, <&rcc CK_KER_LVDSPHY>, <&syscfg 0>;
		clock-names = "pclk", "ref", "pixclk";
		resets = <&rcc LVDS_R>;
		access-controllers = <&rifsc 84>;
		power-domains = <&CLUSTER_PD>;
		status = "disabled";
	};
...


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

When configuring the board device tree, it is important to know the kind of the used LVDS display panel:

  • Number of links, Single-Link or Dual-Link (also named Single-Port & Dual-Port or Single-Channel & Dual-Channel):
    • Single-Link case: Only one port node is used.
    • Dual-Link case: 2 port nodes are used with the dual-lvds-odd-pixels and dual-lvds-even-pixels properties in each port nodes.
    • 2x Single-Link case: 2 port nodes are used.
  • Bit-mapping: data-mapping property is set to jeida-18, jeida-24 or vesa-24.
  • Bit-ordering: data-mirror property is set if the reversed bit ordering is needed.
Info white.png Information
Only STM32MP25x lines More info.png support Dual-Link and 2x Single-Link cases.
Warning white.png Warning
The data-mirror and jeida-18 properties are not yet available in current ecosystem release v6.0.0 More info.png .

Below examples present some of these possibilities.

3.2.1. Single-Link LVDS display panel[edit | edit source]

Depending on the board hardware, the LVDS device tree related to a particular board may have the following nodes:

  • lvds node: it contains the in/out port descriptions.
  • ltdc node: it contains the in/out port description related to the lvds node.
  • panel_lvds node: it contains the LVDS panel description.
  • panel_lvds_backlight node: it is related to the panel node.

A full example of the STM32MP257 Evaluation board device tree is available in stm32mp257f-ev1.dts [1].

/ {
...
	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";
	};

...
};

&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>;
			};
		};
	};
};
...
Info white.png Information
In the above example, the compatible is set to compatible = "edt,etml0700z9ndha", "panel-lvds";. It is important to keep "panel-lvds" but the part "edt,etml0700z9ndha" can be any string (most of the time, the panel name found in the board documentation).

3.2.2. JEIDA or VESA Bit-Mapping[edit | edit source]

The LVDS display panels use typically only two types of bit-mapping, defined in the VESA and JEIDA sub-standards:

  • The transmission of RGB666 requires three data lanes (+1 clock lane) while the transmission of RGB888 requires four data lanes (+1 clock lane).
  • VESA groups on its three first lanes the LSB of the RGB components, which results in a different pattern for RGB666 and for RGB888.
  • JEIDA groups on its three first lanes the MSB of the RGB components, which results in a same pattern for RGB666 and for RGB888:
    • the 6 MSB bits are transmitted onto a common three data lanes (+1 clock lane), which maps RGB666.
    • the additional bits for RGB888 are mapped into the additional 4th data lane.

The two following figures illustrates the above description, with the here-named bit R7,G7,B7 are the component MSB, while the R0,G0,B0 are the LSB.

Alternate text
Info white.png Information
Note that some panel specifications mention the MSB as R5,G5,B5, while the two LSB are called R7 and R6 (same for G and B), which can create some confusion.

The lvds-data-mapping.yaml device tree binding documentation describes the Linux kernel available data-mapping property with the following possible values: jeida-18, jeida-24 and vesa-24.

For instance, use data-mapping = "vesa-24"; for a LVDS VESA RGB888 display panel like in the below example :

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

3.2.3. Dual-Link LVDS display panel[edit | edit source]

For Dual-Link LVDS display panels, two port nodes are used with the dual-lvds-odd-pixels and dual-lvds-even-pixels properties in each port nodes.

Info white.png Information
Only STM32MP25x lines More info.png support Dual-Link and 2x Single-Link cases.

The below devicetree code can be used as example for a Dual-Link LVDS display panel:

/ {
...
	panel_backlight_8dl: panel-backlight-8dl {
		compatible = "gpio-backlight";
		gpios = <&gpioi 5 GPIO_ACTIVE_HIGH>;
		default-on;
		default-brightness-level = <0>;
		status = "okay";
	};

	panel_lvds_8dl: panel-lvds-8dl {
		compatible = "ampire,amp19201200b5tzqw-t03", "panel-lvds";
		enable-gpios = <&gpioi 9 GPIO_ACTIVE_HIGH>;
		backlight = <&panel_backlight_8dl>;
		status = "okay";

		width-mm = <217>;
		height-mm = <136>;
		data-mapping = "vesa-24";

		panel-timing {
			clock-frequency = <150000000>;
			hactive = <1920>;
			vactive = <1200>;
			hsync-len = <18>;
			hfront-porch = <60>;
			hback-porch = <60>;
			vsync-len = <2>;
			vfront-porch = <6>;
			vback-porch = <6>;
			hsync-active = <0>;
		};

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

			port@0 {
				reg = <0>;
				dual-lvds-odd-pixels;
				lvds_panel_8dl_in0: endpoint {
					remote-endpoint = <&lvds_out0>;
				};
			};

			port@1 {
				reg = <1>;
				dual-lvds-even-pixels;
				lvds_panel_8dl_in1: endpoint {
					remote-endpoint = <&lvds_out1>;
			};
		};
	};
};

...

&ltdc {
	status = "okay";

	port {
		ltdc_ep0_out: endpoint {
			remote-endpoint = <&lvds_in>;
		};
	};
};

&lvds {
	vdd-supply =  <&vddcore>;
	vdda18-supply = <&v1v8>;
	status = "okay";

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

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

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

		port@2 {
			reg = <2>;
			lvds_out1: endpoint {
				remote-endpoint = <&lvds_panel_8dl_in1>;
			};
		};
	};
};
...
Info white.png Information
Depending on the display panel hardware configuration, it may be necessary to permute dual-lvds-odd-pixels and dual-lvds-even-pixels properties in each port nodes.


3.2.4. 2x Single-Link LVDS display panels (same content duplicated on both)[edit | edit source]

For 2x Single-Link LVDS display panels (same content duplicated on both), two port nodes are used.

Info white.png Information
Only STM32MP25x lines More info.png support Dual-Link and 2x Single-Link cases.

The below devicetree code can be used as example for a 2x Single-Link LVDS display panels:

/ {
...
	panel_lvds: panel-lvds {
		compatible = "edt,etml0700z9ndha", "panel-lvds";
		enable-gpios = <&gpioi 9 GPIO_ACTIVE_HIGH>;
		backlight = <&panel_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>;
		};

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

			port@0 {
				reg = <0>;
				panel_lvds_in0: endpoint {
					remote-endpoint = <&lvds_out0>;
				};
			};

			port@1 {
				reg = <1>;
				panel_lvds_in1: endpoint {
					remote-endpoint = <&lvds_out1>;
				};
			};
		};
	};

	panel_backlight: panel-backlight {
		compatible = "gpio-backlight";
		gpios = <&gpiod 13 GPIO_ACTIVE_HIGH>;
		default-on;
		default-brightness-level = <0>;
		status = "okay";
	};
...
};

&ltdc {
	status = "okay";

	port {
		ltdc_ep0_out: endpoint {
			remote-endpoint = <&lvds_in>;
		};
	};
};

&lvds {
	vdd-supply =  <&vddcore>;
	vdda18-supply = <&v1v8>;
	status = "okay";

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

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

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

		port@2 {
			reg = <2>;
			lvds_out1: endpoint {
				remote-endpoint = <&panel_lvds_in1>;
			};
		};
	};
};
...

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.
STM32CubeMX may not support all the properties described in the DT binding files listed 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]

Refer to the following links for additional information: