[MIPS] TXx9: Cleanup watchdog
[deliverable/linux.git] / arch / mips / txx9 / generic / setup.c
CommitLineData
89d63fe1
AN
1/*
2 * linux/arch/mips/txx9/generic/setup.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive.
6 *
7 * 2003-2005 (c) MontaVista Software, Inc.
8 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
9 *
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.
13 */
14#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/types.h>
edcaf1a6
AN
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>
e0eb7307 22#include <linux/gpio.h>
68314725 23#include <linux/platform_device.h>
edcaf1a6 24#include <asm/bootinfo.h>
e0eb7307 25#include <asm/time.h>
a49297e8 26#include <asm/reboot.h>
89d63fe1 27#include <asm/txx9/generic.h>
07517529 28#include <asm/txx9/pci.h>
edcaf1a6
AN
29#ifdef CONFIG_CPU_TX49XX
30#include <asm/txx9/tx4938.h>
31#endif
89d63fe1
AN
32
33/* EBUSC settings of TX4927, etc. */
34struct resource txx9_ce_res[8];
35static char txx9_ce_res_name[8][4]; /* "CEn" */
36
37/* pcode, internal register */
94a4c329 38unsigned int txx9_pcode;
89d63fe1
AN
39char txx9_pcode_str[8];
40static struct resource txx9_reg_res = {
41 .name = txx9_pcode_str,
42 .flags = IORESOURCE_MEM,
43};
44void __init
45txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size)
46{
47 int i;
48
49 for (i = 0; i < ARRAY_SIZE(txx9_ce_res); i++) {
50 sprintf(txx9_ce_res_name[i], "CE%d", i);
51 txx9_ce_res[i].flags = IORESOURCE_MEM;
52 txx9_ce_res[i].name = txx9_ce_res_name[i];
53 }
54
55 sprintf(txx9_pcode_str, "TX%x", pcode);
56 if (base) {
57 txx9_reg_res.start = base & 0xfffffffffULL;
58 txx9_reg_res.end = (base & 0xfffffffffULL) + (size - 1);
59 request_resource(&iomem_resource, &txx9_reg_res);
60 }
61}
62
63/* clocks */
64unsigned int txx9_master_clock;
65unsigned int txx9_cpu_clock;
66unsigned int txx9_gbus_clock;
edcaf1a6 67
94a4c329 68int txx9_ccfg_toeon __initdata = 1;
edcaf1a6
AN
69
70/* Minimum CLK support */
71
72struct clk *clk_get(struct device *dev, const char *id)
73{
74 if (!strcmp(id, "spi-baseclk"))
94a4c329 75 return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 4);
edcaf1a6 76 if (!strcmp(id, "imbus_clk"))
94a4c329 77 return (struct clk *)((unsigned long)txx9_gbus_clock / 2);
edcaf1a6
AN
78 return ERR_PTR(-ENOENT);
79}
80EXPORT_SYMBOL(clk_get);
81
82int clk_enable(struct clk *clk)
83{
84 return 0;
85}
86EXPORT_SYMBOL(clk_enable);
87
88void clk_disable(struct clk *clk)
89{
90}
91EXPORT_SYMBOL(clk_disable);
92
93unsigned long clk_get_rate(struct clk *clk)
94{
95 return (unsigned long)clk;
96}
97EXPORT_SYMBOL(clk_get_rate);
98
99void clk_put(struct clk *clk)
100{
101}
102EXPORT_SYMBOL(clk_put);
103
8d795f2a
AN
104/* GPIO support */
105
106#ifdef CONFIG_GENERIC_GPIO
107int gpio_to_irq(unsigned gpio)
108{
109 return -EINVAL;
110}
111EXPORT_SYMBOL(gpio_to_irq);
112
113int irq_to_gpio(unsigned irq)
114{
115 return -EINVAL;
116}
117EXPORT_SYMBOL(irq_to_gpio);
118#endif
119
edcaf1a6
AN
120extern struct txx9_board_vec jmr3927_vec;
121extern struct txx9_board_vec rbtx4927_vec;
122extern struct txx9_board_vec rbtx4937_vec;
123extern struct txx9_board_vec rbtx4938_vec;
124
edcaf1a6
AN
125struct txx9_board_vec *txx9_board_vec __initdata;
126static char txx9_system_type[32];
127
128void __init prom_init_cmdline(void)
129{
130 int argc = (int)fw_arg0;
131 char **argv = (char **)fw_arg1;
132 int i; /* Always ignore the "-c" at argv[0] */
94a4c329
AN
133#ifdef CONFIG_64BIT
134 char *fixed_argv[32];
135 for (i = 0; i < argc; i++)
136 fixed_argv[i] = (char *)(long)(*((__s32 *)argv + i));
137 argv = fixed_argv;
138#endif
edcaf1a6
AN
139
140 /* ignore all built-in args if any f/w args given */
141 if (argc > 1)
142 *arcs_cmdline = '\0';
143
144 for (i = 1; i < argc; i++) {
145 if (i != 1)
146 strcat(arcs_cmdline, " ");
147 strcat(arcs_cmdline, argv[i]);
148 }
149}
150
151void __init prom_init(void)
152{
edcaf1a6 153#ifdef CONFIG_CPU_TX39XX
7a1fdf19 154 txx9_board_vec = &jmr3927_vec;
edcaf1a6
AN
155#endif
156#ifdef CONFIG_CPU_TX49XX
157 switch (TX4938_REV_PCODE()) {
8d795f2a 158#ifdef CONFIG_TOSHIBA_RBTX4927
edcaf1a6 159 case 0x4927:
7a1fdf19 160 txx9_board_vec = &rbtx4927_vec;
edcaf1a6
AN
161 break;
162 case 0x4937:
7a1fdf19 163 txx9_board_vec = &rbtx4937_vec;
edcaf1a6 164 break;
8d795f2a
AN
165#endif
166#ifdef CONFIG_TOSHIBA_RBTX4938
edcaf1a6 167 case 0x4938:
7a1fdf19 168 txx9_board_vec = &rbtx4938_vec;
edcaf1a6 169 break;
8d795f2a 170#endif
edcaf1a6
AN
171 }
172#endif
7a1fdf19
YY
173
174 strcpy(txx9_system_type, txx9_board_vec->system);
175
7b226094 176 txx9_board_vec->prom_init();
edcaf1a6
AN
177}
178
179void __init prom_free_prom_memory(void)
180{
181}
182
183const char *get_system_type(void)
184{
185 return txx9_system_type;
186}
187
188char * __init prom_getcmdline(void)
189{
190 return &(arcs_cmdline[0]);
191}
192
a49297e8
AN
193static void __noreturn txx9_machine_halt(void)
194{
195 local_irq_disable();
196 clear_c0_status(ST0_IM);
197 while (1) {
198 if (cpu_wait) {
199 (*cpu_wait)();
200 if (cpu_has_counter) {
201 /*
202 * Clear counter interrupt while it
203 * breaks WAIT instruction even if
204 * masked.
205 */
206 write_c0_compare(0);
207 }
208 }
209 }
210}
211
68314725
AN
212/* Watchdog support */
213void __init txx9_wdt_init(unsigned long base)
214{
215 struct resource res = {
216 .start = base,
217 .end = base + 0x100 - 1,
218 .flags = IORESOURCE_MEM,
219 };
220 platform_device_register_simple("txx9wdt", -1, &res, 1);
221}
222
edcaf1a6
AN
223/* wrappers */
224void __init plat_mem_setup(void)
225{
94a4c329
AN
226 ioport_resource.start = 0;
227 ioport_resource.end = ~0UL; /* no limit */
228 iomem_resource.start = 0;
229 iomem_resource.end = ~0UL; /* no limit */
a49297e8
AN
230
231 /* fallback restart/halt routines */
232 _machine_restart = (void (*)(char *))txx9_machine_halt;
233 _machine_halt = txx9_machine_halt;
234 pm_power_off = txx9_machine_halt;
235
07517529
AN
236#ifdef CONFIG_PCI
237 pcibios_plat_setup = txx9_pcibios_setup;
238#endif
edcaf1a6
AN
239 txx9_board_vec->mem_setup();
240}
241
242void __init arch_init_irq(void)
243{
244 txx9_board_vec->irq_setup();
245}
246
247void __init plat_time_init(void)
248{
249 txx9_board_vec->time_init();
250}
251
252static int __init _txx9_arch_init(void)
253{
254 if (txx9_board_vec->arch_init)
255 txx9_board_vec->arch_init();
256 return 0;
257}
258arch_initcall(_txx9_arch_init);
259
260static int __init _txx9_device_init(void)
261{
262 if (txx9_board_vec->device_init)
263 txx9_board_vec->device_init();
264 return 0;
265}
266device_initcall(_txx9_device_init);
267
268int (*txx9_irq_dispatch)(int pending);
269asmlinkage void plat_irq_dispatch(void)
270{
271 int pending = read_c0_status() & read_c0_cause() & ST0_IM;
272 int irq = txx9_irq_dispatch(pending);
273
274 if (likely(irq >= 0))
275 do_IRQ(irq);
276 else
277 spurious_interrupt();
278}
4c642f3f
AN
279
280/* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
281#ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
282static unsigned long __swizzle_addr_none(unsigned long port)
283{
284 return port;
285}
286unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
287EXPORT_SYMBOL(__swizzle_addr_b);
288#endif
This page took 0.052836 seconds and 5 git commands to generate.