summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2004-10-24 07:08:00 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-10-24 07:08:00 -0700
commit18bfebee0206ca105d9ef5b7b79aaa7f3a4b8fe1 (patch)
tree48516aa4ce46f6e838e20222eac901515e655a81
parent378193eb5452e2bf2e99cda40d77b82b5b2c13be (diff)
[PATCH] 8250: Let arch provide the list of leagacy ports
This patch adds an optional callback for the 8250 driver to request the list of legacy port via a function call instead of relying on a #define of an array. This finally allows to fix the problem of platforms like ppc and ppc64 for which the same kernel can boot machines with and without a 8250, and is necessary to properly deal with a new platform coming to ppc64 which has a 8250 but with different irq numbers. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/serial/8250.c42
-rw-r--r--drivers/serial/8250_pci.c4
-rw-r--r--drivers/serial/8250_pnp.c3
-rw-r--r--drivers/serial/au1x00_uart.c2
-rw-r--r--drivers/serial/serial_cs.c3
-rw-r--r--include/linux/8250.h (renamed from drivers/serial/8250.h)0
6 files changed, 35 insertions, 19 deletions
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index a5e821bbcd73..becce1d1f06a 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -32,6 +32,7 @@
#include <linux/serialP.h>
#include <linux/delay.h>
#include <linux/device.h>
+#include <linux/8250.h>
#include <asm/io.h>
#include <asm/irq.h>
@@ -41,7 +42,6 @@
#endif
#include <linux/serial_core.h>
-#include "8250.h"
/*
* Configuration:
@@ -112,11 +112,17 @@ unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
#define SERIAL_PORT_DFNS
#endif
+#ifndef ARCH_HAS_GET_LEGACY_SERIAL_PORTS
static struct old_serial_port old_serial_port[] = {
SERIAL_PORT_DFNS /* defined in asm/serial.h */
};
-
+static inline struct old_serial_port *get_legacy_serial_ports(unsigned int *count)
+{
+ *count = ARRAY_SIZE(old_serial_port);
+ return old_serial_port;
+}
#define UART_NR (ARRAY_SIZE(old_serial_port) + CONFIG_SERIAL_8250_NR_UARTS)
+#endif /* ARCH_HAS_DYNAMIC_LEGACY_SERIAL_PORTS */
#ifdef CONFIG_SERIAL_8250_RSA
@@ -1958,22 +1964,27 @@ static void __init serial8250_isa_init_ports(void)
{
struct uart_8250_port *up;
static int first = 1;
+ struct old_serial_port *old_ports;
+ int count;
int i;
if (!first)
return;
first = 0;
- for (i = 0, up = serial8250_ports; i < ARRAY_SIZE(old_serial_port);
- i++, up++) {
- up->port.iobase = old_serial_port[i].port;
- up->port.irq = irq_canonicalize(old_serial_port[i].irq);
- up->port.uartclk = old_serial_port[i].baud_base * 16;
- up->port.flags = old_serial_port[i].flags;
- up->port.hub6 = old_serial_port[i].hub6;
- up->port.membase = old_serial_port[i].iomem_base;
- up->port.iotype = old_serial_port[i].io_type;
- up->port.regshift = old_serial_port[i].iomem_reg_shift;
+ old_ports = get_legacy_serial_ports(&count);
+ if (old_ports == NULL)
+ return;
+
+ for (i = 0, up = serial8250_ports; i < count; i++, up++) {
+ up->port.iobase = old_ports[i].port;
+ up->port.irq = irq_canonicalize(old_ports[i].irq);
+ up->port.uartclk = old_ports[i].baud_base * 16;
+ up->port.flags = old_ports[i].flags;
+ up->port.hub6 = old_ports[i].hub6;
+ up->port.membase = old_ports[i].iomem_base;
+ up->port.iotype = old_ports[i].io_type;
+ up->port.regshift = old_ports[i].iomem_reg_shift;
up->port.ops = &serial8250_pops;
if (share_irqs)
up->port.flags |= UPF_SHARE_IRQ;
@@ -1990,6 +2001,13 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev)
for (i = 0; i < UART_NR; i++) {
struct uart_8250_port *up = &serial8250_ports[i];
+ /* Don't register "empty" ports, setting "ops" on them
+ * makes the console driver "setup" routine to succeed,
+ * which is wrong. --BenH.
+ */
+ if (!up->port.iobase)
+ continue;
+
up->port.line = i;
up->port.ops = &serial8250_pops;
up->port.dev = dev;
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index ef536ae16861..da80db8b4173 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -23,13 +23,13 @@
#include <linux/delay.h>
#include <linux/tty.h>
#include <linux/serial_core.h>
-#include <linux/8250_pci.h>
#include <linux/bitops.h>
+#include <linux/8250.h>
+#include <linux/8250_pci.h>
#include <asm/byteorder.h>
#include <asm/io.h>
-#include "8250.h"
/*
* Definitions for PCI support.
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
index 1b6dd76ee619..bb215f0e8971 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/serial/8250_pnp.c
@@ -26,12 +26,11 @@
#include <linux/serialP.h>
#include <linux/serial_core.h>
#include <linux/bitops.h>
+#include <linux/8250.h>
#include <asm/byteorder.h>
#include <asm/serial.h>
-#include "8250.h"
-
#define UNKNOWN_DEV 0x3000
diff --git a/drivers/serial/au1x00_uart.c b/drivers/serial/au1x00_uart.c
index f1c524aca9b2..22c39f9aca20 100644
--- a/drivers/serial/au1x00_uart.c
+++ b/drivers/serial/au1x00_uart.c
@@ -29,6 +29,7 @@
#include <linux/serial.h>
#include <linux/serialP.h>
#include <linux/delay.h>
+#include <linux/8250.h>
#include <asm/serial.h>
#include <asm/io.h>
@@ -40,7 +41,6 @@
#endif
#include <linux/serial_core.h>
-#include "8250.h"
/*
* Debugging.
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index a36650b87fb2..ce73affea290 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -44,6 +44,7 @@
#include <linux/serial.h>
#include <linux/serial_core.h>
#include <linux/major.h>
+#include <linux/8250.h>
#include <asm/io.h>
#include <asm/system.h>
@@ -55,8 +56,6 @@
#include <pcmcia/ds.h>
#include <pcmcia/cisreg.h>
-#include "8250.h"
-
#ifdef PCMCIA_DEBUG
static int pc_debug = PCMCIA_DEBUG;
MODULE_PARM(pc_debug, "i");
diff --git a/drivers/serial/8250.h b/include/linux/8250.h
index 58bf671b1cde..58bf671b1cde 100644
--- a/drivers/serial/8250.h
+++ b/include/linux/8250.h