Skip to content

Commit b3ca380

Browse files
committed
drivers: wifi: Add WLAN wakeup for MIMXRT1060-EVK
Added wlan wakeup pin in IW610 overlay file. This WLAN wakeup support is for IW610 and MIMXRT1060-EVK acts as host. Add wakeup pin configuration when doing device related initialization. Signed-off-by: Hui Bai <hui.bai@nxp.com>
1 parent 94a6c1f commit b3ca380

File tree

6 files changed

+93
-9
lines changed

6 files changed

+93
-9
lines changed

boards/shields/nxp_m2_wifi_bt/nxp_m2_2ll_wifi_bt.overlay

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
&m2_wifi_sdio {
3333
nxp_wifi {
3434
compatible = "nxp,wifi";
35+
wakeup-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
3536
status = "okay";
3637
};
3738
};

drivers/wifi/nxp/Kconfig.nxp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ menu "Wi-Fi driver Stack configurations"
402402

403403
config NXP_WIFI_MON_TASK_STACK_SIZE
404404
int "Mon thread stack size"
405-
depends on NXP_RW610
405+
depends on NXP_RW610 || NXP_IW610
406406
default 3072
407407
help
408408
This option specifies the size of the stack used by the mon task.
@@ -444,7 +444,7 @@ menu "Wi-Fi thread priority configurations"
444444

445445
config NXP_WIFI_MON_TASK_PRIO
446446
int "Mon task priority"
447-
depends on NXP_RW610
447+
depends on NXP_RW610 || NXP_IW610
448448
default 4
449449
help
450450
This option specifies the priority of the mon task.

drivers/wifi/nxp/nxp_wifi_drv.c

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#include <zephyr/net/wifi_mgmt.h>
2121
#ifdef CONFIG_PM_DEVICE
2222
#include <zephyr/pm/device.h>
23+
#ifdef CONFIG_NXP_IW610
24+
#include <fsl_gpc.h>
25+
#endif
2326
#endif
2427
#ifdef CONFIG_WIFI_NM
2528
#include <zephyr/net/wifi_nm.h>
@@ -73,7 +76,7 @@ extern struct interface g_uap;
7376
extern const rtos_wpa_supp_dev_ops wpa_supp_ops;
7477
#endif
7578

76-
#if defined(CONFIG_PM_DEVICE) && defined(CONFIG_NXP_RW610)
79+
#ifdef CONFIG_PM_DEVICE
7780
extern int is_hs_handshake_done;
7881
extern int wlan_host_sleep_state;
7982
extern bool skip_hs_handshake;
@@ -1989,6 +1992,18 @@ extern void WL_MCI_WAKEUP0_DriverIRQHandler(void);
19891992
extern void WL_MCI_WAKEUP_DONE0_DriverIRQHandler(void);
19901993
#endif
19911994

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+
19922007
static int nxp_wifi_dev_init(const struct device *dev)
19932008
{
19942009
struct nxp_wifi_dev *nxp_wifi = &nxp_wifi0;
@@ -2000,13 +2015,52 @@ static int nxp_wifi_dev_init(const struct device *dev)
20002015
#ifdef CONFIG_NXP_RW610
20012016
IRQ_CONNECT(IMU_IRQ_N, IMU_IRQ_P, WL_MCI_WAKEUP0_DriverIRQHandler, 0, 0);
20022017
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);
20042020
irq_enable(IMU_WAKEUP_IRQ_N);
20052021
#if (DT_INST_PROP(0, wakeup_source))
20062022
EnableDeepSleepIRQ(IMU_IRQ_N);
20072023
#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+
}
20092048

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
20102064
return 0;
20112065
}
20122066

@@ -2045,7 +2099,8 @@ static int nxp_wifi_set_config(const struct device *dev, enum ethernet_config_ty
20452099
return 0;
20462100
}
20472101

2048-
#if defined(CONFIG_PM_DEVICE) && defined(CONFIG_NXP_RW610)
2102+
#ifdef CONFIG_PM_DEVICE
2103+
#ifdef CONFIG_NXP_RW610
20492104
void device_pm_dump_wakeup_source(void)
20502105
{
20512106
if (POWER_GetWakeupStatus(IMU_IRQ_N)) {
@@ -2059,6 +2114,18 @@ void device_pm_dump_wakeup_source(void)
20592114
POWER_ClearWakeupStatus(32);
20602115
}
20612116
}
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+
}
20622129

20632130
static int device_wlan_pm_action(const struct device *dev, enum pm_device_action pm_action)
20642131
{
@@ -2103,7 +2170,7 @@ static int device_wlan_pm_action(const struct device *dev, enum pm_device_action
21032170
/* If we are not woken up by WLAN, skip posting host sleep exit event.
21042171
* And skip host sleep handshake next time we are about to sleep.
21052172
*/
2106-
if (POWER_GetWakeupStatus(WL_MCI_WAKEUP0_IRQn)) {
2173+
if (nxp_wifi_wlan_wakeup()) {
21072174
ret = wlan_hs_send_event(HOST_SLEEP_EXIT, NULL);
21082175
if (ret != 0) {
21092176
return -EFAULT;
@@ -2112,8 +2179,9 @@ static int device_wlan_pm_action(const struct device *dev, enum pm_device_action
21122179
} else {
21132180
wlan_hs_hanshake_cfg(true);
21142181
}
2115-
2182+
#ifdef CONFIG_NXP_RW610
21162183
device_pm_dump_wakeup_source();
2184+
#endif
21172185
if (wlan_host_sleep_state == HOST_SLEEP_ONESHOT) {
21182186
wlan_host_sleep_state = HOST_SLEEP_DISABLE;
21192187
wlan_hs_hanshake_cfg(false);

dts/bindings/wifi/nxp,wifi.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@ description: |
88
compatible: "nxp,wifi"
99

1010
include: [base.yaml, pinctrl-device.yaml]
11+
12+
properties:
13+
wakeup-gpios:
14+
type: phandle-array
15+
description: |
16+
WLAN wakeup host pin
17+
This pin defaults to active low when consumed by the SDK card. The
18+
property value should ensure the flags properly describ the signal
19+
that is presendted to the driver.

samples/net/wifi/shell/nxp/overlay_iw610.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,9 @@ CONFIG_ETH_DRIVER=n
7070
CONFIG_NET_TC_TX_SKIP_FOR_HIGH_PRIO=y
7171
CONFIG_NET_MGMT_THREAD_PRIORITY=3
7272
CONFIG_NXP_WIFI_DRIVER_TASK_PRIO=2
73+
74+
# power mgmt
75+
CONFIG_PM=y
76+
CONFIG_PM_DEVICE=y
77+
CONFIG_PM_LOG_LEVEL_OFF=y
78+
CONFIG_PM_DEVICE_LOG_LEVEL_OFF=y

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ manifest:
210210
groups:
211211
- hal
212212
- name: hal_nxp
213-
revision: 111f568bda6f119cd896f38ae5843ecde92039bd
213+
revision: pull/566/head
214214
path: modules/hal/nxp
215215
groups:
216216
- hal

0 commit comments

Comments
 (0)