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) = {
428
428
#ifdef CONFIG_PM_DEVICE
429
429
static int i2c_ambiq_pm_action (const struct device * dev , enum pm_device_action action )
430
430
{
431
+ const struct i2c_ambiq_config * config = dev -> config ;
431
432
struct i2c_ambiq_data * data = dev -> data ;
432
- uint32_t ret ;
433
+ int ret ;
433
434
am_hal_sysctrl_power_state_e status ;
434
435
435
436
switch (action ) {
436
437
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
+ }
437
444
status = AM_HAL_SYSCTRL_WAKE ;
438
445
break ;
439
446
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
+ }
440
455
status = AM_HAL_SYSCTRL_DEEPSLEEP ;
441
456
break ;
442
457
default :
You can’t perform that action at this time.
0 commit comments