Skip to content

Commit 33a110d

Browse files
committed
drivers: pinctrl: nrf: Optimize access to gpd service
Request and release global power domain only once during setup of pins. Request and release involves communication over IPC and it should be avoided if possible. For example if there are 4 pins (like in UART) where GPD is requested we can limit number of request/release operations fourfold. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 24c2c43 commit 33a110d

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

drivers/pinctrl/pinctrl_nrf.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ static const nrf_gpio_pin_drive_t drive_modes[NRF_DRIVE_COUNT] = {
9797
int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
9898
uintptr_t reg)
9999
{
100+
#ifdef CONFIG_SOC_NRF54H20_GPD
101+
bool gpd_requested = false;
102+
#endif
103+
100104
for (uint8_t i = 0U; i < pin_cnt; i++) {
101105
nrf_gpio_pin_drive_t drive;
102106
uint8_t drive_idx = NRF_GET_DRIVE(pins[i]);
@@ -357,13 +361,17 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
357361

358362
#ifdef CONFIG_SOC_NRF54H20_GPD
359363
if (NRF_GET_GPD_FAST_ACTIVE1(pins[i]) == 1U) {
360-
int ret;
361364
uint32_t d_pin = pin;
362365
NRF_GPIO_Type *port = nrf_gpio_pin_port_decode(&d_pin);
363366

364-
ret = nrf_gpd_request(NRF_GPD_SLOW_ACTIVE);
365-
if (ret < 0) {
366-
return ret;
367+
if (!gpd_requested) {
368+
int ret;
369+
370+
ret = nrf_gpd_request(NRF_GPD_SLOW_ACTIVE);
371+
if (ret < 0) {
372+
return ret;
373+
}
374+
gpd_requested = true;
367375
}
368376

369377
port->RETAINCLR = BIT(d_pin);
@@ -387,20 +395,26 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
387395
#endif
388396
#ifdef CONFIG_SOC_NRF54H20_GPD
389397
if (NRF_GET_GPD_FAST_ACTIVE1(pins[i]) == 1U) {
390-
int ret;
391398
uint32_t d_pin = pin;
392399
NRF_GPIO_Type *port = nrf_gpio_pin_port_decode(&d_pin);
393400

394401
port->RETAINSET = BIT(d_pin);
395402

396-
ret = nrf_gpd_release(NRF_GPD_SLOW_ACTIVE);
397-
if (ret < 0) {
398-
return ret;
399-
}
400403
}
401404
#endif /* CONFIG_SOC_NRF54H20_GPD */
402405
}
403406
}
404407

408+
#ifdef CONFIG_SOC_NRF54H20_GPD
409+
if (gpd_requested) {
410+
int ret;
411+
412+
ret = nrf_gpd_release(NRF_GPD_SLOW_ACTIVE);
413+
if (ret < 0) {
414+
return ret;
415+
}
416+
}
417+
#endif
418+
405419
return 0;
406420
}

0 commit comments

Comments
 (0)