aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/txx9
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2008-08-19 09:55:08 -0400
committerRalf Baechle <ralf@linux-mips.org>2008-10-11 11:18:42 -0400
commit860e546c19d88c21819c7f0861c505debd2d6eed (patch)
tree273d21e0610523ae6c783ad0aea5f810d782c539 /arch/mips/txx9
parent265b89db1058124ddbf0091ba3f8c020e3a5ae9d (diff)
MIPS: TXx9: Early command-line preprocessing
* Select board by command-line option or firmware environment variable. * Handle "masterclk=" option. * Add boards.h to centerize board_vec declaration. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org> create mode 100644 include/asm-mips/txx9/boards.h
Diffstat (limited to 'arch/mips/txx9')
-rw-r--r--arch/mips/txx9/generic/setup.c74
1 files changed, 68 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