[Silabs][SiWx917] 917 SoC and NCP sleepy Improvements for the better power consumption (#32216)

* letting our device sleep when it is uncommissioned

* using the default clk for the 917 SoC

* reducing the firmware retry to 5

* formatting changes reverting which was not needed

* Restyled by clang-format

* fix the warning for the 917 SoC

* Restyled by clang-format

* addressing review comments

---------

Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/examples/platform/silabs/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp
index 4216dbb..c98882f 100644
--- a/examples/platform/silabs/BaseApplication.cpp
+++ b/examples/platform/silabs/BaseApplication.cpp
@@ -146,6 +146,9 @@
 bool BaseApplication::sIsProvisioned           = false;
 bool BaseApplication::sIsFactoryResetTriggered = false;
 LEDWidget * BaseApplication::sAppActionLed     = nullptr;
+#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
+BaseApplicationDelegate BaseApplication::sAppDelegate = BaseApplicationDelegate();
+#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
 
 #ifdef DIC_ENABLE
 namespace {
@@ -163,6 +166,28 @@
 } // namespace
 #endif // DIC_ENABLE
 
+#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
+void BaseApplicationDelegate::OnCommissioningSessionStarted()
+{
+    isComissioningStarted = true;
+}
+void BaseApplicationDelegate::OnCommissioningSessionStopped()
+{
+    isComissioningStarted = false;
+}
+void BaseApplicationDelegate::OnCommissioningWindowClosed()
+{
+    if (!BaseApplication::GetProvisionStatus() && !isComissioningStarted)
+    {
+        int32_t status = wfx_power_save(RSI_SLEEP_MODE_8, STANDBY_POWER_SAVE_WITH_RAM_RETENTION);
+        if (status != SL_STATUS_OK)
+        {
+            ChipLogError(DeviceLayer, "Failed to enable the TA Deep Sleep");
+        }
+    }
+}
+#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
+
 /**********************************************************
  * AppTask Definitions
  *********************************************************/
@@ -261,7 +286,6 @@
 #if CHIP_ENABLE_OPENTHREAD
     BaseApplication::sIsProvisioned = ConnectivityMgr().IsThreadProvisioned();
 #endif
-
     return err;
 }
 
diff --git a/examples/platform/silabs/BaseApplication.h b/examples/platform/silabs/BaseApplication.h
index 1714f47..1a5c555 100644
--- a/examples/platform/silabs/BaseApplication.h
+++ b/examples/platform/silabs/BaseApplication.h
@@ -30,6 +30,7 @@
 #include "FreeRTOS.h"
 #include "timers.h" // provides FreeRTOS timer support
 #include <app/clusters/identify-server/identify-server.h>
+#include <app/server/AppDelegate.h>
 #include <app/util/config.h>
 #include <ble/BLEEndPoint.h>
 #include <lib/core/CHIPError.h>
@@ -62,6 +63,17 @@
 #define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05)
 #define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06)
 
+#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
+class BaseApplicationDelegate : public AppDelegate
+{
+private:
+    bool isComissioningStarted;
+    void OnCommissioningSessionStarted() override;
+    void OnCommissioningSessionStopped() override;
+    void OnCommissioningWindowClosed() override;
+};
+#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
+
 /**********************************************************
  * BaseApplication Declaration
  *********************************************************/
@@ -75,6 +87,9 @@
     static bool sIsProvisioned;
     static bool sIsFactoryResetTriggered;
     static LEDWidget * sAppActionLed;
+#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
+    static BaseApplicationDelegate sAppDelegate;
+#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
 
     /**
      * @brief Create AppTask task and Event Queue
diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp
index e9fed8d..32bf04c 100644
--- a/examples/platform/silabs/MatterConfig.cpp
+++ b/examples/platform/silabs/MatterConfig.cpp
@@ -18,6 +18,7 @@
  */
 
 #include "AppConfig.h"
+#include "BaseApplication.h"
 #include "OTAConfig.h"
 #include <MatterConfig.h>
 
@@ -254,6 +255,9 @@
     initParams.endpointNativeParams    = static_cast<void *>(&nativeParams);
 #endif
 
