1. Article purpose[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 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
anddual-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
andvesa-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.
3. DT configuration[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 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 LVDS device tree node is declared in stm32mp255.dtsi [1]. The declaration (shown below) defines the hardware register base address, the clocks, and the reset.
soc@0 { rifsc: rifsc@42080000 { ... lvds: lvds@48060000 { #clock-cells = <0>; compatible = "st,stm32mp25-lvds"; reg = <0x48060000 0x2000>; clocks = <&rcc CK_BUS_LVDS>, <&rcc CK_KER_LVDSPHY>; clock-names = "pclk", "ref"; resets = <&rcc LVDS_R>; feature-domains = <&rifsc STM32MP25_RIFSC_LVDS_ID>; power-domains = <&CLUSTER_PD>; status = "disabled"; }; ...
3.2. DT configuration (board level)[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 thedual-lvds-odd-pixels
anddual-lvds-even-pixels
properties in each port nodes.
- Single-Link case: Only one
- Bit-mapping:
data-mapping
property is set tojeida-18
,jeida-24
orvesa-24
. - Bit-ordering:
data-mirror
property is set if the reversed bit ordering is needed.
Below examples present some of these possibilities.
3.2.1. Single-Link LVDS display panel[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 [2].
/ {
...
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";
};
...
};
<dc {
default-on;
rotation-memory = <<dc_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 = <<dc_ep1_out>;
};
};
port@1 {
reg = <1>;
lvds_out0: endpoint {
remote-endpoint = <&lvds_panel_in>;
};
};
};
};
...
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 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.
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 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.
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>;
};
};
};
};
...
<dc {
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 = <<dc_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>;
};
};
};
};
...
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 source]
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.
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 source]
Refer to the following links for additional information: