aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/txx9/generic/setup.c74
-rw-r--r--include/asm-mips/txx9/boards.h10
2 files changed, 78 insertions, 6 deletions
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 005179c2af21..dc5dbcc53a91 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -119,14 +119,31 @@ int irq_to_gpio(unsigned irq)
119EXPORT_SYMBOL(irq_to_gpio); 119EXPORT_SYMBOL(irq_to_gpio);
120#endif 120#endif
121 121
122extern struct txx9_board_vec jmr3927_vec; 122#define BOARD_VEC(board) extern struct txx9_board_vec board;
123extern struct txx9_board_vec rbtx4927_vec; 123#include <asm/txx9/boards.h>
124extern struct txx9_board_vec rbtx4937_vec; 124#undef BOARD_VEC
125extern struct txx9_board_vec rbtx4938_vec;
126 125
127struct txx9_board_vec *txx9_board_vec __initdata; 126struct txx9_board_vec *txx9_board_vec __initdata;
128static char txx9_system_type[32]; 127static char txx9_system_type[32];
129 128
129static struct txx9_board_vec *board_vecs[] __initdata = {
130#define BOARD_VEC(board) &board,
131#include <asm/txx9/boards.h>
132#undef BOARD_VEC
133};
134
135static struct txx9_board_vec *__init find_board_byname(const char *name)
136{
137 int i;
138
139 /* search board_vecs table */
140 for (i = 0; i < ARRAY_SIZE(board_vecs); i++) {
141 if (strstr(board_vecs[i]->system, name))
142 return board_vecs[i];
143 }
144 return NULL;
145}
146
130static void __init prom_init_cmdline(void) 147static void __init prom_init_cmdline(void)
131{ 148{
132 int argc = (int)fw_arg0; 149 int argc = (int)fw_arg0;
@@ -169,9 +186,47 @@ static void __init prom_init_cmdline(void)
169 } 186 }
170} 187}
171 188
172void __init prom_init(void) 189static void __init preprocess_cmdline(void)
173{ 190{
174 prom_init_cmdline(); 191 char cmdline[CL_SIZE];
192 char *s;
193
194 strcpy(cmdline, arcs_cmdline);
195 s = cmdline;
196 arcs_cmdline[0] = '\0';
197 while (s && *s) {
198 char *str = strsep(&s, " ");
199 if (strncmp(str, "board=", 6) == 0) {
200 txx9_board_vec = find_board_byname(str + 6);
201 continue;
202 } else if (strncmp(str, "masterclk=", 10) == 0) {
203 unsigned long val;
204 if (strict_strtoul(str + 10, 10, &val) == 0)
205 txx9_master_clock = val;
206 continue;
207 }
208 if (arcs_cmdline[0])
209 strcat(arcs_cmdline, " ");
210 strcat(arcs_cmdline, str);
211 }
212}
213
214static void __init select_board(void)
215{
216 const char *envstr;
217
218 /* first, determine by "board=" argument in preprocess_cmdline() */
219 if (txx9_board_vec)
220 return;
221 /* next, determine by "board" envvar */
222 envstr = prom_getenv("board");
223 if (envstr) {
224 txx9_board_vec = find_board_byname(envstr);
225 if (txx9_board_vec)
226 return;
227 }
228
229 /* select "default" board */
175#ifdef CONFIG_CPU_TX39XX 230#ifdef CONFIG_CPU_TX39XX
176 txx9_board_vec = &jmr3927_vec; 231 txx9_board_vec = &jmr3927_vec;
177#endif 232#endif
@@ -192,6 +247,13 @@ void __init prom_init(void)
192#endif 247#endif
193 } 248 }
194#endif 249#endif
250}
251
252void __init prom_init(void)
253{
254 prom_init_cmdline();
255 preprocess_cmdline();
256 select_board();
195 257
196 strcpy(txx9_system_type, txx9_board_vec->system); 258 strcpy(txx9_system_type, txx9_board_vec->system);
197 259
diff --git a/include/asm-mips/txx9/boards.h b/include/asm-mips/txx9/boards.h
new file mode 100644
index 000000000000..4abc8142fbb7
--- /dev/null
+++ b/include/asm-mips/txx9/boards.h
@@ -0,0 +1,10 @@
1#ifdef CONFIG_TOSHIBA_JMR3927
2BOARD_VEC(jmr3927_vec)
3#endif
4#ifdef CONFIG_TOSHIBA_RBTX4927
5BOARD_VEC(rbtx4927_vec)
6BOARD_VEC(rbtx4937_vec)
7#endif
8#ifdef CONFIG_TOSHIBA_RBTX4938
9BOARD_VEC(rbtx4938_vec)
10#endif