jlaitine commented on code in PR #20365:
URL: https://github.com/apache/nuttx/pull/20365#discussion_r4118944994


##########
arch/arm/src/imxrt/imxrt_clockconfig_ver3.c:
##########
@@ -267,6 +260,49 @@ static void imxrt_init_arm_pll(void)
 
 #endif /* CONFIG_ARCH_CHIP_MIMXRT1189CVM8C_CM33 */
 
+static void imxrt_enable_osc_24m(void)
+{
+  uint32_t reg;
+
+  /* Check if the 24 MHz crystal oscillator not enabled, is gated
+   * or is not stable
+   */
+
+  reg  = getreg32(IMXRT_ANADIG_OSC_24M_CTRL);
+
+  if ((reg & (ANADIG_OSC_24M_CTRL_OSC_EN |
+              ANADIG_OSC_24M_CTRL_GATE |
+              ANADIG_OSC_24M_CTRL_STABLE)) !=
+             (ANADIG_OSC_24M_CTRL_OSC_EN |
+              ANADIG_OSC_24M_CTRL_STABLE))
+    {
+      /* It needs to be enabled */
+
+      reg |= ANADIG_OSC_24M_CTRL_OSC_EN;
+      putreg32(reg, IMXRT_ANADIG_OSC_24M_CTRL);
+
+      while ((getreg32(IMXRT_ANADIG_OSC_24M_CTRL) &
+              ANADIG_OSC_24M_CTRL_STABLE) == 0);
+
+      reg  = getreg32(IMXRT_ANADIG_OSC_24M_CTRL);
+      reg &= ~ANADIG_OSC_24M_CTRL_GATE;
+      putreg32(reg, IMXRT_ANADIG_OSC_24M_CTRL);
+    }
+}
+
+static void imxrt_enable_clock_source(int source)
+{
+  switch (source)
+    {
+      case OSC_24M:
+        imxrt_enable_osc_24m();
+        break;
+
+      default:

Review Comment:
   @acassis: I modified the clock source enabling function so that 1) all the 
clock sources which don't need to be enabled separately break out cleanly and 
2) there is an error from a source which would require enabling but is not yet 
implemented (if any). 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to