@@ -88,6 +88,20 @@ static void pl011_disable_fifo(const struct device *dev)
88
88
get_uart (dev )-> lcr_h &= ~PL011_LCRH_FEN ;
89
89
}
90
90
91
+ static void pl011_set_flow_control (const struct device * dev , bool rts , bool cts )
92
+ {
93
+ if (rts ) {
94
+ get_uart (dev )-> cr |= PL011_CR_RTSEn ;
95
+ } else {
96
+ get_uart (dev )-> cr &= ~PL011_CR_RTSEn ;
97
+ }
98
+ if (cts ) {
99
+ get_uart (dev )-> cr |= PL011_CR_CTSEn ;
100
+ } else {
101
+ get_uart (dev )-> cr &= ~PL011_CR_CTSEn ;
102
+ }
103
+ }
104
+
91
105
static int pl011_set_baudrate (const struct device * dev ,
92
106
uint32_t clk , uint32_t baudrate )
93
107
{
@@ -240,6 +254,10 @@ static int pl011_runtime_configure_internal(const struct device *dev,
240
254
241
255
switch (cfg -> flow_ctrl ) {
242
256
case UART_CFG_FLOW_CTRL_NONE :
257
+ pl011_set_flow_control (dev , false, false);
258
+ break ;
259
+ case UART_CFG_FLOW_CTRL_RTS_CTS :
260
+ pl011_set_flow_control (dev , true, true);
243
261
break ;
244
262
default :
245
263
goto enable ;
@@ -506,7 +524,7 @@ static int pl011_init(const struct device *dev)
506
524
if (!data -> sbsa ) {
507
525
get_uart (dev )-> dmacr = 0U ;
508
526
barrier_isync_fence_full ();
509
- get_uart (dev )-> cr &= ~( BIT ( 14 ) | BIT ( 15 ) | BIT ( 1 )) ;
527
+ get_uart (dev )-> cr &= ~PL011_CR_SIREN ;
510
528
get_uart (dev )-> cr |= PL011_CR_RXE | PL011_CR_TXE ;
511
529
barrier_isync_fence_full ();
512
530
}
@@ -641,7 +659,9 @@ void pl011_isr(const struct device *dev)
641
659
.parity = UART_CFG_PARITY_NONE, \
642
660
.stop_bits = UART_CFG_STOP_BITS_1, \
643
661
.data_bits = UART_CFG_DATA_BITS_8, \
644
- .flow_ctrl = UART_CFG_FLOW_CTRL_NONE, \
662
+ .flow_ctrl = DT_INST_PROP(n, hw_flow_control) \
663
+ ? UART_CFG_FLOW_CTRL_RTS_CTS \
664
+ : UART_CFG_FLOW_CTRL_NONE, \
645
665
}, \
646
666
.clk_freq = COND_CODE_1( \
647
667
DT_NODE_HAS_COMPAT(DT_INST_CLOCKS_CTLR(n), fixed_clock), \
0 commit comments