Skip to content

Commit 39b61d7

Browse files
bjarki-andreasencarlescufi
authored andcommitted
[nrf fromtree] drivers: gpio: nrfx: extend pin retain to every pin
The usage of nrf_gpio_port_retain_disable/_enable, in cases where the soc pins support retention, every pin must be retained/unretained regardless of what power domain the pad is in. This patch ensures retain is applied to all pins in all domains by the gpio_nrfx device driver, not only pins specifically in the fast_active_1 domain. Without this patch, pinctrl will correctly retain pins, while gpio_nrfx will fail to unretain them when again. We no longer check the output state either, which was passed with the flags arg of gpio_nrfx_gpd_retain_set() so this arg has been removed. Signed-off-by: Bjarki Arge Andreasen <[email protected]> (cherry picked from commit 691b335)
1 parent a4a4579 commit 39b61d7

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

drivers/gpio/gpio_nrfx.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,15 @@ static nrf_gpio_pin_pull_t get_pull(gpio_flags_t flags)
6464
return NRF_GPIO_PIN_NOPULL;
6565
}
6666

67-
static void gpio_nrfx_gpd_retain_set(const struct device *port, uint32_t mask, gpio_flags_t flags)
67+
static void gpio_nrfx_gpd_retain_set(const struct device *port, uint32_t mask)
6868
{
6969
#ifdef CONFIG_SOC_NRF54H20_GPD
7070
const struct gpio_nrfx_cfg *cfg = get_port_cfg(port);
7171

72-
if (cfg->pad_pd != NRF_GPD_FAST_ACTIVE1 || !(flags & GPIO_OUTPUT)) {
73-
return;
74-
}
75-
7672
nrf_gpio_port_retain_enable(cfg->port, mask);
7773
#else
7874
ARG_UNUSED(port);
7975
ARG_UNUSED(mask);
80-
ARG_UNUSED(flags);
8176
#endif
8277
}
8378

@@ -86,10 +81,6 @@ static void gpio_nrfx_gpd_retain_clear(const struct device *port, uint32_t mask)
8681
#ifdef CONFIG_SOC_NRF54H20_GPD
8782
const struct gpio_nrfx_cfg *cfg = get_port_cfg(port);
8883

89-
if (cfg->pad_pd != NRF_GPD_FAST_ACTIVE1) {
90-
return;
91-
}
92-
9384
nrf_gpio_port_retain_disable(cfg->port, mask);
9485
#else
9586
ARG_UNUSED(port);
@@ -225,7 +216,7 @@ static int gpio_nrfx_pin_configure(const struct device *port, gpio_pin_t pin,
225216
}
226217

227218
end:
228-
gpio_nrfx_gpd_retain_set(port, BIT(pin), flags);
219+
gpio_nrfx_gpd_retain_set(port, BIT(pin));
229220
return pm_device_runtime_put(port);
230221
}
231222

@@ -329,7 +320,7 @@ static int gpio_nrfx_port_set_masked_raw(const struct device *port,
329320
gpio_nrfx_gpd_retain_clear(port, mask);
330321
nrf_gpio_port_out_set(reg, set_mask);
331322
nrf_gpio_port_out_clear(reg, clear_mask);
332-
gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT);
323+
gpio_nrfx_gpd_retain_set(port, mask);
333324
return pm_device_runtime_put(port);
334325
}
335326

@@ -346,7 +337,7 @@ static int gpio_nrfx_port_set_bits_raw(const struct device *port,
346337

347338
gpio_nrfx_gpd_retain_clear(port, mask);
348339
nrf_gpio_port_out_set(reg, mask);
349-
gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT);
340+
gpio_nrfx_gpd_retain_set(port, mask);
350341
return pm_device_runtime_put(port);
351342
}
352343

@@ -363,7 +354,7 @@ static int gpio_nrfx_port_clear_bits_raw(const struct device *port,
363354

364355
gpio_nrfx_gpd_retain_clear(port, mask);
365356
nrf_gpio_port_out_clear(reg, mask);
366-
gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT);
357+
gpio_nrfx_gpd_retain_set(port, mask);
367358
return pm_device_runtime_put(port);
368359
}
369360

@@ -384,7 +375,7 @@ static int gpio_nrfx_port_toggle_bits(const struct device *port,
384375
gpio_nrfx_gpd_retain_clear(port, mask);
385376
nrf_gpio_port_out_set(reg, set_mask);
386377
nrf_gpio_port_out_clear(reg, clear_mask);
387-
gpio_nrfx_gpd_retain_set(port, mask, GPIO_OUTPUT);
378+
gpio_nrfx_gpd_retain_set(port, mask);
388379
return pm_device_runtime_put(port);
389380
}
390381

0 commit comments

Comments
 (0)