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/jmr3927 | |
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/jmr3927')
-rw-r--r-- | arch/mips/txx9/jmr3927/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/txx9/jmr3927/init.c | 57 | ||||
-rw-r--r-- | arch/mips/txx9/jmr3927/irq.c | 45 | ||||
-rw-r--r-- | arch/mips/txx9/jmr3927/prom.c | 46 | ||||
-rw-r--r-- | arch/mips/txx9/jmr3927/setup.c | 54 |
5 files changed, 54 insertions, 150 deletions
diff --git a/arch/mips/txx9/jmr3927/Makefile b/arch/mips/txx9/jmr3927/Makefile index 5f83ea375225..ba292c945669 100644 --- a/arch/mips/txx9/jmr3927/Makefile +++ b/arch/mips/txx9/jmr3927/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for TOSHIBA JMR-TX3927 board | 2 | # Makefile for TOSHIBA JMR-TX3927 board |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y += prom.o init.o irq.o setup.o | 5 | obj-y += prom.o irq.o setup.o |
6 | obj-$(CONFIG_KGDB) += kgdb_io.o | 6 | obj-$(CONFIG_KGDB) += kgdb_io.o |
7 | 7 | ||
8 | EXTRA_CFLAGS += -Werror | 8 | EXTRA_CFLAGS += -Werror |
diff --git a/arch/mips/txx9/jmr3927/init.c b/arch/mips/txx9/jmr3927/init.c deleted file mode 100644 index 1bbb5343baf4..000000000000 --- a/arch/mips/txx9/jmr3927/init.c +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2001 MontaVista Software Inc. | ||
3 | * Author: MontaVista Software, Inc. | ||
4 | * ahennessy@mvista.com | ||
5 | * | ||
6 | * arch/mips/jmr3927/common/init.c | ||
7 | * | ||
8 | * Copyright (C) 2000-2001 Toshiba Corporation | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License as published by the | ||
12 | * Free Software Foundation; either version 2 of the License, or (at your | ||
13 | * option) any later version. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
16 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
17 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
18 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
21 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
22 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License along | ||
27 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
28 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
29 | */ | ||
30 | #include <linux/init.h> | ||
31 | #include <asm/bootinfo.h> | ||
32 | #include <asm/txx9/jmr3927.h> | ||
33 | |||
34 | extern void __init prom_init_cmdline(void); | ||
35 | |||
36 | const char *get_system_type(void) | ||
37 | { | ||
38 | return "Toshiba" | ||
39 | #ifdef CONFIG_TOSHIBA_JMR3927 | ||
40 | " JMR_TX3927" | ||
41 | #endif | ||
42 | ; | ||
43 | } | ||
44 | |||
45 | extern void puts(const char *cp); | ||
46 | |||
47 | void __init prom_init(void) | ||
48 | { | ||
49 | #ifdef CONFIG_TOSHIBA_JMR3927 | ||
50 | /* CCFG */ | ||
51 | if ((tx3927_ccfgptr->ccfg & TX3927_CCFG_TLBOFF) == 0) | ||
52 | puts("Warning: TX3927 TLB off\n"); | ||
53 | #endif | ||
54 | |||
55 | prom_init_cmdline(); | ||
56 | add_memory_region(0, JMR3927_SDRAM_SIZE, BOOT_MEM_RAM); | ||
57 | } | ||
diff --git a/arch/mips/txx9/jmr3927/irq.c b/arch/mips/txx9/jmr3927/irq.c index b97d22e15da6..070c9a115e57 100644 --- a/arch/mips/txx9/jmr3927/irq.c +++ b/arch/mips/txx9/jmr3927/irq.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <asm/system.h> | 39 | #include <asm/system.h> |
40 | 40 | ||
41 | #include <asm/processor.h> | 41 | #include <asm/processor.h> |
42 | #include <asm/txx9/generic.h> | ||
42 | #include <asm/txx9/jmr3927.h> | 43 | #include <asm/txx9/jmr3927.h> |
43 | 44 | ||
44 | #if JMR3927_IRQ_END > NR_IRQS | 45 | #if JMR3927_IRQ_END > NR_IRQS |
@@ -77,37 +78,30 @@ static void unmask_irq_ioc(unsigned int irq) | |||
77 | (void)jmr3927_ioc_reg_in(JMR3927_IOC_REV_ADDR); | 78 | (void)jmr3927_ioc_reg_in(JMR3927_IOC_REV_ADDR); |
78 | } | 79 | } |
79 | 80 | ||
80 | asmlinkage void plat_irq_dispatch(void) | 81 | static int jmr3927_ioc_irqroute(void) |
81 | { | ||
82 | unsigned long cp0_cause = read_c0_cause(); | ||
83 | int irq; | ||
84 | |||
85 | if ((cp0_cause & CAUSEF_IP7) == 0) | ||
86 | return; | ||
87 | irq = (cp0_cause >> CAUSEB_IP2) & 0x0f; | ||
88 | |||
89 | do_IRQ(irq + JMR3927_IRQ_IRC); | ||
90 | } | ||
91 | |||
92 | static irqreturn_t jmr3927_ioc_interrupt(int irq, void *dev_id) | ||
93 | { | 82 | { |
94 | unsigned char istat = jmr3927_ioc_reg_in(JMR3927_IOC_INTS2_ADDR); | 83 | unsigned char istat = jmr3927_ioc_reg_in(JMR3927_IOC_INTS2_ADDR); |
95 | int i; | 84 | int i; |
96 | 85 | ||
97 | for (i = 0; i < JMR3927_NR_IRQ_IOC; i++) { | 86 | for (i = 0; i < JMR3927_NR_IRQ_IOC; i++) { |
98 | if (istat & (1 << i)) { | 87 | if (istat & (1 << i)) |
99 | irq = JMR3927_IRQ_IOC + i; | 88 | return JMR3927_IRQ_IOC + i; |
100 | do_IRQ(irq); | ||
101 | } | ||
102 | } | 89 | } |
103 | return IRQ_HANDLED; | 90 | return -1; |
104 | } | 91 | } |
105 | 92 | ||
106 | static struct irqaction ioc_action = { | 93 | static int jmr3927_irq_dispatch(int pending) |
107 | .handler = jmr3927_ioc_interrupt, | 94 | { |
108 | .mask = CPU_MASK_NONE, | 95 | int irq; |
109 | .name = "IOC", | 96 | |
110 | }; | 97 | if ((pending & CAUSEF_IP7) == 0) |
98 | return -1; | ||
99 | irq = (pending >> CAUSEB_IP2) & 0x0f; | ||
100 | irq += JMR3927_IRQ_IRC; | ||
101 | if (irq == JMR3927_IRQ_IOCINT) | ||
102 | irq = jmr3927_ioc_irqroute(); | ||
103 | return irq; | ||
104 | } | ||
111 | 105 | ||
112 | #ifdef CONFIG_PCI | 106 | #ifdef CONFIG_PCI |
113 | static irqreturn_t jmr3927_pcierr_interrupt(int irq, void *dev_id) | 107 | static irqreturn_t jmr3927_pcierr_interrupt(int irq, void *dev_id) |
@@ -127,8 +121,9 @@ static struct irqaction pcierr_action = { | |||
127 | 121 | ||
128 | static void __init jmr3927_irq_init(void); | 122 | static void __init jmr3927_irq_init(void); |
129 | 123 | ||
130 | void __init arch_init_irq(void) | 124 | void __init jmr3927_irq_setup(void) |
131 | { | 125 | { |
126 | txx9_irq_dispatch = jmr3927_irq_dispatch; | ||
132 | /* Now, interrupt control disabled, */ | 127 | /* Now, interrupt control disabled, */ |
133 | /* all IRC interrupts are masked, */ | 128 | /* all IRC interrupts are masked, */ |
134 | /* all IRC interrupt mode are Low Active. */ | 129 | /* all IRC interrupt mode are Low Active. */ |
@@ -146,7 +141,7 @@ void __init arch_init_irq(void) | |||
146 | jmr3927_irq_init(); | 141 | jmr3927_irq_init(); |
147 | 142 | ||
148 | /* setup IOC interrupt 1 (PCI, MODEM) */ | 143 | /* setup IOC interrupt 1 (PCI, MODEM) */ |
149 | setup_irq(JMR3927_IRQ_IOCINT, &ioc_action); | 144 | set_irq_chained_handler(JMR3927_IRQ_IOCINT, handle_simple_irq); |
150 | 145 | ||
151 | #ifdef CONFIG_PCI | 146 | #ifdef CONFIG_PCI |
152 | setup_irq(JMR3927_IRQ_IRC_PCI, &pcierr_action); | 147 | setup_irq(JMR3927_IRQ_IRC_PCI, &pcierr_action); |
diff --git a/arch/mips/txx9/jmr3927/prom.c b/arch/mips/txx9/jmr3927/prom.c index 8bc1049b622e..2cadb423face 100644 --- a/arch/mips/txx9/jmr3927/prom.c +++ b/arch/mips/txx9/jmr3927/prom.c | |||
@@ -35,42 +35,10 @@ | |||
35 | * with this program; if not, write to the Free Software Foundation, Inc., | 35 | * with this program; if not, write to the Free Software Foundation, Inc., |
36 | * 675 Mass Ave, Cambridge, MA 02139, USA. | 36 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
37 | */ | 37 | */ |
38 | #include <linux/kernel.h> | ||
39 | #include <linux/init.h> | 38 | #include <linux/init.h> |
40 | #include <linux/string.h> | ||
41 | |||
42 | #include <asm/bootinfo.h> | 39 | #include <asm/bootinfo.h> |
43 | #include <asm/txx9/tx3927.h> | 40 | #include <asm/txx9/generic.h> |
44 | 41 | #include <asm/txx9/jmr3927.h> | |
45 | char * __init prom_getcmdline(void) | ||
46 | { | ||
47 | return &(arcs_cmdline[0]); | ||
48 | } | ||
49 | |||
50 | void __init prom_init_cmdline(void) | ||
51 | { | ||
52 | char *cp; | ||
53 | int actr; | ||
54 | int prom_argc = fw_arg0; | ||
55 | char **prom_argv = (char **) fw_arg1; | ||
56 | |||
57 | actr = 1; /* Always ignore argv[0] */ | ||
58 | |||
59 | cp = &(arcs_cmdline[0]); | ||
60 | while(actr < prom_argc) { | ||
61 | strcpy(cp, prom_argv[actr]); | ||
62 | cp += strlen(prom_argv[actr]); | ||
63 | *cp++ = ' '; | ||
64 | actr++; | ||
65 | } | ||
66 | if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */ | ||
67 | --cp; | ||
68 | *cp = '\0'; | ||
69 | } | ||
70 | |||
71 | void __init prom_free_prom_memory(void) | ||
72 | { | ||
73 | } | ||
74 | 42 | ||
75 | #define TIMEOUT 0xffffff | 43 | #define TIMEOUT 0xffffff |
76 | 44 | ||
@@ -96,3 +64,13 @@ puts(const char *cp) | |||
96 | prom_putchar('\r'); | 64 | prom_putchar('\r'); |
97 | prom_putchar('\n'); | 65 | prom_putchar('\n'); |
98 | } | 66 | } |
67 | |||
68 | void __init jmr3927_prom_init(void) | ||
69 | { | ||
70 | /* CCFG */ | ||
71 | if ((tx3927_ccfgptr->ccfg & TX3927_CCFG_TLBOFF) == 0) | ||
72 | puts("Warning: TX3927 TLB off\n"); | ||
73 | |||
74 | prom_init_cmdline(); | ||
75 | add_memory_region(0, JMR3927_SDRAM_SIZE, BOOT_MEM_RAM); | ||
76 | } | ||
diff --git a/arch/mips/txx9/jmr3927/setup.c b/arch/mips/txx9/jmr3927/setup.c index baa8c8db9a94..128a4ae3e72e 100644 --- a/arch/mips/txx9/jmr3927/setup.c +++ b/arch/mips/txx9/jmr3927/setup.c | |||
@@ -34,15 +34,16 @@ | |||
34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
35 | #include <linux/pm.h> | 35 | #include <linux/pm.h> |
36 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> |
37 | #include <linux/clk.h> | ||
38 | #include <linux/gpio.h> | 37 | #include <linux/gpio.h> |
39 | #ifdef CONFIG_SERIAL_TXX9 | 38 | #ifdef CONFIG_SERIAL_TXX9 |
40 | #include <linux/serial_core.h> | 39 | #include <linux/serial_core.h> |
41 | #endif | 40 | #endif |
42 | 41 | ||
42 | #include <asm/bootinfo.h> | ||
43 | #include <asm/txx9tmr.h> | 43 | #include <asm/txx9tmr.h> |
44 | #include <asm/txx9pio.h> | 44 | #include <asm/txx9pio.h> |
45 | #include <asm/reboot.h> | 45 | #include <asm/reboot.h> |
46 | #include <asm/txx9/generic.h> | ||
46 | #include <asm/txx9/pci.h> | 47 | #include <asm/txx9/pci.h> |
47 | #include <asm/txx9/jmr3927.h> | 48 | #include <asm/txx9/jmr3927.h> |
48 | #include <asm/mipsregs.h> | 49 | #include <asm/mipsregs.h> |
@@ -83,7 +84,7 @@ static void jmr3927_machine_power_off(void) | |||
83 | while (1); | 84 | while (1); |
84 | } | 85 | } |
85 | 86 | ||
86 | void __init plat_time_init(void) | 87 | static void __init jmr3927_time_init(void) |
87 | { | 88 | { |
88 | txx9_clockevent_init(TX3927_TMR_REG(0), | 89 | txx9_clockevent_init(TX3927_TMR_REG(0), |
89 | TXX9_IRQ_BASE + JMR3927_IRQ_IRC_TMR(0), | 90 | TXX9_IRQ_BASE + JMR3927_IRQ_IRC_TMR(0), |
@@ -97,7 +98,7 @@ void __init plat_time_init(void) | |||
97 | extern char * __init prom_getcmdline(void); | 98 | extern char * __init prom_getcmdline(void); |
98 | static void jmr3927_board_init(void); | 99 | static void jmr3927_board_init(void); |
99 | 100 | ||
100 | void __init plat_mem_setup(void) | 101 | static void __init jmr3927_mem_setup(void) |
101 | { | 102 | { |
102 | char *argptr; | 103 | char *argptr; |
103 | 104 | ||
@@ -233,6 +234,8 @@ static void __init tx3927_setup(void) | |||
233 | { | 234 | { |
234 | int i; | 235 | int i; |
235 | 236 | ||
237 | txx9_cpu_clock = JMR3927_CORECLK; | ||
238 | txx9_gbus_clock = JMR3927_GBUSCLK; | ||
236 | /* SDRAMC are configured by PROM */ | 239 | /* SDRAMC are configured by PROM */ |
237 | 240 | ||
238 | /* ROMC */ | 241 | /* ROMC */ |
@@ -336,7 +339,6 @@ static int __init jmr3927_rtc_init(void) | |||
336 | dev = platform_device_register_simple("rtc-ds1742", -1, &res, 1); | 339 | dev = platform_device_register_simple("rtc-ds1742", -1, &res, 1); |
337 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; | 340 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
338 | } | 341 | } |
339 | device_initcall(jmr3927_rtc_init); | ||
340 | 342 | ||
341 | /* Watchdog support */ | 343 | /* Watchdog support */ |
342 | 344 | ||
@@ -356,36 +358,22 @@ static int __init jmr3927_wdt_init(void) | |||
356 | { | 358 | { |
357 | return txx9_wdt_init(TX3927_TMR_REG(2)); | 359 | return txx9_wdt_init(TX3927_TMR_REG(2)); |
358 | } | 360 | } |
359 | device_initcall(jmr3927_wdt_init); | ||
360 | 361 | ||
361 | /* Minimum CLK support */ | 362 | static void __init jmr3927_device_init(void) |
362 | |||
363 | struct clk *clk_get(struct device *dev, const char *id) | ||
364 | { | ||
365 | if (!strcmp(id, "imbus_clk")) | ||
366 | return (struct clk *)JMR3927_IMCLK; | ||
367 | return ERR_PTR(-ENOENT); | ||
368 | } | ||
369 | EXPORT_SYMBOL(clk_get); | ||
370 | |||
371 | int clk_enable(struct clk *clk) | ||
372 | { | ||
373 | return 0; | ||
374 | } | ||
375 | EXPORT_SYMBOL(clk_enable); | ||
376 | |||
377 | void clk_disable(struct clk *clk) | ||
378 | { | 363 | { |
364 | jmr3927_rtc_init(); | ||
365 | jmr3927_wdt_init(); | ||
379 | } | 366 | } |
380 | EXPORT_SYMBOL(clk_disable); | ||
381 | 367 | ||
382 | unsigned long clk_get_rate(struct clk *clk) | 368 | struct txx9_board_vec jmr3927_vec __initdata = { |
383 | { | 369 | .type = MACH_TOSHIBA_JMR3927, |
384 | return (unsigned long)clk; | 370 | .system = "Toshiba JMR_TX3927", |
385 | } | 371 | .prom_init = jmr3927_prom_init, |
386 | EXPORT_SYMBOL(clk_get_rate); | 372 | .mem_setup = jmr3927_mem_setup, |
387 | 373 | .irq_setup = jmr3927_irq_setup, | |
388 | void clk_put(struct clk *clk) | 374 | .time_init = jmr3927_time_init, |
389 | { | 375 | .device_init = jmr3927_device_init, |
390 | } | 376 | #ifdef CONFIG_PCI |
391 | EXPORT_SYMBOL(clk_put); | 377 | .pci_map_irq = jmr3927_pci_map_irq, |
378 | #endif | ||
379 | }; | ||