lipengfei28 commented on code in PR #16798: URL: https://github.com/apache/nuttx/pull/16798#discussion_r2265558884
########## arch/arm64/src/imx9/imx9_iomuxc.c: ########## @@ -51,8 +55,89 @@ * ****************************************************************************/ +#ifdef CONFIG_IMX9_IOMUX_OVER_SCMI + +/* Sets the IOMUXC pin mux mode. + */ + +void imx9_sm_iomucx_configure(scmi_pinctrl_t *sm_pinctrl) +{ + scmi_pin_config_t configs[4]; + uint32_t num_configs = 0; + uint32_t channel = sm_pinctrl->channel; + uint32_t mux_register = sm_pinctrl->mux_register; + uint32_t mux_mode = sm_pinctrl->mux_mode; + uint32_t input_register = sm_pinctrl->input_register; + uint32_t input_daisy = sm_pinctrl->input_daisy; + uint32_t input_on_field = sm_pinctrl->input_on_field; + uint32_t config_register = sm_pinctrl->config_register; + uint32_t config_value = sm_pinctrl->config_value; + + if (mux_register) + { + configs[num_configs].type = SCMI_PINCTRL_TYPE_MUX; + configs[num_configs].value = SCMI_PLATFORM_PINCTRL_MUX_MODE(mux_mode) + | SCMI_PLATFORM_PINCTRL_SION( + input_on_field); + num_configs++; + } + + if (input_register & 0xffff) + { + configs[num_configs].type = SCMI_PINCTRL_TYPE_DAISY_ID; + configs[num_configs].value = + (input_register - SCMI_PLATFORM_PINCTRL_DAISYREG_OFF) / 4; + num_configs++; + configs[num_configs].type = SCMI_PINCTRL_TYPE_DAISY_CFG; + configs[num_configs].value = input_daisy; + num_configs++; + } + + if (config_register) + { + configs[num_configs].type = SCMI_PINCTRL_TYPE_CONFIG; + configs[num_configs].value = config_value; + num_configs++; + } + + if (mux_register || input_register) + { + uint32_t attributes = SCMI_PINCTRL_SET_ATTR_SELECTOR( + SCMI_PINCTRL_SEL_PIN) + | SCMI_PINCTRL_SET_ATTR_NUM_CONFIGS( + num_configs); + + int32_t ret = imx9_scmi_set_pinctrl_config( + channel, (mux_register - SCMI_PLATFORM_PINCTRL_MUXREG_OFF) / 4, + attributes, configs); + if (ret != 0) + { + assert("Unable to set iomux over SCMI"); + } + } +} + +#endif + int imx9_iomux_configure(iomux_cfg_t cfg) { +#ifdef CONFIG_IMX9_IOMUX_OVER_SCMI + scmi_pinctrl_t sm_pinctrl = 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