imxrt10xx: Fix clk glitch after setting the clock gates
@@ -2170,6 +2170,9 @@ void _imxrt_init(void)
*(imxrt_common.ccm + ccm_ccgr5) = 0xf00f330f;
*(imxrt_common.ccm + ccm_ccgr6) = 0x00fc0f0f;
+ hal_cpuDataSyncBarrier();
+ hal_cpuInstrBarrier();
+
/* Remain in run mode on wfi */
_imxrt_ccmSetMode(0);
@@ -2178,6 +2181,9 @@ void _imxrt_init(void)
_imxrt_ccmDeinitEnetPll();
_imxrt_ccmDeinitUsb2Pll();
+ /* Wait for any pending CCM div/mux handshake process to complete */
+ while (*(imxrt_common.ccm + ccm_cdhipr) & 0x1002b);
+
/* Allow userspace applications to access hardware registers */
for (i = 0; i < sizeof(imxrt_common.aips) / sizeof(imxrt_common.aips[0]); ++i) {
*(imxrt_common.aips[i] + aipstz_opacr) &= ~0x44444444;
