aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/txx9/rbtx4927
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2008-07-11 10:27:54 -0400
committerRalf Baechle <ralf@linux-mips.org>2008-07-15 13:44:35 -0400
commitedcaf1a6a77315562e9781245cc8e028c9a921dc (patch)
treea20a0a85071fa283c36db87a41d1a7e091a35781 /arch/mips/txx9/rbtx4927
parent766891565bdaf605ea4aebe3e75de77e848254d0 (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/rbtx4927')
-rw-r--r--arch/mips/txx9/rbtx4927/irq.c57
-rw-r--r--arch/mips/txx9/rbtx4927/prom.c52
-rw-r--r--arch/mips/txx9/rbtx4927/setup.c78
3 files changed, 69 insertions, 118 deletions
diff --git a/arch/mips/txx9/rbtx4927/irq.c b/arch/mips/txx9/rbtx4927/irq.c
index bef1447aeed2..70f13211bc2a 100644
--- a/arch/mips/txx9/rbtx4927/irq.c
+++ b/arch/mips/txx9/rbtx4927/irq.c
@@ -111,17 +111,10 @@ JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthB
111#include <linux/types.h> 111#include <linux/types.h>
112#include <linux/interrupt.h> 112#include <linux/interrupt.h>
113#include <asm/io.h> 113#include <asm/io.h>
114#include <asm/mipsregs.h>
115#include <asm/txx9/generic.h>
114#include <asm/txx9/rbtx4927.h> 116#include <asm/txx9/rbtx4927.h>
115 117
116#define TOSHIBA_RBTX4927_IRQ_IOC_RAW_BEG 0
117#define TOSHIBA_RBTX4927_IRQ_IOC_RAW_END 7
118
119#define TOSHIBA_RBTX4927_IRQ_IOC_BEG ((TX4927_IRQ_PIC_END+1)+TOSHIBA_RBTX4927_IRQ_IOC_RAW_BEG) /* 56 */
120#define TOSHIBA_RBTX4927_IRQ_IOC_END ((TX4927_IRQ_PIC_END+1)+TOSHIBA_RBTX4927_IRQ_IOC_RAW_END) /* 63 */
121
122#define TOSHIBA_RBTX4927_IRQ_NEST_IOC_ON_PIC TX4927_IRQ_NEST_EXT_ON_PIC
123#define TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC (TOSHIBA_RBTX4927_IRQ_IOC_BEG+2)
124
125static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq); 118static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq);
126static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq); 119static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq);
127 120
@@ -136,34 +129,25 @@ static struct irq_chip toshiba_rbtx4927_irq_ioc_type = {
136#define TOSHIBA_RBTX4927_IOC_INTR_ENAB (void __iomem *)0xbc002000UL 129#define TOSHIBA_RBTX4927_IOC_INTR_ENAB (void __iomem *)0xbc002000UL
137#define TOSHIBA_RBTX4927_IOC_INTR_STAT (void __iomem *)0xbc002006UL 130#define TOSHIBA_RBTX4927_IOC_INTR_STAT (void __iomem *)0xbc002006UL
138 131
139int toshiba_rbtx4927_irq_nested(int sw_irq) 132static int toshiba_rbtx4927_irq_nested(int sw_irq)
140{ 133{
141 u8 level3; 134 u8 level3;
142 135
143 level3 = readb(TOSHIBA_RBTX4927_IOC_INTR_STAT) & 0x1f; 136 level3 = readb(TOSHIBA_RBTX4927_IOC_INTR_STAT) & 0x1f;
144 if (level3) 137 if (level3)
145 sw_irq = TOSHIBA_RBTX4927_IRQ_IOC_BEG + fls(level3) - 1; 138 sw_irq = RBTX4927_IRQ_IOC + fls(level3) - 1;
146 return (sw_irq); 139 return (sw_irq);
147} 140}
148 141
149static struct irqaction toshiba_rbtx4927_irq_ioc_action = {
150 .handler = no_action,
151 .flags = IRQF_SHARED,
152 .mask = CPU_MASK_NONE,
153 .name = TOSHIBA_RBTX4927_IOC_NAME
154};
155
156static void __init toshiba_rbtx4927_irq_ioc_init(void) 142static void __init toshiba_rbtx4927_irq_ioc_init(void)
157{ 143{
158 int i; 144 int i;
159 145
160 for (i = TOSHIBA_RBTX4927_IRQ_IOC_BEG; 146 for (i = RBTX4927_IRQ_IOC;
161 i <= TOSHIBA_RBTX4927_IRQ_IOC_END; i++) 147 i < RBTX4927_IRQ_IOC + RBTX4927_NR_IRQ_IOC; i++)
162 set_irq_chip_and_handler(i, &toshiba_rbtx4927_irq_ioc_type, 148 set_irq_chip_and_handler(i, &toshiba_rbtx4927_irq_ioc_type,
163 handle_level_irq); 149 handle_level_irq);
164 150 set_irq_chained_handler(RBTX4927_IRQ_IOCINT, handle_simple_irq);
165 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_IOC_ON_PIC,
166 &toshiba_rbtx4927_irq_ioc_action);
167} 151}
168 152
169static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq) 153static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq)
@@ -171,7 +155,7 @@ static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq)
171 unsigned char v; 155 unsigned char v;
172 156
173 v = readb(TOSHIBA_RBTX4927_IOC_INTR_ENAB); 157 v = readb(TOSHIBA_RBTX4927_IOC_INTR_ENAB);
174 v |= (1 << (irq - TOSHIBA_RBTX4927_IRQ_IOC_BEG)); 158 v |= (1 << (irq - RBTX4927_IRQ_IOC));
175 writeb(v, TOSHIBA_RBTX4927_IOC_INTR_ENAB); 159 writeb(v, TOSHIBA_RBTX4927_IOC_INTR_ENAB);
176} 160}
177 161
@@ -180,15 +164,34 @@ static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq)
180 unsigned char v; 164 unsigned char v;
181 165
182 v = readb(TOSHIBA_RBTX4927_IOC_INTR_ENAB); 166 v = readb(TOSHIBA_RBTX4927_IOC_INTR_ENAB);
183 v &= ~(1 << (irq - TOSHIBA_RBTX4927_IRQ_IOC_BEG)); 167 v &= ~(1 << (irq - RBTX4927_IRQ_IOC));
184 writeb(v, TOSHIBA_RBTX4927_IOC_INTR_ENAB); 168 writeb(v, TOSHIBA_RBTX4927_IOC_INTR_ENAB);
185 mmiowb(); 169 mmiowb();
186} 170}
187 171
188void __init arch_init_irq(void) 172
173static int rbtx4927_irq_dispatch(int pending)
189{ 174{
190 extern void tx4927_irq_init(void); 175 int irq;
176
177 if (pending & STATUSF_IP7) /* cpu timer */
178 irq = MIPS_CPU_IRQ_BASE + 7;
179 else if (pending & STATUSF_IP2) { /* tx4927 pic */
180 irq = txx9_irq();
181 if (irq == RBTX4927_IRQ_IOCINT)
182 irq = toshiba_rbtx4927_irq_nested(irq);
183 } else if (pending & STATUSF_IP0) /* user line 0 */
184 irq = MIPS_CPU_IRQ_BASE + 0;
185 else if (pending & STATUSF_IP1) /* user line 1 */
186 irq = MIPS_CPU_IRQ_BASE + 1;
187 else
188 irq = -1;
189 return irq;
190}
191 191
192void __init rbtx4927_irq_setup(void)
193{
194 txx9_irq_dispatch = rbtx4927_irq_dispatch;
192 tx4927_irq_init(); 195 tx4927_irq_init();
193 toshiba_rbtx4927_irq_ioc_init(); 196 toshiba_rbtx4927_irq_ioc_init();
194 /* Onboard 10M Ether: High Active */ 197 /* Onboard 10M Ether: High Active */
diff --git a/arch/mips/txx9/rbtx4927/prom.c b/arch/mips/txx9/rbtx4927/prom.c
index 0020bbee838b..942e627d2dc1 100644
--- a/arch/mips/txx9/rbtx4927/prom.c
+++ b/arch/mips/txx9/rbtx4927/prom.c
@@ -30,62 +30,16 @@
30 * 675 Mass Ave, Cambridge, MA 02139, USA. 30 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 */ 31 */
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/string.h>
34#include <asm/bootinfo.h> 33#include <asm/bootinfo.h>
35#include <asm/cpu.h> 34#include <asm/txx9/generic.h>
36#include <asm/mipsregs.h> 35#include <asm/txx9/rbtx4927.h>
37#include <asm/txx9/tx4927.h>
38 36
39void __init prom_init_cmdline(void) 37void __init rbtx4927_prom_init(void)
40{
41 int argc = (int) fw_arg0;
42 char **argv = (char **) fw_arg1;
43 int i; /* Always ignore the "-c" at argv[0] */
44
45 /* ignore all built-in args if any f/w args given */
46 if (argc > 1) {
47 *arcs_cmdline = '\0';
48 }
49
50 for (i = 1; i < argc; i++) {
51 if (i != 1) {
52 strcat(arcs_cmdline, " ");
53 }
54 strcat(arcs_cmdline, argv[i]);
55 }
56}
57
58void __init prom_init(void)
59{ 38{
60 extern int tx4927_get_mem_size(void); 39 extern int tx4927_get_mem_size(void);
61 extern char* toshiba_name;
62 int msize; 40 int msize;
63 41
64 prom_init_cmdline(); 42 prom_init_cmdline();
65
66 if ((read_c0_prid() & 0xff) == PRID_REV_TX4927) {
67 mips_machtype = MACH_TOSHIBA_RBTX4927;
68 toshiba_name = "TX4927";
69 } else {
70 mips_machtype = MACH_TOSHIBA_RBTX4937;
71 toshiba_name = "TX4937";
72 }
73
74 msize = tx4927_get_mem_size(); 43 msize = tx4927_get_mem_size();
75 add_memory_region(0, msize << 20, BOOT_MEM_RAM); 44 add_memory_region(0, msize << 20, BOOT_MEM_RAM);
76} 45}
77
78void __init prom_free_prom_memory(void)
79{
80}
81
82const char *get_system_type(void)
83{
84 return "Toshiba RBTX4927/RBTX4937";
85}
86
87char * __init prom_getcmdline(void)
88{
89 return &(arcs_cmdline[0]);
90}
91
diff --git a/arch/mips/txx9/rbtx4927/setup.c b/arch/mips/txx9/rbtx4927/setup.c
index 86b870abc319..c3566c39c26c 100644
--- a/arch/mips/txx9/rbtx4927/setup.c
+++ b/arch/mips/txx9/rbtx4927/setup.c
@@ -49,7 +49,6 @@
49#include <linux/interrupt.h> 49#include <linux/interrupt.h>
50#include <linux/pm.h> 50#include <linux/pm.h>
51#include <linux/platform_device.h> 51#include <linux/platform_device.h>
52#include <linux/clk.h>
53#include <linux/delay.h> 52#include <linux/delay.h>
54 53
55#include <asm/bootinfo.h> 54#include <asm/bootinfo.h>
@@ -76,8 +75,6 @@ char *prom_getcmdline(void);
76 75
77static int tx4927_ccfg_toeon = 1; 76static int tx4927_ccfg_toeon = 1;
78 77
79char *toshiba_name = "";
80
81#ifdef CONFIG_PCI 78#ifdef CONFIG_PCI
82static void __init tx4927_pci_setup(void) 79static void __init tx4927_pci_setup(void)
83{ 80{
@@ -171,15 +168,15 @@ static void __init tx4937_pci_setup(void)
171 } 168 }
172} 169}
173 170
174static int __init rbtx4927_arch_init(void) 171static void __init rbtx4927_arch_init(void)
175{ 172{
176 if (mips_machtype == MACH_TOSHIBA_RBTX4937) 173 if (mips_machtype == MACH_TOSHIBA_RBTX4937)
177 tx4937_pci_setup(); 174 tx4937_pci_setup();
178 else 175 else
179 tx4927_pci_setup(); 176 tx4927_pci_setup();
180 return 0;
181} 177}
182arch_initcall(rbtx4927_arch_init); 178#else
179#define rbtx4927_arch_init NULL
183#endif /* CONFIG_PCI */ 180#endif /* CONFIG_PCI */
184 181
185static void __noreturn wait_forever(void) 182static void __noreturn wait_forever(void)
@@ -223,14 +220,12 @@ void toshiba_rbtx4927_power_off(void)
223 /* no return */ 220 /* no return */
224} 221}
225 222
226void __init plat_mem_setup(void) 223static void __init rbtx4927_mem_setup(void)
227{ 224{
228 int i; 225 int i;
229 u32 cp0_config; 226 u32 cp0_config;
230 char *argptr; 227 char *argptr;
231 228
232 printk("CPU is %s\n", toshiba_name);
233
234 /* f/w leaves this on at startup */ 229 /* f/w leaves this on at startup */
235 clear_c0_status(ST0_ERL); 230 clear_c0_status(ST0_ERL);
236 231
@@ -323,7 +318,7 @@ void __init plat_mem_setup(void)
323 req.iotype = UPIO_MEM; 318 req.iotype = UPIO_MEM;
324 req.membase = (char *)(0xff1ff300 + i * 0x100); 319 req.membase = (char *)(0xff1ff300 + i * 0x100);
325 req.mapbase = 0xff1ff300 + i * 0x100; 320 req.mapbase = 0xff1ff300 + i * 0x100;
326 req.irq = TX4927_IRQ_PIC_BEG + 8 + i; 321 req.irq = TXX9_IRQ_BASE + TX4927_IR_SIO(i);
327 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/; 322 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
328 req.uartclk = 50000000; 323 req.uartclk = 50000000;
329 early_serial_txx9_setup(&req); 324 early_serial_txx9_setup(&req);
@@ -352,7 +347,7 @@ void __init plat_mem_setup(void)
352#endif 347#endif
353} 348}
354 349
355void __init plat_time_init(void) 350static void __init rbtx4927_time_init(void)
356{ 351{
357 mips_hpt_frequency = txx9_cpu_clock / 2; 352 mips_hpt_frequency = txx9_cpu_clock / 2;
358 if (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_TINTDIS) 353 if (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_TINTDIS)
@@ -372,7 +367,6 @@ static int __init toshiba_rbtx4927_rtc_init(void)
372 platform_device_register_simple("rtc-ds1742", -1, &res, 1); 367 platform_device_register_simple("rtc-ds1742", -1, &res, 1);
373 return IS_ERR(dev) ? PTR_ERR(dev) : 0; 368 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
374} 369}
375device_initcall(toshiba_rbtx4927_rtc_init);
376 370
377static int __init rbtx4927_ne_init(void) 371static int __init rbtx4927_ne_init(void)
378{ 372{
@@ -391,7 +385,6 @@ static int __init rbtx4927_ne_init(void)
391 res, ARRAY_SIZE(res)); 385 res, ARRAY_SIZE(res));
392 return IS_ERR(dev) ? PTR_ERR(dev) : 0; 386 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
393} 387}
394device_initcall(rbtx4927_ne_init);
395 388
396/* Watchdog support */ 389/* Watchdog support */
397 390
@@ -411,36 +404,37 @@ static int __init rbtx4927_wdt_init(void)
411{ 404{
412 return txx9_wdt_init(TX4927_TMR_REG(2) & 0xfffffffffULL); 405 return txx9_wdt_init(TX4927_TMR_REG(2) & 0xfffffffffULL);
413} 406}
414device_initcall(rbtx4927_wdt_init);
415
416/* Minimum CLK support */
417
418struct clk *clk_get(struct device *dev, const char *id)
419{
420 if (!strcmp(id, "imbus_clk"))
421 return (struct clk *)50000000;
422 return ERR_PTR(-ENOENT);
423}
424EXPORT_SYMBOL(clk_get);
425
426int clk_enable(struct clk *clk)
427{
428 return 0;
429}
430EXPORT_SYMBOL(clk_enable);
431 407
432void clk_disable(struct clk *clk) 408static void __init rbtx4927_device_init(void)
433{ 409{
410 toshiba_rbtx4927_rtc_init();
411 rbtx4927_ne_init();
412 rbtx4927_wdt_init();
434} 413}
435EXPORT_SYMBOL(clk_disable);
436 414
437unsigned long clk_get_rate(struct clk *clk) 415struct txx9_board_vec rbtx4927_vec __initdata = {
438{ 416 .type = MACH_TOSHIBA_RBTX4927,
439 return (unsigned long)clk; 417 .system = "Toshiba RBTX4927",
440} 418 .prom_init = rbtx4927_prom_init,
441EXPORT_SYMBOL(clk_get_rate); 419 .mem_setup = rbtx4927_mem_setup,
442 420 .irq_setup = rbtx4927_irq_setup,
443void clk_put(struct clk *clk) 421 .time_init = rbtx4927_time_init,
444{ 422 .device_init = rbtx4927_device_init,
445} 423 .arch_init = rbtx4927_arch_init,
446EXPORT_SYMBOL(clk_put); 424#ifdef CONFIG_PCI
425 .pci_map_irq = rbtx4927_pci_map_irq,
426#endif
427};
428struct txx9_board_vec rbtx4937_vec __initdata = {
429 .type = MACH_TOSHIBA_RBTX4937,
430 .system = "Toshiba RBTX4937",
431 .prom_init = rbtx4927_prom_init,
432 .mem_setup = rbtx4927_mem_setup,
433 .irq_setup = rbtx4927_irq_setup,
434 .time_init = rbtx4927_time_init,
435 .device_init = rbtx4927_device_init,
436 .arch_init = rbtx4927_arch_init,
437#ifdef CONFIG_PCI
438 .pci_map_irq = rbtx4927_pci_map_irq,
439#endif
440};