Skip to content

Commit 1374415

Browse files
EmilioCBenmmahadevan108
authored andcommitted
soc: Updated clock_init in rt6xx
Updated the clock_init function to the latest sdk and added a safe initialization for the flash setup Signed-off-by: Emilio Benavente <[email protected]>
1 parent a3e3cbc commit 1374415

File tree

1 file changed

+29
-0
lines changed
  • soc/arm/nxp_imx/rt6xx

1 file changed

+29
-0
lines changed

soc/arm/nxp_imx/rt6xx/soc.c

+29
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@
2525
#include <fsl_common.h>
2626
#include <fsl_device_registers.h>
2727

28+
#ifdef CONFIG_CODE_FLEXSPI
29+
#include "flash_clock_setup.h"
30+
#endif
31+
2832
#if CONFIG_USB_DC_NXP_LPCIP3511
2933
#include "usb_phy.h"
3034
#include "usb.h"
3135
#endif
3236

37+
/* Core clock frequency: 250105263Hz */
38+
#define CLOCK_INIT_CORE_CLOCK 250105263U
3339

3440
#define SYSTEM_IS_XIP_FLEXSPI() \
3541
((((uint32_t)nxp_rt600_init >= 0x08000000U) && \
@@ -68,6 +74,9 @@ const clock_audio_pll_config_t g_audioPllConfig = {
6874
#define BOARD_USB_PHY_TXCAL45DM (0x06U)
6975
#endif
7076

77+
/* System clock frequency. */
78+
extern uint32_t SystemCoreClock;
79+
7180
#ifdef CONFIG_NXP_IMX_RT6XX_BOOT_HEADER
7281
extern char z_main_stack[];
7382
extern char _flash_used[];
@@ -186,6 +195,15 @@ static ALWAYS_INLINE void clock_init(void)
186195
POWER_DisablePD(kPDRUNCFG_PD_SFRO);
187196
CLOCK_EnableSfroClk();
188197

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+
189207
/* Let CPU run on FFRO for safe switching. */
190208
CLOCK_AttachClk(kFFRO_to_MAIN_CLK);
191209

@@ -285,6 +303,17 @@ static ALWAYS_INLINE void clock_init(void)
285303
CLOCK_AttachClk(kLPOSC_to_I3C_TC_CLK);
286304
#endif
287305

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+
288317
#endif /* CONFIG_SOC_MIMXRT685S_CM33 */
289318
}
290319

0 commit comments

Comments
 (0)