diff options
24 files changed, 351 insertions, 133 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 3414e2301824..482dcc3b91e1 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -174,30 +174,15 @@ config LASAT | |||
174 | select SYS_SUPPORTS_64BIT_KERNEL if BROKEN | 174 | select SYS_SUPPORTS_64BIT_KERNEL if BROKEN |
175 | select SYS_SUPPORTS_LITTLE_ENDIAN | 175 | select SYS_SUPPORTS_LITTLE_ENDIAN |
176 | 176 | ||
177 | config LEMOTE_FULOONG2E | 177 | config MACH_LOONGSON |
178 | bool "Lemote Fuloong2e mini-PC" | 178 | bool "Loongson family of machines" |
179 | select ARCH_SPARSEMEM_ENABLE | ||
180 | select CEVT_R4K | ||
181 | select CSRC_R4K | ||
182 | select SYS_HAS_CPU_LOONGSON2 | ||
183 | select DMA_NONCOHERENT | ||
184 | select BOOT_ELF32 | ||
185 | select BOARD_SCACHE | ||
186 | select HAVE_STD_PC_SERIAL_PORT | ||
187 | select HW_HAS_PCI | ||
188 | select I8259 | ||
189 | select ISA | ||
190 | select IRQ_CPU | ||
191 | select SYS_SUPPORTS_32BIT_KERNEL | ||
192 | select SYS_SUPPORTS_64BIT_KERNEL | ||
193 | select SYS_SUPPORTS_LITTLE_ENDIAN | ||
194 | select SYS_SUPPORTS_HIGHMEM | ||
195 | select SYS_HAS_EARLY_PRINTK | ||
196 | select GENERIC_ISA_DMA_SUPPORT_BROKEN | ||
197 | select CPU_HAS_WB | ||
198 | help | 179 | help |
199 | Lemote Fuloong2e mini-PC board based on the Chinese Loongson-2E CPU and | 180 | This enables the support of Loongson family of machines. |
200 | an FPGA northbridge | 181 | |
182 | Loongson is a family of general-purpose MIPS-compatible CPUs. | ||
183 | developed at Institute of Computing Technology (ICT), | ||
184 | Chinese Academy of Sciences (CAS) in the People's Republic | ||
185 | of China. The chief architect is Professor Weiwu Hu. | ||
201 | 186 | ||
202 | config MIPS_MALTA | 187 | config MIPS_MALTA |
203 | bool "MIPS Malta board" | 188 | bool "MIPS Malta board" |
@@ -668,6 +653,7 @@ source "arch/mips/sibyte/Kconfig" | |||
668 | source "arch/mips/txx9/Kconfig" | 653 | source "arch/mips/txx9/Kconfig" |
669 | source "arch/mips/vr41xx/Kconfig" | 654 | source "arch/mips/vr41xx/Kconfig" |
670 | source "arch/mips/cavium-octeon/Kconfig" | 655 | source "arch/mips/cavium-octeon/Kconfig" |
656 | source "arch/mips/loongson/Kconfig" | ||
671 | 657 | ||
672 | endmenu | 658 | endmenu |
673 | 659 | ||
diff --git a/arch/mips/Makefile b/arch/mips/Makefile index 7754cbbbf4ed..94d6f5813860 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile | |||
@@ -314,11 +314,12 @@ cflags-$(CONFIG_WR_PPMC) += -I$(srctree)/arch/mips/include/asm/mach-wrppmc | |||
314 | load-$(CONFIG_WR_PPMC) += 0xffffffff80100000 | 314 | load-$(CONFIG_WR_PPMC) += 0xffffffff80100000 |
315 | 315 | ||
316 | # | 316 | # |
317 | # lemote fuloong2e mini-PC board | 317 | # Loongson family |
318 | # | 318 | # |
319 | core-$(CONFIG_LEMOTE_FULOONG2E) +=arch/mips/loongson/fuloong-2e/ | 319 | core-$(CONFIG_MACH_LOONGSON) +=arch/mips/loongson/ |
320 | cflags-$(CONFIG_MACH_LOONGSON) += -I$(srctree)/arch/mips/include/asm/mach-loongson \ | ||
321 | -mno-branch-likely | ||
320 | load-$(CONFIG_LEMOTE_FULOONG2E) +=0xffffffff80100000 | 322 | load-$(CONFIG_LEMOTE_FULOONG2E) +=0xffffffff80100000 |
321 | cflags-$(CONFIG_LEMOTE_FULOONG2E) += -I$(srctree)/arch/mips/include/asm/mach-loongson/ | ||
322 | 323 | ||
323 | # | 324 | # |
324 | # MIPS Malta board | 325 | # MIPS Malta board |
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h index e9f74dee24ef..da70bcf2304e 100644 --- a/arch/mips/include/asm/mach-loongson/loongson.h +++ b/arch/mips/include/asm/mach-loongson/loongson.h | |||
@@ -21,6 +21,10 @@ | |||
21 | /* loongson internal northbridge initialization */ | 21 | /* loongson internal northbridge initialization */ |
22 | extern void bonito_irq_init(void); | 22 | extern void bonito_irq_init(void); |
23 | 23 | ||
24 | /* machine-specific reboot/halt operation */ | ||
25 | extern void mach_prepare_reboot(void); | ||
26 | extern void mach_prepare_shutdown(void); | ||
27 | |||
24 | /* environment arguments from bootloader */ | 28 | /* environment arguments from bootloader */ |
25 | extern unsigned long bus_clock, cpu_clock_freq; | 29 | extern unsigned long bus_clock, cpu_clock_freq; |
26 | extern unsigned long memsize, highmemsize; | 30 | extern unsigned long memsize, highmemsize; |
@@ -30,6 +34,13 @@ extern void __init prom_init_memory(void); | |||
30 | extern void __init prom_init_cmdline(void); | 34 | extern void __init prom_init_cmdline(void); |
31 | extern void __init prom_init_env(void); | 35 | extern void __init prom_init_env(void); |
32 | 36 | ||
37 | /* irq operation functions */ | ||
38 | extern void bonito_irqdispatch(void); | ||
39 | extern void __init bonito_irq_init(void); | ||
40 | extern void __init set_irq_trigger_mode(void); | ||
41 | extern void __init mach_init_irq(void); | ||
42 | extern void mach_irq_dispatch(unsigned int pending); | ||
43 | |||
33 | /* PCI Configuration Registers */ | 44 | /* PCI Configuration Registers */ |
34 | #define LOONGSON_PCI_ISR4C BONITO_PCI_REG(0x4c) | 45 | #define LOONGSON_PCI_ISR4C BONITO_PCI_REG(0x4c) |
35 | 46 | ||
diff --git a/arch/mips/include/asm/mach-loongson/machine.h b/arch/mips/include/asm/mach-loongson/machine.h new file mode 100644 index 000000000000..8e60d363594e --- /dev/null +++ b/arch/mips/include/asm/mach-loongson/machine.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 Lemote, Inc. & Institute of Computing Technology | ||
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 | #ifndef __ASM_MACH_LOONGSON_MACHINE_H | ||
12 | #define __ASM_MACH_LOONGSON_MACHINE_H | ||
13 | |||
14 | #ifdef CONFIG_LEMOTE_FULOONG2E | ||
15 | |||
16 | #define LOONGSON_UART_BASE (BONITO_PCIIO_BASE + 0x3f8) | ||
17 | |||
18 | #define LOONGSON_MACHNAME "lemote-fuloong-2e-box" | ||
19 | |||
20 | #endif | ||
21 | |||
22 | #endif /* __ASM_MACH_LOONGSON_MACHINE_H */ | ||
diff --git a/arch/mips/include/asm/mach-loongson/mem.h b/arch/mips/include/asm/mach-loongson/mem.h new file mode 100644 index 000000000000..bd7b3cba7e35 --- /dev/null +++ b/arch/mips/include/asm/mach-loongson/mem.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 Lemote, Inc. & Institute of Computing Technology | ||
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 | #ifndef __ASM_MACH_LOONGSON_MEM_H | ||
12 | #define __ASM_MACH_LOONGSON_MEM_H | ||
13 | |||
14 | /* | ||
15 | * On Lemote Loongson 2e | ||
16 | * | ||
17 | * the high memory space starts from 512M. | ||
18 | * the peripheral registers reside between 0x1000:0000 and 0x2000:0000. | ||
19 | */ | ||
20 | |||
21 | #ifdef CONFIG_LEMOTE_FULOONG2E | ||
22 | |||
23 | #define LOONGSON_HIGHMEM_START 0x20000000 | ||
24 | |||
25 | #define LOONGSON_MMIO_MEM_START 0x10000000 | ||
26 | #define LOONGSON_MMIO_MEM_END 0x20000000 | ||
27 | |||
28 | #endif | ||
29 | |||
30 | #endif /* __ASM_MACH_LOONGSON_MEM_H */ | ||
diff --git a/arch/mips/include/asm/mach-loongson/pci.h b/arch/mips/include/asm/mach-loongson/pci.h index e229b2904cc9..f1663ca81da0 100644 --- a/arch/mips/include/asm/mach-loongson/pci.h +++ b/arch/mips/include/asm/mach-loongson/pci.h | |||
@@ -24,8 +24,14 @@ | |||
24 | 24 | ||
25 | extern struct pci_ops bonito64_pci_ops; | 25 | extern struct pci_ops bonito64_pci_ops; |
26 | 26 | ||
27 | #define LOONGSON2E_PCI_MEM_START BONITO_PCILO1_BASE | 27 | #ifdef CONFIG_LEMOTE_FULOONG2E |
28 | #define LOONGSON2E_PCI_MEM_END (BONITO_PCILO1_BASE + 0x04000000 * 2) | 28 | |
29 | #define LOONGSON2E_PCI_IO_START 0x00004000UL | 29 | /* this pci memory space is mapped by pcimap in pci.c */ |
30 | #define LOONGSON_PCI_MEM_START BONITO_PCILO1_BASE | ||
31 | #define LOONGSON_PCI_MEM_END (BONITO_PCILO1_BASE + 0x04000000 * 2) | ||
32 | /* this is an offset from mips_io_port_base */ | ||
33 | #define LOONGSON_PCI_IO_START 0x00004000UL | ||
34 | |||
35 | #endif | ||
30 | 36 | ||
31 | #endif /* !__ASM_MACH_LOONGSON_PCI_H_ */ | 37 | #endif /* !__ASM_MACH_LOONGSON_PCI_H_ */ |
diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig new file mode 100644 index 000000000000..376712a0e2f1 --- /dev/null +++ b/arch/mips/loongson/Kconfig | |||
@@ -0,0 +1,31 @@ | |||
1 | choice | ||
2 | prompt "Machine Type" | ||
3 | depends on MACH_LOONGSON | ||
4 | |||
5 | config LEMOTE_FULOONG2E | ||
6 | bool "Lemote Fuloong(2e) mini-PC" | ||
7 | select ARCH_SPARSEMEM_ENABLE | ||
8 | select CEVT_R4K | ||
9 | select CSRC_R4K | ||
10 | select SYS_HAS_CPU_LOONGSON2 | ||
11 | select DMA_NONCOHERENT | ||
12 | select BOOT_ELF32 | ||
13 | select BOARD_SCACHE | ||
14 | select HW_HAS_PCI | ||
15 | select I8259 | ||
16 | select ISA | ||
17 | select IRQ_CPU | ||
18 | select SYS_SUPPORTS_32BIT_KERNEL | ||
19 | select SYS_SUPPORTS_64BIT_KERNEL | ||
20 | select SYS_SUPPORTS_LITTLE_ENDIAN | ||
21 | select SYS_SUPPORTS_HIGHMEM | ||
22 | select SYS_HAS_EARLY_PRINTK | ||
23 | select GENERIC_HARDIRQS_NO__DO_IRQ | ||
24 | select GENERIC_ISA_DMA_SUPPORT_BROKEN | ||
25 | select CPU_HAS_WB | ||
26 | help | ||
27 | Lemote Fuloong(2e) mini-PC board based on the Chinese Loongson-2E CPU and | ||
28 | an FPGA northbridge | ||
29 | |||
30 | Lemote Fuloong(2e) mini PC have a VIA686B south bridge. | ||
31 | endchoice | ||
diff --git a/arch/mips/loongson/Makefile b/arch/mips/loongson/Makefile new file mode 100644 index 000000000000..39048c455d7d --- /dev/null +++ b/arch/mips/loongson/Makefile | |||
@@ -0,0 +1,11 @@ | |||
1 | # | ||
2 | # Common code for all Loongson based systems | ||
3 | # | ||
4 | |||
5 | obj-$(CONFIG_MACH_LOONGSON) += common/ | ||
6 | |||
7 | # | ||
8 | # Lemote Fuloong mini-PC (Loongson 2E-based) | ||
9 | # | ||
10 | |||
11 | obj-$(CONFIG_LEMOTE_FULOONG2E) += fuloong-2e/ | ||
diff --git a/arch/mips/loongson/common/Makefile b/arch/mips/loongson/common/Makefile new file mode 100644 index 000000000000..4e3889dec39e --- /dev/null +++ b/arch/mips/loongson/common/Makefile | |||
@@ -0,0 +1,11 @@ | |||
1 | # | ||
2 | # Makefile for loongson based machines. | ||
3 | # | ||
4 | |||
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 | ||
7 | |||
8 | # | ||
9 | # Early printk support | ||
10 | # | ||
11 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o | ||
diff --git a/arch/mips/loongson/fuloong-2e/bonito-irq.c b/arch/mips/loongson/common/bonito-irq.c index 3e31e7ad713e..3e31e7ad713e 100644 --- a/arch/mips/loongson/fuloong-2e/bonito-irq.c +++ b/arch/mips/loongson/common/bonito-irq.c | |||
diff --git a/arch/mips/loongson/fuloong-2e/cmdline.c b/arch/mips/loongson/common/cmdline.c index 75f1b243ee4e..75f1b243ee4e 100644 --- a/arch/mips/loongson/fuloong-2e/cmdline.c +++ b/arch/mips/loongson/common/cmdline.c | |||
diff --git a/arch/mips/loongson/fuloong-2e/early_printk.c b/arch/mips/loongson/common/early_printk.c index 3e0a6eaa4041..bc73edc0cfd8 100644 --- a/arch/mips/loongson/fuloong-2e/early_printk.c +++ b/arch/mips/loongson/common/early_printk.c | |||
@@ -12,8 +12,7 @@ | |||
12 | #include <linux/serial_reg.h> | 12 | #include <linux/serial_reg.h> |
13 | 13 | ||
14 | #include <loongson.h> | 14 | #include <loongson.h> |
15 | 15 | #include <machine.h> | |
16 | #define UART_BASE (BONITO_PCIIO_BASE + 0x3f8) | ||
17 | 16 | ||
18 | #define PORT(base, offset) (u8 *)(base + offset) | 17 | #define PORT(base, offset) (u8 *)(base + offset) |
19 | 18 | ||
@@ -30,7 +29,7 @@ static inline void serial_out(phys_addr_t base, int offset, int value) | |||
30 | void prom_putchar(char c) | 29 | void prom_putchar(char c) |
31 | { | 30 | { |
32 | phys_addr_t uart_base = | 31 | phys_addr_t uart_base = |
33 | (phys_addr_t) ioremap_nocache(UART_BASE, 8); | 32 | (phys_addr_t) ioremap_nocache(LOONGSON_UART_BASE, 8); |
34 | 33 | ||
35 | while ((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) | 34 | while ((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) |
36 | ; | 35 | ; |
diff --git a/arch/mips/loongson/fuloong-2e/env.c b/arch/mips/loongson/common/env.c index b9ef50385541..b9ef50385541 100644 --- a/arch/mips/loongson/fuloong-2e/env.c +++ b/arch/mips/loongson/common/env.c | |||
diff --git a/arch/mips/loongson/fuloong-2e/init.c b/arch/mips/loongson/common/init.c index 3abe927422a3..3abe927422a3 100644 --- a/arch/mips/loongson/fuloong-2e/init.c +++ b/arch/mips/loongson/common/init.c | |||
diff --git a/arch/mips/loongson/common/irq.c b/arch/mips/loongson/common/irq.c new file mode 100644 index 000000000000..f368c735cbd3 --- /dev/null +++ b/arch/mips/loongson/common/irq.c | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | ||
3 | * Author: Fuxin Zhang, zhangfx@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 | #include <linux/delay.h> | ||
11 | #include <linux/interrupt.h> | ||
12 | |||
13 | #include <loongson.h> | ||
14 | /* | ||
15 | * the first level int-handler will jump here if it is a bonito irq | ||
16 | */ | ||
17 | void bonito_irqdispatch(void) | ||
18 | { | ||
19 | u32 int_status; | ||
20 | int i; | ||
21 | |||
22 | /* workaround the IO dma problem: let cpu looping to allow DMA finish */ | ||
23 | int_status = BONITO_INTISR; | ||
24 | if (int_status & (1 << 10)) { | ||
25 | while (int_status & (1 << 10)) { | ||
26 | udelay(1); | ||
27 | int_status = BONITO_INTISR; | ||
28 | } | ||
29 | } | ||
30 | |||
31 | /* Get pending sources, masked by current enables */ | ||
32 | int_status = BONITO_INTISR & BONITO_INTEN; | ||
33 | |||
34 | if (int_status != 0) { | ||
35 | i = __ffs(int_status); | ||
36 | int_status &= ~(1 << i); | ||
37 | do_IRQ(BONITO_IRQ_BASE + i); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | asmlinkage void plat_irq_dispatch(void) | ||
42 | { | ||
43 | unsigned int pending; | ||
44 | |||
45 | pending = read_c0_cause() & read_c0_status() & ST0_IM; | ||
46 | |||
47 | /* machine-specific plat_irq_dispatch */ | ||
48 | mach_irq_dispatch(pending); | ||
49 | } | ||
50 | |||
51 | void __init arch_init_irq(void) | ||
52 | { | ||
53 | /* | ||
54 | * Clear all of the interrupts while we change the able around a bit. | ||
55 | * int-handler is not on bootstrap | ||
56 | */ | ||
57 | clear_c0_status(ST0_IM | ST0_BEV); | ||
58 | local_irq_disable(); | ||
59 | |||
60 | /* setting irq trigger mode */ | ||
61 | set_irq_trigger_mode(); | ||
62 | |||
63 | /* no steer */ | ||
64 | BONITO_INTSTEER = 0; | ||
65 | |||
66 | /* | ||
67 | * Mask out all interrupt by writing "1" to all bit position in | ||
68 | * the interrupt reset reg. | ||
69 | */ | ||
70 | BONITO_INTENCLR = ~0; | ||
71 | |||
72 | /* machine specific irq init */ | ||
73 | mach_init_irq(); | ||
74 | } | ||
diff --git a/arch/mips/loongson/fuloong-2e/machtype.c b/arch/mips/loongson/common/machtype.c index e03aa0de6176..845b3fb47e0f 100644 --- a/arch/mips/loongson/fuloong-2e/machtype.c +++ b/arch/mips/loongson/common/machtype.c | |||
@@ -8,8 +8,10 @@ | |||
8 | * option) any later version. | 8 | * option) any later version. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <machine.h> | ||
12 | |||
11 | const char *get_system_type(void) | 13 | const char *get_system_type(void) |
12 | { | 14 | { |
13 | return "lemote-fuloong-2e-box"; | 15 | return LOONGSON_MACHNAME; |
14 | } | 16 | } |
15 | 17 | ||
diff --git a/arch/mips/loongson/fuloong-2e/mem.c b/arch/mips/loongson/common/mem.c index 6a7feb178fa5..7c92f79b6480 100644 --- a/arch/mips/loongson/fuloong-2e/mem.c +++ b/arch/mips/loongson/common/mem.c | |||
@@ -11,13 +11,15 @@ | |||
11 | #include <asm/bootinfo.h> | 11 | #include <asm/bootinfo.h> |
12 | 12 | ||
13 | #include <loongson.h> | 13 | #include <loongson.h> |
14 | #include <mem.h> | ||
14 | 15 | ||
15 | void __init prom_init_memory(void) | 16 | void __init prom_init_memory(void) |
16 | { | 17 | { |
17 | add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM); | 18 | add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM); |
18 | #ifdef CONFIG_64BIT | 19 | #ifdef CONFIG_64BIT |
19 | if (highmemsize > 0) | 20 | if (highmemsize > 0) |
20 | add_memory_region(0x20000000, highmemsize << 20, BOOT_MEM_RAM); | 21 | add_memory_region(LOONGSON_HIGHMEM_START, |
22 | highmemsize << 20, BOOT_MEM_RAM); | ||
21 | #endif /* CONFIG_64BIT */ | 23 | #endif /* CONFIG_64BIT */ |
22 | } | 24 | } |
23 | 25 | ||
@@ -27,10 +29,7 @@ int __uncached_access(struct file *file, unsigned long addr) | |||
27 | if (file->f_flags & O_SYNC) | 29 | if (file->f_flags & O_SYNC) |
28 | return 1; | 30 | return 1; |
29 | 31 | ||
30 | /* | ||
31 | * On the Lemote Loongson 2e system, the peripheral registers | ||
32 | * reside between 0x1000:0000 and 0x2000:0000. | ||
33 | */ | ||
34 | return addr >= __pa(high_memory) || | 32 | return addr >= __pa(high_memory) || |
35 | ((addr >= 0x10000000) && (addr < 0x20000000)); | 33 | ((addr >= LOONGSON_MMIO_MEM_START) && |
34 | (addr < LOONGSON_MMIO_MEM_END)); | ||
36 | } | 35 | } |
diff --git a/arch/mips/loongson/fuloong-2e/pci.c b/arch/mips/loongson/common/pci.c index 9812c30cc6eb..a3a4abfb6c9a 100644 --- a/arch/mips/loongson/fuloong-2e/pci.c +++ b/arch/mips/loongson/common/pci.c | |||
@@ -12,24 +12,24 @@ | |||
12 | #include <pci.h> | 12 | #include <pci.h> |
13 | #include <loongson.h> | 13 | #include <loongson.h> |
14 | 14 | ||
15 | static struct resource loongson2e_pci_mem_resource = { | 15 | static struct resource loongson_pci_mem_resource = { |
16 | .name = "LOONGSON2E PCI MEM", | 16 | .name = "pci memory space", |
17 | .start = LOONGSON2E_PCI_MEM_START, | 17 | .start = LOONGSON_PCI_MEM_START, |
18 | .end = LOONGSON2E_PCI_MEM_END, | 18 | .end = LOONGSON_PCI_MEM_END, |
19 | .flags = IORESOURCE_MEM, | 19 | .flags = IORESOURCE_MEM, |
20 | }; | 20 | }; |
21 | 21 | ||
22 | static struct resource loongson2e_pci_io_resource = { | 22 | static struct resource loongson_pci_io_resource = { |
23 | .name = "LOONGSON2E PCI IO MEM", | 23 | .name = "pci io space", |
24 | .start = LOONGSON2E_PCI_IO_START, | 24 | .start = LOONGSON_PCI_IO_START, |
25 | .end = IO_SPACE_LIMIT, | 25 | .end = IO_SPACE_LIMIT, |
26 | .flags = IORESOURCE_IO, | 26 | .flags = IORESOURCE_IO, |
27 | }; | 27 | }; |
28 | 28 | ||
29 | static struct pci_controller loongson2e_pci_controller = { | 29 | static struct pci_controller loongson_pci_controller = { |
30 | .pci_ops = &bonito64_pci_ops, | 30 | .pci_ops = &bonito64_pci_ops, |
31 | .io_resource = &loongson2e_pci_io_resource, | 31 | .io_resource = &loongson_pci_io_resource, |
32 | .mem_resource = &loongson2e_pci_mem_resource, | 32 | .mem_resource = &loongson_pci_mem_resource, |
33 | .mem_offset = 0x00000000UL, | 33 | .mem_offset = 0x00000000UL, |
34 | .io_offset = 0x00000000UL, | 34 | .io_offset = 0x00000000UL, |
35 | }; | 35 | }; |
@@ -73,9 +73,9 @@ static int __init pcibios_init(void) | |||
73 | { | 73 | { |
74 | setup_pcimap(); | 74 | setup_pcimap(); |
75 | 75 | ||
76 | loongson2e_pci_controller.io_map_base = mips_io_port_base; | 76 | loongson_pci_controller.io_map_base = mips_io_port_base; |
77 | 77 | ||
78 | register_pci_controller(&loongson2e_pci_controller); | 78 | register_pci_controller(&loongson_pci_controller); |
79 | 79 | ||
80 | return 0; | 80 | return 0; |
81 | } | 81 | } |
diff --git a/arch/mips/loongson/common/reset.c b/arch/mips/loongson/common/reset.c new file mode 100644 index 000000000000..97e918251edd --- /dev/null +++ b/arch/mips/loongson/common/reset.c | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or modify it | ||
3 | * under the terms of the GNU General Public License as published by the | ||
4 | * Free Software Foundation; either version 2 of the License, or (at your | ||
5 | * option) any later version. | ||
6 | * | ||
7 | * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology | ||
8 | * Author: Fuxin Zhang, zhangfx@lemote.com | ||
9 | * Copyright (C) 2009 Lemote, Inc. & Institute of Computing Technology | ||
10 | * Author: Zhangjin Wu, wuzj@lemote.com | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/pm.h> | ||
14 | |||
15 | #include <asm/reboot.h> | ||
16 | |||
17 | #include <loongson.h> | ||
18 | |||
19 | static void loongson_restart(char *command) | ||
20 | { | ||
21 | /* do preparation for reboot */ | ||
22 | mach_prepare_reboot(); | ||
23 | |||
24 | /* reboot via jumping to boot base address */ | ||
25 | ((void (*)(void))ioremap_nocache(BONITO_BOOT_BASE, 4)) (); | ||
26 | } | ||
27 | |||
28 | static void loongson_halt(void) | ||
29 | { | ||
30 | mach_prepare_shutdown(); | ||
31 | while (1) | ||
32 | ; | ||
33 | } | ||
34 | |||
35 | static int __init mips_reboot_setup(void) | ||
36 | { | ||
37 | _machine_restart = loongson_restart; | ||
38 | _machine_halt = loongson_halt; | ||
39 | pm_power_off = loongson_halt; | ||
40 | |||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | arch_initcall(mips_reboot_setup); | ||
diff --git a/arch/mips/loongson/common/setup.c b/arch/mips/loongson/common/setup.c new file mode 100644 index 000000000000..4cd2aa9a342c --- /dev/null +++ b/arch/mips/loongson/common/setup.c | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | ||
3 | * Author: Fuxin Zhang, zhangfx@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 | #include <linux/module.h> | ||
11 | |||
12 | #include <asm/wbflush.h> | ||
13 | |||
14 | #include <loongson.h> | ||
15 | |||
16 | #ifdef CONFIG_VT | ||
17 | #include <linux/console.h> | ||
18 | #include <linux/screen_info.h> | ||
19 | #endif | ||
20 | |||
21 | void (*__wbflush)(void); | ||
22 | EXPORT_SYMBOL(__wbflush); | ||
23 | |||
24 | static void wbflush_loongson(void) | ||
25 | { | ||
26 | asm(".set\tpush\n\t" | ||
27 | ".set\tnoreorder\n\t" | ||
28 | ".set mips3\n\t" | ||
29 | "sync\n\t" | ||
30 | "nop\n\t" | ||
31 | ".set\tpop\n\t" | ||
32 | ".set mips0\n\t"); | ||
33 | } | ||
34 | |||
35 | void __init plat_mem_setup(void) | ||
36 | { | ||
37 | __wbflush = wbflush_loongson; | ||
38 | |||
39 | #ifdef CONFIG_VT | ||
40 | #if defined(CONFIG_VGA_CONSOLE) | ||
41 | conswitchp = &vga_con; | ||
42 | |||
43 | screen_info = (struct screen_info) { | ||
44 | 0, 25, /* orig-x, orig-y */ | ||
45 | 0, /* unused */ | ||
46 | 0, /* orig-video-page */ | ||
47 | 0, /* orig-video-mode */ | ||
48 | 80, /* orig-video-cols */ | ||
49 | 0, 0, 0, /* ega_ax, ega_bx, ega_cx */ | ||
50 | 25, /* orig-video-lines */ | ||
51 | VIDEO_TYPE_VGAC, /* orig-video-isVGA */ | ||
52 | 16 /* orig-video-points */ | ||
53 | }; | ||
54 | #elif defined(CONFIG_DUMMY_CONSOLE) | ||
55 | conswitchp = &dummy_con; | ||
56 | #endif | ||
57 | #endif | ||
58 | } | ||
diff --git a/arch/mips/loongson/fuloong-2e/time.c b/arch/mips/loongson/common/time.c index b13d17174654..b13d17174654 100644 --- a/arch/mips/loongson/fuloong-2e/time.c +++ b/arch/mips/loongson/common/time.c | |||
diff --git a/arch/mips/loongson/fuloong-2e/Makefile b/arch/mips/loongson/fuloong-2e/Makefile index feb1d6bba499..96e45c13c850 100644 --- a/arch/mips/loongson/fuloong-2e/Makefile +++ b/arch/mips/loongson/fuloong-2e/Makefile | |||
@@ -2,12 +2,6 @@ | |||
2 | # Makefile for Lemote Fuloong2e mini-PC board. | 2 | # Makefile for Lemote Fuloong2e mini-PC board. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += setup.o init.o reset.o irq.o pci.o bonito-irq.o mem.o \ | 5 | obj-y += irq.o reset.o machtype.o |
6 | env.o cmdline.o time.o machtype.o | ||
7 | |||
8 | # | ||
9 | # Early printk support | ||
10 | # | ||
11 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o | ||
12 | 6 | ||
13 | EXTRA_CFLAGS += -Werror | 7 | EXTRA_CFLAGS += -Werror |
diff --git a/arch/mips/loongson/fuloong-2e/irq.c b/arch/mips/loongson/fuloong-2e/irq.c index 9585f5aa7cce..7888cf69424a 100644 --- a/arch/mips/loongson/fuloong-2e/irq.c +++ b/arch/mips/loongson/fuloong-2e/irq.c | |||
@@ -7,39 +7,12 @@ | |||
7 | * Free Software Foundation; either version 2 of the License, or (at your | 7 | * Free Software Foundation; either version 2 of the License, or (at your |
8 | * option) any later version. | 8 | * option) any later version. |
9 | */ | 9 | */ |
10 | #include <linux/delay.h> | ||
11 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
12 | 11 | ||
13 | #include <asm/irq_cpu.h> | 12 | #include <asm/irq_cpu.h> |
14 | #include <asm/i8259.h> | 13 | #include <asm/i8259.h> |
15 | 14 | ||
16 | #include <loongson.h> | 15 | #include <loongson.h> |
17 | /* | ||
18 | * the first level int-handler will jump here if it is a bonito irq | ||
19 | */ | ||
20 | static void bonito_irqdispatch(void) | ||
21 | { | ||
22 | u32 int_status; | ||
23 | int i; | ||
24 | |||
25 | /* workaround the IO dma problem: let cpu looping to allow DMA finish */ | ||
26 | int_status = BONITO_INTISR; | ||
27 | if (int_status & (1 << 10)) { | ||
28 | while (int_status & (1 << 10)) { | ||
29 | udelay(1); | ||
30 | int_status = BONITO_INTISR; | ||
31 | } | ||
32 | } | ||
33 | |||
34 | /* Get pending sources, masked by current enables */ | ||
35 | int_status = BONITO_INTISR & BONITO_INTEN; | ||
36 | |||
37 | if (int_status != 0) { | ||
38 | i = __ffs(int_status); | ||
39 | int_status &= ~(1 << i); | ||
40 | do_IRQ(BONITO_IRQ_BASE + i); | ||
41 | } | ||
42 | } | ||
43 | 16 | ||
44 | static void i8259_irqdispatch(void) | 17 | static void i8259_irqdispatch(void) |
45 | { | 18 | { |
@@ -52,10 +25,8 @@ static void i8259_irqdispatch(void) | |||
52 | spurious_interrupt(); | 25 | spurious_interrupt(); |
53 | } | 26 | } |
54 | 27 | ||
55 | asmlinkage void plat_irq_dispatch(void) | 28 | asmlinkage void mach_irq_dispatch(unsigned int pending) |
56 | { | 29 | { |
57 | unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM; | ||
58 | |||
59 | if (pending & CAUSEF_IP7) | 30 | if (pending & CAUSEF_IP7) |
60 | do_IRQ(MIPS_CPU_IRQ_BASE + 7); | 31 | do_IRQ(MIPS_CPU_IRQ_BASE + 7); |
61 | else if (pending & CAUSEF_IP6) /* perf counter loverflow */ | 32 | else if (pending & CAUSEF_IP6) /* perf counter loverflow */ |
@@ -73,26 +44,15 @@ static struct irqaction cascade_irqaction = { | |||
73 | .name = "cascade", | 44 | .name = "cascade", |
74 | }; | 45 | }; |
75 | 46 | ||
76 | void __init arch_init_irq(void) | 47 | void __init set_irq_trigger_mode(void) |
77 | { | 48 | { |
78 | /* | ||
79 | * Clear all of the interrupts while we change the able around a bit. | ||
80 | * int-handler is not on bootstrap | ||
81 | */ | ||
82 | clear_c0_status(ST0_IM | ST0_BEV); | ||
83 | local_irq_disable(); | ||
84 | |||
85 | /* most bonito irq should be level triggered */ | 49 | /* most bonito irq should be level triggered */ |
86 | BONITO_INTEDGE = BONITO_ICU_SYSTEMERR | BONITO_ICU_MASTERERR | | 50 | BONITO_INTEDGE = BONITO_ICU_SYSTEMERR | BONITO_ICU_MASTERERR | |
87 | BONITO_ICU_RETRYERR | BONITO_ICU_MBOXES; | 51 | BONITO_ICU_RETRYERR | BONITO_ICU_MBOXES; |
88 | BONITO_INTSTEER = 0; | 52 | } |
89 | |||
90 | /* | ||
91 | * Mask out all interrupt by writing "1" to all bit position in | ||
92 | * the interrupt reset reg. | ||
93 | */ | ||
94 | BONITO_INTENCLR = ~0; | ||
95 | 53 | ||
54 | void __init mach_init_irq(void) | ||
55 | { | ||
96 | /* init all controller | 56 | /* init all controller |
97 | * 0-15 ------> i8259 interrupt | 57 | * 0-15 ------> i8259 interrupt |
98 | * 16-23 ------> mips cpu interrupt | 58 | * 16-23 ------> mips cpu interrupt |
diff --git a/arch/mips/loongson/fuloong-2e/reset.c b/arch/mips/loongson/fuloong-2e/reset.c index c21299af7f64..677fe186db95 100644 --- a/arch/mips/loongson/fuloong-2e/reset.c +++ b/arch/mips/loongson/fuloong-2e/reset.c | |||
@@ -1,44 +1,23 @@ | |||
1 | /* | 1 | /* Board-specific reboot/shutdown routines |
2 | * Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca> | ||
3 | * | ||
4 | * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | ||
5 | * Author: Wu Zhangjin, wuzj@lemote.com | ||
6 | * | ||
2 | * This program is free software; you can redistribute it and/or modify it | 7 | * This program is free software; you can redistribute it and/or modify it |
3 | * under the terms of the GNU General Public License as published by the | 8 | * under the terms of the GNU General Public License as published by the |
4 | * Free Software Foundation; either version 2 of the License, or (at your | 9 | * Free Software Foundation; either version 2 of the License, or (at your |
5 | * option) any later version. | 10 | * option) any later version. |
6 | * | ||
7 | * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology | ||
8 | * Author: Fuxin Zhang, zhangfx@lemote.com | ||
9 | * Copyright (C) 2009 Lemote, Inc. & Institute of Computing Technology | ||
10 | * Author: Zhangjin Wu, wuzj@lemote.com | ||
11 | */ | 11 | */ |
12 | #include <linux/init.h> | ||
13 | #include <linux/pm.h> | ||
14 | |||
15 | #include <asm/reboot.h> | ||
16 | 12 | ||
17 | #include <loongson.h> | 13 | #include <loongson.h> |
18 | 14 | ||
19 | static void loongson2e_restart(char *command) | 15 | void mach_prepare_reboot(void) |
20 | { | 16 | { |
21 | /* do preparation for reboot */ | ||
22 | BONITO_BONGENCFG &= ~(1 << 2); | 17 | BONITO_BONGENCFG &= ~(1 << 2); |
23 | BONITO_BONGENCFG |= (1 << 2); | 18 | BONITO_BONGENCFG |= (1 << 2); |
24 | |||
25 | /* reboot via jumping to boot base address */ | ||
26 | ((void (*)(void))ioremap_nocache(BONITO_BOOT_BASE, 4)) (); | ||
27 | } | 19 | } |
28 | 20 | ||
29 | static void loongson2e_halt(void) | 21 | void mach_prepare_shutdown(void) |
30 | { | 22 | { |
31 | while (1) | ||
32 | ; | ||
33 | } | 23 | } |
34 | |||
35 | static int __init mips_reboot_setup(void) | ||
36 | { | ||
37 | _machine_restart = loongson2e_restart; | ||
38 | _machine_halt = loongson2e_halt; | ||
39 | pm_power_off = loongson2e_halt; | ||
40 | |||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | arch_initcall(mips_reboot_setup); | ||