+#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
+    initParams.appDelegate = &BaseApplication::sAppDelegate;
+#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
     // Init Matter Server and Start Event Loop
     err = chip::Server::GetInstance().Init(initParams);
 
@@ -303,10 +307,6 @@
 extern "C" void vApplicationIdleHook(void)
 {
 #if SIWX_917 && CHIP_CONFIG_ENABLE_ICD_SERVER
-    if (ConnectivityMgr().IsWiFiStationConnected())
-    {
-        // Let the M4 sleep once commissioning is done and device is in idle state
-        sl_wfx_host_si91x_sleep_wakeup();
-    }
+    sl_wfx_host_si91x_sleep_wakeup();
 #endif
 }
diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c
index 6dcfcfa..c5044fc 100644
--- a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c
+++ b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c
@@ -44,6 +44,7 @@
 #if SL_ICD_ENABLED && SIWX_917
 #include "rsi_rom_power_save.h"
 #include "sl_si91x_button_pin_config.h"
+#include "sl_si91x_driver.h"
 #include "sl_si91x_m4_ps.h"
 
 // TODO: should be removed once we are getting the press interrupt for button 0 with sleep
@@ -188,8 +189,8 @@
         SILABS_LOG("F: Join Event received with %u bytes payload\n", result_length);
         callback_status = *(sl_status_t *) result;
         wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTED);
-        wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++);
         is_wifi_disconnection_event = true;
+        wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++);
         if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN)
         {
             xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN);
@@ -256,28 +257,36 @@
  * @brief
  *       Setting the RS911x in DTIM sleep based mode
  *
- * @param[in] None
+ * @param[in] sl_si91x_ble_state : State to set for the BLE
+              sl_si91x_wifi_state : State to set for the WiFi
  * @return
  *        None
  *********************************************************************/
-int32_t wfx_rsi_power_save()
+int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state)
 {
     int32_t status;
-    status = rsi_bt_power_save_profile(2, 0);
+
+    status = rsi_bt_power_save_profile(sl_si91x_ble_state, 0);
     if (status != RSI_SUCCESS)
     {
         SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status);
         return status;
     }
-
-    sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE };
+    sl_wifi_performance_profile_t wifi_profile = { .profile = sl_si91x_wifi_state };
     status                                     = sl_wifi_set_performance_profile(&wifi_profile);
     if (status != RSI_SUCCESS)
     {
         SILABS_LOG("Powersave Config Failed, Error Code : 0x%lX", status);
         return status;
     }
-    wfx_rsi.dev_state |= WFX_RSI_ST_SLEEP_READY;
+    if (sl_si91x_wifi_state == HIGH_PERFORMANCE)
+    {
+        wfx_rsi.dev_state &= ~(WFX_RSI_ST_SLEEP_READY);
+    }
+    else
+    {
+        wfx_rsi.dev_state |= WFX_RSI_ST_SLEEP_READY;
+    }
     return status;
 }
 #endif /* SL_ICD_ENABLED */
@@ -376,7 +385,7 @@
     }
 
     // Initiate and program the key required for TRNG hardware engine
-    status = sl_si91x_trng_program_key(trngKey, TRNGKEY_SIZE);
+    status = sl_si91x_trng_program_key((uint32_t *) trngKey, TRNGKEY_SIZE);
     if (status != SL_STATUS_OK)
     {
         SILABS_LOG("TRNG Key Programming Failed");
@@ -581,10 +590,14 @@
 
         sl_wifi_set_join_callback(join_callback_handler, NULL);
 
+#if SL_ICD_ENABLED
         // Setting the listen interval to 0 which will set it to DTIM interval
         sl_wifi_listen_interval_t sleep_interval = { .listen_interval = 0 };
         status                                   = sl_wifi_set_listen_interval(SL_WIFI_CLIENT_INTERFACE, sleep_interval);
 
+        sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 5 };
+        sl_wifi_set_advanced_client_configuration(SL_WIFI_CLIENT_INTERFACE, &client_config);
+#endif // SL_ICD_ENABLED
         /* Try to connect Wifi with given Credentials
          * untill there is a success or maximum number of tries allowed
          */
