-
Notifications
You must be signed in to change notification settings - Fork 7.8k
drivers: wifi: Add WLAN wakeup for MIMXRT1060-EVK #92067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ | |
#include <zephyr/net/wifi_mgmt.h> | ||
#ifdef CONFIG_PM_DEVICE | ||
#include <zephyr/pm/device.h> | ||
#ifdef CONFIG_NXP_IW610 | ||
#include <fsl_gpc.h> | ||
#endif | ||
#endif | ||
#ifdef CONFIG_WIFI_NM | ||
#include <zephyr/net/wifi_nm.h> | ||
|
@@ -73,7 +76,7 @@ extern struct interface g_uap; | |
extern const rtos_wpa_supp_dev_ops wpa_supp_ops; | ||
#endif | ||
|
||
#if defined(CONFIG_PM_DEVICE) && defined(CONFIG_NXP_RW610) | ||
#ifdef CONFIG_PM_DEVICE | ||
extern int is_hs_handshake_done; | ||
extern int wlan_host_sleep_state; | ||
extern bool skip_hs_handshake; | ||
|
@@ -2010,6 +2013,18 @@ extern void WL_MCI_WAKEUP0_DriverIRQHandler(void); | |
extern void WL_MCI_WAKEUP_DONE0_DriverIRQHandler(void); | ||
#endif | ||
|
||
#ifdef CONFIG_PM_DEVICE | ||
#ifdef CONFIG_NXP_IW610 | ||
struct gpio_callback wakeup_callback; | ||
|
||
static void gpio_wakeup_callback(const struct device *port, struct gpio_callback *cb, | ||
gpio_port_pins_t pins) | ||
{ | ||
/* TODO: Reserved for future use. */ | ||
} | ||
#endif | ||
#endif | ||
|
||
static int nxp_wifi_dev_init(const struct device *dev) | ||
{ | ||
struct nxp_wifi_dev *nxp_wifi = &nxp_wifi0; | ||
|
@@ -2021,13 +2036,52 @@ static int nxp_wifi_dev_init(const struct device *dev) | |
#ifdef CONFIG_NXP_RW610 | ||
IRQ_CONNECT(IMU_IRQ_N, IMU_IRQ_P, WL_MCI_WAKEUP0_DriverIRQHandler, 0, 0); | ||
irq_enable(IMU_IRQ_N); | ||
IRQ_CONNECT(IMU_WAKEUP_IRQ_N, IMU_WAKEUP_IRQ_P, WL_MCI_WAKEUP_DONE0_DriverIRQHandler, 0, 0); | ||
IRQ_CONNECT(IMU_WAKEUP_IRQ_N, IMU_WAKEUP_IRQ_P, | ||
WL_MCI_WAKEUP_DONE0_DriverIRQHandler, 0, 0); | ||
irq_enable(IMU_WAKEUP_IRQ_N); | ||
#if (DT_INST_PROP(0, wakeup_source)) | ||
EnableDeepSleepIRQ(IMU_IRQ_N); | ||
#endif | ||
#endif | ||
#elif defined(CONFIG_NXP_IW610) | ||
#ifdef CONFIG_PM_DEVICE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does it need to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. Thanks! Hopefully the wakeup_gpios can be used for all wifi chips with OOB wakeup, except for RW610. |
||
#if DT_NODE_HAS_PROP(DT_DRV_INST(0), wakeup_gpios) | ||
int err = 0; | ||
struct gpio_dt_spec wakeup = GPIO_DT_SPEC_GET(DT_DRV_INST(0), wakeup_gpios); | ||
|
||
if (!gpio_is_ready_dt(&wakeup)) { | ||
LOG_ERR("Error: failed to configure wakeup %s pin %d", wakeup.port->name, | ||
wakeup.pin); | ||
return -EIO; | ||
} | ||
|
||
/* Configure wakeup gpio as input */ | ||
err = gpio_pin_configure_dt(&wakeup, GPIO_INPUT); | ||
if (err) { | ||
LOG_ERR("Error %d: failed to configure wakeup %s pin %d", err, | ||
wakeup.port->name, wakeup.pin); | ||
return err; | ||
} | ||
|
||
err = gpio_pin_set_dt(&wakeup, 0); | ||
if (err) { | ||
return err; | ||
} | ||
|
||
/* Configure wakeup gpio interrupt */ | ||
err = gpio_pin_interrupt_configure_dt(&wakeup, GPIO_INT_EDGE_FALLING); | ||
if (err) { | ||
return err; | ||
} | ||
|
||
/* Set wakeup gpio callback function */ | ||
gpio_init_callback(&wakeup_callback, gpio_wakeup_callback, BIT(wakeup.pin)); | ||
err = gpio_add_callback_dt(&wakeup, &wakeup_callback); | ||
if (err) { | ||
return err; | ||
} | ||
#endif | ||
#endif | ||
#endif | ||
return 0; | ||
} | ||
|
||
|
@@ -2066,7 +2120,8 @@ static int nxp_wifi_set_config(const struct device *dev, enum ethernet_config_ty | |
return 0; | ||
} | ||
|
||
#if defined(CONFIG_PM_DEVICE) && defined(CONFIG_NXP_RW610) | ||
#ifdef CONFIG_PM_DEVICE | ||
#ifdef CONFIG_NXP_RW610 | ||
void device_pm_dump_wakeup_source(void) | ||
{ | ||
if (POWER_GetWakeupStatus(IMU_IRQ_N)) { | ||
|
@@ -2080,6 +2135,18 @@ void device_pm_dump_wakeup_source(void) | |
POWER_ClearWakeupStatus(32); | ||
} | ||
} | ||
#endif | ||
|
||
static bool nxp_wifi_wlan_wakeup(void) | ||
{ | ||
#ifdef CONFIG_NXP_RW610 | ||
return POWER_GetWakeupStatus(WL_MCI_WAKEUP0_IRQn); | ||
#elif CONFIG_NXP_IW610 | ||
return GPC_GetIRQStatusFlag(GPC, GPIO1_Combined_0_15_IRQn); | ||
#else | ||
return false; | ||
#endif | ||
} | ||
|
||
static int device_wlan_pm_action(const struct device *dev, enum pm_device_action pm_action) | ||
{ | ||
|
@@ -2124,7 +2191,7 @@ static int device_wlan_pm_action(const struct device *dev, enum pm_device_action | |
/* 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)) { | ||
if (nxp_wifi_wlan_wakeup()) { | ||
ret = wlan_hs_send_event(HOST_SLEEP_EXIT, NULL); | ||
if (ret != 0) { | ||
return -EFAULT; | ||
|
@@ -2133,8 +2200,9 @@ static int device_wlan_pm_action(const struct device *dev, enum pm_device_action | |
} else { | ||
wlan_hs_hanshake_cfg(true); | ||
} | ||
|
||
#ifdef CONFIG_NXP_RW610 | ||
device_pm_dump_wakeup_source(); | ||
#endif | ||
if (wlan_host_sleep_state == HOST_SLEEP_ONESHOT) { | ||
wlan_host_sleep_state = HOST_SLEEP_DISABLE; | ||
wlan_hs_hanshake_cfg(false); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is causing a build failure in twister testing of the PR for not being used