2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-14 16:23:51 +08:00

serial: MMIO32 support for 8250_early.c

Provide MMIO32 support in 8250_early (aka earlycon)

[randy.dunlap@oracle.com: fix printk format warnings]
[akpm@linux-foundation.org: fix printk args some more]
Signed-off-by: Samium Gromoff <_deepfire@feelingofgreen.ru>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Samium Gromoff 2010-07-20 15:26:51 -07:00 committed by Greg Kroah-Hartman
parent 0ac8382e9c
commit 1917ac76e0
2 changed files with 45 additions and 15 deletions

View File

@ -681,8 +681,11 @@ and is between 256 and 4096 characters. It is defined in the file
earlycon= [KNL] Output early console device and options. earlycon= [KNL] Output early console device and options.
uart[8250],io,<addr>[,options] uart[8250],io,<addr>[,options]
uart[8250],mmio,<addr>[,options] uart[8250],mmio,<addr>[,options]
uart[8250],mmio32,<addr>[,options]
Start an early, polled-mode console on the 8250/16550 Start an early, polled-mode console on the 8250/16550
UART at the specified I/O port or MMIO address. UART at the specified I/O port or MMIO address.
MMIO inter-register address stride is either 8bit (mmio)
or 32bit (mmio32).
The options are the same as for ttyS, above. The options are the same as for ttyS, above.
earlyprintk= [X86,SH,BLACKFIN] earlyprintk= [X86,SH,BLACKFIN]

View File

@ -19,9 +19,11 @@
* The user can specify the device directly, e.g., * The user can specify the device directly, e.g.,
* earlycon=uart8250,io,0x3f8,9600n8 * earlycon=uart8250,io,0x3f8,9600n8
* earlycon=uart8250,mmio,0xff5e0000,115200n8 * earlycon=uart8250,mmio,0xff5e0000,115200n8
* earlycon=uart8250,mmio32,0xff5e0000,115200n8
* or * or
* console=uart8250,io,0x3f8,9600n8 * console=uart8250,io,0x3f8,9600n8
* console=uart8250,mmio,0xff5e0000,115200n8 * console=uart8250,mmio,0xff5e0000,115200n8
* console=uart8250,mmio32,0xff5e0000,115200n8
*/ */
#include <linux/tty.h> #include <linux/tty.h>
@ -48,18 +50,31 @@ static struct early_serial8250_device early_device;
static unsigned int __init serial_in(struct uart_port *port, int offset) static unsigned int __init serial_in(struct uart_port *port, int offset)
{ {
if (port->iotype == UPIO_MEM) switch (port->iotype) {
case UPIO_MEM:
return readb(port->membase + offset); return readb(port->membase + offset);
else case UPIO_MEM32:
return readl(port->membase + (offset << 2));
case UPIO_PORT:
return inb(port->iobase + offset); return inb(port->iobase + offset);
default:
return 0;
}
} }
static void __init serial_out(struct uart_port *port, int offset, int value) static void __init serial_out(struct uart_port *port, int offset, int value)
{ {
if (port->iotype == UPIO_MEM) switch (port->iotype) {
case UPIO_MEM:
writeb(value, port->membase + offset); writeb(value, port->membase + offset);
else break;
case UPIO_MEM32:
writel(value, port->membase + (offset << 2));
break;
case UPIO_PORT:
outb(value, port->iobase + offset); outb(value, port->iobase + offset);
break;
}
} }
#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
@ -137,15 +152,21 @@ static int __init parse_options(struct early_serial8250_device *device,
char *options) char *options)
{ {
struct uart_port *port = &device->port; struct uart_port *port = &device->port;
int mmio, length; int mmio, mmio32, length;
if (!options) if (!options)
return -ENODEV; return -ENODEV;
port->uartclk = BASE_BAUD * 16; port->uartclk = BASE_BAUD * 16;
if (!strncmp(options, "mmio,", 5)) {
port->iotype = UPIO_MEM; mmio = !strncmp(options, "mmio,", 5);
port->mapbase = simple_strtoul(options + 5, &options, 0); mmio32 = !strncmp(options, "mmio32,", 7);
if (mmio || mmio32) {
port->iotype = (mmio ? UPIO_MEM : UPIO_MEM32);
port->mapbase = simple_strtoul(options + (mmio ? 5 : 7),
&options, 0);
if (mmio32)
port->regshift = 2;
#ifdef CONFIG_FIX_EARLYCON_MEM #ifdef CONFIG_FIX_EARLYCON_MEM
set_fixmap_nocache(FIX_EARLYCON_MEM_BASE, set_fixmap_nocache(FIX_EARLYCON_MEM_BASE,
port->mapbase & PAGE_MASK); port->mapbase & PAGE_MASK);
@ -157,11 +178,10 @@ static int __init parse_options(struct early_serial8250_device *device,
if (!port->membase) { if (!port->membase) {
printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n", printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n",
__func__, __func__,
(unsigned long long)port->mapbase); (unsigned long long) port->mapbase);
return -ENOMEM; return -ENOMEM;
} }
#endif #endif
mmio = 1;
} else if (!strncmp(options, "io,", 3)) { } else if (!strncmp(options, "io,", 3)) {
port->iotype = UPIO_PORT; port->iotype = UPIO_PORT;
port->iobase = simple_strtoul(options + 3, &options, 0); port->iobase = simple_strtoul(options + 3, &options, 0);
@ -181,11 +201,18 @@ static int __init parse_options(struct early_serial8250_device *device,
device->baud); device->baud);
} }
printk(KERN_INFO "Early serial console at %s 0x%llx (options '%s')\n", if (mmio || mmio32)
mmio ? "MMIO" : "I/O port", printk(KERN_INFO
mmio ? (unsigned long long) port->mapbase "Early serial console at MMIO%s 0x%llu (options '%s')\n",
: (unsigned long long) port->iobase, mmio32 ? "32" : "",
device->options); (unsigned long long)port->mapbase,
device->options);
else
printk(KERN_INFO
"Early serial console at I/O port 0x%lu (options '%s')\n",
port->iobase,
device->options);
return 0; return 0;
} }