Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions drivers/serial/uart_nrfx_uarte.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@
/* If enabled then UARTE peripheral is using memory which is cacheable. */
#define UARTE_CFG_FLAG_CACHEABLE BIT(3)

/* If enabled then pins must be retained when UARTE is disabled. */
#define UARTE_CFG_FLAG_RETAIN_PINS BIT(4)

/* Macro for converting numerical baudrate to register value. It is convenient
* to use this approach because for constant input it can calculate nrf setting
* at compile time.
Expand Down Expand Up @@ -590,6 +593,11 @@

(void)data;
nrf_uarte_enable(uarte);
#ifdef CONFIG_SOC_NRF54H20_GPD
if (config->flags & UARTE_CFG_FLAG_RETAIN_PINS) {
nrf_gpd_retain_pins_set(config->pcfg, false);
}
#endif
#if UARTE_BAUDRATE_RETENTION_WORKAROUND
nrf_uarte_baudrate_set(uarte,
COND_CODE_1(CONFIG_UART_USE_RUNTIME_CONFIGURE,
Expand Down Expand Up @@ -702,6 +710,13 @@
}
#endif

#ifdef CONFIG_SOC_NRF54H20_GPD
const struct uarte_nrfx_config *cfg = dev->config;

if (cfg->flags & UARTE_CFG_FLAG_RETAIN_PINS) {
nrf_gpd_retain_pins_set(cfg->pcfg, true);
}
#endif
nrf_uarte_disable(get_uarte_instance(dev));
}

Expand Down Expand Up @@ -2103,9 +2118,6 @@

if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) || !LOW_POWER_ENABLED(cfg)) {
uarte_periph_enable(dev);
#ifdef CONFIG_SOC_NRF54H20_GPD
nrf_gpd_retain_pins_set(cfg->pcfg, false);
#endif
}
}

Expand Down Expand Up @@ -2169,7 +2181,9 @@
}

#ifdef CONFIG_SOC_NRF54H20_GPD
nrf_gpd_retain_pins_set(cfg->pcfg, true);
if (cfg->flags & UARTE_CFG_FLAG_RETAIN_PINS) {
nrf_gpd_retain_pins_set(cfg->pcfg, true);
}
#endif

nrf_uarte_disable(uarte);
Expand Down Expand Up @@ -2383,6 +2397,8 @@
(!IS_ENABLED(CONFIG_HAS_NORDIC_DMM) ? 0 : \
(UARTE_IS_CACHEABLE(idx) ? \
UARTE_CFG_FLAG_CACHEABLE : 0)) | \
(UARTE_PROP(idx, pin_retention) ? \
UARTE_CFG_FLAG_RETAIN_PINS : 0) | \
USE_LOW_POWER(idx), \
UARTE_DISABLE_RX_INIT(UARTE(idx)), \
.poll_out_byte = &uarte##idx##_poll_out_byte, \
Expand Down Expand Up @@ -2415,7 +2431,7 @@
PRE_KERNEL_1, \
CONFIG_SERIAL_INIT_PRIORITY, \
&uart_nrfx_uarte_driver_api)

Check notice on line 2434 in drivers/serial/uart_nrfx_uarte.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/serial/uart_nrfx_uarte.c:2434 -#define UART_NRF_UARTE_DEVICE(idx) \ - NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP(UARTE(idx)); \ - UARTE_INT_DRIVEN(idx); \ - PINCTRL_DT_DEFINE(UARTE(idx)); \ - IF_ENABLED(CONFIG_UART_##idx##_ASYNC, ( \ - static uint8_t \ - uarte##idx##_tx_cache[CONFIG_UART_ASYNC_TX_CACHE_SIZE] \ - DMM_MEMORY_SECTION(UARTE(idx)); \ - static uint8_t uarte##idx##_flush_buf[UARTE_HW_RX_FIFO_SIZE] \ - DMM_MEMORY_SECTION(UARTE(idx)); \ - struct uarte_async_cb uarte##idx##_async;)) \ - static uint8_t uarte##idx##_poll_out_byte DMM_MEMORY_SECTION(UARTE(idx));\ - static uint8_t uarte##idx##_poll_in_byte DMM_MEMORY_SECTION(UARTE(idx)); \ - static struct uarte_nrfx_data uarte_##idx##_data = { \ - IF_ENABLED(CONFIG_UART_USE_RUNTIME_CONFIGURE, \ - (.uart_config = UARTE_CONFIG(idx),)) \ - IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \ - (.async = &uarte##idx##_async,)) \ - IF_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN, \ - (.int_driven = &uarte##idx##_int_driven,)) \ - }; \ - COND_CODE_1(CONFIG_UART_USE_RUNTIME_CONFIGURE, (), \ - (BUILD_ASSERT(NRF_BAUDRATE(UARTE_PROP(idx, current_speed)) > 0,\ - "Unsupported baudrate");)) \ - static const struct uarte_nrfx_config uarte_##idx##z_config = { \ - COND_CODE_1(CONFIG_UART_USE_RUNTIME_CONFIGURE, \ - (IF_ENABLED(DT_CLOCKS_HAS_IDX(UARTE(idx), 0), \ - (.clock_freq = UARTE_GET_FREQ(idx),))), \ - (IF_ENABLED(UARTE_HAS_FRAME_TIMEOUT, \ - (.baudrate = UARTE_PROP(idx, current_speed),)) \ - .nrf_baudrate = UARTE_GET_BAUDRATE(idx), \ - .hw_config = UARTE_NRF_CONFIG(idx),)) \ - .pcfg = PINCTRL_DT_DEV_CONFIG_GET(UARTE(idx)), \ - .uarte_regs = _CONCAT(NRF_UARTE, idx), \ - IF_ENABLED(CONFIG_HAS_NORDIC_DMM, \ - (.mem_reg = DMM_DEV_TO_REG(UARTE(idx)),)) \ - .flags = \ - (IS_ENABLED(CONFIG_UART_##idx##_ENHANCED_POLL_OUT) ? \ - UARTE_CFG_FLAG_PPI_ENDTX : 0) | \ - (IS_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC) ? \ - UARTE_CFG_FLAG_HW_BYTE_COUNTING : 0) | \ - (!IS_ENABLED(CONFIG_HAS_NORDIC_DMM) ? 0 : \ - (UARTE_IS_CACHEABLE(idx) ? \ - UARTE_CFG_FLAG_CACHEABLE : 0)) | \ - (UARTE_PROP(idx, pin_retention) ? \ - UARTE_CFG_FLAG_RETAIN_PINS : 0) | \ - USE_LOW_POWER(idx), \ - UARTE_DISABLE_RX_INIT(UARTE(idx)), \ - .poll_out_byte = &uarte##idx##_poll_out_byte, \ - .poll_in_byte = &uarte##idx##_poll_in_byte, \ - IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \ - (.tx_cache = uarte##idx##_tx_cache, \ - .rx_flush_buf = uarte##idx##_flush_buf,)) \ - IF_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC, \ - (.timer = NRFX_TIMER_INSTANCE( \ - CONFIG_UART_##idx##_NRF_HW_ASYNC_TIMER),)) \ - }; \ - static int uarte_##idx##_init(const struct device *dev) \ - { \ - COND_CODE_1(CONFIG_UART_##idx##_ASYNC, \ - (UARTE_IRQ_CONFIGURE(idx, uarte_nrfx_isr_async);), \ - (UARTE_IRQ_CONFIGURE(idx, uarte_nrfx_isr_int);)) \ - return uarte_instance_init( \ - dev, \ - IS_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN)); \ - } \ - \ - PM_DEVICE_DT_DEFINE(UARTE(idx), uarte_nrfx_pm_action, \ - PM_DEVICE_ISR_SAFE); \ - \ - DEVICE_DT_DEFINE(UARTE(idx), \ - uarte_##idx##_init, \ - PM_DEVICE_DT_GET(UARTE(idx)), \ - &uarte_##idx##_data, \ - &uarte_##idx##z_config, \ - PRE_KERNEL_1, \ - CONFIG_SERIAL_INIT_PRIORITY, \ - &uart_nrfx_uarte_driver_api) +#define UART_NRF_UARTE_DEVICE(idx) \ + NRF_D
#define UARTE_INT_DRIVEN(idx) \
IF_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN, \
(static uint8_t uarte##idx##_tx_buffer \
Expand Down
6 changes: 6 additions & 0 deletions dts/bindings/serial/nordic,nrf-uarte.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ properties:
type: boolean
description: |
UARTE has RX frame timeout HW feature.
pin-retention:
type: boolean
description: |
UARTE pin states must be retained when peripheral is disabled.
It is required when CTRLSEL is used to route UARTE pins. It is always the
case for fast peripheral and in special cases for slow peripherals.
1 change: 1 addition & 0 deletions dts/common/nordic/nrf54h20.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@
power-domains = <&gpd NRF_GPD_FAST_ACTIVE1>;
endtx-stoptx-supported;
frame-timeout-supported;
pin-retention;
};

spi121: spi@8e7000 {
Expand Down
1 change: 1 addition & 0 deletions dts/common/nordic/nrf9280.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@
interrupts = <230 NRF_DEFAULT_IRQ_PRIORITY>;
endtx-stoptx-supported;
frame-timeout-supported;
pin-retention;
};

spi121: spi@8e7000 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
&pinctrl {
uart137_default_alt: uart137_default_alt {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 6)>,
<NRF_PSEL(UART_RX, 0, 7)>;
psels = <NRF_PSEL(UART_TX, 0, 6)>;
};
group2 {
psels = <NRF_PSEL(UART_RX, 0, 7)>;
bias-pull-up;
};
};

Expand All @@ -15,6 +18,23 @@
low-power-enable;
};
};
uart120_default_alt: uart120_default_alt {
group1 {
psels = <NRF_PSEL(UART_TX, 7, 7)>;
};
group2 {
psels = <NRF_PSEL(UART_RX, 7, 4)>;
bias-pull-up;
};
};

uart120_sleep_alt: uart120_sleep_alt {
group1 {
psels = <NRF_PSEL(UART_TX, 7, 7)>,
<NRF_PSEL(UART_RX, 7, 4)>;
low-power-enable;
};
};
};

dut: &uart137 {
Expand All @@ -24,3 +44,11 @@ dut: &uart137 {
pinctrl-names = "default", "sleep";
current-speed = <115200>;
};

dut2: &uart120 {
status = "okay";
pinctrl-0 = <&uart120_default_alt>;
pinctrl-1 = <&uart120_sleep_alt>;
pinctrl-names = "default", "sleep";
current-speed = <115200>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
&dut {
memory-regions = <&cpuapp_dma_region>;
};

&dut2 {
memory-regions = <&dma_fast_region>;
};

&dma_fast_region {
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0 */

#include "nrf54h20dk_nrf54h20_common.dtsi"

dut2: &uart120 {
status = "disabled";
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

#include "nrf54h20dk_nrf54h20_common.dtsi"

&cpurad_dma_region {
reg = <0xe80 DT_SIZE_K(4)>;
};

&dut {
memory-regions = <&cpurad_dma_region>;
};

&dma_fast_region {
status = "okay";
};

&dut2 {
memory-regions = <&dma_fast_region>;
};
Loading
Loading