diff options
Diffstat (limited to 'arch/mips/lemote/lm2e')
-rw-r--r-- | arch/mips/lemote/lm2e/Makefile | 7 | ||||
-rw-r--r-- | arch/mips/lemote/lm2e/bonito-irq.c | 74 | ||||
-rw-r--r-- | arch/mips/lemote/lm2e/dbg_io.c | 146 | ||||
-rw-r--r-- | arch/mips/lemote/lm2e/irq.c | 145 | ||||
-rw-r--r-- | arch/mips/lemote/lm2e/mem.c | 23 | ||||
-rw-r--r-- | arch/mips/lemote/lm2e/pci.c | 93 | ||||
-rw-r--r-- | arch/mips/lemote/lm2e/prom.c | 104 | ||||
-rw-r--r-- | arch/mips/lemote/lm2e/reset.c | 41 | ||||
-rw-r--r-- | arch/mips/lemote/lm2e/setup.c | 134 |
9 files changed, 767 insertions, 0 deletions
diff --git a/arch/mips/lemote/lm2e/Makefile b/arch/mips/lemote/lm2e/Makefile new file mode 100644 index 000000000000..fb1b48c48cb3 --- /dev/null +++ b/arch/mips/lemote/lm2e/Makefile | |||
@@ -0,0 +1,7 @@ | |||
1 | # | ||
2 | # Makefile for Lemote Fulong mini-PC board. | ||
3 | # | ||
4 | |||
5 | obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o dbg_io.o mem.o | ||
6 | EXTRA_AFLAGS := $(CFLAGS) | ||
7 | |||
diff --git a/arch/mips/lemote/lm2e/bonito-irq.c b/arch/mips/lemote/lm2e/bonito-irq.c new file mode 100644 index 000000000000..8fc3bce7075b --- /dev/null +++ b/arch/mips/lemote/lm2e/bonito-irq.c | |||
@@ -0,0 +1,74 @@ | |||
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 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
15 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
16 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
17 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
20 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License along | ||
26 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
27 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
28 | * | ||
29 | */ | ||
30 | #include <linux/errno.h> | ||
31 | #include <linux/init.h> | ||
32 | #include <linux/io.h> | ||
33 | #include <linux/types.h> | ||
34 | #include <linux/interrupt.h> | ||
35 | #include <linux/irq.h> | ||
36 | |||
37 | #include <asm/mips-boards/bonito64.h> | ||
38 | |||
39 | |||
40 | static inline void bonito_irq_enable(unsigned int irq) | ||
41 | { | ||
42 | BONITO_INTENSET = (1 << (irq - BONITO_IRQ_BASE)); | ||
43 | mmiowb(); | ||
44 | } | ||
45 | |||
46 | static inline void bonito_irq_disable(unsigned int irq) | ||
47 | { | ||
48 | BONITO_INTENCLR = (1 << (irq - BONITO_IRQ_BASE)); | ||
49 | mmiowb(); | ||
50 | } | ||
51 | |||
52 | static struct irq_chip bonito_irq_type = { | ||
53 | .name = "bonito_irq", | ||
54 | .ack = bonito_irq_disable, | ||
55 | .mask = bonito_irq_disable, | ||
56 | .mask_ack = bonito_irq_disable, | ||
57 | .unmask = bonito_irq_enable, | ||
58 | }; | ||
59 | |||
60 | static struct irqaction dma_timeout_irqaction = { | ||
61 | .handler = no_action, | ||
62 | .name = "dma_timeout", | ||
63 | }; | ||
64 | |||
65 | void bonito_irq_init(void) | ||
66 | { | ||
67 | u32 i; | ||
68 | |||
69 | for (i = BONITO_IRQ_BASE; i < BONITO_IRQ_BASE + 32; i++) { | ||
70 | set_irq_chip_and_handler(i, &bonito_irq_type, handle_level_irq); | ||
71 | } | ||
72 | |||
73 | setup_irq(BONITO_IRQ_BASE + 10, &dma_timeout_irqaction); | ||
74 | } | ||
diff --git a/arch/mips/lemote/lm2e/dbg_io.c b/arch/mips/lemote/lm2e/dbg_io.c new file mode 100644 index 000000000000..6c95da3ca76f --- /dev/null +++ b/arch/mips/lemote/lm2e/dbg_io.c | |||
@@ -0,0 +1,146 @@ | |||
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 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
15 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
16 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
17 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
20 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License along | ||
26 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
27 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
28 | * | ||
29 | */ | ||
30 | |||
31 | #include <linux/io.h> | ||
32 | #include <linux/init.h> | ||
33 | #include <linux/types.h> | ||
34 | |||
35 | #include <asm/serial.h> | ||
36 | |||
37 | #define UART16550_BAUD_2400 2400 | ||
38 | #define UART16550_BAUD_4800 4800 | ||
39 | #define UART16550_BAUD_9600 9600 | ||
40 | #define UART16550_BAUD_19200 19200 | ||
41 | #define UART16550_BAUD_38400 38400 | ||
42 | #define UART16550_BAUD_57600 57600 | ||
43 | #define UART16550_BAUD_115200 115200 | ||
44 | |||
45 | #define UART16550_PARITY_NONE 0 | ||
46 | #define UART16550_PARITY_ODD 0x08 | ||
47 | #define UART16550_PARITY_EVEN 0x18 | ||
48 | #define UART16550_PARITY_MARK 0x28 | ||
49 | #define UART16550_PARITY_SPACE 0x38 | ||
50 | |||
51 | #define UART16550_DATA_5BIT 0x0 | ||
52 | #define UART16550_DATA_6BIT 0x1 | ||
53 | #define UART16550_DATA_7BIT 0x2 | ||
54 | #define UART16550_DATA_8BIT 0x3 | ||
55 | |||
56 | #define UART16550_STOP_1BIT 0x0 | ||
57 | #define UART16550_STOP_2BIT 0x4 | ||
58 | |||
59 | /* ----------------------------------------------------- */ | ||
60 | |||
61 | /* === CONFIG === */ | ||
62 | #ifdef CONFIG_64BIT | ||
63 | #define BASE (0xffffffffbfd003f8) | ||
64 | #else | ||
65 | #define BASE (0xbfd003f8) | ||
66 | #endif | ||
67 | |||
68 | #define MAX_BAUD BASE_BAUD | ||
69 | /* === END OF CONFIG === */ | ||
70 | |||
71 | #define REG_OFFSET 1 | ||
72 | |||
73 | /* register offset */ | ||
74 | #define OFS_RCV_BUFFER 0 | ||
75 | #define OFS_TRANS_HOLD 0 | ||
76 | #define OFS_SEND_BUFFER 0 | ||
77 | #define OFS_INTR_ENABLE (1*REG_OFFSET) | ||
78 | #define OFS_INTR_ID (2*REG_OFFSET) | ||
79 | #define OFS_DATA_FORMAT (3*REG_OFFSET) | ||
80 | #define OFS_LINE_CONTROL (3*REG_OFFSET) | ||
81 | #define OFS_MODEM_CONTROL (4*REG_OFFSET) | ||
82 | #define OFS_RS232_OUTPUT (4*REG_OFFSET) | ||
83 | #define OFS_LINE_STATUS (5*REG_OFFSET) | ||
84 | #define OFS_MODEM_STATUS (6*REG_OFFSET) | ||
85 | #define OFS_RS232_INPUT (6*REG_OFFSET) | ||
86 | #define OFS_SCRATCH_PAD (7*REG_OFFSET) | ||
87 | |||
88 | #define OFS_DIVISOR_LSB (0*REG_OFFSET) | ||
89 | #define OFS_DIVISOR_MSB (1*REG_OFFSET) | ||
90 | |||
91 | /* memory-mapped read/write of the port */ | ||
92 | #define UART16550_READ(y) readb((char *)BASE + (y)) | ||
93 | #define UART16550_WRITE(y, z) writeb(z, (char *)BASE + (y)) | ||
94 | |||
95 | void debugInit(u32 baud, u8 data, u8 parity, u8 stop) | ||
96 | { | ||
97 | u32 divisor; | ||
98 | |||
99 | /* disable interrupts */ | ||
100 | UART16550_WRITE(OFS_INTR_ENABLE, 0); | ||
101 | |||
102 | /* set up buad rate */ | ||
103 | /* set DIAB bit */ | ||
104 | UART16550_WRITE(OFS_LINE_CONTROL, 0x80); | ||
105 | |||
106 | /* set divisor */ | ||
107 | divisor = MAX_BAUD / baud; | ||
108 | UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff); | ||
109 | UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00) >> 8); | ||
110 | |||
111 | /* clear DIAB bit */ | ||
112 | UART16550_WRITE(OFS_LINE_CONTROL, 0x0); | ||
113 | |||
114 | /* set data format */ | ||
115 | UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop); | ||
116 | } | ||
117 | |||
118 | static int remoteDebugInitialized; | ||
119 | |||
120 | u8 getDebugChar(void) | ||
121 | { | ||
122 | if (!remoteDebugInitialized) { | ||
123 | remoteDebugInitialized = 1; | ||
124 | debugInit(UART16550_BAUD_115200, | ||
125 | UART16550_DATA_8BIT, | ||
126 | UART16550_PARITY_NONE, UART16550_STOP_1BIT); | ||
127 | } | ||
128 | |||
129 | while ((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0) ; | ||
130 | return UART16550_READ(OFS_RCV_BUFFER); | ||
131 | } | ||
132 | |||
133 | int putDebugChar(u8 byte) | ||
134 | { | ||
135 | if (!remoteDebugInitialized) { | ||
136 | remoteDebugInitialized = 1; | ||
137 | /* | ||
138 | debugInit(UART16550_BAUD_115200, | ||
139 | UART16550_DATA_8BIT, | ||
140 | UART16550_PARITY_NONE, UART16550_STOP_1BIT); */ | ||
141 | } | ||
142 | |||
143 | while ((UART16550_READ(OFS_LINE_STATUS) & 0x20) == 0) ; | ||
144 | UART16550_WRITE(OFS_SEND_BUFFER, byte); | ||
145 | return 1; | ||
146 | } | ||
diff --git a/arch/mips/lemote/lm2e/irq.c b/arch/mips/lemote/lm2e/irq.c new file mode 100644 index 000000000000..05693bceaeaf --- /dev/null +++ b/arch/mips/lemote/lm2e/irq.c | |||
@@ -0,0 +1,145 @@ | |||
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 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
11 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
12 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
13 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
14 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
15 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
16 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
17 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
18 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
19 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License along | ||
22 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
23 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | */ | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/io.h> | ||
28 | #include <linux/irq.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/interrupt.h> | ||
31 | #include <linux/irq.h> | ||
32 | |||
33 | #include <asm/irq_cpu.h> | ||
34 | #include <asm/i8259.h> | ||
35 | #include <asm/mipsregs.h> | ||
36 | #include <asm/mips-boards/bonito64.h> | ||
37 | |||
38 | |||
39 | /* | ||
40 | * the first level int-handler will jump here if it is a bonito irq | ||
41 | */ | ||
42 | static void bonito_irqdispatch(void) | ||
43 | { | ||
44 | u32 int_status; | ||
45 | int i; | ||
46 | |||
47 | /* workaround the IO dma problem: let cpu looping to allow DMA finish */ | ||
48 | int_status = BONITO_INTISR; | ||
49 | if (int_status & (1 << 10)) { | ||
50 | while (int_status & (1 << 10)) { | ||
51 | udelay(1); | ||
52 | int_status = BONITO_INTISR; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | /* Get pending sources, masked by current enables */ | ||
57 | int_status = BONITO_INTISR & BONITO_INTEN; | ||
58 | |||
59 | if (int_status != 0) { | ||
60 | i = __ffs(int_status); | ||
61 | int_status &= ~(1 << i); | ||
62 | do_IRQ(BONITO_IRQ_BASE + i); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | static void i8259_irqdispatch(void) | ||
67 | { | ||
68 | int irq; | ||
69 | |||
70 | irq = i8259_irq(); | ||
71 | if (irq >= 0) { | ||
72 | do_IRQ(irq); | ||
73 | } else { | ||
74 | spurious_interrupt(); | ||
75 | } | ||
76 | |||
77 | } | ||
78 | |||
79 | asmlinkage void plat_irq_dispatch(void) | ||
80 | { | ||
81 | unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM; | ||
82 | |||
83 | if (pending & CAUSEF_IP7) { | ||
84 | do_IRQ(MIPS_CPU_IRQ_BASE + 7); | ||
85 | } else if (pending & CAUSEF_IP5) { | ||
86 | i8259_irqdispatch(); | ||
87 | } else if (pending & CAUSEF_IP2) { | ||
88 | bonito_irqdispatch(); | ||
89 | } else { | ||
90 | spurious_interrupt(); | ||
91 | } | ||
92 | } | ||
93 | |||
94 | static struct irqaction cascade_irqaction = { | ||
95 | .handler = no_action, | ||
96 | .mask = CPU_MASK_NONE, | ||
97 | .name = "cascade", | ||
98 | }; | ||
99 | |||
100 | void __init arch_init_irq(void) | ||
101 | { | ||
102 | extern void bonito_irq_init(void); | ||
103 | |||
104 | /* | ||
105 | * Clear all of the interrupts while we change the able around a bit. | ||
106 | * int-handler is not on bootstrap | ||
107 | */ | ||
108 | clear_c0_status(ST0_IM | ST0_BEV); | ||
109 | local_irq_disable(); | ||
110 | |||
111 | /* most bonito irq should be level triggered */ | ||
112 | BONITO_INTEDGE = BONITO_ICU_SYSTEMERR | BONITO_ICU_MASTERERR | | ||
113 | BONITO_ICU_RETRYERR | BONITO_ICU_MBOXES; | ||
114 | BONITO_INTSTEER = 0; | ||
115 | |||
116 | /* | ||
117 | * Mask out all interrupt by writing "1" to all bit position in | ||
118 | * the interrupt reset reg. | ||
119 | */ | ||
120 | BONITO_INTENCLR = ~0; | ||
121 | |||
122 | /* init all controller | ||
123 | * 0-15 ------> i8259 interrupt | ||
124 | * 16-23 ------> mips cpu interrupt | ||
125 | * 32-63 ------> bonito irq | ||
126 | */ | ||
127 | |||
128 | /* Sets the first-level interrupt dispatcher. */ | ||
129 | mips_cpu_irq_init(); | ||
130 | init_i8259_irqs(); | ||
131 | bonito_irq_init(); | ||
132 | |||
133 | /* | ||
134 | printk("GPIODATA=%x, GPIOIE=%x\n", BONITO_GPIODATA, BONITO_GPIOIE); | ||
135 | printk("INTEN=%x, INTSET=%x, INTCLR=%x, INTISR=%x\n", | ||
136 | BONITO_INTEN, BONITO_INTENSET, | ||
137 | BONITO_INTENCLR, BONITO_INTISR); | ||
138 | */ | ||
139 | |||
140 | /* bonito irq at IP2 */ | ||
141 | setup_irq(MIPS_CPU_IRQ_BASE + 2, &cascade_irqaction); | ||
142 | /* 8259 irq at IP5 */ | ||
143 | setup_irq(MIPS_CPU_IRQ_BASE + 5, &cascade_irqaction); | ||
144 | |||
145 | } | ||
diff --git a/arch/mips/lemote/lm2e/mem.c b/arch/mips/lemote/lm2e/mem.c new file mode 100644 index 000000000000..16cd21587d34 --- /dev/null +++ b/arch/mips/lemote/lm2e/mem.c | |||
@@ -0,0 +1,23 @@ | |||
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 | /* override of arch/mips/mm/cache.c: __uncached_access */ | ||
12 | int __uncached_access(struct file *file, unsigned long addr) | ||
13 | { | ||
14 | if (file->f_flags & O_SYNC) | ||
15 | return 1; | ||
16 | |||
17 | /* | ||
18 | * On the Lemote Loongson 2e system, the peripheral registers | ||
19 | * reside between 0x1000:0000 and 0x2000:0000. | ||
20 | */ | ||
21 | return addr >= __pa(high_memory) || | ||
22 | ((addr >= 0x10000000) && (addr < 0x20000000)); | ||
23 | } | ||
diff --git a/arch/mips/lemote/lm2e/pci.c b/arch/mips/lemote/lm2e/pci.c new file mode 100644 index 000000000000..1ade1cef3899 --- /dev/null +++ b/arch/mips/lemote/lm2e/pci.c | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | * pci.c | ||
3 | * | ||
4 | * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology | ||
5 | * Author: Fuxin Zhang, zhangfx@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 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
13 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
14 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
15 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
16 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
17 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
18 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
19 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
20 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
21 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
22 | * | ||
23 | * You should have received a copy of the GNU General Public License along | ||
24 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
25 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
26 | * | ||
27 | */ | ||
28 | #include <linux/types.h> | ||
29 | #include <linux/pci.h> | ||
30 | #include <linux/kernel.h> | ||
31 | #include <linux/init.h> | ||
32 | #include <asm/mips-boards/bonito64.h> | ||
33 | |||
34 | extern struct pci_ops bonito64_pci_ops; | ||
35 | |||
36 | static struct resource loongson2e_pci_mem_resource = { | ||
37 | .name = "LOONGSON2E PCI MEM", | ||
38 | .start = 0x14000000UL, | ||
39 | .end = 0x1fffffffUL, | ||
40 | .flags = IORESOURCE_MEM, | ||
41 | }; | ||
42 | |||
43 | static struct resource loongson2e_pci_io_resource = { | ||
44 | .name = "LOONGSON2E PCI IO MEM", | ||
45 | .start = 0x00004000UL, | ||
46 | .end = IO_SPACE_LIMIT, | ||
47 | .flags = IORESOURCE_IO, | ||
48 | }; | ||
49 | |||
50 | static struct pci_controller loongson2e_pci_controller = { | ||
51 | .pci_ops = &bonito64_pci_ops, | ||
52 | .io_resource = &loongson2e_pci_io_resource, | ||
53 | .mem_resource = &loongson2e_pci_mem_resource, | ||
54 | .mem_offset = 0x00000000UL, | ||
55 | .io_offset = 0x00000000UL, | ||
56 | }; | ||
57 | |||
58 | static void __init ict_pcimap(void) | ||
59 | { | ||
60 | /* | ||
61 | * local to PCI mapping: [256M,512M] -> [256M,512M]; differ from PMON | ||
62 | * | ||
63 | * CPU address space [256M,448M] is window for accessing pci space | ||
64 | * we set pcimap_lo[0,1,2] to map it to pci space [256M,448M] | ||
65 | * pcimap: bit18,pcimap_2; bit[17-12],lo2;bit[11-6],lo1;bit[5-0],lo0 | ||
66 | */ | ||
67 | /* 1,00 0110 ,0001 01,00 0000 */ | ||
68 | BONITO_PCIMAP = 0x46140; | ||
69 | |||
70 | /* 1, 00 0010, 0000,01, 00 0000 */ | ||
71 | /* BONITO_PCIMAP = 0x42040; */ | ||
72 | |||
73 | /* | ||
74 | * PCI to local mapping: [2G,2G+256M] -> [0,256M] | ||
75 | */ | ||
76 | BONITO_PCIBASE0 = 0x80000000; | ||
77 | BONITO_PCIBASE1 = 0x00800000; | ||
78 | BONITO_PCIBASE2 = 0x90000000; | ||
79 | |||
80 | } | ||
81 | |||
82 | static int __init pcibios_init(void) | ||
83 | { | ||
84 | extern int pci_probe_only; | ||
85 | pci_probe_only = 0; | ||
86 | |||
87 | ict_pcimap(); | ||
88 | register_pci_controller(&loongson2e_pci_controller); | ||
89 | |||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | arch_initcall(pcibios_init); | ||
diff --git a/arch/mips/lemote/lm2e/prom.c b/arch/mips/lemote/lm2e/prom.c new file mode 100644 index 000000000000..67312d7acf2a --- /dev/null +++ b/arch/mips/lemote/lm2e/prom.c | |||
@@ -0,0 +1,104 @@ | |||
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 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License as published by the | ||
14 | * Free Software Foundation; either version 2 of the License, or (at your | ||
15 | * option) any later version. | ||
16 | */ | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/mm.h> | ||
19 | #include <linux/sched.h> | ||
20 | #include <linux/bootmem.h> | ||
21 | |||
22 | #include <asm/addrspace.h> | ||
23 | #include <asm/bootinfo.h> | ||
24 | |||
25 | extern unsigned long bus_clock; | ||
26 | extern unsigned long cpu_clock; | ||
27 | extern unsigned int memsize, highmemsize; | ||
28 | extern int putDebugChar(unsigned char byte); | ||
29 | |||
30 | static int argc; | ||
31 | /* pmon passes arguments in 32bit pointers */ | ||
32 | static int *arg; | ||
33 | static int *env; | ||
34 | |||
35 | const char *get_system_type(void) | ||
36 | { | ||
37 | return "lemote-fulong"; | ||
38 | } | ||
39 | |||
40 | void __init prom_init_cmdline(void) | ||
41 | { | ||
42 | int i; | ||
43 | long l; | ||
44 | |||
45 | /* arg[0] is "g", the rest is boot parameters */ | ||
46 | arcs_cmdline[0] = '\0'; | ||
47 | for (i = 1; i < argc; i++) { | ||
48 | l = (long)arg[i]; | ||
49 | if (strlen(arcs_cmdline) + strlen(((char *)l) + 1) | ||
50 | >= sizeof(arcs_cmdline)) | ||
51 | break; | ||
52 | strcat(arcs_cmdline, ((char *)l)); | ||
53 | strcat(arcs_cmdline, " "); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | void __init prom_init(void) | ||
58 | { | ||
59 | long l; | ||
60 | argc = fw_arg0; | ||
61 | arg = (int *)fw_arg1; | ||
62 | env = (int *)fw_arg2; | ||
63 | |||
64 | mips_machgroup = MACH_GROUP_LEMOTE; | ||
65 | mips_machtype = MACH_LEMOTE_FULONG; | ||
66 | |||
67 | prom_init_cmdline(); | ||
68 | |||
69 | if ((strstr(arcs_cmdline, "console=")) == NULL) | ||
70 | strcat(arcs_cmdline, " console=ttyS0,115200"); | ||
71 | if ((strstr(arcs_cmdline, "root=")) == NULL) | ||
72 | strcat(arcs_cmdline, " root=/dev/hda1"); | ||
73 | |||
74 | #define parse_even_earlier(res, option, p) \ | ||
75 | do { \ | ||
76 | if (strncmp(option, (char *)p, strlen(option)) == 0) \ | ||
77 | res = simple_strtol((char *)p + strlen(option"="), \ | ||
78 | NULL, 10); \ | ||
79 | } while (0) | ||
80 | |||
81 | l = (long)*env; | ||
82 | while (l != 0) { | ||
83 | parse_even_earlier(bus_clock, "busclock", l); | ||
84 | parse_even_earlier(cpu_clock, "cpuclock", l); | ||
85 | parse_even_earlier(memsize, "memsize", l); | ||
86 | parse_even_earlier(highmemsize, "highmemsize", l); | ||
87 | env++; | ||
88 | l = (long)*env; | ||
89 | } | ||
90 | if (memsize == 0) | ||
91 | memsize = 256; | ||
92 | |||
93 | pr_info("busclock=%ld, cpuclock=%ld,memsize=%d,highmemsize=%d\n", | ||
94 | bus_clock, cpu_clock, memsize, highmemsize); | ||
95 | } | ||
96 | |||
97 | void __init prom_free_prom_memory(void) | ||
98 | { | ||
99 | } | ||
100 | |||
101 | void prom_putchar(char c) | ||
102 | { | ||
103 | putDebugChar(c); | ||
104 | } | ||
diff --git a/arch/mips/lemote/lm2e/reset.c b/arch/mips/lemote/lm2e/reset.c new file mode 100644 index 000000000000..099387a3827a --- /dev/null +++ b/arch/mips/lemote/lm2e/reset.c | |||
@@ -0,0 +1,41 @@ | |||
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 | */ | ||
10 | #include <linux/pm.h> | ||
11 | |||
12 | #include <asm/reboot.h> | ||
13 | |||
14 | static void loongson2e_restart(char *command) | ||
15 | { | ||
16 | #ifdef CONFIG_32BIT | ||
17 | *(unsigned long *)0xbfe00104 &= ~(1 << 2); | ||
18 | *(unsigned long *)0xbfe00104 |= (1 << 2); | ||
19 | #else | ||
20 | *(unsigned long *)0xffffffffbfe00104 &= ~(1 << 2); | ||
21 | *(unsigned long *)0xffffffffbfe00104 |= (1 << 2); | ||
22 | #endif | ||
23 | __asm__ __volatile__("jr\t%0"::"r"(0xbfc00000)); | ||
24 | } | ||
25 | |||
26 | static void loongson2e_halt(void) | ||
27 | { | ||
28 | while (1) ; | ||
29 | } | ||
30 | |||
31 | static void loongson2e_power_off(void) | ||
32 | { | ||
33 | loongson2e_halt(); | ||
34 | } | ||
35 | |||
36 | void mips_reboot_setup(void) | ||
37 | { | ||
38 | _machine_restart = loongson2e_restart; | ||
39 | _machine_halt = loongson2e_halt; | ||
40 | pm_power_off = loongson2e_power_off; | ||
41 | } | ||
diff --git a/arch/mips/lemote/lm2e/setup.c b/arch/mips/lemote/lm2e/setup.c new file mode 100644 index 000000000000..0e4d1fa572b5 --- /dev/null +++ b/arch/mips/lemote/lm2e/setup.c | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * BRIEF MODULE DESCRIPTION | ||
3 | * setup.c - board dependent boot routines | ||
4 | * | ||
5 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | ||
6 | * Author: Fuxin Zhang, zhangfx@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 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
16 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
17 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
18 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
19 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
20 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License along | ||
25 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
26 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
27 | * | ||
28 | */ | ||
29 | #include <linux/bootmem.h> | ||
30 | #include <linux/init.h> | ||
31 | #include <linux/io.h> | ||
32 | #include <linux/ioport.h> | ||
33 | #include <linux/interrupt.h> | ||
34 | #include <linux/irq.h> | ||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/mc146818rtc.h> | ||
37 | #include <linux/mm.h> | ||
38 | #include <linux/module.h> | ||
39 | #include <linux/pci.h> | ||
40 | #include <linux/tty.h> | ||
41 | #include <linux/types.h> | ||
42 | |||
43 | #include <asm/bootinfo.h> | ||
44 | #include <asm/mc146818-time.h> | ||
45 | #include <asm/time.h> | ||
46 | #include <asm/wbflush.h> | ||
47 | |||
48 | #ifdef CONFIG_VT | ||
49 | #include <linux/console.h> | ||
50 | #include <linux/screen_info.h> | ||
51 | #endif | ||
52 | |||
53 | extern void mips_reboot_setup(void); | ||
54 | |||
55 | #ifdef CONFIG_64BIT | ||
56 | #define PTR_PAD(p) ((0xffffffff00000000)|((unsigned long long)(p))) | ||
57 | #else | ||
58 | #define PTR_PAD(p) (p) | ||
59 | #endif | ||
60 | |||
61 | unsigned long cpu_clock; | ||
62 | unsigned long bus_clock; | ||
63 | unsigned int memsize; | ||
64 | unsigned int highmemsize = 0; | ||
65 | |||
66 | void __init plat_timer_setup(struct irqaction *irq) | ||
67 | { | ||
68 | setup_irq(MIPS_CPU_IRQ_BASE + 7, irq); | ||
69 | } | ||
70 | |||
71 | static void __init loongson2e_time_init(void) | ||
72 | { | ||
73 | /* setup mips r4k timer */ | ||
74 | mips_hpt_frequency = cpu_clock / 2; | ||
75 | } | ||
76 | |||
77 | static unsigned long __init mips_rtc_get_time(void) | ||
78 | { | ||
79 | return mc146818_get_cmos_time(); | ||
80 | } | ||
81 | |||
82 | void (*__wbflush)(void); | ||
83 | EXPORT_SYMBOL(__wbflush); | ||
84 | |||
85 | static void wbflush_loongson2e(void) | ||
86 | { | ||
87 | asm(".set\tpush\n\t" | ||
88 | ".set\tnoreorder\n\t" | ||
89 | ".set mips3\n\t" | ||
90 | "sync\n\t" | ||
91 | "nop\n\t" | ||
92 | ".set\tpop\n\t" | ||
93 | ".set mips0\n\t"); | ||
94 | } | ||
95 | |||
96 | void __init plat_mem_setup(void) | ||
97 | { | ||
98 | set_io_port_base(PTR_PAD(0xbfd00000)); | ||
99 | |||
100 | mips_reboot_setup(); | ||
101 | |||
102 | board_time_init = loongson2e_time_init; | ||
103 | rtc_mips_get_time = mips_rtc_get_time; | ||
104 | |||
105 | __wbflush = wbflush_loongson2e; | ||
106 | |||
107 | add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM); | ||
108 | #ifdef CONFIG_64BIT | ||
109 | if (highmemsize > 0) { | ||
110 | add_memory_region(0x20000000, highmemsize << 20, BOOT_MEM_RAM); | ||
111 | } | ||
112 | #endif | ||
113 | |||
114 | #ifdef CONFIG_VT | ||
115 | #if defined(CONFIG_VGA_CONSOLE) | ||
116 | conswitchp = &vga_con; | ||
117 | |||
118 | screen_info = (struct screen_info) { | ||
119 | 0, 25, /* orig-x, orig-y */ | ||
120 | 0, /* unused */ | ||
121 | 0, /* orig-video-page */ | ||
122 | 0, /* orig-video-mode */ | ||
123 | 80, /* orig-video-cols */ | ||
124 | 0, 0, 0, /* ega_ax, ega_bx, ega_cx */ | ||
125 | 25, /* orig-video-lines */ | ||
126 | VIDEO_TYPE_VGAC, /* orig-video-isVGA */ | ||
127 | 16 /* orig-video-points */ | ||
128 | }; | ||
129 | #elif defined(CONFIG_DUMMY_CONSOLE) | ||
130 | conswitchp = &dummy_con; | ||
131 | #endif | ||
132 | #endif | ||
133 | |||
134 | } | ||