Skip to content

Commit 48ff7da

Browse files
committed
drivers: wifi: Add WLAN wakeup for MIMXRT1060-EVK
Added wlan wakeup pin in MIMXRT1060-EVK dts 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 <[email protected]>
1 parent 94a6c1f commit 48ff7da

File tree

6 files changed

+93
-8
lines changed

6 files changed

+93
-8
lines changed

boards/nxp/mimxrt1060_evk/mimxrt1060_evk.dtsi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ zephyr_uhc1: &usbh2 {
256256
disk-name = "SD";
257257
status = "okay";
258258
};
259+
nxp_wifi {
260+
compatible = "nxp,wifi";
261+
wakeup-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
262+
status = "okay";
263+
};
259264
};
260265

261266
&edma0 {

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: 70 additions & 5 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,16 @@ extern void WL_MCI_WAKEUP0_DriverIRQHandler(void);
19891992
extern void WL_MCI_WAKEUP_DONE0_DriverIRQHandler(void);
19901993
#endif
19911994

1995+
#ifdef CONFIG_NXP_IW610
1996+
struct gpio_callback wakeup_callback;
1997+
1998+
static void gpio_wakeup_callback(const struct device *port, struct gpio_callback *cb,
1999+
gpio_port_pins_t pins)
2000+
{
2001+
/* TODO: Reserved for future use. */
2002+
}
2003+
#endif
2004+
19922005
static int nxp_wifi_dev_init(const struct device *dev)
19932006
{
19942007
struct nxp_wifi_dev *nxp_wifi = &nxp_wifi0;
@@ -2000,11 +2013,49 @@ static int nxp_wifi_dev_init(const struct device *dev)
20002013
#ifdef CONFIG_NXP_RW610
20012014
IRQ_CONNECT(IMU_IRQ_N, IMU_IRQ_P, WL_MCI_WAKEUP0_DriverIRQHandler, 0, 0);
20022015
irq_enable(IMU_IRQ_N);
2003-
IRQ_CONNECT(IMU_WAKEUP_IRQ_N, IMU_WAKEUP_IRQ_P, WL_MCI_WAKEUP_DONE0_DriverIRQHandler, 0, 0);
2016+
IRQ_CONNECT(IMU_WAKEUP_IRQ_N, IMU_WAKEUP_IRQ_P,
2017+
WL_MCI_WAKEUP_DONE0_DriverIRQHandler, 0, 0);
20042018
irq_enable(IMU_WAKEUP_IRQ_N);
20052019
#if (DT_INST_PROP(0, wakeup_source))
20062020
EnableDeepSleepIRQ(IMU_IRQ_N);
20072021
#endif
2022+
#else
2023+
#if DT_NODE_HAS_PROP(DT_DRV_INST(0), wakeup_gpios)
2024+
int err = 0;
2025+
struct gpio_dt_spec wakeup = GPIO_DT_SPEC_GET(DT_DRV_INST(0), wakeup_gpios);
2026+
2027+
if (!gpio_is_ready_dt(&wakeup)) {
2028+
LOG_ERR("Error: failed to configure wakeup %s pin %d", wakeup.port->name,
2029+
wakeup.pin);
2030+
return -EIO;
2031+
}
2032+
2033+
/* Configure wakeup gpio as input */
2034+
err = gpio_pin_configure_dt(&wakeup, GPIO_INPUT);
2035+
if (err) {
2036+
LOG_ERR("Error %d: failed to configure wakeup %s pin %d", err,
2037+
wakeup.port->name, wakeup.pin);
2038+
return err;
2039+
}
2040+
2041+
err = gpio_pin_set_dt(&wakeup, 0);
2042+
if (err) {
2043+
return err;
2044+
}
2045+
2046+
/* Configure wakeup gpio interrupt */
2047+
err = gpio_pin_interrupt_configure_dt(&wakeup, GPIO_INT_EDGE_FALLING);
2048+
if (err) {
2049+
return err;
2050+
}
2051+
2052+
/* Set wakeup gpio callback function */
2053+
gpio_init_callback(&wakeup_callback, gpio_wakeup_callback, BIT(wakeup.pin));
2054+
err = gpio_add_callback_dt(&wakeup, &wakeup_callback);
2055+
if (err) {
2056+
return err;
2057+
}
2058+
#endif
20082059
#endif
20092060

20102061
return 0;
@@ -2045,7 +2096,8 @@ static int nxp_wifi_set_config(const struct device *dev, enum ethernet_config_ty
20452096
return 0;
20462097
}
20472098

2048-
#if defined(CONFIG_PM_DEVICE) && defined(CONFIG_NXP_RW610)
2099+
#ifdef CONFIG_PM_DEVICE
2100+
#ifdef CONFIG_NXP_RW610
20492101
void device_pm_dump_wakeup_source(void)
20502102
{
20512103
if (POWER_GetWakeupStatus(IMU_IRQ_N)) {
@@ -2059,6 +2111,18 @@ void device_pm_dump_wakeup_source(void)
20592111
POWER_ClearWakeupStatus(32);
20602112
}
20612113
}
2114+
#endif
2115+
2116+
static bool nxp_wifi_wlan_wakeup(void)
2117+
{
2118+
#ifdef CONFIG_NXP_RW610
2119+
return POWER_GetWakeupStatus(WL_MCI_WAKEUP0_IRQn);
2120+
#elif CONFIG_NXP_IW610
2121+
return GPC_GetIRQStatusFlag(GPC, GPIO1_Combined_0_15_IRQn);
2122+
#else
2123+
return false;
2124+
#endif
2125+
}
20622126

20632127
static int device_wlan_pm_action(const struct device *dev, enum pm_device_action pm_action)
20642128
{
@@ -2103,7 +2167,7 @@ static int device_wlan_pm_action(const struct device *dev, enum pm_device_action
21032167
/* If we are not woken up by WLAN, skip posting host sleep exit event.
21042168
* And skip host sleep handshake next time we are about to sleep.
21052169
*/
2106-
if (POWER_GetWakeupStatus(WL_MCI_WAKEUP0_IRQn)) {
2170+
if (nxp_wifi_wlan_wakeup()) {
21072171
ret = wlan_hs_send_event(HOST_SLEEP_EXIT, NULL);
21082172
if (ret != 0) {
21092173
return -EFAULT;
@@ -2112,8 +2176,9 @@ static int device_wlan_pm_action(const struct device *dev, enum pm_device_action
21122176
} else {
21132177
wlan_hs_hanshake_cfg(true);
21142178
}
2115-
2179+
#ifdef CONFIG_NXP_RW610
21162180
device_pm_dump_wakeup_source();
2181+
#endif
21172182
if (wlan_host_sleep_state == HOST_SLEEP_ONESHOT) {
21182183
wlan_host_sleep_state = HOST_SLEEP_DISABLE;
21192184
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/boards/mimxrt1060_evk_mimxrt1062_qspi_C.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@ CONFIG_SPEED_OPTIMIZATIONS=y
4444

4545
# comment out for -O0
4646
CONFIG_CODE_DATA_RELOCATION_SRAM=y
47+
48+
# power mgmt
49+
CONFIG_PM=y
50+
CONFIG_PM_DEVICE=y
51+
CONFIG_PM_LOG_LEVEL_OFF=y
52+
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)