Skip to content

Commit b3be871

Browse files
mib1-nordicjaz1-nordic
authored andcommitted
[nrf fromlist] drivers: serial: uart_nrfx_uarte: align to changes in nrfx
Align driver to changes in nrfx UARTE driver. Upstream PR #: 96858 Signed-off-by: Michał Bainczyk <[email protected]>
1 parent 4664a50 commit b3be871

File tree

2 files changed

+22
-34
lines changed

2 files changed

+22
-34
lines changed

drivers/serial/Kconfig.nrfx

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -213,37 +213,25 @@ nrfx_uart_num = 137
213213
rsource "Kconfig.nrfx_uart_instance"
214214
endif
215215

216-
config NRFX_TIMER0
216+
config NRFX_TIMER
217217
default y
218218
depends on UART_0_NRF_HW_ASYNC_TIMER = 0 \
219219
|| UART_1_NRF_HW_ASYNC_TIMER = 0 \
220220
|| UART_2_NRF_HW_ASYNC_TIMER = 0 \
221-
|| UART_3_NRF_HW_ASYNC_TIMER = 0
222-
223-
config NRFX_TIMER1
224-
default y
225-
depends on UART_0_NRF_HW_ASYNC_TIMER = 1 \
221+
|| UART_3_NRF_HW_ASYNC_TIMER = 0 \
222+
|| UART_0_NRF_HW_ASYNC_TIMER = 1 \
226223
|| UART_1_NRF_HW_ASYNC_TIMER = 1 \
227224
|| UART_2_NRF_HW_ASYNC_TIMER = 1 \
228-
|| UART_3_NRF_HW_ASYNC_TIMER = 1
229-
230-
config NRFX_TIMER2
231-
default y
232-
depends on UART_0_NRF_HW_ASYNC_TIMER = 2 \
225+
|| UART_3_NRF_HW_ASYNC_TIMER = 1 \
226+
|| UART_0_NRF_HW_ASYNC_TIMER = 2 \
233227
|| UART_1_NRF_HW_ASYNC_TIMER = 2 \
234228
|| UART_2_NRF_HW_ASYNC_TIMER = 2 \
235-
|| UART_3_NRF_HW_ASYNC_TIMER = 2
236-
237-
config NRFX_TIMER3
238-
default y
239-
depends on UART_0_NRF_HW_ASYNC_TIMER = 3 \
229+
|| UART_3_NRF_HW_ASYNC_TIMER = 2 \
230+
|| UART_0_NRF_HW_ASYNC_TIMER = 3 \
240231
|| UART_1_NRF_HW_ASYNC_TIMER = 3 \
241232
|| UART_2_NRF_HW_ASYNC_TIMER = 3 \
242-
|| UART_3_NRF_HW_ASYNC_TIMER = 3
243-
244-
config NRFX_TIMER4
245-
default y
246-
depends on UART_0_NRF_HW_ASYNC_TIMER = 4 \
233+
|| UART_3_NRF_HW_ASYNC_TIMER = 3 \
234+
|| UART_0_NRF_HW_ASYNC_TIMER = 4 \
247235
|| UART_1_NRF_HW_ASYNC_TIMER = 4 \
248236
|| UART_2_NRF_HW_ASYNC_TIMER = 4 \
249237
|| UART_3_NRF_HW_ASYNC_TIMER = 4