@@ -629,11 +642,11 @@
                            wfx_rsi.join_retries);
                 wfx_rsi.join_retries += 1;
                 wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED);
+                wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries);
                 if (is_wifi_disconnection_event || wfx_rsi.join_retries <= MAX_JOIN_RETRIES_COUNT)
                 {
                     xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN);
                 }
-                wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries);
             }
         }
     }
diff --git a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h
index 6721071..998b3ac 100644
--- a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h
+++ b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h
@@ -95,7 +95,7 @@
 int32_t wfx_wifi_rsi_init(void);
 #if SL_ICD_ENABLED
 void sl_wfx_host_si91x_sleep_wakeup();
-int32_t wfx_rsi_power_save();
+int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state);
 #endif /* SL_ICD_ENABLED */
 
 #ifdef __cplusplus
diff --git a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c
index 0c7efc7..85525fc 100644
--- a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c
+++ b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi_host.c
@@ -194,13 +194,14 @@
  * @fn  sl_status_t wfx_power_save()
  * @brief
  *      Implements the power save in sleepy application
- * @param[in]  None
+ * @param[in]  sl_si91x_ble_state : State to set for the BLE
+               sl_si91x_wifi_state : State to set for the WiFi
  * @return  SL_STATUS_OK if successful,
  *          SL_STATUS_FAIL otherwise
  ***********************************************************************/
-sl_status_t wfx_power_save()
+sl_status_t wfx_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state)
 {
-    if (wfx_rsi_power_save() != SL_STATUS_OK)
+    if (wfx_rsi_power_save(sl_si91x_ble_state, sl_si91x_wifi_state) != SL_STATUS_OK)
     {
         return SL_STATUS_FAIL;
     }
diff --git a/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h b/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h
index 4310bf7..5591467 100644
--- a/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h
+++ b/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h
@@ -48,6 +48,4 @@
 #define INTERRUPT_PIN PIN(A, 7)

 #define SLEEP_CONFIRM_PIN PIN(A, 5) /* Exp hdr 7 */

 #endif

-

-#define NETWORK_INTERFACE_VALID(x) (x == SL_NET_DEFAULT_WIFI_CLIENT_INTERFACE) || (x == SL_NET_DEFAULT_WIFI_AP_INTERFACE)

 #endif /* _RSI_BOARD_CONFIGURATION_H_ */
\ No newline at end of file
diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h
index 4d69206..0721705 100644
--- a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h
+++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h
@@ -92,7 +92,11 @@
 int32_t wfx_rsi_reset_count();
 int32_t wfx_rsi_disconnect();
 #if SL_ICD_ENABLED
+#if SLI_SI917
+int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state);
+#else
 int32_t wfx_rsi_power_save();
+#endif /* SLI_SI917 */
 #endif /* SL_ICD_ENABLED */
 
 #ifdef __cplusplus
diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c
index 1591585..8764c0a 100644
--- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c
+++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c
@@ -192,6 +192,21 @@
 }
 
 #if SL_ICD_ENABLED
