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