serial: 8250: Add IIR FIFOs enabled field properly
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 25 Nov 2022 13:05:07 +0000 (15:05 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jan 2023 14:01:20 +0000 (15:01 +0100)
Don't use magic literals & comments but define a real field instead
for UART_IIR_FIFO_ENABLED and name also the values.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20221125130509.8482-5-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 e79bf2a..a47ce3e 100644 (file)
@@ -1293,22 +1293,19 @@ static void autoconfig(struct uart_8250_port *up)
 
        serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO);
 
-       /* Assign this as it is to truncate any bits above 7.  */
-       scratch = serial_in(up, UART_IIR);
-
-       switch (scratch >> 6) {
-       case 0:
+       switch (serial_in(up, UART_IIR) & UART_IIR_FIFO_ENABLED) {
+       case UART_IIR_FIFO_ENABLED_8250:
                autoconfig_8250(up);
                break;
-       case 1:
-               port->type = PORT_UNKNOWN;
-               break;
-       case 2:
+       case UART_IIR_FIFO_ENABLED_16550:
                port->type = PORT_16550;
                break;
-       case 3:
+       case UART_IIR_FIFO_ENABLED_16550A:
                autoconfig_16550a(up);
                break;
+       default:
+               port->type = PORT_UNKNOWN;
+               break;
        }
 
 #ifdef CONFIG_SERIAL_8250_RSA
index bab3b39..19aef5b 100644 (file)
 #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_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 */
+#define  UART_IIR_FIFO_ENABLED_16550A  0xc0    /* 16550A: FIFO enabled */
 
 #define UART_FCR       2       /* Out: FIFO Control Register */
 #define UART_FCR_ENABLE_FIFO   0x01 /* Enable the FIFO */