Skip to content

Commit e7dcac6

Browse files
committed
drivers: serial: nrfx_uarte: Retain pins only when needed
Since pin retantion is done as a part of suspend/resume which is done in the critical section, it shall be done only when needed. Use DT flag to determine which UARTE instance needs it. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 409bd99 commit e7dcac6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

drivers/serial/uart_nrfx_uarte.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ struct uarte_nrfx_data {
242242
/* If enabled then UARTE peripheral is using memory which is cacheable. */
243243
#define UARTE_CFG_FLAG_CACHEABLE BIT(3)
244244

245+
/* If enabled then pins must be retained when UARTE is disabled. */
246+
#define UARTE_CFG_FLAG_RETAIN_PINS BIT(4)
247+
245248
/* Macro for converting numerical baudrate to register value. It is convenient
246249
* to use this approach because for constant input it can calculate nrf setting
247250
* at compile time.
@@ -591,7 +594,9 @@ static void uarte_periph_enable(const struct device *dev)
591594
(void)data;
592595
nrf_uarte_enable(uarte);
593596
#ifdef CONFIG_SOC_NRF54H20_GPD
594-
nrf_gpd_retain_pins_set(config->pcfg, false);
597+
if (config->flags & UARTE_CFG_FLAG_RETAIN_PINS) {
598+
nrf_gpd_retain_pins_set(config->pcfg, false);
599+
}
595600
#endif
596601
#if UARTE_BAUDRATE_RETENTION_WORKAROUND
597602
nrf_uarte_baudrate_set(uarte,
@@ -708,7 +713,9 @@ static void uarte_disable_locked(const struct device *dev, uint32_t dis_mask)
708713
#ifdef CONFIG_SOC_NRF54H20_GPD
709714
const struct uarte_nrfx_config *cfg = dev->config;
710715

711-
nrf_gpd_retain_pins_set(cfg->pcfg, true);
716+
if (cfg->flags & UARTE_CFG_FLAG_RETAIN_PINS) {
717+
nrf_gpd_retain_pins_set(cfg->pcfg, true);
718+
}
712719
#endif
713720
nrf_uarte_disable(get_uarte_instance(dev));
714721
}
@@ -2174,7 +2181,9 @@ static void uarte_pm_suspend(const struct device *dev)
21742181
}
21752182

21762183
#ifdef CONFIG_SOC_NRF54H20_GPD
2177-
nrf_gpd_retain_pins_set(cfg->pcfg, true);
2184+
if (cfg->flags & UARTE_CFG_FLAG_RETAIN_PINS) {
2185+
nrf_gpd_retain_pins_set(cfg->pcfg, true);
2186+
}
21782187
#endif
21792188

21802189
nrf_uarte_disable(uarte);
@@ -2388,6 +2397,8 @@ static int uarte_instance_init(const struct device *dev,
23882397
(!IS_ENABLED(CONFIG_HAS_NORDIC_DMM) ? 0 : \
23892398
(UARTE_IS_CACHEABLE(idx) ? \
23902399
UARTE_CFG_FLAG_CACHEABLE : 0)) | \
2400+
(UARTE_PROP(idx, pin_retention) ? \
2401+
UARTE_CFG_FLAG_RETAIN_PINS : 0) | \
23912402
USE_LOW_POWER(idx), \
23922403
UARTE_DISABLE_RX_INIT(UARTE(idx)), \
23932404
.poll_out_byte = &uarte##idx##_poll_out_byte, \

0 commit comments

Comments
 (0)