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 ;
@@ -1989,6 +1992,18 @@ extern void WL_MCI_WAKEUP0_DriverIRQHandler(void);
1989
1992
extern void WL_MCI_WAKEUP_DONE0_DriverIRQHandler (void );
1990
1993
#endif
1991
1994
1995
+ #ifdef CONFIG_PM_DEVICE
1996
+ #ifdef CONFIG_NXP_IW610
1997
+ struct gpio_callback wakeup_callback ;
1998
+
1999
+ static void gpio_wakeup_callback (const struct device * port , struct gpio_callback * cb ,
2000
+ gpio_port_pins_t pins )
2001
+ {
2002
+ /* TODO: Reserved for future use. */
2003
+ }
2004
+ #endif
2005
+ #endif
2006
+
1992
2007
static int nxp_wifi_dev_init (const struct device * dev )
1993
2008
{
1994
2009
struct nxp_wifi_dev * nxp_wifi = & nxp_wifi0 ;
@@ -2000,13 +2015,52 @@ static int nxp_wifi_dev_init(const struct device *dev)
2000
2015
#ifdef CONFIG_NXP_RW610
2001
2016
IRQ_CONNECT (IMU_IRQ_N , IMU_IRQ_P , WL_MCI_WAKEUP0_DriverIRQHandler , 0 , 0 );
2002
2017
irq_enable (IMU_IRQ_N );
2003
- IRQ_CONNECT (IMU_WAKEUP_IRQ_N , IMU_WAKEUP_IRQ_P , WL_MCI_WAKEUP_DONE0_DriverIRQHandler , 0 , 0 );
2018
+ IRQ_CONNECT (IMU_WAKEUP_IRQ_N , IMU_WAKEUP_IRQ_P ,
2019
+ WL_MCI_WAKEUP_DONE0_DriverIRQHandler , 0 , 0 );
2004
2020
irq_enable (IMU_WAKEUP_IRQ_N );
2005
2021
#if (DT_INST_PROP (0 , wakeup_source ))
2006
2022
EnableDeepSleepIRQ (IMU_IRQ_N );
2007
2023
#endif
2008
- #endif
2024
+ #else
2025
+ #ifdef CONFIG_PM_DEVICE
2026
+ #if DT_NODE_HAS_PROP (DT_DRV_INST (0 ), wakeup_gpios )
2027
+ int err = 0 ;
2028
+ struct gpio_dt_spec wakeup = GPIO_DT_SPEC_GET (DT_DRV_INST (0 ), wakeup_gpios );
2029
+
2030
+ if (!gpio_is_ready_dt (& wakeup )) {
2031
+ LOG_ERR ("Error: failed to configure wakeup %s pin %d" , wakeup .port -> name ,
2032
+ wakeup .pin );
2033
+ return - EIO ;
2034
+ }
2035
+
2036
+ /* Configure wakeup gpio as input */
2037
+ err = gpio_pin_configure_dt (& wakeup , GPIO_INPUT );
2038
+ if (err ) {
2039
+ LOG_ERR ("Error %d: failed to configure wakeup %s pin %d" , err ,
2040
+ wakeup .port -> name , wakeup .pin );
2041
+ return err ;
2042
+ }
2043
+
2044
+ err = gpio_pin_set_dt (& wakeup , 0 );
2045
+ if (err ) {
2046
+ return err ;
2047
+ }
2009
2048
2049
+ /* Configure wakeup gpio interrupt */
2050
+ err = gpio_pin_interrupt_configure_dt (& wakeup , GPIO_INT_EDGE_FALLING );
2051
+ if (err ) {
2052
+ return err ;
2053
+ }
2054
+
2055
+ /* Set wakeup gpio callback function */
2056
+ gpio_init_callback (& wakeup_callback , gpio_wakeup_callback , BIT (wakeup .pin ));
2057
+ err = gpio_add_callback_dt (& wakeup , & wakeup_callback );
2058
+ if (err ) {
2059
+ return err ;
2060
+ }
2061
+ #endif
2062
+ #endif
2063
+ #endif
2010
2064
return 0 ;
2011
2065
}
2012
2066
@@ -2045,7 +2099,8 @@ static int nxp_wifi_set_config(const struct device *dev, enum ethernet_config_ty
2045
2099
return 0 ;
2046
2100
}
2047
2101
2048
- #if defined(CONFIG_PM_DEVICE ) && defined(CONFIG_NXP_RW610 )
2102
+ #ifdef CONFIG_PM_DEVICE
2103
+ #ifdef CONFIG_NXP_RW610
2049
2104
void device_pm_dump_wakeup_source (void )
2050
2105
{
2051
2106
if (POWER_GetWakeupStatus (IMU_IRQ_N )) {
@@ -2059,6 +2114,18 @@ void device_pm_dump_wakeup_source(void)
2059
2114
POWER_ClearWakeupStatus (32 );
2060
2115
}
2061
2116
}
2117
+ #endif
2118
+
2119
+ static bool nxp_wifi_wlan_wakeup (void )
2120
+ {
2121
+ #ifdef CONFIG_NXP_RW610
2122
+ return POWER_GetWakeupStatus (WL_MCI_WAKEUP0_IRQn );
2123
+ #elif CONFIG_NXP_IW610
2124
+ return GPC_GetIRQStatusFlag (GPC , GPIO1_Combined_0_15_IRQn );
2125
+ #else
2126
+ return false;
2127
+ #endif
2128
+ }
2062
2129
2063
2130
static int device_wlan_pm_action (const struct device * dev , enum pm_device_action pm_action )
2064
2131
{
@@ -2103,7 +2170,7 @@ static int device_wlan_pm_action(const struct device *dev, enum pm_device_action
2103
2170
/* If we are not woken up by WLAN, skip posting host sleep exit event.
2104
2171
* And skip host sleep handshake next time we are about to sleep.
2105
2172
*/
2106
- if (POWER_GetWakeupStatus ( WL_MCI_WAKEUP0_IRQn )) {
2173
+ if (nxp_wifi_wlan_wakeup ( )) {
2107
2174
ret = wlan_hs_send_event (HOST_SLEEP_EXIT , NULL );
2108
2175
if (ret != 0 ) {
2109
2176
return - EFAULT ;
@@ -2112,8 +2179,9 @@ static int device_wlan_pm_action(const struct device *dev, enum pm_device_action
2112
2179
} else {
2113
2180
wlan_hs_hanshake_cfg (true);
2114
2181
}
2115
-
2182
+ #ifdef CONFIG_NXP_RW610
2116
2183
device_pm_dump_wakeup_source ();
2184
+ #endif
2117
2185
if (wlan_host_sleep_state == HOST_SLEEP_ONESHOT ) {
2118
2186
wlan_host_sleep_state = HOST_SLEEP_DISABLE ;
2119
2187
wlan_hs_hanshake_cfg (false);
0 commit comments