Comprehensive Guide to LCD Screen and MIPI-DSI Parameter Calculation

Introduction

Display is an important component of the i.MX series chips, and we will detail the working principles of display-related modules and the steps to enable customized screens and potential issues based on the i.MX8MP in the near future.This article will focus on D-PHY and further calculate the parameters needed to enable MIPI-DSI interface screens.
D-PHY Parameter Calculation and Analysis

Comprehensive Guide to LCD Screen and MIPI-DSI Parameter Calculation

1.1 Bit_Clk and MIPI_Clock Calculation

In the MIPI communication protocol, several lanes transmit data simultaneously within a unit time. According to the DSI specification, there can be at least one and at most four data channels. Therefore, we can expand the previously calculated parameters to obtain the number of bits transmitted per second for one lane in MIPI-DSI, known as Data Rate Per Lane (DRPL):

DRPL = Bit_per_Second / lane_number

Bit_Clk must be greater than or equal to the calculated value of DRPL, which is typically generated by the D-PHY PLL. Subsequently, D-PHY uses Bit_Clk to generate MIPI_Clock.

As mentioned earlier, the MIPI-DSI interface samples DDR (sampling on both the rising and falling edges), so the MIPI transmission clock is half of the data rate per channel. The MIPI transmission clock (MIPI_Clock) can also be summarized as:

MIPI_Clock = DRPL/2

The output frequency of the D-PHY CLOCK is half of DRPL, meaning the transmission clock frequency (CLK_P and CLK_N) for MIPI screens is the value from the above formula. This value is also what we typically measure at the MIPI-DSI end CLK_N or CLK_P.

Comprehensive Guide to LCD Screen and MIPI-DSI Parameter Calculation

We usually also need to set the D-PHY Phase Locked Loop (PLL) Clock to generate the Bit Clock through frequency multiplication. When calculating the PLL Clock, the input is F_in, which is an external input clock given to the D-PHY PLL, usually provided by the CCM divider. The output clock F_out is the previously calculated Bit Clock:

F_out = F_in x ( M / (P x 2^S) )
Bit_Clk = F_in x ( M / (P x 2^S) )

Thus, we can obtain the parameter information needed for frequency multiplication through the above formulas. In the i.MX8MP, this part of the parameters is automatically calculated through the drivers/gpu/drm/bridge/sec-dsim.c driver in the sec_mipi_dsim_calc_pmsk function. Additionally, it is important to note that the parameters in the formula must meet the ranges listed in the following table:

Comprehensive Guide to LCD Screen and MIPI-DSI Parameter CalculationNotice: The F_in mentioned here is derived from the CCM divider, and detailed information can be found in the relevant Clk Root’s ‘Target Register (CCM_TARGET_ROOTn)’ register. In the following sections, we will detail the RM67191.

Calculating MIPI DSI Parameters Based on RM67191
2.1 Bit_Clk and MIPI_Clock Calculation
In previous articles, we calculated the relevant parameters of the screen and the required Pixel_Clk for configuring the RM67191 screen. Here, we will further calculate and configure Bit Clock and MIPI Clock:
  • Pixel_Clk = 131,957,760 Hz 132MHz

  • Bit_per_Second = 3,166,986,240 bps

We use 4 lanes for data transmission, so we can obtain the number of bits transmitted per second for one lane, i.e., the Data Rate Per Lane (DRPL):

DRPL = 3,166,986,240/4 = 791,746,560 Hz

Based on the relationship between DRPL and Bit_Clk values, we can obtain Bit_Clk as:

Bit_Clk >= 791,746,560 Hz ≈ 792 MHz

We can further calculate the output clock of DSI-PHY as:

MIPI_Clock =

791,746,560/2=395,873,280 Hz

MIPI_Clock ≈ 396 MHz

2.2 Bit_Clk and D-PHY Input Signal (PHY_REF_CLK)
In addition, we also need to ensure that we can normally multiply the Bit Clock from Fin (CCM) using the following parameters:

792,000,000 = 12,000,000 x (M/(P x 2^S))

Notice: Bit_Clk is usually automatically calculated from sec-dsim.c using Pixel_Clk, and we do not need to set it manually.
As mentioned earlier, the parameters M, P, and S here are automatically generated through the sec-dsim.c driver, so we do not need to perform further manual calculations and configurations. In the DSI driver, it will first try within the range of m and then gradually select the corresponding best values for m, p, and s. In the default BSP, the best values for m, p, and s are calculated as:
m = 132, p = 1 & s= 1
After the calculation is completed, the values of m, p, and s will be configured into the corresponding registers as shown in the figure below, DSI_PLLCTRL (0x32E60094).

