@@ -660,6 +660,12 @@ static int mspi_ambiq_pm_action(const struct device *controller, enum pm_device_
660
660
661
661
switch (action ) {
662
662
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
+ }
663
669
ret = am_hal_mspi_power_control (data -> mspiHandle , AM_HAL_SYSCTRL_WAKE , true);
664
670
if (ret ) {
665
671
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_
669
675
break ;
670
676
671
677
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
+ }
672
691
ret = am_hal_mspi_power_control (data -> mspiHandle , AM_HAL_SYSCTRL_DEEPSLEEP , true);
673
692
if (ret ) {
674
693
LOG_INST_ERR (cfg -> log , "%u, fail to suspend MSPI, code:%d." , __LINE__ ,
0 commit comments