@@ -660,6 +660,12 @@ static int mspi_ambiq_pm_action(const struct device *controller, enum pm_device_
660660
661661 switch (action ) {
662662 case PM_DEVICE_ACTION_RESUME :
663+ /* Set pins to active state */
664+ ret = pinctrl_apply_state (cfg -> pcfg ,
665+ PINCTRL_STATE_PRIV_START + data -> dev_id -> dev_idx );
666+ if (ret < 0 ) {
667+ return ret ;
668+ }
663669 ret = am_hal_mspi_power_control (data -> mspiHandle , AM_HAL_SYSCTRL_WAKE , true);
664670 if (ret ) {
665671 LOG_INST_ERR (cfg -> log , "%u, fail to resume MSPI, code:%d." , __LINE__ ,
@@ -669,6 +675,19 @@ static int mspi_ambiq_pm_action(const struct device *controller, enum pm_device_
669675 break ;
670676
671677 case PM_DEVICE_ACTION_SUSPEND :
678+ /* Move pins to sleep state */
679+ ret = pinctrl_apply_state (cfg -> pcfg , PINCTRL_STATE_SLEEP );
680+ if ((ret < 0 ) && (ret != - ENOENT )) {
681+ /*
682+ * If returning -ENOENT, no pins where defined for sleep mode :
683+ * Do not output on console (might sleep already) when going to
684+ * sleep,
685+ * "MSPI pinctrl sleep state not available"
686+ * and don't block PM suspend.
687+ * Else return the error.
688+ */
689+ return ret ;
690+ }
672691 ret = am_hal_mspi_power_control (data -> mspiHandle , AM_HAL_SYSCTRL_DEEPSLEEP , true);
673692 if (ret ) {
674693 LOG_INST_ERR (cfg -> log , "%u, fail to suspend MSPI, code:%d." , __LINE__ ,
0 commit comments