diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2008-07-11 10:27:54 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2008-07-15 13:44:35 -0400 |
commit | edcaf1a6a77315562e9781245cc8e028c9a921dc (patch) | |
tree | a20a0a85071fa283c36db87a41d1a7e091a35781 /arch/mips/txx9/generic | |
parent | 766891565bdaf605ea4aebe3e75de77e848254d0 (diff) |
[MIPS] TXx9: Make single kernel can support multiple boards
Make single kernel can be used on RBTX4927/37/38. Also make
some SoC-specific code independent from board-specific code.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/txx9/generic')
-rw-r--r-- | arch/mips/txx9/generic/Makefile | 4 | ||||
-rw-r--r-- | arch/mips/txx9/generic/irq_tx4927.c | 33 | ||||
-rw-r--r-- | arch/mips/txx9/generic/irq_tx4938.c | 31 | ||||
-rw-r--r-- | arch/mips/txx9/generic/pci.c | 11 | ||||
-rw-r--r-- | arch/mips/txx9/generic/setup.c | 169 |
5 files changed, 189 insertions, 59 deletions
diff --git a/arch/mips/txx9/generic/Makefile b/arch/mips/txx9/generic/Makefile index b80b6e072284..668fdaad6448 100644 --- a/arch/mips/txx9/generic/Makefile +++ b/arch/mips/txx9/generic/Makefile | |||
@@ -4,8 +4,8 @@ | |||
4 | 4 | ||
5 | obj-y += setup.o | 5 | obj-y += setup.o |
6 | obj-$(CONFIG_PCI) += pci.o | 6 | obj-$(CONFIG_PCI) += pci.o |
7 | obj-$(CONFIG_TOSHIBA_RBTX4927) += mem_tx4927.o irq_tx4927.o | 7 | obj-$(CONFIG_SOC_TX4927) += mem_tx4927.o irq_tx4927.o |
8 | obj-$(CONFIG_TOSHIBA_RBTX4938) += mem_tx4938.o irq_tx4938.o | 8 | obj-$(CONFIG_SOC_TX4938) += mem_tx4938.o irq_tx4938.o |
9 | obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o | 9 | obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o |
10 | obj-$(CONFIG_KGDB) += dbgio.o | 10 | obj-$(CONFIG_KGDB) += dbgio.o |
11 | 11 | ||
diff --git a/arch/mips/txx9/generic/irq_tx4927.c b/arch/mips/txx9/generic/irq_tx4927.c index 685ecc2ed551..6377bd8a9050 100644 --- a/arch/mips/txx9/generic/irq_tx4927.c +++ b/arch/mips/txx9/generic/irq_tx4927.c | |||
@@ -26,39 +26,12 @@ | |||
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
28 | #include <asm/irq_cpu.h> | 28 | #include <asm/irq_cpu.h> |
29 | #include <asm/mipsregs.h> | 29 | #include <asm/txx9/tx4927.h> |
30 | #ifdef CONFIG_TOSHIBA_RBTX4927 | ||
31 | #include <asm/txx9/rbtx4927.h> | ||
32 | #endif | ||
33 | 30 | ||
34 | void __init tx4927_irq_init(void) | 31 | void __init tx4927_irq_init(void) |
35 | { | 32 | { |
36 | mips_cpu_irq_init(); | 33 | mips_cpu_irq_init(); |
37 | txx9_irq_init(TX4927_IRC_REG); | 34 | txx9_irq_init(TX4927_IRC_REG); |
38 | set_irq_chained_handler(TX4927_IRQ_NEST_PIC_ON_CP0, handle_simple_irq); | 35 | set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4927_IRC_INT, |
39 | } | 36 | handle_simple_irq); |
40 | |||
41 | asmlinkage void plat_irq_dispatch(void) | ||
42 | { | ||
43 | unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM; | ||
44 | |||
45 | if (pending & STATUSF_IP7) /* cpu timer */ | ||
46 | do_IRQ(TX4927_IRQ_CPU_TIMER); | ||
47 | else if (pending & STATUSF_IP2) { /* tx4927 pic */ | ||
48 | int irq = txx9_irq(); | ||
49 | #ifdef CONFIG_TOSHIBA_RBTX4927 | ||
50 | if (irq == TX4927_IRQ_NEST_EXT_ON_PIC) | ||
51 | irq = toshiba_rbtx4927_irq_nested(irq); | ||
52 | #endif | ||
53 | if (unlikely(irq < 0)) { | ||
54 | spurious_interrupt(); | ||
55 | return; | ||
56 | } | ||
57 | do_IRQ(irq); | ||
58 | } else if (pending & STATUSF_IP0) /* user line 0 */ | ||
59 | do_IRQ(TX4927_IRQ_USER0); | ||
60 | else if (pending & STATUSF_IP1) /* user line 1 */ | ||
61 | do_IRQ(TX4927_IRQ_USER1); | ||
62 | else | ||
63 | spurious_interrupt(); | ||
64 | } | 37 | } |
diff --git a/arch/mips/txx9/generic/irq_tx4938.c b/arch/mips/txx9/generic/irq_tx4938.c index 0886d9138818..5fc86c9c9d2f 100644 --- a/arch/mips/txx9/generic/irq_tx4938.c +++ b/arch/mips/txx9/generic/irq_tx4938.c | |||
@@ -14,35 +14,12 @@ | |||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
16 | #include <asm/irq_cpu.h> | 16 | #include <asm/irq_cpu.h> |
17 | #include <asm/mipsregs.h> | 17 | #include <asm/txx9/tx4938.h> |
18 | #include <asm/txx9/rbtx4938.h> | ||
19 | 18 | ||
20 | void __init | 19 | void __init tx4938_irq_init(void) |
21 | tx4938_irq_init(void) | ||
22 | { | 20 | { |
23 | mips_cpu_irq_init(); | 21 | mips_cpu_irq_init(); |
24 | txx9_irq_init(TX4938_IRC_REG); | 22 | txx9_irq_init(TX4938_IRC_REG); |
25 | set_irq_chained_handler(TX4938_IRQ_NEST_PIC_ON_CP0, handle_simple_irq); | 23 | set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4938_IRC_INT, |
26 | } | 24 | handle_simple_irq); |
27 | |||
28 | int toshiba_rbtx4938_irq_nested(int irq); | ||
29 | |||
30 | asmlinkage void plat_irq_dispatch(void) | ||
31 | { | ||
32 | unsigned int pending = read_c0_cause() & read_c0_status(); | ||
33 | |||
34 | if (pending & STATUSF_IP7) | ||
35 | do_IRQ(TX4938_IRQ_CPU_TIMER); | ||
36 | else if (pending & STATUSF_IP2) { | ||
37 | int irq = txx9_irq(); | ||
38 | if (irq == TX4938_IRQ_PIC_BEG + TX4938_IR_INT(0)) | ||
39 | irq = toshiba_rbtx4938_irq_nested(irq); | ||
40 | if (irq >= 0) | ||
41 | do_IRQ(irq); | ||
42 | else | ||
43 | spurious_interrupt(); | ||
44 | } else if (pending & STATUSF_IP1) | ||
45 | do_IRQ(TX4938_IRQ_USER1); | ||
46 | else if (pending & STATUSF_IP0) | ||
47 | do_IRQ(TX4938_IRQ_USER0); | ||
48 | } | 25 | } |
diff --git a/arch/mips/txx9/generic/pci.c b/arch/mips/txx9/generic/pci.c index 8173faab99bb..0b92d8c13208 100644 --- a/arch/mips/txx9/generic/pci.c +++ b/arch/mips/txx9/generic/pci.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | #include <linux/jiffies.h> | 17 | #include <linux/jiffies.h> |
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <asm/txx9/generic.h> | ||
19 | #include <asm/txx9/pci.h> | 20 | #include <asm/txx9/pci.h> |
20 | #ifdef CONFIG_TOSHIBA_FPCIB0 | 21 | #ifdef CONFIG_TOSHIBA_FPCIB0 |
21 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
@@ -375,3 +376,13 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1, | |||
375 | #endif | 376 | #endif |
376 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, final_fixup); | 377 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, final_fixup); |
377 | DECLARE_PCI_FIXUP_RESUME(PCI_ANY_ID, PCI_ANY_ID, final_fixup); | 378 | DECLARE_PCI_FIXUP_RESUME(PCI_ANY_ID, PCI_ANY_ID, final_fixup); |
379 | |||
380 | int pcibios_plat_dev_init(struct pci_dev *dev) | ||
381 | { | ||
382 | return 0; | ||
383 | } | ||
384 | |||
385 | int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | ||
386 | { | ||
387 | return txx9_board_vec->pci_map_irq(dev, slot, pin); | ||
388 | } | ||
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c index 46a631177757..66ff74f80c6b 100644 --- a/arch/mips/txx9/generic/setup.c +++ b/arch/mips/txx9/generic/setup.c | |||
@@ -14,7 +14,16 @@ | |||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/string.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/clk.h> | ||
21 | #include <linux/err.h> | ||
22 | #include <asm/bootinfo.h> | ||
17 | #include <asm/txx9/generic.h> | 23 | #include <asm/txx9/generic.h> |
24 | #ifdef CONFIG_CPU_TX49XX | ||
25 | #include <asm/txx9/tx4938.h> | ||
26 | #endif | ||
18 | 27 | ||
19 | /* EBUSC settings of TX4927, etc. */ | 28 | /* EBUSC settings of TX4927, etc. */ |
20 | struct resource txx9_ce_res[8]; | 29 | struct resource txx9_ce_res[8]; |
@@ -49,3 +58,163 @@ txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size) | |||
49 | unsigned int txx9_master_clock; | 58 | unsigned int txx9_master_clock; |
50 | unsigned int txx9_cpu_clock; | 59 | unsigned int txx9_cpu_clock; |
51 | unsigned int txx9_gbus_clock; | 60 | unsigned int txx9_gbus_clock; |
61 | |||
62 | |||
63 | /* Minimum CLK support */ | ||
64 | |||
65 | struct clk *clk_get(struct device *dev, const char *id) | ||
66 | { | ||
67 | if (!strcmp(id, "spi-baseclk")) | ||
68 | return (struct clk *)(txx9_gbus_clock / 2 / 4); | ||
69 | if (!strcmp(id, "imbus_clk")) | ||
70 | return (struct clk *)(txx9_gbus_clock / 2); | ||
71 | return ERR_PTR(-ENOENT); | ||
72 | } | ||
73 | EXPORT_SYMBOL(clk_get); | ||
74 | |||
75 | int clk_enable(struct clk *clk) | ||
76 | { | ||
77 | return 0; | ||
78 | } | ||
79 | EXPORT_SYMBOL(clk_enable); | ||
80 | |||
81 | void clk_disable(struct clk *clk) | ||
82 | { | ||
83 | } | ||
84 | EXPORT_SYMBOL(clk_disable); | ||
85 | |||
86 | unsigned long clk_get_rate(struct clk *clk) | ||
87 | { | ||
88 | return (unsigned long)clk; | ||
89 | } | ||
90 | EXPORT_SYMBOL(clk_get_rate); | ||
91 | |||
92 | void clk_put(struct clk *clk) | ||
93 | { | ||
94 | } | ||
95 | EXPORT_SYMBOL(clk_put); | ||
96 | |||
97 | extern struct txx9_board_vec jmr3927_vec; | ||
98 | extern struct txx9_board_vec rbtx4927_vec; | ||
99 | extern struct txx9_board_vec rbtx4937_vec; | ||
100 | extern struct txx9_board_vec rbtx4938_vec; | ||
101 | |||
102 | /* board definitions */ | ||
103 | static struct txx9_board_vec *board_vecs[] __initdata = { | ||
104 | #ifdef CONFIG_TOSHIBA_JMR3927 | ||
105 | &jmr3927_vec, | ||
106 | #endif | ||
107 | #ifdef CONFIG_TOSHIBA_RBTX4927 | ||
108 | &rbtx4927_vec, | ||
109 | &rbtx4937_vec, | ||
110 | #endif | ||
111 | #ifdef CONFIG_TOSHIBA_RBTX4938 | ||
112 | &rbtx4938_vec, | ||
113 | #endif | ||
114 | }; | ||
115 | struct txx9_board_vec *txx9_board_vec __initdata; | ||
116 | static char txx9_system_type[32]; | ||
117 | |||
118 | void __init prom_init_cmdline(void) | ||
119 | { | ||
120 | int argc = (int)fw_arg0; | ||
121 | char **argv = (char **)fw_arg1; | ||
122 | int i; /* Always ignore the "-c" at argv[0] */ | ||
123 | |||
124 | /* ignore all built-in args if any f/w args given */ | ||
125 | if (argc > 1) | ||
126 | *arcs_cmdline = '\0'; | ||
127 | |||
128 | for (i = 1; i < argc; i++) { | ||
129 | if (i != 1) | ||
130 | strcat(arcs_cmdline, " "); | ||
131 | strcat(arcs_cmdline, argv[i]); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | void __init prom_init(void) | ||
136 | { | ||
137 | int i; | ||
138 | |||
139 | #ifdef CONFIG_CPU_TX39XX | ||
140 | mips_machtype = MACH_TOSHIBA_JMR3927; | ||
141 | #endif | ||
142 | #ifdef CONFIG_CPU_TX49XX | ||
143 | switch (TX4938_REV_PCODE()) { | ||
144 | case 0x4927: | ||
145 | mips_machtype = MACH_TOSHIBA_RBTX4927; | ||
146 | break; | ||
147 | case 0x4937: | ||
148 | mips_machtype = MACH_TOSHIBA_RBTX4937; | ||
149 | break; | ||
150 | case 0x4938: | ||
151 | mips_machtype = MACH_TOSHIBA_RBTX4938; | ||
152 | break; | ||
153 | } | ||
154 | #endif | ||
155 | for (i = 0; i < ARRAY_SIZE(board_vecs); i++) { | ||
156 | if (board_vecs[i]->type == mips_machtype) { | ||
157 | txx9_board_vec = board_vecs[i]; | ||
158 | strcpy(txx9_system_type, txx9_board_vec->system); | ||
159 | return txx9_board_vec->prom_init(); | ||
160 | } | ||
161 | } | ||
162 | } | ||
163 | |||
164 | void __init prom_free_prom_memory(void) | ||
165 | { | ||
166 | } | ||
167 | |||
168 | const char *get_system_type(void) | ||
169 | { | ||
170 | return txx9_system_type; | ||
171 | } | ||
172 | |||
173 | char * __init prom_getcmdline(void) | ||
174 | { | ||
175 | return &(arcs_cmdline[0]); | ||
176 | } | ||
177 | |||
178 | /* wrappers */ | ||
179 | void __init plat_mem_setup(void) | ||
180 | { | ||
181 | txx9_board_vec->mem_setup(); | ||
182 | } | ||
183 | |||
184 | void __init arch_init_irq(void) | ||
185 | { | ||
186 | txx9_board_vec->irq_setup(); | ||
187 | } | ||
188 | |||
189 | void __init plat_time_init(void) | ||
190 | { | ||
191 | txx9_board_vec->time_init(); | ||
192 | } | ||
193 | |||
194 | static int __init _txx9_arch_init(void) | ||
195 | { | ||
196 | if (txx9_board_vec->arch_init) | ||
197 | txx9_board_vec->arch_init(); | ||
198 | return 0; | ||
199 | } | ||
200 | arch_initcall(_txx9_arch_init); | ||
201 | |||
202 | static int __init _txx9_device_init(void) | ||
203 | { | ||
204 | if (txx9_board_vec->device_init) | ||
205 | txx9_board_vec->device_init(); | ||
206 | return 0; | ||
207 | } | ||
208 | device_initcall(_txx9_device_init); | ||
209 | |||
210 | int (*txx9_irq_dispatch)(int pending); | ||
211 | asmlinkage void plat_irq_dispatch(void) | ||
212 | { | ||
213 | int pending = read_c0_status() & read_c0_cause() & ST0_IM; | ||
214 | int irq = txx9_irq_dispatch(pending); | ||
215 | |||
216 | if (likely(irq >= 0)) | ||
217 | do_IRQ(irq); | ||
218 | else | ||
219 | spurious_interrupt(); | ||
220 | } | ||