serial: 8250_dw: Replace ACPI device check by a quirk
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 6 Mar 2024 14:33:22 +0000 (16:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Mar 2024 22:52:13 +0000 (22:52 +0000)
Instead of checking for APMC0D08 ACPI device presence,
use a quirk based on driver data.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240306143322.3291123-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_dw.c

index e369b429e060366afa5e123e46630efda9fa313c..1300c92b8702a3237459190d9027f12319581b25 100644 (file)
@@ -9,7 +9,6 @@
  * LCR is written whilst busy.  If it is, then a busy detect interrupt is
  * raised, the LCR needs to be rewritten and the uart status register read.
  */
-#include <linux/acpi.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/device.h>
@@ -55,6 +54,7 @@
 #define DW_UART_QUIRK_ARMADA_38X       BIT(1)
 #define DW_UART_QUIRK_SKIP_SET_RATE    BIT(2)
 #define DW_UART_QUIRK_IS_DMA_FC                BIT(3)
+#define DW_UART_QUIRK_APMC0D08         BIT(4)
 
 static inline struct dw8250_data *clk_to_dw8250_data(struct notifier_block *nb)
 {
@@ -444,33 +444,29 @@ static void dw8250_prepare_rx_dma(struct uart_8250_port *p)
 
 static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
 {
-       struct device_node *np = p->dev->of_node;
-
-       if (np) {
-               unsigned int quirks = data->pdata->quirks;
+       unsigned int quirks = data->pdata ? data->pdata->quirks : 0;
 
 #ifdef CONFIG_64BIT
-               if (quirks & DW_UART_QUIRK_OCTEON) {
-                       p->serial_in = dw8250_serial_inq;
-                       p->serial_out = dw8250_serial_outq;
-                       p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
-                       p->type = PORT_OCTEON;
-                       data->skip_autocfg = true;
-               }
+       if (quirks & DW_UART_QUIRK_OCTEON) {
+               p->serial_in = dw8250_serial_inq;
+               p->serial_out = dw8250_serial_outq;
+               p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
+               p->type = PORT_OCTEON;
+               data->skip_autocfg = true;
+       }
 #endif
 
-               if (quirks & DW_UART_QUIRK_ARMADA_38X)
-                       p->serial_out = dw8250_serial_out38x;
-               if (quirks & DW_UART_QUIRK_SKIP_SET_RATE)
-                       p->set_termios = dw8250_do_set_termios;
-               if (quirks & DW_UART_QUIRK_IS_DMA_FC) {
-                       data->data.dma.txconf.device_fc = 1;
-                       data->data.dma.rxconf.device_fc = 1;
-                       data->data.dma.prepare_tx_dma = dw8250_prepare_tx_dma;
-                       data->data.dma.prepare_rx_dma = dw8250_prepare_rx_dma;
-               }
-
-       } else if (acpi_dev_present("APMC0D08", NULL, -1)) {
+       if (quirks & DW_UART_QUIRK_ARMADA_38X)
+               p->serial_out = dw8250_serial_out38x;
+       if (quirks & DW_UART_QUIRK_SKIP_SET_RATE)
+               p->set_termios = dw8250_do_set_termios;
+       if (quirks & DW_UART_QUIRK_IS_DMA_FC) {
+               data->data.dma.txconf.device_fc = 1;
+               data->data.dma.rxconf.device_fc = 1;
+               data->data.dma.prepare_tx_dma = dw8250_prepare_tx_dma;
+               data->data.dma.prepare_rx_dma = dw8250_prepare_rx_dma;
+       }
+       if (quirks & DW_UART_QUIRK_APMC0D08) {
                p->iotype = UPIO_MEM32;
                p->regshift = 2;
                p->serial_in = dw8250_serial_in32;
@@ -750,13 +746,18 @@ static const struct of_device_id dw8250_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, dw8250_of_match);
 
+static const struct dw8250_platform_data dw8250_apmc0d08 = {
+       .usr_reg = DW_UART_USR,
+       .quirks = DW_UART_QUIRK_APMC0D08,
+};
+
 static const struct acpi_device_id dw8250_acpi_match[] = {
        { "80860F0A", (kernel_ulong_t)&dw8250_dw_apb },
        { "8086228A", (kernel_ulong_t)&dw8250_dw_apb },
        { "AMD0020", (kernel_ulong_t)&dw8250_dw_apb },
        { "AMDI0020", (kernel_ulong_t)&dw8250_dw_apb },
        { "AMDI0022", (kernel_ulong_t)&dw8250_dw_apb },
-       { "APMC0D08", (kernel_ulong_t)&dw8250_dw_apb},
+       { "APMC0D08", (kernel_ulong_t)&dw8250_apmc0d08 },
        { "BRCM2032", (kernel_ulong_t)&dw8250_dw_apb },
        { "HISI0031", (kernel_ulong_t)&dw8250_dw_apb },
        { "INT33C4", (kernel_ulong_t)&dw8250_dw_apb },