lipengfei28 commented on code in PR #16798:
URL: https://github.com/apache/nuttx/pull/16798#discussion_r2261850092


##########
arch/arm64/src/imx9/imx9_clockconfig.c:
##########
@@ -562,3 +693,128 @@ int imx9_get_rootclock(int clkroot, uint32_t *frequency)
 
   return -ENODEV;
 }
+#endif
+
+#ifdef CONFIG_IMX9_CLK_OVER_SCMI
+/****************************************************************************
+ * Name: imx9_configure_clock
+ *
+ * Description:
+ *   This function config and enable the clock
+ *
+ * Input Parameters:
+ *   clk_config - The clock config
+ *   enabled    - If enable the clock
+ *
+ * Returned Value:
+ *   Zero (OK) is returned on success; a negated errno value is returned on
+ *   any failure.
+ *
+ ****************************************************************************/
+
+int imx9_configure_clock(clock_config_t clk_config, bool enabled)
+{
+  scmi_clock_t sm_clk =
+    {
+      0
+    };
+
+  sm_clk.clk_id  = GET_ROOT(clk_config) + ROOT_CLOCK_OFFSET;
+  sm_clk.pclk_id = GET_ID(clk_config);
+  sm_clk.channel = SCMI_PLATFORM_A2P;
+  sm_clk.div     = GET_DIV(clk_config);
+
+  if (sm_clk.div == 0)
+    {
+      /* Make sure div is always 1 */
+
+      sm_clk.div = 1;
+    }
+
+  sm_clk.attributes = SCMI_CLOCK_CONFIG_SET_ENABLE(enabled);
+  sm_clk.flags      = SCMI_CLOCK_RATE_FLAGS_ROUND(SCMI_CLOCK_ROUND_AUTO);
+
+  return imx9_sm_setrootclock(&sm_clk);
+}
+
+/****************************************************************************
+ * Name: imx9_get_rootclock
+ *
+ * Description:
+ *   This function returns the clock frequency of the specified root
+ *   functional clock.
+ *
+ * Input Parameters:
+ *   clkroot   - Identifies the peripheral clock of interest
+ *   frequency - The location where the peripheral clock frequency will be
+ *              returned
+ *
+ * Returned Value:
+ *   Zero (OK) is returned on success; a negated errno value is returned on
+ *   any failure.
+ *
+ ****************************************************************************/
+
+int imx9_get_rootclock(int clkroot, uint32_t *frequency)
+{
+  if (clkroot <= CCM_CR_COUNT)
+    {
+      uint32_t ret = 0;
+
+      scmi_clock_t sm_clk =

Review Comment:
   done



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to