+#if SLI_SI917
+/*********************************************************************
+ * @fn  sl_status_t wfx_power_save()
+ * @brief
+ *      Implements the power save in sleepy application
+ * @param[in]  sl_si91x_ble_state : State to set for the BLE
+               sl_si91x_wifi_state : State to set for the WiFi
+ * @return  SL_STATUS_OK if successful,
+ *          SL_STATUS_FAIL otherwise
+ ***********************************************************************/
+sl_status_t wfx_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state)
+{
+    return (wfx_rsi_power_save(sl_si91x_ble_state, sl_si91x_wifi_state) ? SL_STATUS_FAIL : SL_STATUS_OK);
+}
+#else  // For RS9116
 /*********************************************************************
  * @fn  sl_status_t wfx_power_save()
  * @brief
@@ -204,6 +219,7 @@
 {
     return (wfx_rsi_power_save() ? SL_STATUS_FAIL : SL_STATUS_OK);
 }
+#endif /* SLI_SI917 */
 #endif /* SL_ICD_ENABLED */
 
 /*********************************************************************
diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp
index c1a1a7d..214b097 100644
--- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp
+++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp
@@ -368,7 +368,11 @@
     (void) PlatformMgr().PostEvent(&event);
     // Setting the rs911x in the power save mode
 #if (CHIP_CONFIG_ENABLE_ICD_SERVER && RS911X_WIFI)
+#if SLI_SI917
+    sl_status_t err = wfx_power_save(RSI_SLEEP_MODE_2, ASSOCIATED_POWER_SAVE);
+#else
     sl_status_t err = wfx_power_save();
+#endif /* SLI_SI917 */
     if (err != SL_STATUS_OK)
     {
         ChipLogError(DeviceLayer, "Power save config for Wifi failed");
diff --git a/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp b/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp
index b475599..7e58113 100644
--- a/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp
+++ b/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp
@@ -20,8 +20,8 @@
 #include <app/clusters/ota-requestor/OTARequestorInterface.h>
 #include <platform/silabs/OTAImageProcessorImpl.h>
 
+#include "wfx_host_events.h"
 #include <platform/silabs/SilabsConfig.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -35,8 +35,7 @@
 
 #define RPS_HEADER 1
 #define RPS_DATA 2
-/// No error, operation OK
-#define SL_BOOTLOADER_OK 0L
+
 #define SL_STATUS_FW_UPDATE_DONE SL_STATUS_SI91X_NO_AP_FOUND
 uint8_t flag = RPS_HEADER;
 
@@ -124,7 +123,7 @@
 
 void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context)
 {
-    int32_t err           = SL_BOOTLOADER_OK;
+    int32_t status        = SL_STATUS_OK;
     auto * imageProcessor = reinterpret_cast<OTAImageProcessorImpl *>(context);
 
     if (imageProcessor == nullptr)
@@ -148,15 +147,21 @@
 
     imageProcessor->mHeaderParser.Init();
 
-    // Not calling bootloader_eraseStorageSlot(mSlotId) here because we erase during each write
+    // Setting the device is in high performace - no-sleepy mode while OTA tranfer
+#if (CHIP_CONFIG_ENABLE_ICD_SERVER)
+    status = wfx_power_save(RSI_ACTIVE, HIGH_PERFORMANCE);
+    if (status != SL_STATUS_OK)
+    {
+        ChipLogError(DeviceLayer, "Failed to enable the TA Deep Sleep");
+    }
+#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER*/
 
     imageProcessor->mDownloader->OnPreparedForDownload(CHIP_NO_ERROR);
 }
 
 void OTAImageProcessorImpl::HandleFinalize(intptr_t context)
 {
-    uint32_t err          = SL_BOOTLOADER_OK;
-    int32_t status        = 0;
+    int32_t status        = SL_STATUS_OK;
     auto * imageProcessor = reinterpret_cast<OTAImageProcessorImpl *>(context);
     if (imageProcessor == nullptr)
     {
@@ -177,7 +182,7 @@
             }
             else
             {
-                ChipLogError(SoftwareUpdate, "ERROR: In HandleFinalize for last chunk rsi_fwup() error %ld", status);
+                ChipLogError(SoftwareUpdate, "ERROR: In HandleFinalize for last chunk sl_si91x_fwup_load() error %ld", status);
                 imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED);
                 return;
             }
@@ -185,12 +190,21 @@
     }
     imageProcessor->ReleaseBlock();
 
