From 4868c8acaed9cd0dc40ab18f4fc407a4bfd43656 Mon Sep 17 00:00:00 2001 From: Hui Bai Date: Tue, 27 May 2025 09:11:21 +0800 Subject: [PATCH] drivers: wifi: nxp: Host sleep handshake enhancement To reduce low power current value, added host sleep handshake enhancement. If CPU3 is wokenup by WLAN, do host sleep handshake with CPU1 as before. For other wakeup sources, skip host sleep handshake. Signed-off-by: Hui Bai --- drivers/wifi/nxp/nxp_wifi_drv.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/wifi/nxp/nxp_wifi_drv.c b/drivers/wifi/nxp/nxp_wifi_drv.c index aab8dae2d76..062433bdfa1 100644 --- a/drivers/wifi/nxp/nxp_wifi_drv.c +++ b/drivers/wifi/nxp/nxp_wifi_drv.c @@ -76,6 +76,8 @@ extern const rtos_wpa_supp_dev_ops wpa_supp_ops; #if defined(CONFIG_PM_DEVICE) && defined(CONFIG_NXP_RW610) extern int is_hs_handshake_done; extern int wlan_host_sleep_state; +extern bool skip_hs_handshake; +extern void wlan_hs_hanshake_cfg(bool skip); #endif static int nxp_wifi_recv(struct net_if *iface, struct net_pkt *pkt); @@ -2102,16 +2104,33 @@ static int device_wlan_pm_action(const struct device *dev, enum pm_device_action * User can use this time to issue other commands. */ if (is_hs_handshake_done == WLAN_HOSTSLEEP_SUCCESS) { - ret = wlan_hs_send_event(HOST_SLEEP_EXIT, NULL); - if (ret != 0) { - return -EFAULT; + /* If we are not woken up by WLAN, skip posting host sleep exit event. + * And skip host sleep handshake next time we are about to sleep. + */ + if (POWER_GetWakeupStatus(WL_MCI_WAKEUP0_IRQn)) { + ret = wlan_hs_send_event(HOST_SLEEP_EXIT, NULL); + if (ret != 0) { + return -EFAULT; + } + wlan_hs_hanshake_cfg(false); + } else { + wlan_hs_hanshake_cfg(true); } + device_pm_dump_wakeup_source(); - /* reset hs hanshake flag after waking up */ - is_hs_handshake_done = 0; if (wlan_host_sleep_state == HOST_SLEEP_ONESHOT) { wlan_host_sleep_state = HOST_SLEEP_DISABLE; + wlan_hs_hanshake_cfg(false); } +#ifndef CONFIG_BT + if (skip_hs_handshake == true && + is_hs_handshake_done == WLAN_HOSTSLEEP_SUCCESS) { + ret = wlan_hs_send_event(HOST_SLEEP_HANDSHAKE_SKIP, NULL); + if (ret != 0) { + return -EFAULT; + } + } +#endif } break; default: