Commit 18bfebee authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Linus Torvalds

[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: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 378193eb
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/serialP.h> #include <linux/serialP.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/8250.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -41,7 +42,6 @@ ...@@ -41,7 +42,6 @@
#endif #endif
#include <linux/serial_core.h> #include <linux/serial_core.h>
#include "8250.h"
/* /*
* Configuration: * Configuration:
...@@ -112,11 +112,17 @@ unsigned int share_irqs = SERIAL8250_SHARE_IRQS; ...@@ -112,11 +112,17 @@ unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
#define SERIAL_PORT_DFNS #define SERIAL_PORT_DFNS
#endif #endif
#ifndef ARCH_HAS_GET_LEGACY_SERIAL_PORTS
static struct old_serial_port old_serial_port[] = { static struct old_serial_port old_serial_port[] = {
SERIAL_PORT_DFNS /* defined in asm/serial.h */ 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) #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 #ifdef CONFIG_SERIAL_8250_RSA
...@@ -1958,22 +1964,27 @@ static void __init serial8250_isa_init_ports(void) ...@@ -1958,22 +1964,27 @@ static void __init serial8250_isa_init_ports(void)
{ {
struct uart_8250_port *up; struct uart_8250_port *up;
static int first = 1; static int first = 1;
struct old_serial_port *old_ports;
int count;
int i; int i;
if (!first) if (!first)
return; return;
first = 0; first = 0;
for (i = 0, up = serial8250_ports; i < ARRAY_SIZE(old_serial_port); old_ports = get_legacy_serial_ports(&count);
i++, up++) { if (old_ports == NULL)
up->port.iobase = old_serial_port[i].port; return;
up->port.irq = irq_canonicalize(old_serial_port[i].irq);
up->port.uartclk = old_serial_port[i].baud_base * 16; for (i = 0, up = serial8250_ports; i < count; i++, up++) {
up->port.flags = old_serial_port[i].flags; up->port.iobase = old_ports[i].port;
up->port.hub6 = old_serial_port[i].hub6; up->port.irq = irq_canonicalize(old_ports[i].irq);
up->port.membase = old_serial_port[i].iomem_base; up->port.uartclk = old_ports[i].baud_base * 16;
up->port.iotype = old_serial_port[i].io_type; up->port.flags = old_ports[i].flags;
up->port.regshift = old_serial_port[i].iomem_reg_shift; 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; up->port.ops = &serial8250_pops;
if (share_irqs) if (share_irqs)
up->port.flags |= UPF_SHARE_IRQ; up->port.flags |= UPF_SHARE_IRQ;
...@@ -1990,6 +2001,13 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev) ...@@ -1990,6 +2001,13 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev)
for (i = 0; i < UART_NR; i++) { for (i = 0; i < UART_NR; i++) {
struct uart_8250_port *up = &serial8250_ports[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.line = i;
up->port.ops = &serial8250_pops; up->port.ops = &serial8250_pops;
up->port.dev = dev; up->port.dev = dev;
......
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/serial_core.h> #include <linux/serial_core.h>
#include <linux/8250_pci.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/8250.h>
#include <linux/8250_pci.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <asm/io.h> #include <asm/io.h>
#include "8250.h"
/* /*
* Definitions for PCI support. * Definitions for PCI support.
......
...@@ -26,12 +26,11 @@ ...@@ -26,12 +26,11 @@
#include <linux/serialP.h> #include <linux/serialP.h>
#include <linux/serial_core.h> #include <linux/serial_core.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/8250.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <asm/serial.h> #include <asm/serial.h>
#include "8250.h"
#define UNKNOWN_DEV 0x3000 #define UNKNOWN_DEV 0x3000
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/serial.h> #include <linux/serial.h>
#include <linux/serialP.h> #include <linux/serialP.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/8250.h>
#include <asm/serial.h> #include <asm/serial.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -40,7 +41,6 @@ ...@@ -40,7 +41,6 @@
#endif #endif
#include <linux/serial_core.h> #include <linux/serial_core.h>
#include "8250.h"
/* /*
* Debugging. * Debugging.
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <linux/serial.h> #include <linux/serial.h>
#include <linux/serial_core.h> #include <linux/serial_core.h>
#include <linux/major.h> #include <linux/major.h>
#include <linux/8250.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -55,8 +56,6 @@ ...@@ -55,8 +56,6 @@
#include <pcmcia/ds.h> #include <pcmcia/ds.h>
#include <pcmcia/cisreg.h> #include <pcmcia/cisreg.h>
#include "8250.h"
#ifdef PCMCIA_DEBUG #ifdef PCMCIA_DEBUG
static int pc_debug = PCMCIA_DEBUG; static int pc_debug = PCMCIA_DEBUG;
MODULE_PARM(pc_debug, "i"); MODULE_PARM(pc_debug, "i");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment