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/rbtx4938 | |
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/rbtx4938')
-rw-r--r-- | arch/mips/txx9/rbtx4938/irq.c | 48 | ||||
-rw-r--r-- | arch/mips/txx9/rbtx4938/prom.c | 49 | ||||
-rw-r--r-- | arch/mips/txx9/rbtx4938/setup.c | 64 |
3 files changed, 55 insertions, 106 deletions
diff --git a/arch/mips/txx9/rbtx4938/irq.c b/arch/mips/txx9/rbtx4938/irq.c index f4984820251a..3971a061657a 100644 --- a/arch/mips/txx9/rbtx4938/irq.c +++ b/arch/mips/txx9/rbtx4938/irq.c | |||
@@ -66,6 +66,8 @@ IRQ Device | |||
66 | */ | 66 | */ |
67 | #include <linux/init.h> | 67 | #include <linux/init.h> |
68 | #include <linux/interrupt.h> | 68 | #include <linux/interrupt.h> |
69 | #include <asm/mipsregs.h> | ||
70 | #include <asm/txx9/generic.h> | ||
69 | #include <asm/txx9/rbtx4938.h> | 71 | #include <asm/txx9/rbtx4938.h> |
70 | 72 | ||
71 | static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq); | 73 | static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq); |
@@ -80,26 +82,17 @@ static struct irq_chip toshiba_rbtx4938_irq_ioc_type = { | |||
80 | .unmask = toshiba_rbtx4938_irq_ioc_enable, | 82 | .unmask = toshiba_rbtx4938_irq_ioc_enable, |
81 | }; | 83 | }; |
82 | 84 | ||
83 | int | 85 | static int toshiba_rbtx4938_irq_nested(int sw_irq) |
84 | toshiba_rbtx4938_irq_nested(int sw_irq) | ||
85 | { | 86 | { |
86 | u8 level3; | 87 | u8 level3; |
87 | 88 | ||
88 | level3 = readb(rbtx4938_imstat_addr); | 89 | level3 = readb(rbtx4938_imstat_addr); |
89 | if (level3) | 90 | if (level3) |
90 | /* must use fls so onboard ATA has priority */ | 91 | /* must use fls so onboard ATA has priority */ |
91 | sw_irq = TOSHIBA_RBTX4938_IRQ_IOC_BEG + fls(level3) - 1; | 92 | sw_irq = RBTX4938_IRQ_IOC + fls(level3) - 1; |
92 | |||
93 | return sw_irq; | 93 | return sw_irq; |
94 | } | 94 | } |
95 | 95 | ||
96 | static struct irqaction toshiba_rbtx4938_irq_ioc_action = { | ||
97 | .handler = no_action, | ||
98 | .flags = 0, | ||
99 | .mask = CPU_MASK_NONE, | ||
100 | .name = TOSHIBA_RBTX4938_IOC_NAME, | ||
101 | }; | ||
102 | |||
103 | /**********************************************************************************/ | 96 | /**********************************************************************************/ |
104 | /* Functions for ioc */ | 97 | /* Functions for ioc */ |
105 | /**********************************************************************************/ | 98 | /**********************************************************************************/ |
@@ -108,13 +101,12 @@ toshiba_rbtx4938_irq_ioc_init(void) | |||
108 | { | 101 | { |
109 | int i; | 102 | int i; |
110 | 103 | ||
111 | for (i = TOSHIBA_RBTX4938_IRQ_IOC_BEG; | 104 | for (i = RBTX4938_IRQ_IOC; |
112 | i <= TOSHIBA_RBTX4938_IRQ_IOC_END; i++) | 105 | i < RBTX4938_IRQ_IOC + RBTX4938_NR_IRQ_IOC; i++) |
113 | set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type, | 106 | set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type, |
114 | handle_level_irq); | 107 | handle_level_irq); |
115 | 108 | ||
116 | setup_irq(RBTX4938_IRQ_IOCINT, | 109 | set_irq_chained_handler(RBTX4938_IRQ_IOCINT, handle_simple_irq); |
117 | &toshiba_rbtx4938_irq_ioc_action); | ||
118 | } | 110 | } |
119 | 111 | ||
120 | static void | 112 | static void |
@@ -123,7 +115,7 @@ toshiba_rbtx4938_irq_ioc_enable(unsigned int irq) | |||
123 | unsigned char v; | 115 | unsigned char v; |
124 | 116 | ||
125 | v = readb(rbtx4938_imask_addr); | 117 | v = readb(rbtx4938_imask_addr); |
126 | v |= (1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG)); | 118 | v |= (1 << (irq - RBTX4938_IRQ_IOC)); |
127 | writeb(v, rbtx4938_imask_addr); | 119 | writeb(v, rbtx4938_imask_addr); |
128 | mmiowb(); | 120 | mmiowb(); |
129 | } | 121 | } |
@@ -134,15 +126,33 @@ toshiba_rbtx4938_irq_ioc_disable(unsigned int irq) | |||
134 | unsigned char v; | 126 | unsigned char v; |
135 | 127 | ||
136 | v = readb(rbtx4938_imask_addr); | 128 | v = readb(rbtx4938_imask_addr); |
137 | v &= ~(1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG)); | 129 | v &= ~(1 << (irq - RBTX4938_IRQ_IOC)); |
138 | writeb(v, rbtx4938_imask_addr); | 130 | writeb(v, rbtx4938_imask_addr); |
139 | mmiowb(); | 131 | mmiowb(); |
140 | } | 132 | } |
141 | 133 | ||
142 | void __init arch_init_irq(void) | 134 | static int rbtx4938_irq_dispatch(int pending) |
143 | { | 135 | { |
144 | extern void tx4938_irq_init(void); | 136 | int irq; |
137 | |||
138 | if (pending & STATUSF_IP7) | ||
139 | irq = MIPS_CPU_IRQ_BASE + 7; | ||
140 | else if (pending & STATUSF_IP2) { | ||
141 | irq = txx9_irq(); | ||
142 | if (irq == RBTX4938_IRQ_IOCINT) | ||
143 | irq = toshiba_rbtx4938_irq_nested(irq); | ||
144 | } else if (pending & STATUSF_IP1) | ||
145 | irq = MIPS_CPU_IRQ_BASE + 0; | ||
146 | else if (pending & STATUSF_IP0) | ||
147 | irq = MIPS_CPU_IRQ_BASE + 1; | ||
148 | else | ||
149 | irq = -1; | ||
150 | return irq; | ||
151 | } | ||
145 | 152 | ||
153 | void __init rbtx4938_irq_setup(void) | ||
154 | { | ||
155 | txx9_irq_dispatch = rbtx4938_irq_dispatch; | ||
146 | /* Now, interrupt control disabled, */ | 156 | /* Now, interrupt control disabled, */ |
147 | /* all IRC interrupts are masked, */ | 157 | /* all IRC interrupts are masked, */ |
148 | /* all IRC interrupt mode are Low Active. */ | 158 | /* all IRC interrupt mode are Low Active. */ |
diff --git a/arch/mips/txx9/rbtx4938/prom.c b/arch/mips/txx9/rbtx4938/prom.c index 134fcc2dc7d2..fbb37458ddb2 100644 --- a/arch/mips/txx9/rbtx4938/prom.c +++ b/arch/mips/txx9/rbtx4938/prom.c | |||
@@ -11,34 +11,12 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/mm.h> | ||
15 | #include <linux/sched.h> | ||
16 | #include <linux/bootmem.h> | 14 | #include <linux/bootmem.h> |
17 | |||
18 | #include <asm/addrspace.h> | ||
19 | #include <asm/bootinfo.h> | 15 | #include <asm/bootinfo.h> |
20 | #include <asm/txx9/tx4938.h> | 16 | #include <asm/txx9/generic.h> |
21 | 17 | #include <asm/txx9/rbtx4938.h> | |
22 | void __init prom_init_cmdline(void) | ||
23 | { | ||
24 | int argc = (int) fw_arg0; | ||
25 | char **argv = (char **) fw_arg1; | ||
26 | int i; | ||
27 | |||
28 | /* ignore all built-in args if any f/w args given */ | ||
29 | if (argc > 1) { | ||
30 | *arcs_cmdline = '\0'; | ||
31 | } | ||
32 | |||
33 | for (i = 1; i < argc; i++) { | ||
34 | if (i != 1) { | ||
35 | strcat(arcs_cmdline, " "); | ||
36 | } | ||
37 | strcat(arcs_cmdline, argv[i]); | ||
38 | } | ||
39 | } | ||
40 | 18 | ||
41 | void __init prom_init(void) | 19 | void __init rbtx4938_prom_init(void) |
42 | { | 20 | { |
43 | extern int tx4938_get_mem_size(void); | 21 | extern int tx4938_get_mem_size(void); |
44 | int msize; | 22 | int msize; |
@@ -48,25 +26,4 @@ void __init prom_init(void) | |||
48 | 26 | ||
49 | msize = tx4938_get_mem_size(); | 27 | msize = tx4938_get_mem_size(); |
50 | add_memory_region(0, msize << 20, BOOT_MEM_RAM); | 28 | add_memory_region(0, msize << 20, BOOT_MEM_RAM); |
51 | |||
52 | return; | ||
53 | } | ||
54 | |||
55 | void __init prom_free_prom_memory(void) | ||
56 | { | ||
57 | } | ||
58 | |||
59 | void __init prom_fixup_mem_map(unsigned long start, unsigned long end) | ||
60 | { | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | const char *get_system_type(void) | ||
65 | { | ||
66 | return "Toshiba RBTX4938"; | ||
67 | } | ||
68 | |||
69 | char * __init prom_getcmdline(void) | ||
70 | { | ||
71 | return &(arcs_cmdline[0]); | ||
72 | } | 29 | } |
diff --git a/arch/mips/txx9/rbtx4938/setup.c b/arch/mips/txx9/rbtx4938/setup.c index 144d2cada820..8306ba333dda 100644 --- a/arch/mips/txx9/rbtx4938/setup.c +++ b/arch/mips/txx9/rbtx4938/setup.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/console.h> | 17 | #include <linux/console.h> |
18 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/clk.h> | ||
21 | #include <linux/gpio.h> | 20 | #include <linux/gpio.h> |
22 | 21 | ||
23 | #include <asm/reboot.h> | 22 | #include <asm/reboot.h> |
@@ -147,9 +146,9 @@ static void __init rbtx4938_pci_setup(void) | |||
147 | #define SEEPROM3_CS 1 /* IOC */ | 146 | #define SEEPROM3_CS 1 /* IOC */ |
148 | #define SRTC_CS 2 /* IOC */ | 147 | #define SRTC_CS 2 /* IOC */ |
149 | 148 | ||
150 | #ifdef CONFIG_PCI | ||
151 | static int __init rbtx4938_ethaddr_init(void) | 149 | static int __init rbtx4938_ethaddr_init(void) |
152 | { | 150 | { |
151 | #ifdef CONFIG_PCI | ||
153 | unsigned char dat[17]; | 152 | unsigned char dat[17]; |
154 | unsigned char sum; | 153 | unsigned char sum; |
155 | int i; | 154 | int i; |
@@ -179,10 +178,9 @@ static int __init rbtx4938_ethaddr_init(void) | |||
179 | platform_device_add(pdev)) | 178 | platform_device_add(pdev)) |
180 | platform_device_put(pdev); | 179 | platform_device_put(pdev); |
181 | } | 180 | } |
181 | #endif /* CONFIG_PCI */ | ||
182 | return 0; | 182 | return 0; |
183 | } | 183 | } |
184 | device_initcall(rbtx4938_ethaddr_init); | ||
185 | #endif /* CONFIG_PCI */ | ||
186 | 184 | ||
187 | static void __init rbtx4938_spi_setup(void) | 185 | static void __init rbtx4938_spi_setup(void) |
188 | { | 186 | { |
@@ -366,7 +364,7 @@ void __init tx4938_board_setup(void) | |||
366 | #endif | 364 | #endif |
367 | } | 365 | } |
368 | 366 | ||
369 | void __init plat_time_init(void) | 367 | static void __init rbtx4938_time_init(void) |
370 | { | 368 | { |
371 | mips_hpt_frequency = txx9_cpu_clock / 2; | 369 | mips_hpt_frequency = txx9_cpu_clock / 2; |
372 | if (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_TINTDIS) | 370 | if (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_TINTDIS) |
@@ -375,7 +373,7 @@ void __init plat_time_init(void) | |||
375 | txx9_gbus_clock / 2); | 373 | txx9_gbus_clock / 2); |
376 | } | 374 | } |
377 | 375 | ||
378 | void __init plat_mem_setup(void) | 376 | static void __init rbtx4938_mem_setup(void) |
379 | { | 377 | { |
380 | unsigned long long pcfg; | 378 | unsigned long long pcfg; |
381 | char *argptr; | 379 | char *argptr; |
@@ -496,7 +494,6 @@ static int __init rbtx4938_ne_init(void) | |||
496 | res, ARRAY_SIZE(res)); | 494 | res, ARRAY_SIZE(res)); |
497 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; | 495 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
498 | } | 496 | } |
499 | device_initcall(rbtx4938_ne_init); | ||
500 | 497 | ||
501 | /* GPIO support */ | 498 | /* GPIO support */ |
502 | 499 | ||
@@ -587,14 +584,13 @@ static int __init rbtx4938_spi_init(void) | |||
587 | return 0; | 584 | return 0; |
588 | } | 585 | } |
589 | 586 | ||
590 | static int __init rbtx4938_arch_init(void) | 587 | static void __init rbtx4938_arch_init(void) |
591 | { | 588 | { |
592 | txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, 16); | 589 | txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, 16); |
593 | gpiochip_add(&rbtx4938_spi_gpio_chip); | 590 | gpiochip_add(&rbtx4938_spi_gpio_chip); |
594 | rbtx4938_pci_setup(); | 591 | rbtx4938_pci_setup(); |
595 | return rbtx4938_spi_init(); | 592 | rbtx4938_spi_init(); |
596 | } | 593 | } |
597 | arch_initcall(rbtx4938_arch_init); | ||
598 | 594 | ||
599 | /* Watchdog support */ | 595 | /* Watchdog support */ |
600 | 596 | ||
@@ -614,38 +610,24 @@ static int __init rbtx4938_wdt_init(void) | |||
614 | { | 610 | { |
615 | return txx9_wdt_init(TX4938_TMR_REG(2) & 0xfffffffffULL); | 611 | return txx9_wdt_init(TX4938_TMR_REG(2) & 0xfffffffffULL); |
616 | } | 612 | } |
617 | device_initcall(rbtx4938_wdt_init); | ||
618 | |||
619 | /* Minimum CLK support */ | ||
620 | |||
621 | struct clk *clk_get(struct device *dev, const char *id) | ||
622 | { | ||
623 | if (!strcmp(id, "spi-baseclk")) | ||
624 | return (struct clk *)(txx9_gbus_clock / 2 / 4); | ||
625 | if (!strcmp(id, "imbus_clk")) | ||
626 | return (struct clk *)(txx9_gbus_clock / 2); | ||
627 | return ERR_PTR(-ENOENT); | ||
628 | } | ||
629 | EXPORT_SYMBOL(clk_get); | ||
630 | |||
631 | int clk_enable(struct clk *clk) | ||
632 | { | ||
633 | return 0; | ||
634 | } | ||
635 | EXPORT_SYMBOL(clk_enable); | ||
636 | |||
637 | void clk_disable(struct clk *clk) | ||
638 | { | ||
639 | } | ||
640 | EXPORT_SYMBOL(clk_disable); | ||
641 | 613 | ||
642 | unsigned long clk_get_rate(struct clk *clk) | 614 | static void __init rbtx4938_device_init(void) |
643 | { | 615 | { |
644 | return (unsigned long)clk; | 616 | rbtx4938_ethaddr_init(); |
617 | rbtx4938_ne_init(); | ||
618 | rbtx4938_wdt_init(); | ||
645 | } | 619 | } |
646 | EXPORT_SYMBOL(clk_get_rate); | ||
647 | 620 | ||
648 | void clk_put(struct clk *clk) | 621 | struct txx9_board_vec rbtx4938_vec __initdata = { |
649 | { | 622 | .type = MACH_TOSHIBA_RBTX4938, |
650 | } | 623 | .system = "Toshiba RBTX4938", |
651 | EXPORT_SYMBOL(clk_put); | 624 | .prom_init = rbtx4938_prom_init, |
625 | .mem_setup = rbtx4938_mem_setup, | ||
626 | .irq_setup = rbtx4938_irq_setup, | ||
627 | .time_init = rbtx4938_time_init, | ||
628 | .device_init = rbtx4938_device_init, | ||
629 | .arch_init = rbtx4938_arch_init, | ||
630 | #ifdef CONFIG_PCI | ||
631 | .pci_map_irq = rbtx4938_pci_map_irq, | ||
632 | #endif | ||
633 | }; | ||