drivers/serial/uart_nrfx_uarte.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ struct uarte_nrfx_data {
306306
#endif
307307
#ifdef UARTE_ANY_ASYNC
308308
struct uarte_async_cb *async;
309+
nrfx_timer_t timer;
309310
#endif
310311
atomic_val_t poll_out_lock;
311312
atomic_t flags;
@@ -448,7 +449,6 @@ struct uarte_nrfx_config {
448449
size_t bounce_buf_swap_len;
449450
struct uarte_async_rx_cbwt *cbwt_data;
450451
#endif
451-
nrfx_timer_t timer;
452452
uint8_t *tx_cache;
453453
uint8_t *rx_flush_buf;
454454
#endif
@@ -521,7 +521,7 @@ static void uarte_disable_locked(const struct device *dev, uint32_t dis_mask)
521521

522522
#if defined(UARTE_ANY_ASYNC) && !defined(CONFIG_UART_NRFX_UARTE_ENHANCED_RX)
523523
if (data->async && HW_RX_COUNTING_ENABLED(config)) {
524-
nrfx_timer_disable(&config->timer);
524+
nrfx_timer_disable(&data->timer);
525525
/* Timer/counter value is reset when disabled. */
526526
data->async->rx.total_byte_cnt = 0;
527527
data->async->rx.total_user_byte_cnt = 0;
@@ -878,7 +878,7 @@ static void uarte_periph_enable(const struct device *dev)
878878
#ifdef UARTE_ANY_ASYNC
879879
if (data->async) {
880880
if (HW_RX_COUNTING_ENABLED(config)) {
881-
const nrfx_timer_t *timer = &config->timer;
881+
nrfx_timer_t *timer = &data->timer;
882882

883883
nrfx_timer_enable(timer);
884884

@@ -1067,26 +1067,26 @@ static int uarte_nrfx_rx_counting_init(const struct device *dev)
10671067

10681068
if (HW_RX_COUNTING_ENABLED(cfg)) {
10691069
nrfx_timer_config_t tmr_config = NRFX_TIMER_DEFAULT_CONFIG(
1070-
NRF_TIMER_BASE_FREQUENCY_GET(cfg->timer.p_reg));
1070+
NRF_TIMER_BASE_FREQUENCY_GET(data->timer.p_reg));
10711071
uint32_t evt_addr = nrf_uarte_event_address_get(uarte, NRF_UARTE_EVENT_RXDRDY);
1072-
uint32_t tsk_addr = nrfx_timer_task_address_get(&cfg->timer, NRF_TIMER_TASK_COUNT);
1072+
uint32_t tsk_addr = nrfx_timer_task_address_get(&data->timer, NRF_TIMER_TASK_COUNT);
10731073

10741074
tmr_config.mode = NRF_TIMER_MODE_COUNTER;
10751075
tmr_config.bit_width = NRF_TIMER_BIT_WIDTH_32;
1076-
ret = nrfx_timer_init(&cfg->timer,
1076+
ret = nrfx_timer_init(&data->timer,
10771077
&tmr_config,
10781078
timer_handler);
10791079
if (ret != NRFX_SUCCESS) {
10801080
LOG_ERR("Timer already initialized");
10811081
return -EINVAL;
10821082
}
10831083

1084-
nrfx_timer_clear(&cfg->timer);
1084+
nrfx_timer_clear(&data->timer);
10851085

10861086
ret = nrfx_gppi_channel_alloc(&data->async->rx.cnt.ppi);
10871087
if (ret != NRFX_SUCCESS) {
10881088
LOG_ERR("Failed to allocate PPI Channel");
1089-
nrfx_timer_uninit(&cfg->timer);
1089+
nrfx_timer_uninit(&data->timer);
10901090
return -EINVAL;
10911091
}
10921092

@@ -2258,7 +2258,7 @@ static void rx_timeout(struct k_timer *timer)
22582258
NRF_UARTE_INT_ENDRX_MASK);
22592259

22602260
if (HW_RX_COUNTING_ENABLED(cfg)) {
2261-
read = nrfx_timer_capture(&cfg->timer, 0);
2261+
read = nrfx_timer_capture(&data->timer, 0);
22622262
} else {
22632263
read = async_rx->cnt.cnt;
22642264
}
@@ -3241,7 +3241,7 @@ static void uarte_pm_suspend(const struct device *dev)
32413241

32423242
#if !defined(CONFIG_UART_NRFX_UARTE_ENHANCED_RX)
32433243
if (data->async && HW_RX_COUNTING_ENABLED(cfg)) {
3244-
nrfx_timer_disable(&cfg->timer);
3244+
nrfx_timer_disable(&data->timer);
32453245
/* Timer/counter value is reset when disabled. */
32463246
data->async->rx.total_byte_cnt = 0;
32473247
data->async->rx.total_user_byte_cnt = 0;
@@ -3597,6 +3597,9 @@ static int uarte_instance_deinit(const struct device *dev)
35973597
(.uart_config = UARTE_CONFIG(idx),)) \
35983598
IF_ENABLED(CONFIG_UART_##idx##_ASYNC, \
35993599
(.async = &uarte##idx##_async,)) \
3600+
IF_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC, \
3601+
(.timer = NRFX_TIMER_INSTANCE(NRF_TIMER_INST_GET( \
3602+
CONFIG_UART_##idx##_NRF_HW_ASYNC_TIMER)),)) \
36003603
IF_ENABLED(CONFIG_UART_##idx##_INTERRUPT_DRIVEN, \
36013604
(.int_driven = &uarte##idx##_int_driven,)) \
36023605
}; \
@@ -3638,9 +3641,6 @@ static int uarte_instance_deinit(const struct device *dev)
36383641
.rx_flush_buf = uarte##idx##_flush_buf,)) \
36393642
IF_ENABLED(CONFIG_UARTE_NRFX_UARTE_COUNT_BYTES_WITH_TIMER, \
36403643
(UARTE_COUNT_BYTES_WITH_TIMER_CONFIG(idx))) \
3641-
IF_ENABLED(CONFIG_UART_##idx##_NRF_HW_ASYNC, \
3642-
(.timer = NRFX_TIMER_INSTANCE( \
3643-
CONFIG_UART_##idx##_NRF_HW_ASYNC_TIMER),)) \
36443644
IF_ENABLED(INSTANCE_IS_FAST(_, /*empty*/, idx, _), \
36453645
(.clk_dev = DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(UARTE(idx))), \
36463646
.clk_spec = { \

0 commit comments

Comments
 (0)