diff options
author | Wu Zhangjin <wuzhangjin@gmail.com> | 2009-07-02 11:26:08 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2009-09-17 14:07:47 -0400 |
commit | 8e4971175acc910eb4258df82a6bd8f2c4e4e5b5 (patch) | |
tree | 921d53308d0a8a8e9119ec6b262a01fe0ccd1fd5 /arch/mips/loongson/fuloong-2e | |
parent | 67b35e5d01aba7a83f2161b0c90acb08afa01e3e (diff) |
MIPS: Loongson: Change naming methods
To make source code of loongson sharable to the machines(such as gdium)
made by the other companies, we rename arch/mips/lemote to
arch/mips/loongson, asm/mach-lemote to asm/mach-loongson, and rename lm2e
to the name of the machine: fuloong-2e. accordingly, FULONG are renamed to
FULOONG2E to make it distinguishable to the future FULOONG2F. and also,
some other relative tuning is needed.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/loongson/fuloong-2e')
-rw-r--r-- | arch/mips/loongson/fuloong-2e/Makefile | 13 | ||||
-rw-r--r-- | arch/mips/loongson/fuloong-2e/bonito-irq.c | 51 | ||||
-rw-r--r-- | arch/mips/loongson/fuloong-2e/cmdline.c | 52 | ||||
-rw-r--r-- | arch/mips/loongson/fuloong-2e/early_printk.c | 39 | ||||
-rw-r--r-- | arch/mips/loongson/fuloong-2e/env.c | 58 | ||||
-rw-r--r-- | arch/mips/loongson/fuloong-2e/init.c | 30 | ||||
-rw-r--r-- | arch/mips/loongson/fuloong-2e/irq.c | 111 | ||||
-rw-r--r-- | arch/mips/loongson/fuloong-2e/machtype.c | 15 | ||||
-rw-r--r-- | arch/mips/loongson/fuloong-2e/mem.c | 36 | ||||
-rw-r--r-- | arch/mips/loongson/fuloong-2e/pci.c | 83 | ||||
-rw-r--r-- | arch/mips/loongson/fuloong-2e/reset.c | 44 | ||||
-rw-r--r-- | arch/mips/loongson/fuloong-2e/time.c | 27 |
12 files changed, 559 insertions, 0 deletions
diff --git a/arch/mips/loongson/fuloong-2e/Makefile b/arch/mips/loongson/fuloong-2e/Makefile new file mode 100644 index 000000000000..feb1d6bba499 --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/Makefile | |||
@@ -0,0 +1,13 @@ | |||
1 | # | ||
2 | # Makefile for Lemote Fuloong2e mini-PC board. | ||
3 | # | ||
4 | |||
5 | obj-y += setup.o init.o reset.o irq.o pci.o bonito-irq.o mem.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 | |||
13 | EXTRA_CFLAGS += -Werror | ||
diff --git a/arch/mips/loongson/fuloong-2e/bonito-irq.c b/arch/mips/loongson/fuloong-2e/bonito-irq.c new file mode 100644 index 000000000000..3e31e7ad713e --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/bonito-irq.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /* | ||
2 | * Copyright 2001 MontaVista Software Inc. | ||
3 | * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net | ||
4 | * Copyright (C) 2000, 2001 Ralf Baechle (ralf@gnu.org) | ||
5 | * | ||
6 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | ||
7 | * Author: Fuxin Zhang, zhangfx@lemote.com | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | */ | ||
14 | #include <linux/interrupt.h> | ||
15 | |||
16 | #include <loongson.h> | ||
17 | |||
18 | static inline void bonito_irq_enable(unsigned int irq) | ||
19 | { | ||
20 | BONITO_INTENSET = (1 << (irq - BONITO_IRQ_BASE)); | ||
21 | mmiowb(); | ||
22 | } | ||
23 | |||
24 | static inline void bonito_irq_disable(unsigned int irq) | ||
25 | { | ||
26 | BONITO_INTENCLR = (1 << (irq - BONITO_IRQ_BASE)); | ||
27 | mmiowb(); | ||
28 | } | ||
29 | |||
30 | static struct irq_chip bonito_irq_type = { | ||
31 | .name = "bonito_irq", | ||
32 | .ack = bonito_irq_disable, | ||
33 | .mask = bonito_irq_disable, | ||
34 | .mask_ack = bonito_irq_disable, | ||
35 | .unmask = bonito_irq_enable, | ||
36 | }; | ||
37 | |||
38 | static struct irqaction dma_timeout_irqaction = { | ||
39 | .handler = no_action, | ||
40 | .name = "dma_timeout", | ||
41 | }; | ||
42 | |||
43 | void bonito_irq_init(void) | ||
44 | { | ||
45 | u32 i; | ||
46 | |||
47 | for (i = BONITO_IRQ_BASE; i < BONITO_IRQ_BASE + 32; i++) | ||
48 | set_irq_chip_and_handler(i, &bonito_irq_type, handle_level_irq); | ||
49 | |||
50 | setup_irq(BONITO_IRQ_BASE + 10, &dma_timeout_irqaction); | ||
51 | } | ||
diff --git a/arch/mips/loongson/fuloong-2e/cmdline.c b/arch/mips/loongson/fuloong-2e/cmdline.c new file mode 100644 index 000000000000..75f1b243ee4e --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/cmdline.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Based on Ocelot Linux port, which is | ||
3 | * Copyright 2001 MontaVista Software Inc. | ||
4 | * Author: jsun@mvista.com or jsun@junsun.net | ||
5 | * | ||
6 | * Copyright 2003 ICT CAS | ||
7 | * Author: Michael Guo <guoyi@ict.ac.cn> | ||
8 | * | ||
9 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | ||
10 | * Author: Fuxin Zhang, zhangfx@lemote.com | ||
11 | * | ||
12 | * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | ||
13 | * Author: Wu Zhangjin, wuzj@lemote.com | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or modify it | ||
16 | * under the terms of the GNU General Public License as published by the | ||
17 | * Free Software Foundation; either version 2 of the License, or (at your | ||
18 | * option) any later version. | ||
19 | */ | ||
20 | #include <asm/bootinfo.h> | ||
21 | |||
22 | #include <loongson.h> | ||
23 | |||
24 | int prom_argc; | ||
25 | /* pmon passes arguments in 32bit pointers */ | ||
26 | int *_prom_argv; | ||
27 | |||
28 | void __init prom_init_cmdline(void) | ||
29 | { | ||
30 | int i; | ||
31 | long l; | ||
32 | |||
33 | /* firmware arguments are initialized in head.S */ | ||
34 | prom_argc = fw_arg0; | ||
35 | _prom_argv = (int *)fw_arg1; | ||
36 | |||
37 | /* arg[0] is "g", the rest is boot parameters */ | ||
38 | arcs_cmdline[0] = '\0'; | ||
39 | for (i = 1; i < prom_argc; i++) { | ||
40 | l = (long)_prom_argv[i]; | ||
41 | if (strlen(arcs_cmdline) + strlen(((char *)l) + 1) | ||
42 | >= sizeof(arcs_cmdline)) | ||
43 | break; | ||
44 | strcat(arcs_cmdline, ((char *)l)); | ||
45 | strcat(arcs_cmdline, " "); | ||
46 | } | ||
47 | |||
48 | if ((strstr(arcs_cmdline, "console=")) == NULL) | ||
49 | strcat(arcs_cmdline, " console=ttyS0,115200"); | ||
50 | if ((strstr(arcs_cmdline, "root=")) == NULL) | ||
51 | strcat(arcs_cmdline, " root=/dev/hda1"); | ||
52 | } | ||
diff --git a/arch/mips/loongson/fuloong-2e/early_printk.c b/arch/mips/loongson/fuloong-2e/early_printk.c new file mode 100644 index 000000000000..3e0a6eaa4041 --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/early_printk.c | |||
@@ -0,0 +1,39 @@ | |||
1 | /* early printk support | ||
2 | * | ||
3 | * Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca> | ||
4 | * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | ||
5 | * Author: Wu Zhangjin, wuzj@lemote.com | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | */ | ||
12 | #include <linux/serial_reg.h> | ||
13 | |||
14 | #include <loongson.h> | ||
15 | |||
16 | #define UART_BASE (BONITO_PCIIO_BASE + 0x3f8) | ||
17 | |||
18 | #define PORT(base, offset) (u8 *)(base + offset) | ||
19 | |||
20 | static inline unsigned int serial_in(phys_addr_t base, int offset) | ||
21 | { | ||
22 | return readb(PORT(base, offset)); | ||
23 | } | ||
24 | |||
25 | static inline void serial_out(phys_addr_t base, int offset, int value) | ||
26 | { | ||
27 | writeb(value, PORT(base, offset)); | ||
28 | } | ||
29 | |||
30 | void prom_putchar(char c) | ||
31 | { | ||
32 | phys_addr_t uart_base = | ||
33 | (phys_addr_t) ioremap_nocache(UART_BASE, 8); | ||
34 | |||
35 | while ((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) | ||
36 | ; | ||
37 | |||
38 | serial_out(uart_base, UART_TX, c); | ||
39 | } | ||
diff --git a/arch/mips/loongson/fuloong-2e/env.c b/arch/mips/loongson/fuloong-2e/env.c new file mode 100644 index 000000000000..b9ef50385541 --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/env.c | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Based on Ocelot Linux port, which is | ||
3 | * Copyright 2001 MontaVista Software Inc. | ||
4 | * Author: jsun@mvista.com or jsun@junsun.net | ||
5 | * | ||
6 | * Copyright 2003 ICT CAS | ||
7 | * Author: Michael Guo <guoyi@ict.ac.cn> | ||
8 | * | ||
9 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | ||
10 | * Author: Fuxin Zhang, zhangfx@lemote.com | ||
11 | * | ||
12 | * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | ||
13 | * Author: Wu Zhangjin, wuzj@lemote.com | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or modify it | ||
16 | * under the terms of the GNU General Public License as published by the | ||
17 | * Free Software Foundation; either version 2 of the License, or (at your | ||
18 | * option) any later version. | ||
19 | */ | ||
20 | #include <asm/bootinfo.h> | ||
21 | |||
22 | #include <loongson.h> | ||
23 | |||
24 | unsigned long bus_clock, cpu_clock_freq; | ||
25 | unsigned long memsize, highmemsize; | ||
26 | |||
27 | /* pmon passes arguments in 32bit pointers */ | ||
28 | int *_prom_envp; | ||
29 | |||
30 | #define parse_even_earlier(res, option, p) \ | ||
31 | do { \ | ||
32 | if (strncmp(option, (char *)p, strlen(option)) == 0) \ | ||
33 | strict_strtol((char *)p + strlen(option"="), \ | ||
34 | 10, &res); \ | ||
35 | } while (0) | ||
36 | |||
37 | void __init prom_init_env(void) | ||
38 | { | ||
39 | long l; | ||
40 | |||
41 | /* firmware arguments are initialized in head.S */ | ||
42 | _prom_envp = (int *)fw_arg2; | ||
43 | |||
44 | l = (long)*_prom_envp; | ||
45 | while (l != 0) { | ||
46 | parse_even_earlier(bus_clock, "busclock", l); | ||
47 | parse_even_earlier(cpu_clock_freq, "cpuclock", l); | ||
48 | parse_even_earlier(memsize, "memsize", l); | ||
49 | parse_even_earlier(highmemsize, "highmemsize", l); | ||
50 | _prom_envp++; | ||
51 | l = (long)*_prom_envp; | ||
52 | } | ||
53 | if (memsize == 0) | ||
54 | memsize = 256; | ||
55 | |||
56 | pr_info("busclock=%ld, cpuclock=%ld, memsize=%ld, highmemsize=%ld\n", | ||
57 | bus_clock, cpu_clock_freq, memsize, highmemsize); | ||
58 | } | ||
diff --git a/arch/mips/loongson/fuloong-2e/init.c b/arch/mips/loongson/fuloong-2e/init.c new file mode 100644 index 000000000000..3abe927422a3 --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/init.c | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 Lemote Inc. & Insititute 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 | #include <linux/bootmem.h> | ||
12 | |||
13 | #include <asm/bootinfo.h> | ||
14 | |||
15 | #include <loongson.h> | ||
16 | |||
17 | void __init prom_init(void) | ||
18 | { | ||
19 | /* init base address of io space */ | ||
20 | set_io_port_base((unsigned long) | ||
21 | ioremap(BONITO_PCIIO_BASE, BONITO_PCIIO_SIZE)); | ||
22 | |||
23 | prom_init_cmdline(); | ||
24 | prom_init_env(); | ||
25 | prom_init_memory(); | ||
26 | } | ||
27 | |||
28 | void __init prom_free_prom_memory(void) | ||
29 | { | ||
30 | } | ||
diff --git a/arch/mips/loongson/fuloong-2e/irq.c b/arch/mips/loongson/fuloong-2e/irq.c new file mode 100644 index 000000000000..9585f5aa7cce --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/irq.c | |||
@@ -0,0 +1,111 @@ | |||
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 <asm/irq_cpu.h> | ||
14 | #include <asm/i8259.h> | ||
15 | |||
16 | #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 | |||
44 | static void i8259_irqdispatch(void) | ||
45 | { | ||
46 | int irq; | ||
47 | |||
48 | irq = i8259_irq(); | ||
49 | if (irq >= 0) | ||
50 | do_IRQ(irq); | ||
51 | else | ||
52 | spurious_interrupt(); | ||
53 | } | ||
54 | |||
55 | asmlinkage void plat_irq_dispatch(void) | ||
56 | { | ||
57 | unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM; | ||
58 | |||
59 | if (pending & CAUSEF_IP7) | ||
60 | do_IRQ(MIPS_CPU_IRQ_BASE + 7); | ||
61 | else if (pending & CAUSEF_IP6) /* perf counter loverflow */ | ||
62 | do_IRQ(LOONGSON2_PERFCNT_IRQ); | ||
63 | else if (pending & CAUSEF_IP5) | ||
64 | i8259_irqdispatch(); | ||
65 | else if (pending & CAUSEF_IP2) | ||
66 | bonito_irqdispatch(); | ||
67 | else | ||
68 | spurious_interrupt(); | ||
69 | } | ||
70 | |||
71 | static struct irqaction cascade_irqaction = { | ||
72 | .handler = no_action, | ||
73 | .name = "cascade", | ||
74 | }; | ||
75 | |||
76 | void __init arch_init_irq(void) | ||
77 | { | ||
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 */ | ||
86 | BONITO_INTEDGE = BONITO_ICU_SYSTEMERR | BONITO_ICU_MASTERERR | | ||
87 | BONITO_ICU_RETRYERR | BONITO_ICU_MBOXES; | ||
88 | BONITO_INTSTEER = 0; | ||
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 | |||
96 | /* init all controller | ||
97 | * 0-15 ------> i8259 interrupt | ||
98 | * 16-23 ------> mips cpu interrupt | ||
99 | * 32-63 ------> bonito irq | ||
100 | */ | ||
101 | |||
102 | /* Sets the first-level interrupt dispatcher. */ | ||
103 | mips_cpu_irq_init(); | ||
104 | init_i8259_irqs(); | ||
105 | bonito_irq_init(); | ||
106 | |||
107 | /* bonito irq at IP2 */ | ||
108 | setup_irq(MIPS_CPU_IRQ_BASE + 2, &cascade_irqaction); | ||
109 | /* 8259 irq at IP5 */ | ||
110 | setup_irq(MIPS_CPU_IRQ_BASE + 5, &cascade_irqaction); | ||
111 | } | ||
diff --git a/arch/mips/loongson/fuloong-2e/machtype.c b/arch/mips/loongson/fuloong-2e/machtype.c new file mode 100644 index 000000000000..e03aa0de6176 --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/machtype.c | |||
@@ -0,0 +1,15 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 Lemote Inc. & Insititute 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 | const char *get_system_type(void) | ||
12 | { | ||
13 | return "lemote-fuloong-2e-box"; | ||
14 | } | ||
15 | |||
diff --git a/arch/mips/loongson/fuloong-2e/mem.c b/arch/mips/loongson/fuloong-2e/mem.c new file mode 100644 index 000000000000..6a7feb178fa5 --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/mem.c | |||
@@ -0,0 +1,36 @@ | |||
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 | #include <linux/fs.h> | ||
8 | #include <linux/fcntl.h> | ||
9 | #include <linux/mm.h> | ||
10 | |||
11 | #include <asm/bootinfo.h> | ||
12 | |||
13 | #include <loongson.h> | ||
14 | |||
15 | void __init prom_init_memory(void) | ||
16 | { | ||
17 | add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM); | ||
18 | #ifdef CONFIG_64BIT | ||
19 | if (highmemsize > 0) | ||
20 | add_memory_region(0x20000000, highmemsize << 20, BOOT_MEM_RAM); | ||
21 | #endif /* CONFIG_64BIT */ | ||
22 | } | ||
23 | |||
24 | /* override of arch/mips/mm/cache.c: __uncached_access */ | ||
25 | int __uncached_access(struct file *file, unsigned long addr) | ||
26 | { | ||
27 | if (file->f_flags & O_SYNC) | ||
28 | return 1; | ||
29 | |||
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) || | ||
35 | ((addr >= 0x10000000) && (addr < 0x20000000)); | ||
36 | } | ||
diff --git a/arch/mips/loongson/fuloong-2e/pci.c b/arch/mips/loongson/fuloong-2e/pci.c new file mode 100644 index 000000000000..9812c30cc6eb --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/pci.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Lemote, Inc. & Institute 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/pci.h> | ||
11 | |||
12 | #include <pci.h> | ||
13 | #include <loongson.h> | ||
14 | |||
15 | static struct resource loongson2e_pci_mem_resource = { | ||
16 | .name = "LOONGSON2E PCI MEM", | ||
17 | .start = LOONGSON2E_PCI_MEM_START, | ||
18 | .end = LOONGSON2E_PCI_MEM_END, | ||
19 | .flags = IORESOURCE_MEM, | ||
20 | }; | ||
21 | |||
22 | static struct resource loongson2e_pci_io_resource = { | ||
23 | .name = "LOONGSON2E PCI IO MEM", | ||
24 | .start = LOONGSON2E_PCI_IO_START, | ||
25 | .end = IO_SPACE_LIMIT, | ||
26 | .flags = IORESOURCE_IO, | ||
27 | }; | ||
28 | |||
29 | static struct pci_controller loongson2e_pci_controller = { | ||
30 | .pci_ops = &bonito64_pci_ops, | ||
31 | .io_resource = &loongson2e_pci_io_resource, | ||
32 | .mem_resource = &loongson2e_pci_mem_resource, | ||
33 | .mem_offset = 0x00000000UL, | ||
34 | .io_offset = 0x00000000UL, | ||
35 | }; | ||
36 | |||
37 | static void __init setup_pcimap(void) | ||
38 | { | ||
39 | /* | ||
40 | * local to PCI mapping for CPU accessing PCI space | ||
41 | * CPU address space [256M,448M] is window for accessing pci space | ||
42 | * we set pcimap_lo[0,1,2] to map it to pci space[0M,64M], [320M,448M] | ||
43 | * | ||
44 | * pcimap: PCI_MAP2 PCI_Mem_Lo2 PCI_Mem_Lo1 PCI_Mem_Lo0 | ||
45 | * [<2G] [384M,448M] [320M,384M] [0M,64M] | ||
46 | */ | ||
47 | BONITO_PCIMAP = BONITO_PCIMAP_PCIMAP_2 | | ||
48 | BONITO_PCIMAP_WIN(2, BONITO_PCILO2_BASE) | | ||
49 | BONITO_PCIMAP_WIN(1, BONITO_PCILO1_BASE) | | ||
50 | BONITO_PCIMAP_WIN(0, 0); | ||
51 | |||
52 | /* | ||
53 | * PCI-DMA to local mapping: [2G,2G+256M] -> [0M,256M] | ||
54 | */ | ||
55 | BONITO_PCIBASE0 = 0x80000000ul; /* base: 2G -> mmap: 0M */ | ||
56 | /* size: 256M, burst transmission, pre-fetch enable, 64bit */ | ||
57 | LOONGSON_PCI_HIT0_SEL_L = 0xc000000cul; | ||
58 | LOONGSON_PCI_HIT0_SEL_H = 0xfffffffful; | ||
59 | LOONGSON_PCI_HIT1_SEL_L = 0x00000006ul; /* set this BAR as invalid */ | ||
60 | LOONGSON_PCI_HIT1_SEL_H = 0x00000000ul; | ||
61 | LOONGSON_PCI_HIT2_SEL_L = 0x00000006ul; /* set this BAR as invalid */ | ||
62 | LOONGSON_PCI_HIT2_SEL_H = 0x00000000ul; | ||
63 | |||
64 | /* avoid deadlock of PCI reading/writing lock operation */ | ||
65 | LOONGSON_PCI_ISR4C = 0xd2000001ul; | ||
66 | |||
67 | /* can not change gnt to break pci transfer when device's gnt not | ||
68 | deassert for some broken device */ | ||
69 | LOONGSON_PXARB_CFG = 0x00fe0105ul; | ||
70 | } | ||
71 | |||
72 | static int __init pcibios_init(void) | ||
73 | { | ||
74 | setup_pcimap(); | ||
75 | |||
76 | loongson2e_pci_controller.io_map_base = mips_io_port_base; | ||
77 | |||
78 | register_pci_controller(&loongson2e_pci_controller); | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | arch_initcall(pcibios_init); | ||
diff --git a/arch/mips/loongson/fuloong-2e/reset.c b/arch/mips/loongson/fuloong-2e/reset.c new file mode 100644 index 000000000000..c21299af7f64 --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/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 loongson2e_restart(char *command) | ||
20 | { | ||
21 | /* do preparation for reboot */ | ||
22 | BONITO_BONGENCFG &= ~(1 << 2); | ||
23 | BONITO_BONGENCFG |= (1 << 2); | ||
24 | |||
25 | /* reboot via jumping to boot base address */ | ||
26 | ((void (*)(void))ioremap_nocache(BONITO_BOOT_BASE, 4)) (); | ||
27 | } | ||
28 | |||
29 | static void loongson2e_halt(void) | ||
30 | { | ||
31 | while (1) | ||
32 | ; | ||
33 | } | ||
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); | ||
diff --git a/arch/mips/loongson/fuloong-2e/time.c b/arch/mips/loongson/fuloong-2e/time.c new file mode 100644 index 000000000000..b13d17174654 --- /dev/null +++ b/arch/mips/loongson/fuloong-2e/time.c | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology | ||
3 | * Author: Fuxin Zhang, zhangfx@lemote.com | ||
4 | * | ||
5 | * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | ||
6 | * Author: Wu Zhangjin, wuzj@lemote.com | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | #include <asm/mc146818-time.h> | ||
14 | #include <asm/time.h> | ||
15 | |||
16 | #include <loongson.h> | ||
17 | |||
18 | void __init plat_time_init(void) | ||
19 | { | ||
20 | /* setup mips r4k timer */ | ||
21 | mips_hpt_frequency = cpu_clock_freq / 2; | ||
22 | } | ||
23 | |||
24 | unsigned long read_persistent_clock(void) | ||
25 | { | ||
26 | return mc146818_get_cmos_time(); | ||
27 | } | ||