Skip to content

Commit 587042d

Browse files
KATE-WANG-NXPkartben
authored andcommitted
soc: nxp: imxrt: imxrt7xx: update rt7xx soc files
Add functions to configure MIPI_DSI power and clock when MIPI_DSI is enabled. Signed-off-by: Kate Wang <[email protected]>
1 parent 90c0af2 commit 587042d

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

soc/nxp/imxrt/imxrt7xx/cm33/soc.c

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 NXP
2+
* Copyright 2024,2025 NXP
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -17,6 +17,8 @@
1717
#include <zephyr/linker/sections.h>
1818
#include <zephyr/cache.h>
1919
#include <soc.h>
20+
#include "fsl_power.h"
21+
#include "fsl_clock.h"
2022

2123
void soc_early_init_hook(void)
2224
{
@@ -35,3 +37,73 @@ void soc_reset_hook(void)
3537
}
3638

3739
#endif /* CONFIG_SOC_RESET_HOOK */
40+
41+
#ifdef CONFIG_MIPI_DSI
42+
/* Weak so board can override this function */
43+
void __weak imxrt_pre_init_display_interface(void)
44+
{
45+
/* Assert MIPI control reset. */
46+
RESET_SetPeripheralReset(kMIPI_DSI_CTRL_RST_SHIFT_RSTn);
47+
48+
/* Disable MIPI DSI power down. */
49+
POWER_DisablePD(kPDRUNCFG_APD_MIPIDSI);
50+
POWER_DisablePD(kPDRUNCFG_PPD_MIPIDSI);
51+
POWER_DisablePD(kPDRUNCFG_PD_VDD2_MIPI);
52+
53+
/* Apply power down configuration. */
54+
POWER_ApplyPD();
55+
56+
/* Configure MIPY ESC clock. */
57+
/* Use PLL PFD1 as clock source, 396m. */
58+
CLOCK_AttachClk(kMAIN_PLL_PFD1_to_MIPI_DPHYESC_CLK);
59+
/* RxClkEsc min 60MHz, TxClkEsc 12 to 20MHz. */
60+
/* RxClkEsc = 396MHz / 6 = 66MHz. */
61+
CLOCK_SetClkDiv(kCLOCK_DivDphyEscRxClk, 6);
62+
/* TxClkEsc = 396MHz / 6 / 4 = 16.5MHz. */
63+
CLOCK_SetClkDiv(kCLOCK_DivDphyEscTxClk, 4);
64+
65+
#ifdef CONFIG_MIPI_DBI
66+
/* When using LCDIF, with 279.53MHz DBI source clock and 16bpp format, a 14 wr
67+
* period requires a 279.53MHz / 14 * 16 = 319.46Mhz DPHY clk source. Considering
68+
* the DCS packaging cost, the MIPI DPHY speed shall be ***SLIGHTLY*** larger
69+
* than the DBI interface speed. DPHY uses AUDIO_PLL_PFD2 which is 532.48MHz as
70+
* source, the frequency is 532.48 * 18 / 30 = 319.49MHz, which meets the
71+
* requirement.
72+
*/
73+
uint32_t mipiDsiDphyBitClkFreq_Hz =
74+
DT_PROP(DT_NODELABEL(lcdif), clock_frequency) /
75+
DT_PROP_OR(DT_NODELABEL(lcdif), divider, 1) /
76+
DT_PROP(DT_NODELABEL(lcdif), wr_period) * 16U;
77+
#else
78+
/* The DPHY bit clock must be fast enough to send out the pixels, it should be
79+
* larger than:
80+
* (Pixel clock * bit per output pixel) / number of MIPI data lane
81+
* DPHY uses AUDIO pll pfd2 as aource, and its max allowed clock frequency is
82+
* 532.48 x 18 / 16 = 599.04MHz. The MIPI panel supports up to 850MHz bit clock.
83+
*/
84+
uint32_t mipiDsiDphyBitClkFreq_Hz = DT_PROP(DT_NODELABEL(mipi_dsi), phy_clock);
85+
#endif
86+
uint8_t clockDiv = (uint8_t)((uint64_t)CLOCK_GetAudioPllFreq() * 18U /
87+
(uint64_t)mipiDsiDphyBitClkFreq_Hz);
88+
89+
CLOCK_InitAudioPfd(kCLOCK_Pfd2, clockDiv);
90+
91+
CLOCK_AttachClk(kAUDIO_PLL_PFD2_to_MIPI_DSI_HOST_PHY);
92+
CLOCK_SetClkDiv(kCLOCK_DivDphyClk, 1);
93+
}
94+
95+
void __weak imxrt_post_init_display_interface(void)
96+
{
97+
/* Clear MIPI control reset. */
98+
RESET_ClearPeripheralReset(kMIPI_DSI_CTRL_RST_SHIFT_RSTn);
99+
}
100+
101+
void __weak imxrt_deinit_display_interface(void)
102+
{
103+
/* Assert MIPI DSI reset */
104+
RESET_SetPeripheralReset(kMIPI_DSI_CTRL_RST_SHIFT_RSTn);
105+
/* Remove clock from DPHY */
106+
CLOCK_AttachClk(kNONE_to_MIPI_DSI_HOST_PHY);
107+
}
108+
109+
#endif

soc/nxp/imxrt/imxrt7xx/cm33/soc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ extern "C" {
3333
void xspi_clock_safe_config(void);
3434
void xspi_setup_clock(XSPI_Type *base, uint32_t src, uint32_t divider);
3535

36+
#ifdef CONFIG_MIPI_DSI
37+
void imxrt_pre_init_display_interface(void);
38+
39+
void imxrt_post_init_display_interface(void);
40+
41+
void imxrt_deinit_display_interface(void);
42+
#endif
43+
3644
#ifdef __cplusplus
3745
}
3846
#endif

0 commit comments

Comments
 (0)