+    // Setting the device back to power save mode when transfer is completed successfully
+#if (CHIP_CONFIG_ENABLE_ICD_SERVER)
+    sl_status_t err = wfx_power_save(RSI_SLEEP_MODE_2, ASSOCIATED_POWER_SAVE);
+    if (err != SL_STATUS_OK)
+    {
+        ChipLogError(DeviceLayer, "Power save config for Wifi failed");
+    }
+#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER*/
+
     ChipLogProgress(SoftwareUpdate, "OTA image downloaded successfully");
 }
 
 void OTAImageProcessorImpl::HandleApply(intptr_t context)
 {
-    uint32_t err = SL_BOOTLOADER_OK;
+    int32_t status = SL_STATUS_OK;
 
     ChipLogProgress(SoftwareUpdate, "OTAImageProcessorImpl::HandleApply()");
 
@@ -199,6 +213,15 @@
 
     ChipLogProgress(SoftwareUpdate, "OTA image downloaded successfully in HandleApply");
 
+    // Setting the device is in high performace - no-sleepy mode before soft reset as soft reset is not happening in sleep mode
+#if (CHIP_CONFIG_ENABLE_ICD_SERVER)
+    status = wfx_power_save(RSI_ACTIVE, HIGH_PERFORMANCE);
+    if (status != SL_STATUS_OK)
+    {
+        ChipLogError(DeviceLayer, "Failed to enable the TA Deep Sleep");
+    }
+#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER*/
+
     if (mReset)
     {
         ChipLogProgress(SoftwareUpdate, "M4 Firmware update complete");
@@ -217,14 +240,22 @@
         return;
     }
 
+    // Setting the device back to power save mode when transfer is aborted in the middle
+#if (CHIP_CONFIG_ENABLE_ICD_SERVER)
+    sl_status_t err = wfx_power_save(RSI_SLEEP_MODE_2, ASSOCIATED_POWER_SAVE);
+    if (err != SL_STATUS_OK)
+    {
+        ChipLogError(DeviceLayer, "Power save config for Wifi failed");
+    }
+#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER*/
+
     // Not clearing the image storage area as it is done during each write
     imageProcessor->ReleaseBlock();
 }
 
 void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context)
 {
-    uint32_t err          = SL_BOOTLOADER_OK;
-    int32_t status        = 0;
+    int32_t status        = SL_STATUS_OK;
     int32_t content_block = 0;
     auto * imageProcessor = reinterpret_cast<OTAImageProcessorImpl *>(context);
     if (imageProcessor == nullptr)
@@ -280,7 +311,7 @@
                     }
                     else
                     {
-                        ChipLogError(SoftwareUpdate, "ERROR: In HandleFinalize for last chunk rsi_fwup() error %ld", status);
+                        ChipLogError(SoftwareUpdate, "ERROR: In HandleProcessBlock sl_si91x_fwup_load() error %ld", status);
                         imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED);
                         return;
                     }
diff --git a/src/platform/silabs/SiWx917/wifi/wfx_host_events.h b/src/platform/silabs/SiWx917/wifi/wfx_host_events.h
index e153a12..455563e 100644
--- a/src/platform/silabs/SiWx917/wifi/wfx_host_events.h
+++ b/src/platform/silabs/SiWx917/wifi/wfx_host_events.h
@@ -32,6 +32,9 @@
 
 #include "sl_status.h"
 
+#include "rsi_common_apis.h"
+#include "sl_wifi_device.h"
+
 #define SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME_MS 1000
 /* Wi-Fi events*/
 #define SL_WFX_STARTUP_IND_ID (1)
@@ -246,7 +249,8 @@
 void * sl_si91x_host_get_buffer_data(sl_wifi_buffer_t * buffer, uint16_t offset, uint16_t * data_length);
 
 #if SL_ICD_ENABLED
-sl_status_t wfx_power_save();
+sl_status_t wfx_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state);
+void sl_button_on_change(uint8_t btn, uint8_t btnAction);
 #endif /* SL_ICD_ENABLED */
 
 void wfx_ipv6_notify(int got_ip);
diff --git a/src/platform/silabs/SiWx917/wifi/wfx_notify.cpp b/src/platform/silabs/SiWx917/wifi/wfx_notify.cpp
index 3d0f56c..ac5e8c3 100644
--- a/src/platform/silabs/SiWx917/wifi/wfx_notify.cpp
+++ b/src/platform/silabs/SiWx917/wifi/wfx_notify.cpp
@@ -31,6 +31,18 @@
 #include "wfx_rsi.h"
 #endif
 
+#if SL_ICD_ENABLED
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "sl_si91x_m4_ps.h"
+extern "C" uint8_t m4_alarm_initialization_done;
+extern "C" void set_alarm_interrupt_timer(uint16_t interval);
+#ifdef __cplusplus
+}
+#endif
+#endif // SL_ICD_ENABLED
+
 #include <platform/CHIPDeviceLayer.h>
 // #include <app/server/Mdns.h>
 #include <app/server/Dnssd.h>
