Skip to content

Commit 139802b

Browse files
committed
modules: nrf_wifi: Allow using a regulator for IOVDD
Optionally have a regulator as IOVDD power supply. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
1 parent 2a88cb5 commit 139802b

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

dts/bindings/wifi/nordic,nrf70.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44
properties:
55
iovdd-ctrl-gpios:
66
type: phandle-array
7-
required: true
8-
description: GPIO of the SoC controlling IO_VDD Control pin of the nRF70
7+
description: |
8+
GPIO of the SoC controlling IO_VDD Control pin of the nRF70, either this
9+
or iovdd-regulator needs to be set.
10+
11+
iovdd-regulator:
12+
type: phandle
13+
description: |
14+
Regulator controlling IO_VDD of the nRF70, either this or iovdd-ctrl-gpios
15+
needs to be set.
916
1017
bucken-gpios:
1118
type: phandle-array

modules/nrf_wifi/bus/rpu_hw_if.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,23 @@ LOG_MODULE_REGISTER(wifi_nrf_bus, CONFIG_WIFI_NRF70_BUSLIB_LOG_LEVEL);
2929
static const struct gpio_dt_spec host_irq_spec =
3030
GPIO_DT_SPEC_GET(NRF7002_NODE, host_irq_gpios);
3131

32+
#if DT_NODE_HAS_PROP(NRF7002_NODE, iovdd_ctrl_gpios)
33+
34+
#define NRF70_IOVDD_GPIO 1
3235
static const struct gpio_dt_spec iovdd_ctrl_spec =
3336
GPIO_DT_SPEC_GET(NRF7002_NODE, iovdd_ctrl_gpios);
3437

38+
#elif DT_NODE_HAS_PROP(NRF7002_NODE, iovdd_regulator)
39+
40+
#include <zephyr/drivers/regulator.h>
41+
42+
static const struct device *iovdd_regulator =
43+
DEVICE_DT_GET(DT_PHANDLE(NRF7002_NODE, iovdd_regulator));
44+
45+
#else
46+
#error "nRF70 device either needs iovdd-ctrl-gpios or iovdd-regulator property"
47+
#endif
48+
3549
static const struct gpio_dt_spec bucken_spec =
3650
GPIO_DT_SPEC_GET(NRF7002_NODE, bucken_gpios);
3751

@@ -173,10 +187,12 @@ static int rpu_gpio_config(void)
173187
{
174188
int ret;
175189

190+
#ifdef NRF70_IOVDD_GPIO
176191
if (!device_is_ready(iovdd_ctrl_spec.port)) {
177192
LOG_ERR("IOVDD GPIO %s is not ready", iovdd_ctrl_spec.port->name);
178193
return -ENODEV;
179194
}
195+
#endif
180196

181197
if (!device_is_ready(bucken_spec.port)) {
182198
LOG_ERR("BUCKEN GPIO %s is not ready", bucken_spec.port->name);
@@ -189,12 +205,14 @@ static int rpu_gpio_config(void)
189205
return ret;
190206
}
191207

208+
#ifdef NRF70_IOVDD_GPIO
192209
ret = gpio_pin_configure_dt(&iovdd_ctrl_spec, GPIO_OUTPUT);
193210
if (ret) {
194211
LOG_ERR("IOVDD GPIO configuration failed...");
195212
gpio_pin_configure_dt(&bucken_spec, GPIO_DISCONNECTED);
196213
return ret;
197214
}
215+
#endif
198216

199217
LOG_DBG("GPIO configuration done...\n");
200218

@@ -211,11 +229,13 @@ static int rpu_gpio_remove(void)
211229
return ret;
212230
}
213231

232+
#ifdef NRF70_IOVDD_GPIO
214233
ret = gpio_pin_configure_dt(&iovdd_ctrl_spec, GPIO_DISCONNECTED);
215234
if (ret) {
216235
LOG_ERR("IOVDD GPIO remove failed...");
217236
return ret;
218237
}
238+
#endif
219239

220240
LOG_DBG("GPIO remove done...\n");
221241
return ret;
@@ -233,15 +253,20 @@ static int rpu_pwron(void)
233253
/* Settling time is 50us (H0) or 100us (L0) */
234254
k_msleep(1);
235255

256+
#ifdef NRF70_IOVDD_GPIO
236257
ret = gpio_pin_set_dt(&iovdd_ctrl_spec, 1);
258+
#else
259+
ret = regulator_enable(iovdd_regulator);
260+
#endif
237261
if (ret) {
238-
LOG_ERR("IOVDD GPIO set failed...");
262+
LOG_ERR("IOVDD enable failed...");
239263
gpio_pin_set_dt(&bucken_spec, 0);
240264
return ret;
241265
}
242266
/* Settling time for IOVDD */
243267
k_msleep(DT_PROP(NRF7002_NODE, iovdd_power_up_delay_ms));
244268

269+
#ifdef NRF70_IOVDD_GPIO
245270
if ((bucken_spec.port == iovdd_ctrl_spec.port) &&
246271
(bucken_spec.pin == iovdd_ctrl_spec.pin)) {
247272
/* When a single GPIO is used, we need a total wait time after bucken assertion
@@ -252,6 +277,11 @@ static int rpu_pwron(void)
252277

253278
LOG_DBG("Bucken = %d, IOVDD = %d", gpio_pin_get_dt(&bucken_spec),
254279
gpio_pin_get_dt(&iovdd_ctrl_spec));
280+
#else
281+
LOG_DBG("Bucken = %d, IOVDD = %d", gpio_pin_get_dt(&bucken_spec),
282+
regulator_is_enabled(iovdd_regulator) ? 1 : 0);
283+
#endif
284+
255285

256286
return ret;
257287
}
@@ -260,9 +290,13 @@ static int rpu_pwroff(void)
260290
{
261291
int ret;
262292

293+
#ifdef NRF70_IOVDD_GPIO
263294
ret = gpio_pin_set_dt(&iovdd_ctrl_spec, 0); /* IOVDD CNTRL = 0 */
295+
#else
296+
ret = regulator_disable(iovdd_regulator);
297+
#endif
264298
if (ret) {
265-
LOG_ERR("IOVDD GPIO set failed...");
299+
LOG_ERR("IOVDD disable failed...");
266300
return ret;
267301
}
268302

0 commit comments

Comments
 (0)