File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -428,15 +428,30 @@ static DEVICE_API(i2c, i2c_ambiq_driver_api) = {
428428#ifdef CONFIG_PM_DEVICE
429429static int i2c_ambiq_pm_action (const struct device * dev , enum pm_device_action action )
430430{
431+ const struct i2c_ambiq_config * config = dev -> config ;
431432 struct i2c_ambiq_data * data = dev -> data ;
432- uint32_t ret ;
433+ int ret ;
433434 am_hal_sysctrl_power_state_e status ;
434435
435436 switch (action ) {
436437 case PM_DEVICE_ACTION_RESUME :
438+ /* Move pins to active/default state */
439+ ret = pinctrl_apply_state (config -> pcfg , PINCTRL_STATE_DEFAULT );
440+ if (ret < 0 ) {
441+ LOG_ERR ("I2C pinctrl setup failed (%d)" , ret );
442+ return ret ;
443+ }
437444 status = AM_HAL_SYSCTRL_WAKE ;
438445 break ;
439446 case PM_DEVICE_ACTION_SUSPEND :
447+ /* Move pins to sleep state */
448+ ret = pinctrl_apply_state (config -> pcfg , PINCTRL_STATE_SLEEP );
449+ if (ret == - ENOENT ) {
450+ /* Warn but don't block suspend */
451+ LOG_WRN ("I2C pinctrl sleep state not available " );
452+ } else if (ret < 0 ) {
453+ return ret ;
454+ }
440455 status = AM_HAL_SYSCTRL_DEEPSLEEP ;
441456 break ;
442457 default :
You can’t perform that action at this time.
0 commit comments