diff options
author | dmitry pervushin <dpervushin@ru.mvista.com> | 2006-05-21 06:53:06 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2006-06-19 12:39:26 -0400 |
commit | 355c471f2ff324c21f8a1fb8e2e242a0f2a4aa68 (patch) | |
tree | 8a491d03e865b9e16686004dea765a141e048219 /arch/mips/emma2rh/common | |
parent | 4a0312fca6599299bbed944ce09278d90388a3e5 (diff) |
[MIPS] Support for the R5500-based NEC EMMA2RH Mark-eins board
Signed-off-by: dmitry pervushin <dpervushin@ru.mvista.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/emma2rh/common')
-rw-r--r-- | arch/mips/emma2rh/common/Makefile | 13 | ||||
-rw-r--r-- | arch/mips/emma2rh/common/irq.c | 108 | ||||
-rw-r--r-- | arch/mips/emma2rh/common/irq_emma2rh.c | 134 | ||||
-rw-r--r-- | arch/mips/emma2rh/common/prom.c | 77 |
4 files changed, 332 insertions, 0 deletions
diff --git a/arch/mips/emma2rh/common/Makefile b/arch/mips/emma2rh/common/Makefile new file mode 100644 index 000000000000..859121b3867d --- /dev/null +++ b/arch/mips/emma2rh/common/Makefile | |||
@@ -0,0 +1,13 @@ | |||
1 | # | ||
2 | # arch/mips/emma2rh/common/Makefile | ||
3 | # Makefile for the common code of NEC EMMA2RH based board. | ||
4 | # | ||
5 | # Copyright (C) NEC Electronics Corporation 2005-2006 | ||
6 | # | ||
7 | # This program is free software; you can redistribute it and/or modify | ||
8 | # it under the terms of the GNU General Public License as published by | ||
9 | # the Free Software Foundation; either version 2 of the License, or | ||
10 | # (at your option) any later version. | ||
11 | # | ||
12 | |||
13 | obj-$(CONFIG_MARKEINS) += irq.o irq_emma2rh.o prom.o | ||
diff --git a/arch/mips/emma2rh/common/irq.c b/arch/mips/emma2rh/common/irq.c new file mode 100644 index 000000000000..b075281e50e9 --- /dev/null +++ b/arch/mips/emma2rh/common/irq.c | |||
@@ -0,0 +1,108 @@ | |||
1 | /* | ||
2 | * arch/mips/emma2rh/common/irq.c | ||
3 | * This file is common irq dispatcher. | ||
4 | * | ||
5 | * Copyright (C) NEC Electronics Corporation 2005-2006 | ||
6 | * | ||
7 | * This file is based on the arch/mips/ddb5xxx/ddb5477/irq.c | ||
8 | * | ||
9 | * Copyright 2001 MontaVista Software Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | */ | ||
25 | #include <linux/config.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | #include <linux/irq.h> | ||
29 | #include <linux/types.h> | ||
30 | |||
31 | #include <asm/i8259.h> | ||
32 | #include <asm/system.h> | ||
33 | #include <asm/mipsregs.h> | ||
34 | #include <asm/debug.h> | ||
35 | #include <asm/addrspace.h> | ||
36 | #include <asm/bootinfo.h> | ||
37 | |||
38 | #include <asm/emma2rh/emma2rh.h> | ||
39 | |||
40 | /* | ||
41 | * the first level int-handler will jump here if it is a emma2rh irq | ||
42 | */ | ||
43 | asmlinkage void emma2rh_irq_dispatch(struct pt_regs *regs) | ||
44 | { | ||
45 | u32 intStatus; | ||
46 | u32 bitmask; | ||
47 | u32 i; | ||
48 | |||
49 | intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_0) | ||
50 | & emma2rh_in32(EMMA2RH_BHIF_INT_EN_0); | ||
51 | |||
52 | #ifdef EMMA2RH_SW_CASCADE | ||
53 | if (intStatus & | ||
54 | (1 << ((EMMA2RH_SW_CASCADE - EMMA2RH_IRQ_INT0) & (32 - 1)))) { | ||
55 | u32 swIntStatus; | ||
56 | swIntStatus = emma2rh_in32(EMMA2RH_BHIF_SW_INT) | ||
57 | & emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN); | ||
58 | for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) { | ||
59 | if (swIntStatus & bitmask) { | ||
60 | do_IRQ(EMMA2RH_SW_IRQ_BASE + i, regs); | ||
61 | return; | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | #endif | ||
66 | |||
67 | for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) { | ||
68 | if (intStatus & bitmask) { | ||
69 | do_IRQ(EMMA2RH_IRQ_BASE + i, regs); | ||
70 | return; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_1) | ||
75 | & emma2rh_in32(EMMA2RH_BHIF_INT_EN_1); | ||
76 | |||
77 | #ifdef EMMA2RH_GPIO_CASCADE | ||
78 | if (intStatus & | ||
79 | (1 << ((EMMA2RH_GPIO_CASCADE - EMMA2RH_IRQ_INT0) & (32 - 1)))) { | ||
80 | u32 gpioIntStatus; | ||
81 | gpioIntStatus = emma2rh_in32(EMMA2RH_GPIO_INT_ST) | ||
82 | & emma2rh_in32(EMMA2RH_GPIO_INT_MASK); | ||
83 | for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) { | ||
84 | if (gpioIntStatus & bitmask) { | ||
85 | do_IRQ(EMMA2RH_GPIO_IRQ_BASE + i, regs); | ||
86 | return; | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | #endif | ||
91 | |||
92 | for (i = 32, bitmask = 1; i < 64; i++, bitmask <<= 1) { | ||
93 | if (intStatus & bitmask) { | ||
94 | do_IRQ(EMMA2RH_IRQ_BASE + i, regs); | ||
95 | return; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_2) | ||
100 | & emma2rh_in32(EMMA2RH_BHIF_INT_EN_2); | ||
101 | |||
102 | for (i = 64, bitmask = 1; i < 96; i++, bitmask <<= 1) { | ||
103 | if (intStatus & bitmask) { | ||
104 | do_IRQ(EMMA2RH_IRQ_BASE + i, regs); | ||
105 | return; | ||
106 | } | ||
107 | } | ||
108 | } | ||
diff --git a/arch/mips/emma2rh/common/irq_emma2rh.c b/arch/mips/emma2rh/common/irq_emma2rh.c new file mode 100644 index 000000000000..b886aa94ca90 --- /dev/null +++ b/arch/mips/emma2rh/common/irq_emma2rh.c | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * arch/mips/emma2rh/common/irq_emma2rh.c | ||
3 | * This file defines the irq handler for EMMA2RH. | ||
4 | * | ||
5 | * Copyright (C) NEC Electronics Corporation 2005-2006 | ||
6 | * | ||
7 | * This file is based on the arch/mips/ddb5xxx/ddb5477/irq_5477.c | ||
8 | * | ||
9 | * Copyright 2001 MontaVista Software Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | */ | ||
25 | |||
26 | /* | ||
27 | * EMMA2RH defines 64 IRQs. | ||
28 | * | ||
29 | * This file exports one function: | ||
30 | * emma2rh_irq_init(u32 irq_base); | ||
31 | */ | ||
32 | |||
33 | #include <linux/interrupt.h> | ||
34 | #include <linux/types.h> | ||
35 | #include <linux/ptrace.h> | ||
36 | |||
37 | #include <asm/debug.h> | ||
38 | |||
39 | #include <asm/emma2rh/emma2rh.h> | ||
40 | |||
41 | /* number of total irqs supported by EMMA2RH */ | ||
42 | #define NUM_EMMA2RH_IRQ 96 | ||
43 | |||
44 | static int emma2rh_irq_base = -1; | ||
45 | |||
46 | void ll_emma2rh_irq_enable(int); | ||
47 | void ll_emma2rh_irq_disable(int); | ||
48 | |||
49 | static void emma2rh_irq_enable(unsigned int irq) | ||
50 | { | ||
51 | ll_emma2rh_irq_enable(irq - emma2rh_irq_base); | ||
52 | } | ||
53 | |||
54 | static void emma2rh_irq_disable(unsigned int irq) | ||
55 | { | ||
56 | ll_emma2rh_irq_disable(irq - emma2rh_irq_base); | ||
57 | } | ||
58 | |||
59 | static unsigned int emma2rh_irq_startup(unsigned int irq) | ||
60 | { | ||
61 | emma2rh_irq_enable(irq); | ||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | #define emma2rh_irq_shutdown emma2rh_irq_disable | ||
66 | |||
67 | static void emma2rh_irq_ack(unsigned int irq) | ||
68 | { | ||
69 | /* disable interrupt - some handler will re-enable the irq | ||
70 | * and if the interrupt is leveled, we will have infinite loop | ||
71 | */ | ||
72 | ll_emma2rh_irq_disable(irq - emma2rh_irq_base); | ||
73 | } | ||
74 | |||
75 | static void emma2rh_irq_end(unsigned int irq) | ||
76 | { | ||
77 | if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) | ||
78 | ll_emma2rh_irq_enable(irq - emma2rh_irq_base); | ||
79 | } | ||
80 | |||
81 | hw_irq_controller emma2rh_irq_controller = { | ||
82 | .typename = "emma2rh_irq", | ||
83 | .startup = emma2rh_irq_startup, | ||
84 | .shutdown = emma2rh_irq_shutdown, | ||
85 | .enable = emma2rh_irq_enable, | ||
86 | .disable = emma2rh_irq_disable, | ||
87 | .ack = emma2rh_irq_ack, | ||
88 | .end = emma2rh_irq_end, | ||
89 | .set_affinity = NULL /* no affinity stuff for UP */ | ||
90 | }; | ||
91 | |||
92 | void emma2rh_irq_init(u32 irq_base) | ||
93 | { | ||
94 | u32 i; | ||
95 | |||
96 | for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ; i++) { | ||
97 | irq_desc[i].status = IRQ_DISABLED; | ||
98 | irq_desc[i].action = NULL; | ||
99 | irq_desc[i].depth = 1; | ||
100 | irq_desc[i].handler = &emma2rh_irq_controller; | ||
101 | } | ||
102 | |||
103 | emma2rh_irq_base = irq_base; | ||
104 | } | ||
105 | |||
106 | void ll_emma2rh_irq_enable(int emma2rh_irq) | ||
107 | { | ||
108 | u32 reg_value; | ||
109 | u32 reg_bitmask; | ||
110 | u32 reg_index; | ||
111 | |||
112 | reg_index = EMMA2RH_BHIF_INT_EN_0 | ||
113 | + (EMMA2RH_BHIF_INT_EN_1 - EMMA2RH_BHIF_INT_EN_0) | ||
114 | * (emma2rh_irq / 32); | ||
115 | reg_value = emma2rh_in32(reg_index); | ||
116 | reg_bitmask = 0x1 << (emma2rh_irq % 32); | ||
117 | db_assert((reg_value & reg_bitmask) == 0); | ||
118 | emma2rh_out32(reg_index, reg_value | reg_bitmask); | ||
119 | } | ||
120 | |||
121 | void ll_emma2rh_irq_disable(int emma2rh_irq) | ||
122 | { | ||
123 | u32 reg_value; | ||
124 | u32 reg_bitmask; | ||
125 | u32 reg_index; | ||
126 | |||
127 | reg_index = EMMA2RH_BHIF_INT_EN_0 | ||
128 | + (EMMA2RH_BHIF_INT_EN_1 - EMMA2RH_BHIF_INT_EN_0) | ||
129 | * (emma2rh_irq / 32); | ||
130 | reg_value = emma2rh_in32(reg_index); | ||
131 | reg_bitmask = 0x1 << (emma2rh_irq % 32); | ||
132 | db_assert((reg_value & reg_bitmask) != 0); | ||
133 | emma2rh_out32(reg_index, reg_value & ~reg_bitmask); | ||
134 | } | ||
diff --git a/arch/mips/emma2rh/common/prom.c b/arch/mips/emma2rh/common/prom.c new file mode 100644 index 000000000000..8bba0b02a204 --- /dev/null +++ b/arch/mips/emma2rh/common/prom.c | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * arch/mips/emma2rh/common/prom.c | ||
3 | * This file is prom file. | ||
4 | * | ||
5 | * Copyright (C) NEC Electronics Corporation 2004-2006 | ||
6 | * | ||
7 | * This file is based on the arch/mips/ddb5xxx/common/prom.c | ||
8 | * | ||
9 | * Copyright 2001 MontaVista Software Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | */ | ||
25 | #include <linux/config.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/mm.h> | ||
28 | #include <linux/sched.h> | ||
29 | #include <linux/bootmem.h> | ||
30 | |||
31 | #include <asm/addrspace.h> | ||
32 | #include <asm/bootinfo.h> | ||
33 | #include <asm/emma2rh/emma2rh.h> | ||
34 | #include <asm/debug.h> | ||
35 | |||
36 | const char *get_system_type(void) | ||
37 | { | ||
38 | switch (mips_machtype) { | ||
39 | case MACH_NEC_MARKEINS: | ||
40 | return "NEC EMMA2RH Mark-eins"; | ||
41 | default: | ||
42 | return "Unknown NEC board"; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | /* [jsun@junsun.net] PMON passes arguments in C main() style */ | ||
47 | void __init prom_init(void) | ||
48 | { | ||
49 | int argc = fw_arg0; | ||
50 | char **arg = (char **)fw_arg1; | ||
51 | int i; | ||
52 | |||
53 | /* if user passes kernel args, ignore the default one */ | ||
54 | if (argc > 1) | ||
55 | arcs_cmdline[0] = '\0'; | ||
56 | |||
57 | /* arg[0] is "g", the rest is boot parameters */ | ||
58 | for (i = 1; i < argc; i++) { | ||
59 | if (strlen(arcs_cmdline) + strlen(arg[i] + 1) | ||
60 | >= sizeof(arcs_cmdline)) | ||
61 | break; | ||
62 | strcat(arcs_cmdline, arg[i]); | ||
63 | strcat(arcs_cmdline, " "); | ||
64 | } | ||
65 | |||
66 | mips_machgroup = MACH_GROUP_NEC_EMMA2RH; | ||
67 | |||
68 | #if defined(CONFIG_MARKEINS) | ||
69 | mips_machtype = MACH_NEC_MARKEINS; | ||
70 | add_memory_region(0, EMMA2RH_RAM_SIZE, BOOT_MEM_RAM); | ||
71 | #endif | ||
72 | |||
73 | } | ||
74 | |||
75 | void __init prom_free_prom_memory(void) | ||
76 | { | ||
77 | } | ||