lipengfei28 commented on code in PR #16798: URL: https://github.com/apache/nuttx/pull/16798#discussion_r2265553526
########## arch/arm64/src/imx9/imx9_clockconfig.c: ########## @@ -514,6 +649,131 @@ int imx9_get_clock(int clkname, uint32_t *frequency) return OK; } +#endif /* CONFIG_IMX9_CLK_OVER_SCMI */ + +#ifdef CONFIG_IMX9_CLK_OVER_SCMI +/**************************************************************************** + * Name: imx9_configure_clock + * + * Description: + * This function config and enable the clock + * + * Input Parameters: + * 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 config, bool enabled) +{ + scmi_clock_t clk = + { + 0 + }; + + clk.clk_id = GET_ROOT(config) + ROOT_CLOCK_OFFSET; + clk.pclk_id = GET_ID(config); + clk.channel = SCMI_PLATFORM_A2P; + clk.div = GET_DIV(config); + + if (clk.div == 0) + { + /* Make sure div is always 1 */ + + clk.div = 1; + } + + clk.attributes = SCMI_CLOCK_CONFIG_SET_ENABLE(enabled); + clk.flags = SCMI_CLOCK_RATE_FLAGS_ROUND(SCMI_CLOCK_ROUND_AUTO); + + return imx9_sm_setrootclock(&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 clk = + { + 0 + }; + + clk.clk_id = (uint32_t)(clkroot + ROOT_CLOCK_OFFSET); + clk.channel = SCMI_PLATFORM_A2P; + + ret = imx9_sm_getipfreq(&clk); + + if (ret < 0) + { + return -ENODEV; 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