|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2022, NXP |
| 2 | + * Copyright 2022-2023, NXP |
3 | 3 | *
|
4 | 4 | * SPDX-License-Identifier: Apache-2.0
|
5 | 5 | */
|
@@ -303,6 +303,33 @@ static void clock_init(void)
|
303 | 303 | #if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pmic_i2c), nxp_lpc_i2c, okay)
|
304 | 304 | CLOCK_AttachClk(kFRO_DIV4_to_FLEXCOMM15);
|
305 | 305 | #endif
|
| 306 | +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(lcdif), nxp_dcnano_lcdif, okay) && CONFIG_DISPLAY |
| 307 | + POWER_DisablePD(kPDRUNCFG_APD_DCNANO_SRAM); |
| 308 | + POWER_DisablePD(kPDRUNCFG_PPD_DCNANO_SRAM); |
| 309 | + POWER_ApplyPD(); |
| 310 | + |
| 311 | + CLOCK_AttachClk(kAUX0_PLL_to_DCPIXEL_CLK); |
| 312 | + /* Note- pixel clock follows formula |
| 313 | + * (height + VSW + VFP + VBP) * (width + HSW + HFP + HBP) * frame rate. |
| 314 | + * this means the clock divider will vary depending on |
| 315 | + * the attached display. |
| 316 | + */ |
| 317 | + CLOCK_SetClkDiv(kCLOCK_DivDcPixelClk, |
| 318 | + DT_PROP(DT_NODELABEL(lcdif), clk_div)); |
| 319 | + |
| 320 | + CLOCK_EnableClock(kCLOCK_DisplayCtrl); |
| 321 | + RESET_ClearPeripheralReset(kDISP_CTRL_RST_SHIFT_RSTn); |
| 322 | + |
| 323 | + CLOCK_EnableClock(kCLOCK_AxiSwitch); |
| 324 | + RESET_ClearPeripheralReset(kAXI_SWITCH_RST_SHIFT_RSTn); |
| 325 | +#if defined(CONFIG_MEMC) && DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexspi2), \ |
| 326 | + nxp_imx_flexspi, okay) |
| 327 | + /* Enable write-through for FlexSPI1 space */ |
| 328 | + CACHE64_POLSEL0->REG1_TOP = 0x27FFFC00U; |
| 329 | + CACHE64_POLSEL0->POLSEL = 0x11U; |
| 330 | +#endif |
| 331 | +#endif |
| 332 | + |
306 | 333 | /* Switch CLKOUT to FRO_DIV2 */
|
307 | 334 | CLOCK_AttachClk(kFRO_DIV2_to_CLKOUT);
|
308 | 335 |
|
@@ -363,6 +390,49 @@ static void clock_init(void)
|
363 | 390 | POWER_SetDeepSleepClock(kDeepSleepClk_Fro);
|
364 | 391 | }
|
365 | 392 |
|
| 393 | +#if CONFIG_MIPI_DSI |
| 394 | +void imxrt_pre_init_display_interface(void) |
| 395 | +{ |
| 396 | + /* Assert MIPI DPHY reset. */ |
| 397 | + RESET_SetPeripheralReset(kMIPI_DSI_PHY_RST_SHIFT_RSTn); |
| 398 | + POWER_DisablePD(kPDRUNCFG_APD_MIPIDSI_SRAM); |
| 399 | + POWER_DisablePD(kPDRUNCFG_PPD_MIPIDSI_SRAM); |
| 400 | + POWER_DisablePD(kPDRUNCFG_PD_MIPIDSI); |
| 401 | + POWER_ApplyPD(); |
| 402 | + |
| 403 | + /* RxClkEsc max 60MHz, TxClkEsc 12 to 20MHz. */ |
| 404 | + CLOCK_AttachClk(kFRO_DIV1_to_MIPI_DPHYESC_CLK); |
| 405 | + /* RxClkEsc = 192MHz / 4 = 48MHz. */ |
| 406 | + CLOCK_SetClkDiv(kCLOCK_DivDphyEscRxClk, 4); |
| 407 | + /* TxClkEsc = 192MHz / 4 / 3 = 16MHz. */ |
| 408 | + CLOCK_SetClkDiv(kCLOCK_DivDphyEscTxClk, 3); |
| 409 | + |
| 410 | + /* |
| 411 | + * The DPHY bit clock must be fast enough to send out the pixels, |
| 412 | + * it should be larger than: |
| 413 | + * |
| 414 | + * (Pixel clock * bit per output pixel) / number of MIPI data lane |
| 415 | + * |
| 416 | + * DPHY supports up to 895.1MHz bit clock. |
| 417 | + * Note: AUX1 PLL clock is system pll clock * 18 / pfd. |
| 418 | + * system pll clock is configured at 528MHz by default. |
| 419 | + */ |
| 420 | + CLOCK_AttachClk(kAUX1_PLL_to_MIPI_DPHY_CLK); |
| 421 | + CLOCK_InitSysPfd(kCLOCK_Pfd3, |
| 422 | + DT_PROP(DT_NODELABEL(mipi_dsi), dphy_clk_div)); |
| 423 | + CLOCK_SetClkDiv(kCLOCK_DivDphyClk, 1); |
| 424 | + |
| 425 | + /* Clear DSI control reset (Note that DPHY reset is cleared later)*/ |
| 426 | + RESET_ClearPeripheralReset(kMIPI_DSI_CTRL_RST_SHIFT_RSTn); |
| 427 | +} |
| 428 | + |
| 429 | +void imxrt_post_init_display_interface(void) |
| 430 | +{ |
| 431 | + /* Deassert MIPI DPHY reset. */ |
| 432 | + RESET_ClearPeripheralReset(kMIPI_DSI_PHY_RST_SHIFT_RSTn); |
| 433 | +} |
| 434 | +#endif |
| 435 | + |
366 | 436 | /**
|
367 | 437 | *
|
368 | 438 | * @brief Perform basic hardware initialization
|
|
0 commit comments