From 5c876e74c11eb6ca2423f2e96a962464971b467e Mon Sep 17 00:00:00 2001 From: Hui Bai Date: Wed, 12 Nov 2025 17:15:46 +0800 Subject: [PATCH] mcux: wifi_nxp: Add compiler flag for the wake_timer Add new compiler flag CONFIG_WAKE_TIMER_ENABLE for the wake_timer. The duration of this timer is 5 seconds and it is used to block low power mode for 5 seconds after device wakes up from low power mode. User can choose to enable this timer or not by controlling this compiler flag. Signed-off-by: Hui Bai --- mcux/middleware/wifi_nxp/incl/nxp_wifi.h | 4 ++++ mcux/middleware/wifi_nxp/wlcmgr/wlan.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/mcux/middleware/wifi_nxp/incl/nxp_wifi.h b/mcux/middleware/wifi_nxp/incl/nxp_wifi.h index 9fb75fffeb..088721fe0f 100644 --- a/mcux/middleware/wifi_nxp/incl/nxp_wifi.h +++ b/mcux/middleware/wifi_nxp/incl/nxp_wifi.h @@ -329,6 +329,10 @@ extern "C" { #define CONFIG_HOST_SLEEP 1 #endif +#if CONFIG_NXP_WIFI_WAKE_TIMER_ENABLE +#define CONFIG_WAKE_TIMER_ENABLE 1 +#endif + #if CONFIG_PM #define CONFIG_POWER_MANAGER 1 #endif diff --git a/mcux/middleware/wifi_nxp/wlcmgr/wlan.c b/mcux/middleware/wifi_nxp/wlcmgr/wlan.c index 0bcc32c170..40d1ec90dd 100644 --- a/mcux/middleware/wifi_nxp/wlcmgr/wlan.c +++ b/mcux/middleware/wifi_nxp/wlcmgr/wlan.c @@ -281,8 +281,10 @@ int wlan_host_sleep_state = HOST_SLEEP_PERIODIC; */ bool usart_suspend_flag = false; #endif +#if CONFIG_WAKE_TIMER_ENABLE OSA_TIMER_HANDLE_DEFINE(wake_timer); #endif +#endif int is_hs_handshake_done = 0; /* indicate that we did not notify FW after host sleep wake up */ bool skip_hs_handshake = false; @@ -1029,12 +1031,14 @@ status_t wlan_hs_send_event(int id, void *data) #endif #if CONFIG_POWER_MANAGER +#if CONFIG_WAKE_TIMER_ENABLE static void wake_timer_cb(osa_timer_arg_t arg) { if(wakelock_isheld()) wakelock_put(); } #endif +#endif #if CONFIG_MEF_CFG int wlan_wowlan_config(uint8_t is_mef, t_u32 wake_up_conds) @@ -1164,11 +1168,13 @@ void wlan_config_host_sleep(bool is_manual, t_u8 is_periodic) #if CONFIG_POWER_MANAGER /* Reset flag and stop timer if manual mode is selected without cancel periodic sleep */ wlan_host_sleep_state = HOST_SLEEP_DISABLE; +#if CONFIG_WAKE_TIMER_ENABLE if (OSA_TimerIsRunning((osa_timer_handle_t)wake_timer)) { OSA_TimerDeactivate((osa_timer_handle_t)wake_timer); wakelock_put(); } +#endif #endif } } @@ -1205,6 +1211,7 @@ void wlan_clear_host_sleep_config(void) #if CONFIG_UART_INTERRUPT usart_suspend_flag = MFALSE; #endif +#if CONFIG_WAKE_TIMER_ENABLE if (OSA_TimerIsRunning((osa_timer_handle_t)wake_timer)) { OSA_TimerDeactivate((osa_timer_handle_t)wake_timer); @@ -1212,6 +1219,7 @@ void wlan_clear_host_sleep_config(void) } is_hs_handshake_done = 0; #endif +#endif #if CONFIG_MEF_CFG memset(&g_flt_cfg, 0x0, sizeof(wlan_flt_cfg_t)); @@ -10746,12 +10754,14 @@ static void wlcmgr_mon_task(void * data) struct wlan_message msg; #if CONFIG_POWER_MANAGER +#if CONFIG_WAKE_TIMER_ENABLE status = OSA_TimerCreate((osa_timer_handle_t)wake_timer, MSEC_TO_TICK(WAKE_TIMEOUT), &wake_timer_cb, NULL, KOSA_TimerOnce, OSA_TIMER_NO_ACTIVATE); if (status != KOSA_StatusSuccess) { wlcm_e("Unable to create wake timer"); } +#endif #endif while (1) { @@ -10775,6 +10785,7 @@ static void wlcmgr_mon_task(void * data) { #if CONFIG_POWER_MANAGER #ifndef CONFIG_BT +#if CONFIG_WAKE_TIMER_ENABLE if(!wlan_is_manual && wlan_host_sleep_state == HOST_SLEEP_PERIODIC) { wakelock_get(); @@ -10782,6 +10793,7 @@ static void wlcmgr_mon_task(void * data) } #endif #endif +#endif #ifndef RW610 uint16_t hs_wakeup_reason = 0; (void)wifi_get_wakeup_reason(&hs_wakeup_reason); @@ -10796,6 +10808,7 @@ static void wlcmgr_mon_task(void * data) #endif } #ifndef CONFIG_BT +#if CONFIG_WAKE_TIMER_ENABLE else if (msg.id == HOST_SLEEP_HANDSHAKE_SKIP) { if(wlan_host_sleep_state == HOST_SLEEP_PERIODIC) @@ -10806,6 +10819,7 @@ static void wlcmgr_mon_task(void * data) } #endif #endif +#endif #if CONFIG_WIFI_RECOVERY else if (msg.id == WIFI_RECOVERY_REQ) {