1616
1717#include <zephyr/drivers/gpio/gpio_utils.h>
1818
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
2123#endif
2224
2325struct gpio_nrfx_data {
@@ -33,8 +35,8 @@ struct gpio_nrfx_cfg {
3335 uint32_t edge_sense ;
3436 uint8_t port_num ;
3537 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 ;
3840#endif
3941};
4042
@@ -64,30 +66,6 @@ static nrf_gpio_pin_pull_t get_pull(gpio_flags_t flags)
6466 return NRF_GPIO_PIN_NOPULL ;
6567}
6668
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-
9169static int gpio_nrfx_pin_configure (const struct device * port , gpio_pin_t pin ,
9270 gpio_flags_t flags )
9371{
@@ -134,8 +112,6 @@ static int gpio_nrfx_pin_configure(const struct device *port, gpio_pin_t pin,
134112 return ret ;
135113 }
136114
137- gpio_nrfx_gpd_retain_clear (port , BIT (pin ));
138-
139115 if (flags & GPIO_OUTPUT_INIT_HIGH ) {
140116 nrf_gpio_port_out_set (cfg -> port , BIT (pin ));
141117 } 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,
216192 }
217193
218194end :
219- gpio_nrfx_gpd_retain_set (port , BIT (pin ));
220195 return pm_device_runtime_put (port );
221196}
222197
@@ -317,10 +292,8 @@ static int gpio_nrfx_port_set_masked_raw(const struct device *port,
317292 return ret ;
318293 }
319294
320- gpio_nrfx_gpd_retain_clear (port , mask );
321295 nrf_gpio_port_out_set (reg , set_mask );
322296 nrf_gpio_port_out_clear (reg , clear_mask );
323- gpio_nrfx_gpd_retain_set (port , mask );
324297 return pm_device_runtime_put (port );
325298}
326299
@@ -335,9 +308,7 @@ static int gpio_nrfx_port_set_bits_raw(const struct device *port,
335308 return ret ;
336309 }
337310
338- gpio_nrfx_gpd_retain_clear (port , mask );
339311 nrf_gpio_port_out_set (reg , mask );
340- gpio_nrfx_gpd_retain_set (port , mask );
341312 return pm_device_runtime_put (port );
342313}
343314
@@ -352,9 +323,7 @@ static int gpio_nrfx_port_clear_bits_raw(const struct device *port,
352323 return ret ;
353324 }
354325
355- gpio_nrfx_gpd_retain_clear (port , mask );
356326 nrf_gpio_port_out_clear (reg , mask );
357- gpio_nrfx_gpd_retain_set (port , mask );
358327 return pm_device_runtime_put (port );
359328}
360329
@@ -372,10 +341,8 @@ static int gpio_nrfx_port_toggle_bits(const struct device *port,
372341 return ret ;
373342 }
374343
375- gpio_nrfx_gpd_retain_clear (port , mask );
376344 nrf_gpio_port_out_set (reg , set_mask );
377345 nrf_gpio_port_out_clear (reg , clear_mask );
378- gpio_nrfx_gpd_retain_set (port , mask );
379346 return pm_device_runtime_put (port );
380347}
381348
@@ -546,14 +513,10 @@ static void nrfx_gpio_handler(nrfx_gpiote_pin_t abs_pin,
546513
547514static int gpio_nrfx_pm_suspend (const struct device * port )
548515{
549- #ifdef CONFIG_SOC_NRF54H20_GPD
516+ #if NRF_GPIO_HAS_PAD_GROUP
550517 const struct gpio_nrfx_cfg * cfg = get_port_cfg (port );
551518
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 );
557520#else
558521 ARG_UNUSED (port );
559522 return 0 ;
@@ -562,14 +525,10 @@ static int gpio_nrfx_pm_suspend(const struct device *port)
562525
563526static int gpio_nrfx_pm_resume (const struct device * port )
564527{
565- #ifdef CONFIG_SOC_NRF54H20_GPD
528+ #if NRF_GPIO_HAS_PAD_GROUP
566529 const struct gpio_nrfx_cfg * cfg = get_port_cfg (port );
567530
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 );
573532#else
574533 ARG_UNUSED (port );
575534 return 0 ;
@@ -660,12 +619,11 @@ static DEVICE_API(gpio, gpio_nrfx_drv_api_funcs) = {
660619 "Please enable GPIOTE instance for used GPIO port!")), \
661620 ())
662621
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)),
667625#else
668- #define PAD_PD ( inst )
626+ #define GPIO_NRF_PAD_GROUP_INIT ( id )
669627#endif
670628
671629#define GPIO_NRF_DEVICE (id ) \
@@ -679,7 +637,7 @@ static DEVICE_API(gpio, gpio_nrfx_drv_api_funcs) = {
679637 .port_num = DT_INST_PROP(id, port), \
680638 .edge_sense = DT_INST_PROP_OR(id, sense_edge_mask, 0), \
681639 .gpiote = GPIOTE_INSTANCE(id), \
682- PAD_PD (id) \
640+ GPIO_NRF_PAD_GROUP_INIT (id) \
683641 }; \
684642 \
685643 static struct gpio_nrfx_data gpio_nrfx_p##id##_data; \
0 commit comments