]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/mips/txx9/generic/setup.c
[MIPS] TXx9: Add 64-bit support
[linux-2.6-omap-h63xx.git] / arch / mips / txx9 / generic / setup.c
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>
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 <asm/bootinfo.h>
23 #include <asm/txx9/generic.h>
24 #ifdef CONFIG_CPU_TX49XX
25 #include <asm/txx9/tx4938.h>
26 #endif
27
28 /* EBUSC settings of TX4927, etc. */
29 struct resource txx9_ce_res[8];
30 static char txx9_ce_res_name[8][4];     /* "CEn" */
31
32 /* pcode, internal register */
33 unsigned int txx9_pcode;
34 char txx9_pcode_str[8];
35 static struct resource txx9_reg_res = {
36         .name = txx9_pcode_str,
37         .flags = IORESOURCE_MEM,
38 };
39 void __init
40 txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size)
41 {
42         int i;
43
44         for (i = 0; i < ARRAY_SIZE(txx9_ce_res); i++) {
45                 sprintf(txx9_ce_res_name[i], "CE%d", i);
46                 txx9_ce_res[i].flags = IORESOURCE_MEM;
47                 txx9_ce_res[i].name = txx9_ce_res_name[i];
48         }
49
50         sprintf(txx9_pcode_str, "TX%x", pcode);
51         if (base) {
52                 txx9_reg_res.start = base & 0xfffffffffULL;
53                 txx9_reg_res.end = (base & 0xfffffffffULL) + (size - 1);
54                 request_resource(&iomem_resource, &txx9_reg_res);
55         }
56 }
57
58 /* clocks */
59 unsigned int txx9_master_clock;
60 unsigned int txx9_cpu_clock;
61 unsigned int txx9_gbus_clock;
62
63 int txx9_ccfg_toeon __initdata = 1;
64
65 /* Minimum CLK support */
66
67 struct clk *clk_get(struct device *dev, const char *id)
68 {
69         if (!strcmp(id, "spi-baseclk"))
70                 return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 4);
71         if (!strcmp(id, "imbus_clk"))
72                 return (struct clk *)((unsigned long)txx9_gbus_clock / 2);
73         return ERR_PTR(-ENOENT);
74 }
75 EXPORT_SYMBOL(clk_get);
76
77 int clk_enable(struct clk *clk)
78 {
79         return 0;
80 }
81 EXPORT_SYMBOL(clk_enable);
82
83 void clk_disable(struct clk *clk)
84 {
85 }
86 EXPORT_SYMBOL(clk_disable);
87
88 unsigned long clk_get_rate(struct clk *clk)
89 {
90         return (unsigned long)clk;
91 }
92 EXPORT_SYMBOL(clk_get_rate);
93
94 void clk_put(struct clk *clk)
95 {
96 }
97 EXPORT_SYMBOL(clk_put);
98
99 /* GPIO support */
100
101 #ifdef CONFIG_GENERIC_GPIO
102 int gpio_to_irq(unsigned gpio)
103 {
104         return -EINVAL;
105 }
106 EXPORT_SYMBOL(gpio_to_irq);
107
108 int irq_to_gpio(unsigned irq)
109 {
110         return -EINVAL;
111 }
112 EXPORT_SYMBOL(irq_to_gpio);
113 #endif
114
115 extern struct txx9_board_vec jmr3927_vec;
116 extern struct txx9_board_vec rbtx4927_vec;
117 extern struct txx9_board_vec rbtx4937_vec;
118 extern struct txx9_board_vec rbtx4938_vec;
119
120 struct txx9_board_vec *txx9_board_vec __initdata;
121 static char txx9_system_type[32];
122
123 void __init prom_init_cmdline(void)
124 {
125         int argc = (int)fw_arg0;
126         char **argv = (char **)fw_arg1;
127         int i;                  /* Always ignore the "-c" at argv[0] */
128 #ifdef CONFIG_64BIT
129         char *fixed_argv[32];
130         for (i = 0; i < argc; i++)
131                 fixed_argv[i] = (char *)(long)(*((__s32 *)argv + i));
132         argv = fixed_argv;
133 #endif
134
135         /* ignore all built-in args if any f/w args given */
136         if (argc > 1)
137                 *arcs_cmdline = '\0';
138
139         for (i = 1; i < argc; i++) {
140                 if (i != 1)
141                         strcat(arcs_cmdline, " ");
142                 strcat(arcs_cmdline, argv[i]);
143         }
144 }
145
146 void __init prom_init(void)
147 {
148 #ifdef CONFIG_CPU_TX39XX
149         txx9_board_vec = &jmr3927_vec;
150 #endif
151 #ifdef CONFIG_CPU_TX49XX
152         switch (TX4938_REV_PCODE()) {
153 #ifdef CONFIG_TOSHIBA_RBTX4927
154         case 0x4927:
155                 txx9_board_vec = &rbtx4927_vec;
156                 break;
157         case 0x4937:
158                 txx9_board_vec = &rbtx4937_vec;
159                 break;
160 #endif
161 #ifdef CONFIG_TOSHIBA_RBTX4938
162         case 0x4938:
163                 txx9_board_vec = &rbtx4938_vec;
164                 break;
165 #endif
166         }
167 #endif
168
169         strcpy(txx9_system_type, txx9_board_vec->system);
170
171         txx9_board_vec->prom_init();
172 }
173
174 void __init prom_free_prom_memory(void)
175 {
176 }
177
178 const char *get_system_type(void)
179 {
180         return txx9_system_type;
181 }
182
183 char * __init prom_getcmdline(void)
184 {
185         return &(arcs_cmdline[0]);
186 }
187
188 /* wrappers */
189 void __init plat_mem_setup(void)
190 {
191         ioport_resource.start = 0;
192         ioport_resource.end = ~0UL;     /* no limit */
193         iomem_resource.start = 0;
194         iomem_resource.end = ~0UL;      /* no limit */
195         txx9_board_vec->mem_setup();
196 }
197
198 void __init arch_init_irq(void)
199 {
200         txx9_board_vec->irq_setup();
201 }
202
203 void __init plat_time_init(void)
204 {
205         txx9_board_vec->time_init();
206 }
207
208 static int __init _txx9_arch_init(void)
209 {
210         if (txx9_board_vec->arch_init)
211                 txx9_board_vec->arch_init();
212         return 0;
213 }
214 arch_initcall(_txx9_arch_init);
215
216 static int __init _txx9_device_init(void)
217 {
218         if (txx9_board_vec->device_init)
219                 txx9_board_vec->device_init();
220         return 0;
221 }
222 device_initcall(_txx9_device_init);
223
224 int (*txx9_irq_dispatch)(int pending);
225 asmlinkage void plat_irq_dispatch(void)
226 {
227         int pending = read_c0_status() & read_c0_cause() & ST0_IM;
228         int irq = txx9_irq_dispatch(pending);
229
230         if (likely(irq >= 0))
231                 do_IRQ(irq);
232         else
233                 spurious_interrupt();
234 }
235
236 /* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
237 #ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
238 static unsigned long __swizzle_addr_none(unsigned long port)
239 {
240         return port;
241 }
242 unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
243 EXPORT_SYMBOL(__swizzle_addr_b);
244 #endif