@@ -191,6 +203,12 @@
  ********************************************************************************************/
 void wfx_retry_interval_handler(bool is_wifi_disconnection_event, uint16_t retryJoin)
 {
+#if SL_ICD_ENABLED
+    if (m4_alarm_initialization_done == false)
+    {
+        initialize_m4_alarm();
+    }
+#endif // SL_ICD_ENABLED
     if (!is_wifi_disconnection_event)
     {
         /* After the reboot or a commissioning time device failed to connect with AP.
@@ -199,7 +217,22 @@
         if (retryJoin < MAX_JOIN_RETRIES_COUNT)
         {
             SILABS_LOG("wfx_retry_interval_handler : Next attempt after %d Seconds", CONVERT_MS_TO_SEC(WLAN_RETRY_TIMER_MS));
+#if SL_ICD_ENABLED
+            // TODO: cleanup the retry logic MATTER-1921
+            if (!chip::Server::GetInstance().GetCommissioningWindowManager().IsCommissioningWindowOpen())
+            {
+                set_alarm_interrupt_timer(WLAN_RETRY_TIMER_MS / 1000);
+                wfx_rsi_power_save(RSI_SLEEP_MODE_8, STANDBY_POWER_SAVE_WITH_RAM_RETENTION);
+                // TODO: remove this once TICKLESS_IDLE is applied. MATTER-3134
+                sl_wfx_host_si91x_sleep_wakeup();
+            }
+            else
+            {
+                vTaskDelay(pdMS_TO_TICKS(WLAN_RETRY_TIMER_MS));
+            }
+#else
             vTaskDelay(pdMS_TO_TICKS(WLAN_RETRY_TIMER_MS));
+#endif // SL_ICD_ENABLED
         }
         else
         {
@@ -218,7 +251,14 @@
             retryInterval = WLAN_MAX_RETRY_TIMER_MS;
         }
         SILABS_LOG("wfx_retry_interval_handler : Next attempt after %d Seconds", CONVERT_MS_TO_SEC(retryInterval));
+#if SL_ICD_ENABLED
+        set_alarm_interrupt_timer(retryInterval / 1000);
+        wfx_rsi_power_save(RSI_SLEEP_MODE_8, STANDBY_POWER_SAVE_WITH_RAM_RETENTION);
+        // TODO: remove this once TICKLESS_IDLE is applied. MATTER-3134
+        sl_wfx_host_si91x_sleep_wakeup();
+#else
         vTaskDelay(pdMS_TO_TICKS(retryInterval));
+#endif // SL_ICD_ENABLED
         retryInterval += retryInterval;
     }
 }
diff --git a/src/platform/silabs/efr32/wifi/wfx_host_events.h b/src/platform/silabs/efr32/wifi/wfx_host_events.h
index 4070cf4..c9f451f 100644
--- a/src/platform/silabs/efr32/wifi/wfx_host_events.h
+++ b/src/platform/silabs/efr32/wifi/wfx_host_events.h
@@ -103,6 +103,9 @@
 #include "sl_status.h"
 #include "sl_wifi_constants.h"
 
+#include "rsi_common_apis.h"
+#include "sl_wifi_device.h"
+
 #define SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME_MS 1000
 #endif
 
@@ -365,7 +368,11 @@
 #ifdef RS911X_WIFI
 /* RSI Power Save */
 #if SL_ICD_ENABLED
+#if SLI_SI917
+sl_status_t wfx_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state);
+#else
 sl_status_t wfx_power_save();
+#endif /* SLI_SI917 */
 #endif /* SL_ICD_ENABLED */
 /* RSI for LWIP */
 void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off);
diff --git a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp
index 1015d95..f57b73f 100644
--- a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp
+++ b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp
@@ -55,8 +55,10 @@
     // TODO: Setting the highest priority for SVCall_IRQn to avoid the HardFault issue
     NVIC_SetPriority(SVCall_IRQn, CORE_INTERRUPT_HIGHEST_PRIORITY);
 
+#if !CHIP_CONFIG_ENABLE_ICD_SERVER
     // Configuration the clock rate
     soc_pll_config();
+#endif
 
 #if SILABS_LOG_ENABLED
     silabsInitLog();