Skip to content

Commit 0d2e895

Browse files
abhinavnxpcfriedt
authored andcommitted
boards: shields: nxp_m2_wifi_bt: overlay update
- Updated shield overlay file for RT1060 with sdio power and reset pins - added device tree node in sdhc for sd reset pin - added power gpio toggle logic Signed-off-by: Abhinav Kulkarni <[email protected]>
1 parent 84b2bd5 commit 0d2e895

File tree

4 files changed

+106
-3
lines changed

4 files changed

+106
-3
lines changed

boards/shields/nxp_m2_wifi_bt/boards/mimxrt1060_evk_mimxrt1062_qspi_C.overlay

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
pinctrl-names = "default", "slow", "med", "fast", "nopull";
3535
};
3636

37+
&usdhc1 {
38+
nxp_wifi {
39+
pwr-gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>;
40+
sd-gpios = <&gpio1 24 GPIO_ACTIVE_HIGH>;
41+
};
42+
};
43+
3744
&pinctrl {
3845
/* removes pull on dat3 for card detect */
3946
pinmux_usdhc1_dat3_nopull: pinmux_usdhc1_dat3_nopull {

drivers/wifi/nxp/nxp_wifi_drv.c

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2023-2024 NXP
2+
* Copyright 2023-2025 NXP
33
* SPDX-License-Identifier: Apache-2.0
44
*
55
* @file nxp_wifi_drv.c
@@ -394,6 +394,77 @@ int nxp_wifi_wlan_event_callback(enum wlan_event_reason reason, void *data)
394394
return 0;
395395
}
396396

397+
static int nxp_wifi_cpu_reset(uint8_t enable)
398+
{
399+
int err = 0;
400+
#if DT_NODE_HAS_PROP(DT_DRV_INST(0), sd_gpios) && \
401+
DT_NODE_HAS_PROP(DT_DRV_INST(0), pwr_gpios)
402+
403+
struct gpio_dt_spec sdio_reset = GPIO_DT_SPEC_GET(DT_DRV_INST(0), sd_gpios);
404+
struct gpio_dt_spec pwr_gpios = GPIO_DT_SPEC_GET(DT_DRV_INST(0), pwr_gpios);
405+
406+
if (!gpio_is_ready_dt(&sdio_reset)) {
407+
LOG_ERR("Error: failed to configure sdio_reset %s pin %d", sdio_reset.port->name,
408+
sdio_reset.pin);
409+
return -EIO;
410+
}
411+
412+
/* Configure sdio_reset as output */
413+
err = gpio_pin_configure_dt(&sdio_reset, GPIO_OUTPUT);
414+
if (err) {
415+
LOG_ERR("Error %d: failed to configure sdio_reset %s pin %d", err,
416+
sdio_reset.port->name, sdio_reset.pin);
417+
return err;
418+
}
419+
420+
if (!gpio_is_ready_dt(&pwr_gpios)) {
421+
LOG_ERR("Error: failed to configure pwr_gpios %s pin %d", pwr_gpios.port->name,
422+
pwr_gpios.pin);
423+
return -EIO;
424+
}
425+
426+
/* Configure wlan-power-io as an output */
427+
err = gpio_pin_configure_dt(&pwr_gpios, GPIO_OUTPUT);
428+
if (err) {
429+
LOG_ERR("Error %d: failed to configure pwr_gpios %s pin %d", err,
430+
pwr_gpios.port->name, pwr_gpios.pin);
431+
return err;
432+
}
433+
434+
if (enable) {
435+
/* Set SDIO reset pin as high */
436+
err = gpio_pin_set_dt(&sdio_reset, 1);
437+
if (err) {
438+
return err;
439+
}
440+
/* wait for reset done */
441+
k_sleep(K_MSEC(100));
442+
443+
/* Set power gpio pin as high */
444+
err = gpio_pin_set_dt(&pwr_gpios, 1);
445+
if (err) {
446+
return err;
447+
}
448+
} else {
449+
/* Set SDIO reset pin as low */
450+
err = gpio_pin_set_dt(&sdio_reset, 0);
451+
if (err) {
452+
return err;
453+
}
454+
455+
/* Set power gpio pin as low */
456+
err = gpio_pin_set_dt(&pwr_gpios, 0);
457+
if (err) {
458+
return err;
459+
}
460+
}
461+
/* wait for reset done */
462+
k_sleep(K_MSEC(100));
463+
#endif
464+
465+
return err;
466+
}
467+
397468
static int nxp_wifi_wlan_init(void)
398469
{
399470
int status = NXP_WIFI_RET_SUCCESS;
@@ -407,7 +478,9 @@ static int nxp_wifi_wlan_init(void)
407478
k_event_init(&s_nxp_wifi_SyncEvent);
408479
}
409480

410-
if (status == NXP_WIFI_RET_SUCCESS) {
481+
ret = nxp_wifi_cpu_reset(true);
482+
483+
if ((status == NXP_WIFI_RET_SUCCESS) && (ret == 0)) {
411484
ret = wlan_init(wlan_fw_bin, wlan_fw_bin_len);
412485
if (ret != WM_SUCCESS) {
413486
status = NXP_WIFI_RET_FAIL;

dts/bindings/sdhc/nxp,imx-usdhc.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ properties:
4646
property value should ensure the flags properly describe the signal
4747
that is presented to the driver.
4848
49+
sd-gpios:
50+
type: phandle-array
51+
description: |
52+
SDIO Reset pin
53+
This pin defaults to active high when consumed by the SD card. The
54+
property value should ensure the flags properly describe the signal
55+
that is presented to the driver.
56+
4957
cd-gpios:
5058
type: phandle-array
5159
description: |

dts/bindings/wifi/nxp,wifi.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023-2024 NXP
1+
# Copyright 2023-2025 NXP
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -17,3 +17,18 @@ properties:
1717
This pin defaults to active low when consumed by the SDK card. The
1818
property value should ensure the flags properly describ the signal
1919
that is presendted to the driver.
20+
pwr-gpios:
21+
type: phandle-array
22+
description: |
23+
Power pin
24+
This pin defaults to active high when consumed by the wlan cpu power.
25+
The property value should ensure the flags properly describe the signal
26+
that is presented to the driver.
27+
28+
sd-gpios:
29+
type: phandle-array
30+
description: |
31+
SDIO Reset pin
32+
This pin defaults to active high when consumed by the SD card. The
33+
property value should ensure the flags properly describe the signal
34+
that is presented to the driver.

0 commit comments

Comments
 (0)