Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: 8250: Define IIR 64 byte bit & cleanup related code

16750 indicates 64 bytes FIFO with a IIR bit. Add define for it and
make related code more obvious.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20221125130509.8482-6-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ilpo Järvinen and committed by
Greg Kroah-Hartman
afd216ca 3398cc4f

+10 -5
+9 -5
drivers/tty/serial/8250/8250_port.c
··· 1050 1050 serial_out(up, UART_LCR, 0); 1051 1051 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | 1052 1052 UART_FCR7_64BYTE); 1053 - status1 = serial_in(up, UART_IIR) >> 5; 1053 + status1 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | 1054 + UART_IIR_FIFO_ENABLED); 1054 1055 serial_out(up, UART_FCR, 0); 1055 1056 serial_out(up, UART_LCR, 0); 1056 1057 1057 - if (status1 == 7) 1058 + if (status1 == (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED)) 1058 1059 up->port.type = PORT_16550A_FSL64; 1059 1060 else 1060 1061 DEBUG_AUTOCONF("Motorola 8xxx DUART "); ··· 1123 1122 */ 1124 1123 serial_out(up, UART_LCR, 0); 1125 1124 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); 1126 - status1 = serial_in(up, UART_IIR) >> 5; 1125 + status1 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED); 1127 1126 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1127 + 1128 1128 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); 1129 1129 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); 1130 - status2 = serial_in(up, UART_IIR) >> 5; 1130 + status2 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED); 1131 1131 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1132 + 1132 1133 serial_out(up, UART_LCR, 0); 1133 1134 1134 1135 DEBUG_AUTOCONF("iir1=%d iir2=%d ", status1, status2); 1135 1136 1136 - if (status1 == 6 && status2 == 7) { 1137 + if (status1 == UART_IIR_FIFO_ENABLED_16550A && 1138 + status2 == (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED_16550A)) { 1137 1139 up->port.type = PORT_16750; 1138 1140 up->capabilities |= UART_CAP_AFE | UART_CAP_SLEEP; 1139 1141 return;
+1
include/uapi/linux/serial_reg.h
··· 44 44 #define UART_IIR_RX_TIMEOUT 0x0c /* OMAP RX Timeout interrupt */ 45 45 #define UART_IIR_XOFF 0x10 /* OMAP XOFF/Special Character */ 46 46 #define UART_IIR_CTS_RTS_DSR 0x20 /* OMAP CTS/RTS/DSR Change */ 47 + #define UART_IIR_64BYTE_FIFO 0x20 /* 16750 64 bytes FIFO */ 47 48 #define UART_IIR_FIFO_ENABLED 0xc0 /* FIFOs enabled / port type identification */ 48 49 #define UART_IIR_FIFO_ENABLED_8250 0x00 /* 8250: no FIFO */ 49 50 #define UART_IIR_FIFO_ENABLED_16550 0x80 /* 16550: (broken/unusable) FIFO */