1
1
/*
2
- * Copyright (c) 2024 Renesas Electronics Corporation
2
+ * Copyright (c) 2024-2025 Renesas Electronics Corporation
3
3
*
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
14
14
#include <zephyr/spinlock.h>
15
15
16
16
#include "r_sci_rx_if.h"
17
+ #include "iodefine_sci.h"
17
18
18
19
#if CONFIG_SOC_SERIES_RX130
19
20
#include "r_sci_rx130_private.h"
21
+ #elif CONFIG_SOC_SERIES_RX26T
22
+ #include "r_sci_rx26t_private.h"
20
23
#else
21
24
#error Unknown SOC, not (yet) supported.
22
25
#endif
@@ -68,7 +71,7 @@ struct uart_rx_sci_data {
68
71
69
72
static int uart_rx_sci_poll_in (const struct device * dev , unsigned char * c )
70
73
{
71
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
74
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
72
75
73
76
if (IS_ENABLED (CONFIG_UART_ASYNC_API ) && sci -> SCR .BIT .RIE ) {
74
77
return - EBUSY ;
@@ -86,7 +89,7 @@ static int uart_rx_sci_poll_in(const struct device *dev, unsigned char *c)
86
89
87
90
static void uart_rx_sci_poll_out (const struct device * dev , unsigned char c )
88
91
{
89
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
92
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
90
93
91
94
while (sci -> SSR .BIT .TEND == 0U ) {
92
95
}
@@ -96,7 +99,7 @@ static void uart_rx_sci_poll_out(const struct device *dev, unsigned char c)
96
99
97
100
static int uart_rx_err_check (const struct device * dev )
98
101
{
99
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
102
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
100
103
101
104
const uint32_t status = sci -> SSR .BYTE ;
102
105
int errors = 0 ;
@@ -227,7 +230,7 @@ static int uart_rx_config_get(const struct device *dev, struct uart_config *cfg)
227
230
228
231
static int uart_rx_fifo_fill (const struct device * dev , const uint8_t * tx_data , int size )
229
232
{
230
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
233
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
231
234
uint8_t num_tx = 0U ;
232
235
233
236
if (size > 0 && sci -> SSR .BIT .TDRE ) {
@@ -240,7 +243,7 @@ static int uart_rx_fifo_fill(const struct device *dev, const uint8_t *tx_data, i
240
243
241
244
static int uart_rx_fifo_read (const struct device * dev , uint8_t * rx_data , const int size )
242
245
{
243
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
246
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
244
247
uint8_t num_rx = 0U ;
245
248
246
249
if (size > 0 && sci -> SSR .BIT .RDRF ) {
@@ -254,7 +257,7 @@ static int uart_rx_fifo_read(const struct device *dev, uint8_t *rx_data, const i
254
257
static void uart_rx_irq_tx_enable (const struct device * dev )
255
258
{
256
259
struct uart_rx_sci_data * data = dev -> data ;
257
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
260
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
258
261
259
262
sci -> SCR .BYTE |= (BIT (R_SCI_SCR_TIE_Pos ) | BIT (R_SCI_SCR_TEIE_Pos ));
260
263
irq_enable (data -> tei_irq );
@@ -274,44 +277,44 @@ static void uart_rx_irq_tx_enable(const struct device *dev)
274
277
static void uart_rx_irq_tx_disable (const struct device * dev )
275
278
{
276
279
struct uart_rx_sci_data * data = dev -> data ;
277
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
280
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
278
281
279
282
sci -> SCR .BYTE &= ~(BIT (R_SCI_SCR_TIE_Pos ) | BIT (R_SCI_SCR_TEIE_Pos ));
280
283
irq_disable (data -> tei_irq );
281
284
}
282
285
283
286
static int uart_rx_irq_tx_ready (const struct device * dev )
284
287
{
285
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
288
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
286
289
287
290
return (sci -> SCR .BIT .TIE == 1U ) &&
288
291
(sci -> SSR .BYTE & (BIT (R_SCI_SSR_TDRE_Pos ) | BIT (R_SCI_SSR_TEND_Pos )));
289
292
}
290
293
291
294
static int uart_rx_irq_tx_complete (const struct device * dev )
292
295
{
293
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
296
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
294
297
295
298
return (sci -> SCR .BIT .TEIE == 1U ) && (sci -> SSR .BYTE & BIT (R_SCI_SSR_TEND_Pos ));
296
299
}
297
300
298
301
static void uart_rx_irq_rx_enable (const struct device * dev )
299
302
{
300
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
303
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
301
304
302
305
sci -> SCR .BIT .RIE = 1U ;
303
306
}
304
307
305
308
static void uart_rx_irq_rx_disable (const struct device * dev )
306
309
{
307
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
310
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
308
311
309
312
sci -> SCR .BIT .RIE = 0U ;
310
313
}
311
314
312
315
static int uart_rx_irq_rx_ready (const struct device * dev )
313
316
{
314
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
317
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
315
318
316
319
return (sci -> SCR .BIT .RIE == 1U ) && ((sci -> SSR .BYTE & BIT (R_SCI_SSR_RDRF_Pos )));
317
320
}
@@ -332,7 +335,7 @@ static void uart_rx_irq_err_disable(const struct device *dev)
332
335
333
336
static int uart_rx_irq_is_pending (const struct device * dev )
334
337
{
335
- volatile struct st_sci0 * sci = (struct st_sci0 * )DEV_BASE (dev );
338
+ volatile struct st_sci * sci = (struct st_sci * )DEV_BASE (dev );
336
339
bool tx_pending = false;
337
340
bool rx_pending = false;
338
341
@@ -439,7 +442,9 @@ static void uart_rx_sci_txi_isr(const struct device *dev)
439
442
data -> user_cb (dev , data -> user_cb_data );
440
443
}
441
444
}
445
+ #endif
442
446
447
+ #ifndef CONFIG_SOC_SERIES_RX26T
443
448
static void uart_rx_sci_tei_isr (const struct device * dev )
444
449
{
445
450
struct uart_rx_sci_data * data = dev -> data ;
@@ -459,7 +464,16 @@ static void uart_rx_sci_eri_isr(const struct device *dev)
459
464
}
460
465
#endif
461
466
467
+ #if defined(CONFIG_SOC_SERIES_RX26T )
468
+ #define UART_RX_SCI_CONFIG_INIT (index )
469
+ #else
470
+ #define UART_RX_SCI_CONFIG_INIT (index ) \
471
+ .tei_irq = DT_IRQ_BY_NAME(DT_INST_PARENT(index), tei, irq), \
472
+ .eri_irq = DT_IRQ_BY_NAME(DT_INST_PARENT(index), eri, irq),
473
+ #endif
474
+
462
475
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API
476
+ #ifndef CONFIG_SOC_SERIES_RX26T
463
477
#define UART_RX_SCI_IRQ_INIT (index ) \
464
478
do { \
465
479
IRQ_CONNECT(DT_IRQ_BY_NAME(DT_INST_PARENT(index), rxi, irq), \
@@ -480,9 +494,19 @@ static void uart_rx_sci_eri_isr(const struct device *dev)
480
494
irq_enable(DT_IRQ_BY_NAME(DT_INST_PARENT(index), eri, irq)); \
481
495
} while (0)
482
496
#else
483
- #define UART_RX_SCI_IRQ_INIT (index )
497
+ #define UART_RX_SCI_IRQ_INIT (index ) \
498
+ do { \
499
+ IRQ_CONNECT(DT_IRQ_BY_NAME(DT_INST_PARENT(index), rxi, irq), \
500
+ DT_IRQ_BY_NAME(DT_INST_PARENT(index), rxi, priority), \
501
+ uart_rx_sci_rxi_isr, DEVICE_DT_INST_GET(index), 0); \
502
+ IRQ_CONNECT(DT_IRQ_BY_NAME(DT_INST_PARENT(index), txi, irq), \
503
+ DT_IRQ_BY_NAME(DT_INST_PARENT(index), txi, priority), \
504
+ uart_rx_sci_txi_isr, DEVICE_DT_INST_GET(index), 0); \
505
+ irq_enable(DT_IRQ_BY_NAME(DT_INST_PARENT(index), rxi, irq)); \
506
+ irq_enable(DT_IRQ_BY_NAME(DT_INST_PARENT(index), txi, irq)); \
507
+ } while (0)
508
+ #endif
484
509
#endif
485
-
486
510
487
511
#define UART_RX_INIT (index ) \
488
512
PINCTRL_DT_DEFINE(DT_INST_PARENT(index)); \
@@ -506,9 +530,7 @@ static void uart_rx_sci_eri_isr(const struct device *dev)
506
530
}, \
507
531
.rxi_irq = DT_IRQ_BY_NAME(DT_INST_PARENT(index), rxi, irq), \
508
532
.txi_irq = DT_IRQ_BY_NAME(DT_INST_PARENT(index), txi, irq), \
509
- .tei_irq = DT_IRQ_BY_NAME(DT_INST_PARENT(index), tei, irq), \
510
- .eri_irq = DT_IRQ_BY_NAME(DT_INST_PARENT(index), eri, irq), \
511
- }; \
533
+ UART_RX_SCI_CONFIG_INIT(index)}; \
512
534
\
513
535
static int uart_rx_init_##index(const struct device *dev) \
514
536
{ \
0 commit comments