|
25 | 25 | #include <fsl_common.h>
|
26 | 26 | #include <fsl_device_registers.h>
|
27 | 27 |
|
| 28 | +#ifdef CONFIG_CODE_FLEXSPI |
| 29 | +#include "flash_clock_setup.h" |
| 30 | +#endif |
| 31 | + |
28 | 32 | #if CONFIG_USB_DC_NXP_LPCIP3511
|
29 | 33 | #include "usb_phy.h"
|
30 | 34 | #include "usb.h"
|
31 | 35 | #endif
|
32 | 36 |
|
| 37 | +/* Core clock frequency: 250105263Hz */ |
| 38 | +#define CLOCK_INIT_CORE_CLOCK 250105263U |
33 | 39 |
|
34 | 40 | #define SYSTEM_IS_XIP_FLEXSPI() \
|
35 | 41 | ((((uint32_t)nxp_rt600_init >= 0x08000000U) && \
|
@@ -68,6 +74,9 @@ const clock_audio_pll_config_t g_audioPllConfig = {
|
68 | 74 | #define BOARD_USB_PHY_TXCAL45DM (0x06U)
|
69 | 75 | #endif
|
70 | 76 |
|
| 77 | +/* System clock frequency. */ |
| 78 | +extern uint32_t SystemCoreClock; |
| 79 | + |
71 | 80 | #ifdef CONFIG_NXP_IMX_RT6XX_BOOT_HEADER
|
72 | 81 | extern char z_main_stack[];
|
73 | 82 | extern char _flash_used[];
|
@@ -186,6 +195,15 @@ static ALWAYS_INLINE void clock_init(void)
|
186 | 195 | POWER_DisablePD(kPDRUNCFG_PD_SFRO);
|
187 | 196 | CLOCK_EnableSfroClk();
|
188 | 197 |
|
| 198 | +#ifdef CONFIG_CODE_FLEXSPI |
| 199 | + /* |
| 200 | + * Call function flexspi_clock_safe_config() to move FlexSPI clock to a stable |
| 201 | + * clock source to avoid instruction/data fetch issue when updating PLL and Main |
| 202 | + * clock if XIP(execute code on FLEXSPI memory). |
| 203 | + */ |
| 204 | + flexspi_clock_safe_config(); |
| 205 | +#endif |
| 206 | + |
189 | 207 | /* Let CPU run on FFRO for safe switching. */
|
190 | 208 | CLOCK_AttachClk(kFFRO_to_MAIN_CLK);
|
191 | 209 |
|
@@ -285,6 +303,17 @@ static ALWAYS_INLINE void clock_init(void)
|
285 | 303 | CLOCK_AttachClk(kLPOSC_to_I3C_TC_CLK);
|
286 | 304 | #endif
|
287 | 305 |
|
| 306 | +#ifdef CONFIG_CODE_FLEXSPI |
| 307 | + /* |
| 308 | + * Call function flexspi_setup_clock() to set user configured clock source/divider |
| 309 | + * for FlexSPI. |
| 310 | + */ |
| 311 | + flexspi_setup_clock(FLEXSPI, 1U, 9U); |
| 312 | +#endif |
| 313 | + |
| 314 | + /* Set SystemCoreClock variable. */ |
| 315 | + SystemCoreClock = CLOCK_INIT_CORE_CLOCK; |
| 316 | + |
288 | 317 | #endif /* CONFIG_SOC_MIMXRT685S_CM33 */
|
289 | 318 | }
|
290 | 319 |
|
|
0 commit comments