Skip to content

Commit a380ed4

Browse files
Ulrich Hechtgregkh
authored andcommitted
serial: sh-sci: implement FIFO threshold register setting
Sets the closest match for a desired RX trigger level. Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 88641c7 commit a380ed4

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

drivers/tty/serial/sh-sci.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,65 @@ static int sci_handle_breaks(struct uart_port *port)
974974
return copied;
975975
}
976976

977+
static int scif_set_rtrg(struct uart_port *port, int rx_trig)
978+
{
979+
unsigned int bits;
980+
981+
if (rx_trig < 1)
982+
rx_trig = 1;
983+
if (rx_trig >= port->fifosize)
984+
rx_trig = port->fifosize;
985+
986+
/* HSCIF can be set to an arbitrary level. */
987+
if (sci_getreg(port, HSRTRGR)->size) {
988+
serial_port_out(port, HSRTRGR, rx_trig);
989+
return rx_trig;
990+
}
991+
992+
switch (port->type) {
993+
case PORT_SCIF:
994+
if (rx_trig < 4) {
995+
bits = 0;
996+
rx_trig = 1;
997+
} else if (rx_trig < 8) {
998+
bits = SCFCR_RTRG0;
999+
rx_trig = 4;
1000+
} else if (rx_trig < 14) {
1001+
bits = SCFCR_RTRG1;
1002+
rx_trig = 8;
1003+
} else {
1004+
bits = SCFCR_RTRG0 | SCFCR_RTRG1;
1005+
rx_trig = 14;
1006+
}
1007+
break;
1008+
case PORT_SCIFA:
1009+
case PORT_SCIFB:
1010+
if (rx_trig < 16) {
1011+
bits = 0;
1012+
rx_trig = 1;
1013+
} else if (rx_trig < 32) {
1014+
bits = SCFCR_RTRG0;
1015+
rx_trig = 16;
1016+
} else if (rx_trig < 48) {
1017+
bits = SCFCR_RTRG1;
1018+
rx_trig = 32;
1019+
} else {
1020+
bits = SCFCR_RTRG0 | SCFCR_RTRG1;
1021+
rx_trig = 48;
1022+
}
1023+
break;
1024+
default:
1025+
WARN(1, "unknown FIFO configuration");
1026+
return 1;
1027+
}
1028+
1029+
serial_port_out(port, SCFCR,
1030+
(serial_port_in(port, SCFCR) &
1031+
~(SCFCR_RTRG1 | SCFCR_RTRG0)) | bits);
1032+
1033+
return rx_trig;
1034+
}
1035+
9771036
#ifdef CONFIG_SERIAL_SH_SCI_DMA
9781037
static void sci_dma_tx_complete(void *arg)
9791038
{

0 commit comments

Comments
 (0)