[MIPS] TXx9: Cleanup restart/halt/power_off
[linux-2.6/linux-2.6-openrd.git] / arch / mips / txx9 / generic / setup.c
blob82272e85a04212c31b5cf207be06661bf166c7aa
1 /*
2 * linux/arch/mips/txx9/generic/setup.c
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive.
7 * 2003-2005 (c) MontaVista Software, Inc.
8 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
14 #include <linux/init.h>
15 #include <linux/kernel.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 <linux/gpio.h>
23 #include <asm/bootinfo.h>
24 #include <asm/time.h>
25 #include <asm/reboot.h>
26 #include <asm/txx9/generic.h>
27 #include <asm/txx9/pci.h>
28 #ifdef CONFIG_CPU_TX49XX
29 #include <asm/txx9/tx4938.h>
30 #endif
32 /* EBUSC settings of TX4927, etc. */
33 struct resource txx9_ce_res[8];
34 static char txx9_ce_res_name[8][4]; /* "CEn" */
36 /* pcode, internal register */
37 unsigned int txx9_pcode;
38 char txx9_pcode_str[8];
39 static struct resource txx9_reg_res = {
40 .name = txx9_pcode_str,
41 .flags = IORESOURCE_MEM,
43 void __init
44 txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size)
46 int i;
48 for (i = 0; i < ARRAY_SIZE(txx9_ce_res); i++) {
49 sprintf(txx9_ce_res_name[i], "CE%d", i);
50 txx9_ce_res[i].flags = IORESOURCE_MEM;
51 txx9_ce_res[i].name = txx9_ce_res_name[i];
54 sprintf(txx9_pcode_str, "TX%x", pcode);
55 if (base) {
56 txx9_reg_res.start = base & 0xfffffffffULL;
57 txx9_reg_res.end = (base & 0xfffffffffULL) + (size - 1);
58 request_resource(&iomem_resource, &txx9_reg_res);
62 /* clocks */
63 unsigned int txx9_master_clock;
64 unsigned int txx9_cpu_clock;
65 unsigned int txx9_gbus_clock;
67 int txx9_ccfg_toeon __initdata = 1;
69 /* Minimum CLK support */
71 struct clk *clk_get(struct device *dev, const char *id)
73 if (!strcmp(id, "spi-baseclk"))
74 return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 4);
75 if (!strcmp(id, "imbus_clk"))
76 return (struct clk *)((unsigned long)txx9_gbus_clock / 2);
77 return ERR_PTR(-ENOENT);
79 EXPORT_SYMBOL(clk_get);
81 int clk_enable(struct clk *clk)
83 return 0;
85 EXPORT_SYMBOL(clk_enable);
87 void clk_disable(struct clk *clk)
90 EXPORT_SYMBOL(clk_disable);
92 unsigned long clk_get_rate(struct clk *clk)
94 return (unsigned long)clk;
96 EXPORT_SYMBOL(clk_get_rate);
98 void clk_put(struct clk *clk)
101 EXPORT_SYMBOL(clk_put);
103 /* GPIO support */
105 #ifdef CONFIG_GENERIC_GPIO
106 int gpio_to_irq(unsigned gpio)
108 return -EINVAL;
110 EXPORT_SYMBOL(gpio_to_irq);
112 int irq_to_gpio(unsigned irq)
114 return -EINVAL;
116 EXPORT_SYMBOL(irq_to_gpio);
117 #endif
119 extern struct txx9_board_vec jmr3927_vec;
120 extern struct txx9_board_vec rbtx4927_vec;
121 extern struct txx9_board_vec rbtx4937_vec;
122 extern struct txx9_board_vec rbtx4938_vec;
124 struct txx9_board_vec *txx9_board_vec __initdata;
125 static char txx9_system_type[32];
127 void __init prom_init_cmdline(void)
129 int argc = (int)fw_arg0;
130 char **argv = (char **)fw_arg1;
131 int i; /* Always ignore the "-c" at argv[0] */
132 #ifdef CONFIG_64BIT
133 char *fixed_argv[32];
134 for (i = 0; i < argc; i++)
135 fixed_argv[i] = (char *)(long)(*((__s32 *)argv + i));
136 argv = fixed_argv;
137 #endif
139 /* ignore all built-in args if any f/w args given */
140 if (argc > 1)
141 *arcs_cmdline = '\0';
143 for (i = 1; i < argc; i++) {
144 if (i != 1)
145 strcat(arcs_cmdline, " ");
146 strcat(arcs_cmdline, argv[i]);
150 void __init prom_init(void)
152 #ifdef CONFIG_CPU_TX39XX
153 txx9_board_vec = &jmr3927_vec;
154 #endif
155 #ifdef CONFIG_CPU_TX49XX
156 switch (TX4938_REV_PCODE()) {
157 #ifdef CONFIG_TOSHIBA_RBTX4927
158 case 0x4927:
159 txx9_board_vec = &rbtx4927_vec;
160 break;
161 case 0x4937:
162 txx9_board_vec = &rbtx4937_vec;
163 break;
164 #endif
165 #ifdef CONFIG_TOSHIBA_RBTX4938
166 case 0x4938:
167 txx9_board_vec = &rbtx4938_vec;
168 break;
169 #endif
171 #endif
173 strcpy(txx9_system_type, txx9_board_vec->system);
175 txx9_board_vec->prom_init();
178 void __init prom_free_prom_memory(void)
182 const char *get_system_type(void)
184 return txx9_system_type;
187 char * __init prom_getcmdline(void)
189 return &(arcs_cmdline[0]);
192 static void __noreturn txx9_machine_halt(void)
194 local_irq_disable();
195 clear_c0_status(ST0_IM);
196 while (1) {
197 if (cpu_wait) {
198 (*cpu_wait)();
199 if (cpu_has_counter) {
201 * Clear counter interrupt while it
202 * breaks WAIT instruction even if
203 * masked.
205 write_c0_compare(0);
211 /* wrappers */
212 void __init plat_mem_setup(void)
214 ioport_resource.start = 0;
215 ioport_resource.end = ~0UL; /* no limit */
216 iomem_resource.start = 0;
217 iomem_resource.end = ~0UL; /* no limit */
219 /* fallback restart/halt routines */
220 _machine_restart = (void (*)(char *))txx9_machine_halt;
221 _machine_halt = txx9_machine_halt;
222 pm_power_off = txx9_machine_halt;
224 #ifdef CONFIG_PCI
225 pcibios_plat_setup = txx9_pcibios_setup;
226 #endif
227 txx9_board_vec->mem_setup();
230 void __init arch_init_irq(void)
232 txx9_board_vec->irq_setup();
235 void __init plat_time_init(void)
237 txx9_board_vec->time_init();
240 static int __init _txx9_arch_init(void)
242 if (txx9_board_vec->arch_init)
243 txx9_board_vec->arch_init();
244 return 0;
246 arch_initcall(_txx9_arch_init);
248 static int __init _txx9_device_init(void)
250 if (txx9_board_vec->device_init)
251 txx9_board_vec->device_init();
252 return 0;
254 device_initcall(_txx9_device_init);
256 int (*txx9_irq_dispatch)(int pending);
257 asmlinkage void plat_irq_dispatch(void)
259 int pending = read_c0_status() & read_c0_cause() & ST0_IM;
260 int irq = txx9_irq_dispatch(pending);
262 if (likely(irq >= 0))
263 do_IRQ(irq);
264 else
265 spurious_interrupt();
268 /* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
269 #ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
270 static unsigned long __swizzle_addr_none(unsigned long port)
272 return port;
274 unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
275 EXPORT_SYMBOL(__swizzle_addr_b);
276 #endif