serial: 8250: Define IIR 64 byte bit & cleanup related code
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 25 Nov 2022 13:05:08 +0000 (15:05 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jan 2023 14:01:20 +0000 (15:01 +0100)
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>
drivers/tty/serial/8250/8250_port.c
include/uapi/linux/serial_reg.h

index a47ce3e..33be7aa 100644 (file)
@@ -1050,11 +1050,12 @@ static void autoconfig_16550a(struct uart_8250_port *up)
                        serial_out(up, UART_LCR, 0);
                        serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO |
                                   UART_FCR7_64BYTE);
-                       status1 = serial_in(up, UART_IIR) >> 5;
+                       status1 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO |
+                                                            UART_IIR_FIFO_ENABLED);
                        serial_out(up, UART_FCR, 0);
                        serial_out(up, UART_LCR, 0);
 
-                       if (status1 == 7)
+                       if (status1 == (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED))
                                up->port.type = PORT_16550A_FSL64;
                        else
                                DEBUG_AUTOCONF("Motorola 8xxx DUART ");
@@ -1122,17 +1123,20 @@ static void autoconfig_16550a(struct uart_8250_port *up)
         */
        serial_out(up, UART_LCR, 0);
        serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
-       status1 = serial_in(up, UART_IIR) >> 5;
+       status1 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED);
        serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO);
+
        serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
        serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
-       status2 = serial_in(up, UART_IIR) >> 5;
+       status2 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED);
        serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO);
+
        serial_out(up, UART_LCR, 0);
 
        DEBUG_AUTOCONF("iir1=%d iir2=%d ", status1, status2);
 
-       if (status1 == 6 && status2 == 7) {
+       if (status1 == UART_IIR_FIFO_ENABLED_16550A &&
+           status2 == (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED_16550A)) {
                up->port.type = PORT_16750;
                up->capabilities |= UART_CAP_AFE | UART_CAP_SLEEP;
                return;
index 19aef5b..08b3527 100644 (file)
@@ -44,6 +44,7 @@
 #define UART_IIR_RX_TIMEOUT    0x0c /* OMAP RX Timeout interrupt */
 #define UART_IIR_XOFF          0x10 /* OMAP XOFF/Special Character */
 #define UART_IIR_CTS_RTS_DSR   0x20 /* OMAP CTS/RTS/DSR Change */
+#define UART_IIR_64BYTE_FIFO   0x20 /* 16750 64 bytes FIFO */
 #define UART_IIR_FIFO_ENABLED  0xc0 /* FIFOs enabled / port type identification */
 #define  UART_IIR_FIFO_ENABLED_8250    0x00    /* 8250: no FIFO */
 #define  UART_IIR_FIFO_ENABLED_16550   0x80    /* 16550: (broken/unusable) FIFO */