20
20
#include <zephyr/net/wifi_mgmt.h>
21
21
#ifdef CONFIG_PM_DEVICE
22
22
#include <zephyr/pm/device.h>
23
+ #ifdef CONFIG_NXP_IW610
24
+ #include <fsl_gpc.h>
25
+ #endif
23
26
#endif
24
27
#ifdef CONFIG_WIFI_NM
25
28
#include <zephyr/net/wifi_nm.h>
@@ -73,7 +76,7 @@ extern struct interface g_uap;
73
76
extern const rtos_wpa_supp_dev_ops wpa_supp_ops ;
74
77
#endif
75
78
76
- #if defined( CONFIG_PM_DEVICE ) && defined( CONFIG_NXP_RW610 )
79
+ #ifdef CONFIG_PM_DEVICE
77
80
extern int is_hs_handshake_done ;
78
81
extern int wlan_host_sleep_state ;
79
82
extern bool skip_hs_handshake ;
@@ -2014,6 +2017,18 @@ extern void WL_MCI_WAKEUP0_DriverIRQHandler(void);
2014
2017
extern void WL_MCI_WAKEUP_DONE0_DriverIRQHandler (void );
2015
2018
#endif
2016
2019
2020
+ #ifdef CONFIG_PM_DEVICE
2021
+ #ifdef CONFIG_NXP_IW610
2022
+ struct gpio_callback wakeup_callback ;
2023
+
2024
+ static void gpio_wakeup_callback (const struct device * port , struct gpio_callback * cb ,
2025
+ gpio_port_pins_t pins )
2026
+ {
2027
+ /* TODO: Reserved for future use. */
2028
+ }
2029
+ #endif
2030
+ #endif
2031
+
2017
2032
static int nxp_wifi_dev_init (const struct device * dev )
2018
2033
{
2019
2034
struct nxp_wifi_dev * nxp_wifi = & nxp_wifi0 ;
@@ -2028,8 +2043,46 @@ static int nxp_wifi_dev_init(const struct device *dev)
2028
2043
#if (DT_INST_PROP (0 , wakeup_source ))
2029
2044
NXP_ENABLE_WAKEUP_SIGNAL (IMU_IRQ_N );
2030
2045
#endif /* DT_INST_PROP */
2031
- #endif /* CONFIG_NXP_RW610 */
2046
+ #elif defined(CONFIG_NXP_IW610 )
2047
+ #ifdef CONFIG_PM_DEVICE
2048
+ #if DT_NODE_HAS_PROP (DT_DRV_INST (0 ), wakeup_gpios )
2049
+ int err = 0 ;
2050
+ struct gpio_dt_spec wakeup = GPIO_DT_SPEC_GET (DT_DRV_INST (0 ), wakeup_gpios );
2032
2051
2052
+ if (!gpio_is_ready_dt (& wakeup )) {
2053
+ LOG_ERR ("Error: failed to configure wakeup %s pin %d" , wakeup .port -> name ,
2054
+ wakeup .pin );
2055
+ return - EIO ;
2056
+ }
2057
+
2058
+ /* Configure wakeup gpio as input */
2059
+ err = gpio_pin_configure_dt (& wakeup , GPIO_INPUT );
2060
+ if (err ) {
2061
+ LOG_ERR ("Error %d: failed to configure wakeup %s pin %d" , err ,
2062
+ wakeup .port -> name , wakeup .pin );
2063
+ return err ;
2064
+ }
2065
+
2066
+ err = gpio_pin_set_dt (& wakeup , 0 );
2067
+ if (err ) {
2068
+ return err ;
2069
+ }
2070
+
2071
+ /* Configure wakeup gpio interrupt */
2072
+ err = gpio_pin_interrupt_configure_dt (& wakeup , GPIO_INT_EDGE_FALLING );
2073
+ if (err ) {
2074
+ return err ;
2075
+ }
2076
+
2077
+ /* Set wakeup gpio callback function */
2078
+ gpio_init_callback (& wakeup_callback , gpio_wakeup_callback , BIT (wakeup .pin ));
2079
+ err = gpio_add_callback_dt (& wakeup , & wakeup_callback );
2080
+ if (err ) {
2081
+ return err ;
2082
+ }
2083
+ #endif
2084
+ #endif
2085
+ #endif
2033
2086
return 0 ;
2034
2087
}
2035
2088
@@ -2068,7 +2121,8 @@ static int nxp_wifi_set_config(const struct device *dev, enum ethernet_config_ty
2068
2121
return 0 ;
2069
2122
}
2070
2123
2071
- #if defined(CONFIG_PM_DEVICE ) && defined(CONFIG_NXP_RW610 )
2124
+ #ifdef CONFIG_PM_DEVICE
2125
+ #ifdef CONFIG_NXP_RW610
2072
2126
void device_pm_dump_wakeup_source (void )
2073
2127
{
2074
2128
if (POWER_GetWakeupStatus (IMU_IRQ_N )) {
@@ -2082,6 +2136,18 @@ void device_pm_dump_wakeup_source(void)
2082
2136
POWER_ClearWakeupStatus (32 );
2083
2137
}
2084
2138
}
2139
+ #endif
2140
+
2141
+ static bool nxp_wifi_wlan_wakeup (void )
2142
+ {
2143
+ #ifdef CONFIG_NXP_RW610
2144
+ return POWER_GetWakeupStatus (WL_MCI_WAKEUP0_IRQn );
2145
+ #elif CONFIG_NXP_IW610
2146
+ return GPC_GetIRQStatusFlag (GPC , GPIO1_Combined_0_15_IRQn );
2147
+ #else
2148
+ return false;
2149
+ #endif
2150
+ }
2085
2151
2086
2152
static int device_wlan_pm_action (const struct device * dev , enum pm_device_action pm_action )
2087
2153
{
@@ -2126,17 +2192,19 @@ static int device_wlan_pm_action(const struct device *dev, enum pm_device_action
2126
2192
/* If we are not woken up by WLAN, skip posting host sleep exit event.
2127
2193
* And skip host sleep handshake next time we are about to sleep.
2128
2194
*/
2129
- if (POWER_GetWakeupStatus ( WL_MCI_WAKEUP0_IRQn )) {
2195
+ if (nxp_wifi_wlan_wakeup ( )) {
2130
2196
ret = wlan_hs_send_event (HOST_SLEEP_EXIT , NULL );
2131
2197
if (ret != 0 ) {
2132
2198
return - EFAULT ;
2133
2199
}
2134
2200
wlan_hs_hanshake_cfg (false);
2135
2201
} else {
2202
+ LOG_INF ("Wakeup by other sources" );
2136
2203
wlan_hs_hanshake_cfg (true);
2137
2204
}
2138
-
2205
+ #ifdef CONFIG_NXP_RW610
2139
2206
device_pm_dump_wakeup_source ();
2207
+ #endif
2140
2208
if (wlan_host_sleep_state == HOST_SLEEP_ONESHOT ) {
2141
2209
wlan_host_sleep_state = HOST_SLEEP_DISABLE ;
2142
2210
wlan_hs_hanshake_cfg (false);
0 commit comments