]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
serial: 8250: Move CE4100 quirks to a module under 8250 driver
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 27 Jun 2025 18:25:00 +0000 (21:25 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 29 Jun 2025 12:24:46 +0000 (14:24 +0200)
There is inconvenient for maintainers and maintainership to have
some quirks under architectural code. Move it to the specific quirk
file like other 8250-compatible drivers do.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20250627182743.1273326-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/include/asm/ce4100.h
arch/x86/platform/ce4100/ce4100.c
drivers/tty/serial/8250/8250_ce4100.c [new file with mode: 0644]
drivers/tty/serial/8250/Makefile

index 2930f560d7f35180040231016d9ba454af2048bf..e1f965bb1e3127f4e3ce2a9be38c8221100f0305 100644 (file)
@@ -4,4 +4,10 @@
 
 int ce4100_pci_init(void);
 
+#ifdef CONFIG_SERIAL_8250
+void __init sdv_serial_fixup(void);
+#else
+static inline void sdv_serial_fixup(void) {};
+#endif
+
 #endif
index 08492bea9713224d0eb949fc6c8003d1716c7b47..aaa7017416f7b1f29faa2cdb3c5f2eea9130cfad 100644 (file)
@@ -5,19 +5,12 @@
  * (C) Copyright 2010 Intel Corporation
  */
 #include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/irq.h>
 #include <linux/reboot.h>
-#include <linux/serial_reg.h>
-#include <linux/serial_8250.h>
 
 #include <asm/ce4100.h>
 #include <asm/prom.h>
 #include <asm/setup.h>
-#include <asm/i8259.h>
 #include <asm/io.h>
-#include <asm/io_apic.h>
-#include <asm/emergency-restart.h>
 
 /*
  * The CE4100 platform has an internal 8051 Microcontroller which is
@@ -31,97 +24,6 @@ static void ce4100_power_off(void)
        outb(0x4, 0xcf9);
 }
 
-#ifdef CONFIG_SERIAL_8250
-
-static unsigned int mem_serial_in(struct uart_port *p, int offset)
-{
-       offset = offset << p->regshift;
-       return readl(p->membase + offset);
-}
-
-/*
- * The UART Tx interrupts are not set under some conditions and therefore serial
- * transmission hangs. This is a silicon issue and has not been root caused. The
- * workaround for this silicon issue checks UART_LSR_THRE bit and UART_LSR_TEMT
- * bit of LSR register in interrupt handler to see whether at least one of these
- * two bits is set, if so then process the transmit request. If this workaround
- * is not applied, then the serial transmission may hang. This workaround is for
- * errata number 9 in Errata - B step.
-*/
-
-static u32 ce4100_mem_serial_in(struct uart_port *p, unsigned int offset)
-{
-       u32 ret, ier, lsr;
-
-       if (offset != UART_IIR)
-               return mem_serial_in(p, offset);
-
-       offset <<= p->regshift;
-
-       ret = readl(p->membase + offset);
-       if (!(ret & UART_IIR_NO_INT))
-               return ret;
-
-       /* see if the TX interrupt should have really set */
-       ier = mem_serial_in(p, UART_IER);
-       /* see if the UART's XMIT interrupt is enabled */
-       if (!(ier & UART_IER_THRI))
-               return ret;
-
-       lsr = mem_serial_in(p, UART_LSR);
-       /* now check to see if the UART should be generating an interrupt (but isn't) */
-       if (lsr & (UART_LSR_THRE | UART_LSR_TEMT))
-               ret &= ~UART_IIR_NO_INT;
-
-       return ret;
-}
-
-static void ce4100_mem_serial_out(struct uart_port *p, unsigned int offset, u32 value)
-{
-       offset <<= p->regshift;
-       writel(value, p->membase + offset);
-}
-
-static void ce4100_serial_fixup(int port, struct uart_port *up,
-       u32 *capabilities)
-{
-#ifdef CONFIG_EARLY_PRINTK
-       /*
-        * Over ride the legacy port configuration that comes from
-        * asm/serial.h. Using the ioport driver then switching to the
-        * PCI memmaped driver hangs the IOAPIC
-        */
-       if (up->iotype !=  UPIO_MEM32) {
-               up->uartclk  = 14745600;
-               up->mapbase = 0xdffe0200;
-               set_fixmap_nocache(FIX_EARLYCON_MEM_BASE,
-                               up->mapbase & PAGE_MASK);
-               up->membase =
-                       (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE);
-               up->membase += up->mapbase & ~PAGE_MASK;
-               up->mapbase += port * 0x100;
-               up->membase += port * 0x100;
-               up->iotype   = UPIO_MEM32;
-               up->regshift = 2;
-               up->irq = 4;
-       }
-#endif
-       up->iobase = 0;
-       up->serial_in = ce4100_mem_serial_in;
-       up->serial_out = ce4100_mem_serial_out;
-
-       *capabilities |= (1 << 12);
-}
-
-static __init void sdv_serial_fixup(void)
-{
-       serial8250_set_isa_configurator(ce4100_serial_fixup);
-}
-
-#else
-static inline void sdv_serial_fixup(void) {};
-#endif
-
 static void __init sdv_arch_setup(void)
 {
        sdv_serial_fixup();
diff --git a/drivers/tty/serial/8250/8250_ce4100.c b/drivers/tty/serial/8250/8250_ce4100.c
new file mode 100644 (file)
index 0000000..3dd88f3
--- /dev/null
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Intel CE4100  platform specific setup code
+ *
+ * (C) Copyright 2010 Intel Corporation
+ */
+
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/types.h>
+
+#include <asm/ce4100.h>
+#include <asm/fixmap.h>
+#include <asm/page.h>
+
+#include <linux/serial_reg.h>
+#include <linux/serial_8250.h>
+
+static unsigned int mem_serial_in(struct uart_port *p, int offset)
+{
+       offset = offset << p->regshift;
+       return readl(p->membase + offset);
+}
+
+/*
+ * The UART Tx interrupts are not set under some conditions and therefore serial
+ * transmission hangs. This is a silicon issue and has not been root caused. The
+ * workaround for this silicon issue checks UART_LSR_THRE bit and UART_LSR_TEMT
+ * bit of LSR register in interrupt handler to see whether at least one of these
+ * two bits is set, if so then process the transmit request. If this workaround
+ * is not applied, then the serial transmission may hang. This workaround is for
+ * errata number 9 in Errata - B step.
+*/
+static u32 ce4100_mem_serial_in(struct uart_port *p, unsigned int offset)
+{
+       u32 ret, ier, lsr;
+
+       if (offset != UART_IIR)
+               return mem_serial_in(p, offset);
+
+       offset <<= p->regshift;
+
+       ret = readl(p->membase + offset);
+       if (!(ret & UART_IIR_NO_INT))
+               return ret;
+
+       /* see if the TX interrupt should have really set */
+       ier = mem_serial_in(p, UART_IER);
+       /* see if the UART's XMIT interrupt is enabled */
+       if (!(ier & UART_IER_THRI))
+               return ret;
+
+       lsr = mem_serial_in(p, UART_LSR);
+       /* now check to see if the UART should be generating an interrupt (but isn't) */
+       if (lsr & (UART_LSR_THRE | UART_LSR_TEMT))
+               ret &= ~UART_IIR_NO_INT;
+
+       return ret;
+}
+
+static void ce4100_mem_serial_out(struct uart_port *p, unsigned int offset, u32 value)
+{
+       offset <<= p->regshift;
+       writel(value, p->membase + offset);
+}
+
+static void ce4100_serial_fixup(int port, struct uart_port *up, u32 *capabilities)
+{
+#ifdef CONFIG_EARLY_PRINTK
+       /*
+        * Override the legacy port configuration that comes from
+        * asm/serial.h. Using the ioport driver then switching to the
+        * PCI memmaped driver hangs the IOAPIC.
+        */
+       if (up->iotype != UPIO_MEM32) {
+               up->uartclk = 14745600;
+               up->mapbase = 0xdffe0200;
+               set_fixmap_nocache(FIX_EARLYCON_MEM_BASE, up->mapbase & PAGE_MASK);
+               up->membase = (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE);
+               up->membase += up->mapbase & ~PAGE_MASK;
+               up->mapbase += port * 0x100;
+               up->membase += port * 0x100;
+               up->iotype = UPIO_MEM32;
+               up->regshift = 2;
+               up->irq = 4;
+       }
+#endif
+       up->iobase = 0;
+       up->serial_in = ce4100_mem_serial_in;
+       up->serial_out = ce4100_mem_serial_out;
+
+       *capabilities |= (1 << 12);
+}
+
+void __init sdv_serial_fixup(void)
+{
+       serial8250_set_isa_configurator(ce4100_serial_fixup);
+}
index b04eeda03b234b4cc08b6d8c9bf2775dee8de6a6..e61dc3f4ca50eb4fcc65c28ff9ad4b2540399231 100644 (file)
@@ -24,6 +24,7 @@ obj-$(CONFIG_SERIAL_8250_ASPEED_VUART)        += 8250_aspeed_vuart.o
 obj-$(CONFIG_SERIAL_8250_BCM2835AUX)   += 8250_bcm2835aux.o
 obj-$(CONFIG_SERIAL_8250_BCM7271)      += 8250_bcm7271.o
 obj-$(CONFIG_SERIAL_8250_BOCA)         += 8250_boca.o
+obj-$(CONFIG_X86_INTEL_CE)             += 8250_ce4100.o
 obj-$(CONFIG_SERIAL_8250_DFL)          += 8250_dfl.o
 obj-$(CONFIG_SERIAL_8250_DW)           += 8250_dw.o
 obj-$(CONFIG_SERIAL_8250_EM)           += 8250_em.o