diff --git a/boards/shields/nxp_m2_wifi_bt/nxp_m2_2ll_wifi_bt.overlay b/boards/shields/nxp_m2_wifi_bt/nxp_m2_2ll_wifi_bt.overlay index b1d29c15c1d0..5fb1406d636f 100644 --- a/boards/shields/nxp_m2_wifi_bt/nxp_m2_2ll_wifi_bt.overlay +++ b/boards/shields/nxp_m2_wifi_bt/nxp_m2_2ll_wifi_bt.overlay @@ -32,6 +32,7 @@ &m2_wifi_sdio { nxp_wifi { compatible = "nxp,wifi"; + wakeup-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>; status = "okay"; }; }; diff --git a/drivers/wifi/nxp/Kconfig.nxp b/drivers/wifi/nxp/Kconfig.nxp index 49cab155686a..7333e1bbeea8 100644 --- a/drivers/wifi/nxp/Kconfig.nxp +++ b/drivers/wifi/nxp/Kconfig.nxp @@ -402,7 +402,7 @@ menu "Wi-Fi driver Stack configurations" config NXP_WIFI_MON_TASK_STACK_SIZE int "Mon thread stack size" - depends on NXP_RW610 + depends on NXP_RW610 || NXP_IW610 default 3072 help This option specifies the size of the stack used by the mon task. @@ -444,7 +444,7 @@ menu "Wi-Fi thread priority configurations" config NXP_WIFI_MON_TASK_PRIO int "Mon task priority" - depends on NXP_RW610 + depends on NXP_RW610 || NXP_IW610 default 4 help This option specifies the priority of the mon task. diff --git a/drivers/wifi/nxp/nxp_wifi_drv.c b/drivers/wifi/nxp/nxp_wifi_drv.c index a97d15f41cca..f50b9f14c00c 100644 --- a/drivers/wifi/nxp/nxp_wifi_drv.c +++ b/drivers/wifi/nxp/nxp_wifi_drv.c @@ -20,6 +20,9 @@ #include #ifdef CONFIG_PM_DEVICE #include +#ifdef CONFIG_NXP_IW610 +#include +#endif #endif #ifdef CONFIG_WIFI_NM #include @@ -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; @@ -1989,6 +1992,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; @@ -2000,13 +2015,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 +#else +#ifdef CONFIG_PM_DEVICE +#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; } @@ -2045,7 +2099,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)) { @@ -2059,6 +2114,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) { @@ -2103,7 +2170,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; @@ -2112,8 +2179,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); diff --git a/dts/bindings/wifi/nxp,wifi.yaml b/dts/bindings/wifi/nxp,wifi.yaml index 416d334214cd..bbb350266900 100644 --- a/dts/bindings/wifi/nxp,wifi.yaml +++ b/dts/bindings/wifi/nxp,wifi.yaml @@ -8,3 +8,12 @@ description: | compatible: "nxp,wifi" include: [base.yaml, pinctrl-device.yaml] + +properties: + wakeup-gpios: + type: phandle-array + description: | + WLAN wakeup host pin + This pin defaults to active low when consumed by the SDK card. The + property value should ensure the flags properly describ the signal + that is presendted to the driver. diff --git a/samples/net/wifi/shell/nxp/overlay_iw610.conf b/samples/net/wifi/shell/nxp/overlay_iw610.conf index a98e58da10ca..e5c63e948a12 100644 --- a/samples/net/wifi/shell/nxp/overlay_iw610.conf +++ b/samples/net/wifi/shell/nxp/overlay_iw610.conf @@ -70,3 +70,9 @@ CONFIG_ETH_DRIVER=n CONFIG_NET_TC_TX_SKIP_FOR_HIGH_PRIO=y CONFIG_NET_MGMT_THREAD_PRIORITY=3 CONFIG_NXP_WIFI_DRIVER_TASK_PRIO=2 + +# power mgmt +CONFIG_PM=y +CONFIG_PM_DEVICE=y +CONFIG_PM_LOG_LEVEL_OFF=y +CONFIG_PM_DEVICE_LOG_LEVEL_OFF=y diff --git a/west.yml b/west.yml index e079b568d77b..050a65db476f 100644 --- a/west.yml +++ b/west.yml @@ -210,7 +210,7 @@ manifest: groups: - hal - name: hal_nxp - revision: 111f568bda6f119cd896f38ae5843ecde92039bd + revision: pull/566/head path: modules/hal/nxp groups: - hal