Comprehensive Guide to LCD Screen and MIPI-DSI Parameter Calculation

# /unit_tests/memtool -32 0x32e60094 10x32e60094: 00804842 
Comparing the values in the register in the manual above, we can see the values set for PMS and compare them with the previously set values in the driver:
  • PllEn(23) bit is 1: Enable PLL

  • PMS(19-1) bits are 0000 0100 1000 0100 001:

    • P (19-14) bits are 0000 01: The value of P is ‘1’, consistent with the previously set value in the driver.

    • M (13-4) bits are 00 1000 0100: The value of M is ‘132’, consistent with the previously set value in the driver.

    • S (3-1) bits are 001: The value of S is ‘1’, consistent with the previously set value in the driver.
2.3 D-PHY Input Signal (PHY_REF_CLK) and CCM
In the default BSP, the D-PHY PHY_REF_CLK (media_mipi_phy1_ref) is mounted under a 24M crystal oscillator. This means the D-PHY input clock (Fin) is derived from the 24M divider. Subsequently, we perform the previously mentioned frequency multiplication to generate Bit_Clk. The mounting and value of media_mipi_phy1_ref can be set in the DTB through the mipi_dsi node:
mipi_dsi: mipi_dsi@32e60000 {                  ...  clocks = <&media_blk_ctrl IMX8MP_CLK_MEDIA_BLK_CTRL_MIPI_DSI_PCLK>,        <&media_blk_ctrl IMX8MP_CLK_MEDIA_BLK_CTRL_MIPI_DSI_CLKREF>;        clock-names = "cfg", "pll-ref";        assigned-clocks = <&clk IMX8MP_CLK_MEDIA_MIPI_PHY1_REF>;        # PHY_REF_CLK 的源        assigned-clock-parents = <&clk IMX8MP_CLK_24M>;        # PHY_REF_CLK 的值        assigned-clock-rates = <12000000>;  ...};
Thus, we have completed the configuration for the screen. Similar to the division of the VIDEO_PLL, we will further understand the division of media_mipi_phy1_ref at the register level and confirm our previous settings. First, by analyzing the i.MX8MP’s CLK driver (linux-imx/drivers/clk/imx/clk-imx8mp.c), we can see that the offset for the DSI-PHY ‘media_mipi_phy1_ref’ is0xbd80, as indicated in the manual below:

Comprehensive Guide to LCD Screen and MIPI-DSI Parameter Calculation

Comprehensive Guide to LCD Screen and MIPI-DSI Parameter Calculation

Therefore, the division relationship of media_mipi_phy1_ref and the crystal oscillator can be viewed by reading the following register:
# /unit_tests/memtool -32 0x3038bd80 10x3038BD80:  10000001

Comprehensive Guide to LCD Screen and MIPI-DSI Parameter Calculation

From this, we can confirm whether our previous settings for PHY_REF_CLK were successful. Comparing the register values in the manual above, we can see:
  • ENABLE(28) bit is 1Enableclock root

  • MUX(26-24) bits are 000: Source is set to 24M_REF_CLK

  • POST_PODF(5-0) bits are 00001: media_mipi_phy1_ref is obtained by dividing 24M_REF_CLK by two, which gives us the previously set value of12MHz.
2.4 Verifying D-PHY Input Signal (PHY_REF_CLK) through Clock Tree
We can also verify and confirm the value and mounting relationship of media_mipi_phy1_ref by using the command #cat /sys/kernel/debug/clk/clk_summary.
 osc_24m                             11       11        0    24000000          0     0  50000         Y    media_mipi_phy1_ref                       1        1        0    12000000          0     0  50000         Y

Notes: The Clock Tree can only see the D-PHY input clock, and cannot view the subsequent D-PHY output Bit_Clk and MIPI_Clock. This is because the subsequent operations are not derived from the CCM divider, but are obtained from the frequency multiplication of the D-PHY related driver.

Notice:In the MIPI-DSI driver, PHY_REF_CLK is fixed at 12MHz. It cannot be modified by changing the value of CLK in the DTB separately:

/* fixed phy ref clk rate */#define PHY_REF_CLK             12000

Conclusion

This article analyzed D-PHY and calculated the parameters needed to enable MIPI-DSI screens using RM67191 as an example. If you have any questions or suggestions for modifications regarding this article, please contact the author at [email protected]. We welcome everyone to discuss. In the near future, we will continue to update the analysis and calculation of display modules (LVDS and MIPI-DSI) parameters, so stay tuned to our public account for the latest updates. If you have any questions about displays or other modules, please feel free to contact us for discussion.

Leave a Comment

Your email address will not be published. Required fields are marked *