16
16
17
17
#include <zephyr/drivers/gpio/gpio_utils.h>
18
18
19
- #ifdef CONFIG_SOC_NRF54H20_GPD
20
- #include <nrf/gpd.h>
19
+ #if DT_HAS_COMPAT_STATUS_OKAY (nordic_nrf_gpio_pad_group )
20
+ #define NRF_GPIO_HAS_PAD_GROUP 1
21
+ #else
22
+ #define NRF_GPIO_HAS_PAD_GROUP 0
21
23
#endif
22
24
23
25
struct gpio_nrfx_data {
@@ -33,8 +35,8 @@ struct gpio_nrfx_cfg {
33
35
uint32_t edge_sense ;
34
36
uint8_t port_num ;
35
37
nrfx_gpiote_t gpiote ;
36
- #ifdef CONFIG_SOC_NRF54H20_GPD
37
- uint8_t pad_pd ;
38
+ #if NRF_GPIO_HAS_PAD_GROUP
39
+ const struct device * pad_group ;
38
40
#endif
39
41
};
40
42
@@ -64,30 +66,6 @@ static nrf_gpio_pin_pull_t get_pull(gpio_flags_t flags)
64
66
return NRF_GPIO_PIN_NOPULL ;
65
67
}
66
68
67
- static void gpio_nrfx_gpd_retain_set (const struct device * port , uint32_t mask )
68
- {
69
- #ifdef CONFIG_SOC_NRF54H20_GPD
70
- const struct gpio_nrfx_cfg * cfg = get_port_cfg (port );
71
-
72
- nrf_gpio_port_retain_enable (cfg -> port , mask );
73
- #else
74
- ARG_UNUSED (port );
75
- ARG_UNUSED (mask );
76
- #endif
77
- }
78
-
79
- static void gpio_nrfx_gpd_retain_clear (const struct device * port , uint32_t mask )
80
- {
81
- #ifdef CONFIG_SOC_NRF54H20_GPD
82
- const struct gpio_nrfx_cfg * cfg = get_port_cfg (port );
83
-
84
- nrf_gpio_port_retain_disable (cfg -> port , mask );
85
- #else
86
- ARG_UNUSED (port );
87
- ARG_UNUSED (mask );
88
- #endif
89
- }
90
-
91
69
static int gpio_nrfx_pin_configure (const struct device * port , gpio_pin_t pin ,
92
70
gpio_flags_t flags )
93
71
{
@@ -134,8 +112,6 @@ static int gpio_nrfx_pin_configure(const struct device *port, gpio_pin_t pin,
134
112
return ret ;
135
113
}
136
114
137
- gpio_nrfx_gpd_retain_clear (port , BIT (pin ));
138
-
139
115
if (flags & GPIO_OUTPUT_INIT_HIGH ) {
140
116
nrf_gpio_port_out_set (cfg -> port , BIT (pin ));
141
117
} else if (flags & GPIO_OUTPUT_INIT_LOW ) {
@@ -216,7 +192,6 @@ static int gpio_nrfx_pin_configure(const struct device *port, gpio_pin_t pin,
216
192
}
217
193
218
194
end :
219
- gpio_nrfx_gpd_retain_set (port , BIT (pin ));
220
195
return pm_device_runtime_put (port );
221
196
}
222
197
@@ -317,10 +292,8 @@ static int gpio_nrfx_port_set_masked_raw(const struct device *port,
317
292
return ret ;
318
293
}
319
294
320
- gpio_nrfx_gpd_retain_clear (port , mask );
321
295
nrf_gpio_port_out_set (reg , set_mask );
322
296
nrf_gpio_port_out_clear (reg , clear_mask );
323
- gpio_nrfx_gpd_retain_set (port , mask );
324
297
return pm_device_runtime_put (port );
325
298
}
326
299
@@ -335,9 +308,7 @@ static int gpio_nrfx_port_set_bits_raw(const struct device *port,
335
308
return ret ;
336
309
}
337
310
338
- gpio_nrfx_gpd_retain_clear (port , mask );
339
311
nrf_gpio_port_out_set (reg , mask );
340
- gpio_nrfx_gpd_retain_set (port , mask );
341
312
return pm_device_runtime_put (port );
342
313
}
343
314
@@ -352,9 +323,7 @@ static int gpio_nrfx_port_clear_bits_raw(const struct device *port,
352
323
return ret ;
353
324
}
354
325
355
- gpio_nrfx_gpd_retain_clear (port , mask );
356
326
nrf_gpio_port_out_clear (reg , mask );
357
- gpio_nrfx_gpd_retain_set (port , mask );
358
327
return pm_device_runtime_put (port );
359
328
}
360
329
@@ -372,10 +341,8 @@ static int gpio_nrfx_port_toggle_bits(const struct device *port,
372
341
return ret ;
373
342
}
374
343
375
- gpio_nrfx_gpd_retain_clear (port , mask );
376
344
nrf_gpio_port_out_set (reg , set_mask );
377
345
nrf_gpio_port_out_clear (reg , clear_mask );
378
- gpio_nrfx_gpd_retain_set (port , mask );
379
346
return pm_device_runtime_put (port );
380
347
}
381
348
@@ -546,14 +513,10 @@ static void nrfx_gpio_handler(nrfx_gpiote_pin_t abs_pin,
546
513
547
514
static int gpio_nrfx_pm_suspend (const struct device * port )
548
515
{
549
- #ifdef CONFIG_SOC_NRF54H20_GPD
516
+ #if NRF_GPIO_HAS_PAD_GROUP
550
517
const struct gpio_nrfx_cfg * cfg = get_port_cfg (port );
551
518
552
- if (cfg -> pad_pd != NRF_GPD_FAST_ACTIVE1 ) {
553
- return 0 ;
554
- }
555
-
556
- return nrf_gpd_release (NRF_GPD_FAST_ACTIVE1 );
519
+ return pm_device_runtime_put (cfg -> pad_group );
557
520
#else
558
521
ARG_UNUSED (port );
559
522
return 0 ;
@@ -562,14 +525,10 @@ static int gpio_nrfx_pm_suspend(const struct device *port)
562
525
563
526
static int gpio_nrfx_pm_resume (const struct device * port )
564
527
{
565
- #ifdef CONFIG_SOC_NRF54H20_GPD
528
+ #if NRF_GPIO_HAS_PAD_GROUP
566
529
const struct gpio_nrfx_cfg * cfg = get_port_cfg (port );
567
530
568
- if (cfg -> pad_pd != NRF_GPD_FAST_ACTIVE1 ) {
569
- return 0 ;
570
- }
571
-
572
- return nrf_gpd_request (NRF_GPD_FAST_ACTIVE1 );
531
+ return pm_device_runtime_get (cfg -> pad_group );
573
532
#else
574
533
ARG_UNUSED (port );
575
534
return 0 ;
@@ -660,12 +619,11 @@ static DEVICE_API(gpio, gpio_nrfx_drv_api_funcs) = {
660
619
"Please enable GPIOTE instance for used GPIO port!")), \
661
620
())
662
621
663
- #ifdef CONFIG_SOC_NRF54H20_GPD
664
- #define PAD_PD (inst ) \
665
- .pad_pd = DT_INST_PHA_BY_NAME_OR(inst, power_domains, pad, id, \
666
- NRF_GPD_SLOW_MAIN),
622
+ #if NRF_GPIO_HAS_PAD_GROUP
623
+ #define GPIO_NRF_PAD_GROUP_INIT (id ) \
624
+ .pad_group = DEVICE_DT_GET(DT_INST_CHILD(id, pad_group)),
667
625
#else
668
- #define PAD_PD ( inst )
626
+ #define GPIO_NRF_PAD_GROUP_INIT ( id )
669
627
#endif
670
628
671
629
#define GPIO_NRF_DEVICE (id ) \
@@ -679,7 +637,7 @@ static DEVICE_API(gpio, gpio_nrfx_drv_api_funcs) = {
679
637
.port_num = DT_INST_PROP(id, port), \
680
638
.edge_sense = DT_INST_PROP_OR(id, sense_edge_mask, 0), \
681
639
.gpiote = GPIOTE_INSTANCE(id), \
682
- PAD_PD (id) \
640
+ GPIO_NRF_PAD_GROUP_INIT (id) \
683
641
}; \
684
642
\
685
643
static struct gpio_nrfx_data gpio_nrfx_p##id##_data; \
0 commit comments