diff options
author | Wu Zhangjin <wuzhangjin@gmail.com> | 2009-11-06 05:35:34 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2009-12-16 20:57:09 -0500 |
commit | a3ed495190ebe918f4584291ed8c76f1c97a84fd (patch) | |
tree | 700cc7549624c08b38d6003d63a7bb514fe09605 /arch | |
parent | 04cfb90a92a2f9f7b56b2f85c528be7d1561e0e5 (diff) |
MIPS: Loongson: Cleanup the serial port support
To share the same kernel image amon different machines we have added the
machtype command line support.
In the old serial port implementation the UART base address is hardcoded as
a macro in machine.h which breaks with machtype, so change that to discover
the address dynamically. Also move the initialization of the UART base
address to uart_base.c to avoid remapping twice for early_printk.c and
serial.c.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/581/
Patchwork: http://patchwork.linux-mips.org/patch/682/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/mips/include/asm/mach-loongson/loongson.h | 3 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-loongson/machine.h | 2 | ||||
-rw-r--r-- | arch/mips/loongson/common/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/loongson/common/early_printk.c | 11 | ||||
-rw-r--r-- | arch/mips/loongson/common/init.c | 11 | ||||
-rw-r--r-- | arch/mips/loongson/common/serial.c | 17 | ||||
-rw-r--r-- | arch/mips/loongson/common/uart_base.c | 34 |
7 files changed, 60 insertions, 20 deletions
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h index efb234437791..722db9e811e5 100644 --- a/arch/mips/include/asm/mach-loongson/loongson.h +++ b/arch/mips/include/asm/mach-loongson/loongson.h | |||
@@ -31,6 +31,9 @@ extern void __init prom_init_memory(void); | |||
31 | extern void __init prom_init_cmdline(void); | 31 | extern void __init prom_init_cmdline(void); |
32 | extern void __init prom_init_machtype(void); | 32 | extern void __init prom_init_machtype(void); |
33 | extern void __init prom_init_env(void); | 33 | extern void __init prom_init_env(void); |
34 | extern unsigned long _loongson_uart_base; | ||
35 | extern unsigned long uart8250_base[]; | ||
36 | extern void prom_init_uart_base(void); | ||
34 | 37 | ||
35 | /* irq operation functions */ | 38 | /* irq operation functions */ |
36 | extern void bonito_irqdispatch(void); | 39 | extern void bonito_irqdispatch(void); |
diff --git a/arch/mips/include/asm/mach-loongson/machine.h b/arch/mips/include/asm/mach-loongson/machine.h index ea5954c4b221..d2f586157630 100644 --- a/arch/mips/include/asm/mach-loongson/machine.h +++ b/arch/mips/include/asm/mach-loongson/machine.h | |||
@@ -13,8 +13,6 @@ | |||
13 | 13 | ||
14 | #ifdef CONFIG_LEMOTE_FULOONG2E | 14 | #ifdef CONFIG_LEMOTE_FULOONG2E |
15 | 15 | ||
16 | #define LOONGSON_UART_BASE (LOONGSON_PCIIO_BASE + 0x3f8) | ||
17 | |||
18 | #define LOONGSON_MACHTYPE MACH_LEMOTE_FL2E | 16 | #define LOONGSON_MACHTYPE MACH_LEMOTE_FL2E |
19 | 17 | ||
20 | #endif | 18 | #endif |
diff --git a/arch/mips/loongson/common/Makefile b/arch/mips/loongson/common/Makefile index d21d1163fad0..be6adf7eb825 100644 --- a/arch/mips/loongson/common/Makefile +++ b/arch/mips/loongson/common/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \ | 5 | obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \ |
6 | pci.o bonito-irq.o mem.o machtype.o | 6 | pci.o bonito-irq.o mem.o machtype.o uart_base.o |
7 | 7 | ||
8 | # | 8 | # |
9 | # Early printk support | 9 | # Early printk support |
diff --git a/arch/mips/loongson/common/early_printk.c b/arch/mips/loongson/common/early_printk.c index 8ec4fb2066ae..23e7a8f8897f 100644 --- a/arch/mips/loongson/common/early_printk.c +++ b/arch/mips/loongson/common/early_printk.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/serial_reg.h> | 12 | #include <linux/serial_reg.h> |
13 | 13 | ||
14 | #include <loongson.h> | 14 | #include <loongson.h> |
15 | #include <machine.h> | ||
16 | 15 | ||
17 | #define PORT(base, offset) (u8 *)(base + offset) | 16 | #define PORT(base, offset) (u8 *)(base + offset) |
18 | 17 | ||
@@ -28,10 +27,14 @@ static inline void serial_out(unsigned char *base, int offset, int value) | |||
28 | 27 | ||
29 | void prom_putchar(char c) | 28 | void prom_putchar(char c) |
30 | { | 29 | { |
31 | unsigned char *uart_base = | 30 | int timeout; |
32 | (unsigned char *) ioremap_nocache(LOONGSON_UART_BASE, 8); | 31 | unsigned char *uart_base; |
33 | 32 | ||
34 | while ((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) | 33 | uart_base = (unsigned char *)_loongson_uart_base; |
34 | timeout = 1024; | ||
35 | |||
36 | while (((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) && | ||
37 | (timeout-- > 0)) | ||
35 | ; | 38 | ; |
36 | 39 | ||
37 | serial_out(uart_base, UART_TX, c); | 40 | serial_out(uart_base, UART_TX, c); |
diff --git a/arch/mips/loongson/common/init.c b/arch/mips/loongson/common/init.c index b7e4913627ab..3b1dbc1ca242 100644 --- a/arch/mips/loongson/common/init.c +++ b/arch/mips/loongson/common/init.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | 2 | * Copyright (C) 2009 Lemote Inc. |
3 | * Author: Wu Zhangjin, wuzj@lemote.com | 3 | * Author: Wu Zhangjin, wuzj@lemote.com |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
@@ -10,19 +10,22 @@ | |||
10 | 10 | ||
11 | #include <linux/bootmem.h> | 11 | #include <linux/bootmem.h> |
12 | 12 | ||
13 | #include <asm/bootinfo.h> | ||
14 | |||
15 | #include <loongson.h> | 13 | #include <loongson.h> |
16 | 14 | ||
17 | void __init prom_init(void) | 15 | void __init prom_init(void) |
18 | { | 16 | { |
19 | /* init base address of io space */ | 17 | /* init base address of io space */ |
20 | set_io_port_base((unsigned long) | 18 | set_io_port_base((unsigned long) |
21 | ioremap(LOONGSON_PCIIO_BASE, LOONGSON_PCIIO_SIZE)); | 19 | ioremap(LOONGSON_PCIIO_BASE, LOONGSON_PCIIO_SIZE)); |
22 | 20 | ||
23 | prom_init_cmdline(); | 21 | prom_init_cmdline(); |
24 | prom_init_env(); | 22 | prom_init_env(); |
25 | prom_init_memory(); | 23 | prom_init_memory(); |
24 | |||
25 | /*init the uart base address */ | ||
26 | #if defined(CONFIG_EARLY_PRINTK) || defined(CONFIG_SERIAL_8250) | ||
27 | prom_init_uart_base(); | ||
28 | #endif | ||
26 | } | 29 | } |
27 | 30 | ||
28 | void __init prom_free_prom_memory(void) | 31 | void __init prom_free_prom_memory(void) |
diff --git a/arch/mips/loongson/common/serial.c b/arch/mips/loongson/common/serial.c index 6d341e426f64..dc6488c14763 100644 --- a/arch/mips/loongson/common/serial.c +++ b/arch/mips/loongson/common/serial.c | |||
@@ -23,7 +23,6 @@ | |||
23 | { \ | 23 | { \ |
24 | .irq = int, \ | 24 | .irq = int, \ |
25 | .uartclk = 1843200, \ | 25 | .uartclk = 1843200, \ |
26 | .iobase = (LOONGSON_UART_BASE - LOONGSON_PCIIO_BASE),\ | ||
27 | .iotype = UPIO_PORT, \ | 26 | .iotype = UPIO_PORT, \ |
28 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \ | 27 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \ |
29 | .regshift = 0, \ | 28 | .regshift = 0, \ |
@@ -52,20 +51,20 @@ static struct plat_serial8250_port uart8250_data[][2] = { | |||
52 | static struct platform_device uart8250_device = { | 51 | static struct platform_device uart8250_device = { |
53 | .name = "serial8250", | 52 | .name = "serial8250", |
54 | .id = PLAT8250_DEV_PLATFORM, | 53 | .id = PLAT8250_DEV_PLATFORM, |
55 | .dev = { | ||
56 | .platform_data = uart8250_data[LOONGSON_MACHTYPE], | ||
57 | }, | ||
58 | }; | 54 | }; |
59 | 55 | ||
60 | static int __init serial_init(void) | 56 | static int __init serial_init(void) |
61 | { | 57 | { |
62 | if (uart8250_data[LOONGSON_MACHTYPE][0].iotype == UPIO_MEM) | 58 | if (uart8250_data[mips_machtype][0].iotype == UPIO_MEM) |
63 | uart8250_data[LOONGSON_MACHTYPE][0].membase = | 59 | uart8250_data[mips_machtype][0].membase = |
64 | ioremap_nocache(LOONGSON_UART_BASE, 8); | 60 | (void __iomem *)_loongson_uart_base; |
61 | else if (uart8250_data[mips_machtype][0].iotype == UPIO_PORT) | ||
62 | uart8250_data[mips_machtype][0].iobase = | ||
63 | uart8250_base[mips_machtype] - LOONGSON_PCIIO_BASE; | ||
65 | 64 | ||
66 | platform_device_register(&uart8250_device); | 65 | uart8250_device.dev.platform_data = uart8250_data[mips_machtype]; |
67 | 66 | ||
68 | return 0; | 67 | return platform_device_register(&uart8250_device); |
69 | } | 68 | } |
70 | 69 | ||
71 | device_initcall(serial_init); | 70 | device_initcall(serial_init); |
diff --git a/arch/mips/loongson/common/uart_base.c b/arch/mips/loongson/common/uart_base.c new file mode 100644 index 000000000000..233c708fc120 --- /dev/null +++ b/arch/mips/loongson/common/uart_base.c | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 Lemote Inc. | ||
3 | * Author: Wu Zhangjin, wuzj@lemote.com | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms of the GNU General Public License as published by the | ||
7 | * Free Software Foundation; either version 2 of the License, or (at your | ||
8 | * option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <asm/bootinfo.h> | ||
13 | |||
14 | #include <loongson.h> | ||
15 | |||
16 | unsigned long __maybe_unused _loongson_uart_base; | ||
17 | EXPORT_SYMBOL(_loongson_uart_base); | ||
18 | |||
19 | unsigned long __maybe_unused uart8250_base[] = { | ||
20 | [MACH_LOONGSON_UNKNOWN] 0, | ||
21 | [MACH_LEMOTE_FL2E] (LOONGSON_PCIIO_BASE + 0x3f8), | ||
22 | [MACH_LEMOTE_FL2F] (LOONGSON_PCIIO_BASE + 0x2f8), | ||
23 | [MACH_LEMOTE_ML2F7] (LOONGSON_LIO1_BASE + 0x3f8), | ||
24 | [MACH_LEMOTE_YL2F89] (LOONGSON_LIO1_BASE + 0x3f8), | ||
25 | [MACH_DEXXON_GDIUM2F10] (LOONGSON_LIO1_BASE + 0x3f8), | ||
26 | [MACH_LOONGSON_END] 0, | ||
27 | }; | ||
28 | EXPORT_SYMBOL(uart8250_base); | ||
29 | |||
30 | void __maybe_unused prom_init_uart_base(void) | ||
31 | { | ||
32 | _loongson_uart_base = | ||
33 | (unsigned long)ioremap_nocache(uart8250_base[mips_machtype], 8); | ||
34 | } | ||