@@ -29,9 +29,23 @@ LOG_MODULE_REGISTER(wifi_nrf_bus, CONFIG_WIFI_NRF70_BUSLIB_LOG_LEVEL);
29
29
static const struct gpio_dt_spec host_irq_spec =
30
30
GPIO_DT_SPEC_GET (NRF7002_NODE , host_irq_gpios );
31
31
32
+ #if DT_NODE_HAS_PROP (NRF7002_NODE , iovdd_ctrl_gpios )
33
+
34
+ #define NRF70_IOVDD_GPIO 1
32
35
static const struct gpio_dt_spec iovdd_ctrl_spec =
33
36
GPIO_DT_SPEC_GET (NRF7002_NODE , iovdd_ctrl_gpios );
34
37
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
+
35
49
static const struct gpio_dt_spec bucken_spec =
36
50
GPIO_DT_SPEC_GET (NRF7002_NODE , bucken_gpios );
37
51
@@ -173,10 +187,12 @@ static int rpu_gpio_config(void)
173
187
{
174
188
int ret ;
175
189
190
+ #ifdef NRF70_IOVDD_GPIO
176
191
if (!device_is_ready (iovdd_ctrl_spec .port )) {
177
192
LOG_ERR ("IOVDD GPIO %s is not ready" , iovdd_ctrl_spec .port -> name );
178
193
return - ENODEV ;
179
194
}
195
+ #endif
180
196
181
197
if (!device_is_ready (bucken_spec .port )) {
182
198
LOG_ERR ("BUCKEN GPIO %s is not ready" , bucken_spec .port -> name );
@@ -189,12 +205,14 @@ static int rpu_gpio_config(void)
189
205
return ret ;
190
206
}
191
207
208
+ #ifdef NRF70_IOVDD_GPIO
192
209
ret = gpio_pin_configure_dt (& iovdd_ctrl_spec , GPIO_OUTPUT );
193
210
if (ret ) {
194
211
LOG_ERR ("IOVDD GPIO configuration failed..." );
195
212
gpio_pin_configure_dt (& bucken_spec , GPIO_DISCONNECTED );
196
213
return ret ;
197
214
}
215
+ #endif
198
216
199
217
LOG_DBG ("GPIO configuration done...\n" );
200
218
@@ -211,11 +229,13 @@ static int rpu_gpio_remove(void)
211
229
return ret ;
212
230
}
213
231
232
+ #ifdef NRF70_IOVDD_GPIO
214
233
ret = gpio_pin_configure_dt (& iovdd_ctrl_spec , GPIO_DISCONNECTED );
215
234
if (ret ) {
216
235
LOG_ERR ("IOVDD GPIO remove failed..." );
217
236
return ret ;
218
237
}
238
+ #endif
219
239
220
240
LOG_DBG ("GPIO remove done...\n" );
221
241
return ret ;
@@ -233,15 +253,20 @@ static int rpu_pwron(void)
233
253
/* Settling time is 50us (H0) or 100us (L0) */
234
254
k_msleep (1 );
235
255
256
+ #ifdef NRF70_IOVDD_GPIO
236
257
ret = gpio_pin_set_dt (& iovdd_ctrl_spec , 1 );
258
+ #else
259
+ ret = regulator_enable (iovdd_regulator );
260
+ #endif
237
261
if (ret ) {
238
- LOG_ERR ("IOVDD GPIO set failed..." );
262
+ LOG_ERR ("IOVDD enable failed..." );
239
263
gpio_pin_set_dt (& bucken_spec , 0 );
240
264
return ret ;
241
265
}
242
266
/* Settling time for IOVDD */
243
267
k_msleep (DT_PROP (NRF7002_NODE , iovdd_power_up_delay_ms ));
244
268
269
+ #ifdef NRF70_IOVDD_GPIO
245
270
if ((bucken_spec .port == iovdd_ctrl_spec .port ) &&
246
271
(bucken_spec .pin == iovdd_ctrl_spec .pin )) {
247
272
/* When a single GPIO is used, we need a total wait time after bucken assertion
@@ -252,6 +277,11 @@ static int rpu_pwron(void)
252
277
253
278
LOG_DBG ("Bucken = %d, IOVDD = %d" , gpio_pin_get_dt (& bucken_spec ),
254
279
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
+
255
285
256
286
return ret ;
257
287
}
@@ -260,9 +290,13 @@ static int rpu_pwroff(void)
260
290
{
261
291
int ret ;
262
292
293
+ #ifdef NRF70_IOVDD_GPIO
263
294
ret = gpio_pin_set_dt (& iovdd_ctrl_spec , 0 ); /* IOVDD CNTRL = 0 */
295
+ #else
296
+ ret = regulator_disable (iovdd_regulator );
297
+ #endif
264
298
if (ret ) {
265
- LOG_ERR ("IOVDD GPIO set failed..." );
299
+ LOG_ERR ("IOVDD disable failed..." );
266
300
return ret ;
267
301
}
268
302
0 commit comments