blob: cfbfa47e9db2ff921746677bb4732186daf15169 [file] [log] [blame]
Stefan Roese5ff4c3f2005-08-15 12:31:23 +02001/*
2 * Copyright (C) 2005 Sandburst Corporation
3 * Travis B. Sawyer
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <config.h>
25#include <common.h>
26#include <command.h>
27#include "karef.h"
28#include "karef_version.h"
29#include <asm/processor.h>
30#include <asm/io.h>
31#include <spd_sdram.h>
32#include <i2c.h>
33#include "../common/sb_common.h"
34#include "../common/ppc440gx_i2c.h"
35
Stefan Roese5ff4c3f2005-08-15 12:31:23 +020036void fpga_init (void);
37
38KAREF_BOARD_ID_ST board_id_as[] =
39{
40 {"Undefined"}, /* Not specified */
41 {"Kamino Reference Design"},
42 {"Reserved"}, /* Reserved for future use */
43 {"Reserved"}, /* Reserved for future use */
44};
45
46KAREF_BOARD_ID_ST ofem_board_id_as[] =
47{
48 {"Undefined"},
49 {"1x10 + 10x2"},
50 {"Reserved"},
51 {"Reserved"},
52};
53
Stefan Roese5ff4c3f2005-08-15 12:31:23 +020054/*************************************************************************
55 * board_early_init_f
56 *
57 * Setup chip selects, initialize the Opto-FPGA, initialize
58 * interrupt polarity and triggers.
Stefan Roese5ff4c3f2005-08-15 12:31:23 +020059 ************************************************************************/
60int board_early_init_f (void)
61{
62 ppc440_gpio_regs_t *gpio_regs;
63
64 /* Enable GPIO interrupts */
65 mtsdr(sdr_pfc0, 0x00103E00);
66
67 /* Setup access for LEDs, and system topology info */
68 gpio_regs = (ppc440_gpio_regs_t *)CFG_GPIO_BASE;
69 gpio_regs->open_drain = SBCOMMON_GPIO_SYS_LEDS;
70 gpio_regs->tri_state = SBCOMMON_GPIO_DBGLEDS;
71
72 /* Turn on all the leds for now */
73 gpio_regs->out = SBCOMMON_GPIO_LEDS;
74
75 /*--------------------------------------------------------------------+
76 | Initialize EBC CONFIG
77 +-------------------------------------------------------------------*/
78 mtebc(xbcfg,
79 EBC_CFG_LE_UNLOCK | EBC_CFG_PTD_ENABLE |
80 EBC_CFG_RTC_64PERCLK | EBC_CFG_ATC_PREVIOUS |
81 EBC_CFG_DTC_PREVIOUS | EBC_CFG_CTC_PREVIOUS |
82 EBC_CFG_EMC_DEFAULT | EBC_CFG_PME_DISABLE |
83 EBC_CFG_PR_32);
84
85 /*--------------------------------------------------------------------+
86 | 1/2 MB FLASH. Initialize bank 0 with default values.
87 +-------------------------------------------------------------------*/
88 mtebc(pb0ap,
89 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) |
90 EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
91 EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
92 EBC_BXAP_WBF_ENCODE(1)| EBC_BXAP_TH_ENCODE(1) |
93 EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
94 EBC_BXAP_PEN_DISABLED);
95
96 mtebc(pb0cr, EBC_BXCR_BAS_ENCODE(CFG_FLASH_BASE) |
97 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_8BIT);
98 /*--------------------------------------------------------------------+
99 | 8KB NVRAM/RTC. Initialize bank 1 with default values.
100 +-------------------------------------------------------------------*/
101 mtebc(pb1ap,
102 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(10) |
103 EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
104 EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
105 EBC_BXAP_WBF_ENCODE(1)| EBC_BXAP_TH_ENCODE(1) |
106 EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
107 EBC_BXAP_PEN_DISABLED);
108
109 mtebc(pb1cr, EBC_BXCR_BAS_ENCODE(0x48000000) |
110 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_8BIT);
111
112 /*--------------------------------------------------------------------+
113 | Compact Flash, uses 2 Chip Selects (2 & 6)
114 +-------------------------------------------------------------------*/
115 mtebc(pb2ap,
116 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) |
117 EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
118 EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
119 EBC_BXAP_WBF_ENCODE(0)| EBC_BXAP_TH_ENCODE(1) |
120 EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
121 EBC_BXAP_PEN_DISABLED);
122
123 mtebc(pb2cr, EBC_BXCR_BAS_ENCODE(0xF0000000) |
124 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_16BIT);
125
126 /*--------------------------------------------------------------------+
127 | KaRef Scan FPGA. Initialize bank 3 with default values.
128 +-------------------------------------------------------------------*/
129 mtebc(pb5ap,
130 EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
131 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
132 EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
133 EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
134 EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
135
136 mtebc(pb5cr, EBC_BXCR_BAS_ENCODE(0x48200000) |
137 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
138
139 /*--------------------------------------------------------------------+
140 | MAC A & B for Kamino. OFEM FPGA decodes the addresses
141 | Initialize bank 4 with default values.
142 +-------------------------------------------------------------------*/
143 mtebc(pb4ap,
144 EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
145 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
146 EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
147 EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
148 EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
149
150 mtebc(pb4cr, EBC_BXCR_BAS_ENCODE(0x48600000) |
151 EBC_BXCR_BS_2MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
152
153 /*--------------------------------------------------------------------+
154 | OFEM FPGA Initialize bank 5 with default values.
155 +-------------------------------------------------------------------*/
156 mtebc(pb3ap,
157 EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
158 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
159 EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
160 EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
161 EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
162
163
164 mtebc(pb3cr, EBC_BXCR_BAS_ENCODE(0x48400000) |
165 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
166
167
168 /*--------------------------------------------------------------------+
169 | Compact Flash, uses 2 Chip Selects (2 & 6)
170 +-------------------------------------------------------------------*/
171 mtebc(pb6ap,
172 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) |
173 EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
174 EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
175 EBC_BXAP_WBF_ENCODE(0)| EBC_BXAP_TH_ENCODE(1) |
176 EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
177 EBC_BXAP_PEN_DISABLED);
178
179 mtebc(pb6cr, EBC_BXCR_BAS_ENCODE(0xF0100000) |
180 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_16BIT);
181
182 /*--------------------------------------------------------------------+
183 | BME-32. Initialize bank 7 with default values.
184 +-------------------------------------------------------------------*/
185 mtebc(pb7ap,
186 EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
187 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
188 EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
189 EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
190 EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
191
192 mtebc(pb7cr, EBC_BXCR_BAS_ENCODE(0x48500000) |
193 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
194
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200195 /*--------------------------------------------------------------------+
196 * Setup the interrupt controller polarities, triggers, etc.
197 +-------------------------------------------------------------------*/
198 mtdcr (uic0sr, 0xffffffff); /* clear all */
199 mtdcr (uic0er, 0x00000000); /* disable all */
200 mtdcr (uic0cr, 0x00000000); /* all non- critical */
201 mtdcr (uic0pr, 0xfffffe03); /* polarity */
202 mtdcr (uic0tr, 0x01c00000); /* trigger edge vs level */
203 mtdcr (uic0vr, 0x00000001); /* int31 highest, base=0x000 */
204 mtdcr (uic0sr, 0xffffffff); /* clear all */
205
206 mtdcr (uic1sr, 0xffffffff); /* clear all */
207 mtdcr (uic1er, 0x00000000); /* disable all */
208 mtdcr (uic1cr, 0x00000000); /* all non-critical */
209 mtdcr (uic1pr, 0xffffc8ff); /* polarity */
210 mtdcr (uic1tr, 0x00ff0000); /* trigger edge vs level */
211 mtdcr (uic1vr, 0x00000001); /* int31 highest, base=0x000 */
212 mtdcr (uic1sr, 0xffffffff); /* clear all */
213
214 mtdcr (uic2sr, 0xffffffff); /* clear all */
215 mtdcr (uic2er, 0x00000000); /* disable all */
216 mtdcr (uic2cr, 0x00000000); /* all non-critical */
217 mtdcr (uic2pr, 0xffff83ff); /* polarity */
218 mtdcr (uic2tr, 0x00ff8c0f); /* trigger edge vs level */
219 mtdcr (uic2vr, 0x00000001); /* int31 highest, base=0x000 */
220 mtdcr (uic2sr, 0xffffffff); /* clear all */
221
222 mtdcr (uicb0sr, 0xfc000000); /* clear all */
223 mtdcr (uicb0er, 0x00000000); /* disable all */
224 mtdcr (uicb0cr, 0x00000000); /* all non-critical */
225 mtdcr (uicb0pr, 0xfc000000);
226 mtdcr (uicb0tr, 0x00000000);
227 mtdcr (uicb0vr, 0x00000001);
228
229 fpga_init();
230
231 return 0;
232}
233
234
235/*************************************************************************
236 * checkboard
237 *
238 * Dump pertinent info to the console
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200239 ************************************************************************/
240int checkboard (void)
241{
242 sys_info_t sysinfo;
243 unsigned char brd_rev, brd_id;
244 unsigned short sernum;
Wolfgang Denkedb65482005-09-24 21:54:50 +0200245 unsigned char scan_rev, scan_id, ofem_rev=0, ofem_id=0;
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200246 unsigned char ofem_brd_rev, ofem_brd_id;
247 KAREF_FPGA_REGS_ST *karef_ps;
248 OFEM_FPGA_REGS_ST *ofem_ps;
249
250 karef_ps = (KAREF_FPGA_REGS_ST *)CFG_KAREF_FPGA_BASE;
251 ofem_ps = (OFEM_FPGA_REGS_ST *)CFG_OFEM_FPGA_BASE;
252
253 scan_id = (unsigned char)((karef_ps->revision_ul &
254 SAND_HAL_KA_SC_SCAN_REVISION_IDENTIFICATION_MASK)
255 >> SAND_HAL_KA_SC_SCAN_REVISION_IDENTIFICATION_SHIFT);
256
257 scan_rev = (unsigned char)((karef_ps->revision_ul & SAND_HAL_KA_SC_SCAN_REVISION_REVISION_MASK)
258 >> SAND_HAL_KA_SC_SCAN_REVISION_REVISION_SHIFT);
259
260 brd_rev = (unsigned char)((karef_ps->boardinfo_ul & SAND_HAL_KA_SC_SCAN_BRD_INFO_BRD_REV_MASK)
261 >> SAND_HAL_KA_SC_SCAN_BRD_INFO_BRD_REV_SHIFT);
262
263 brd_id = (unsigned char)((karef_ps->boardinfo_ul & SAND_HAL_KA_SC_SCAN_BRD_INFO_BRD_ID_MASK)
264 >> SAND_HAL_KA_SC_SCAN_BRD_INFO_BRD_ID_SHIFT);
265
266 ofem_brd_id = (unsigned char)((karef_ps->boardinfo_ul & SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_ID_MASK)
267 >> SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_ID_SHIFT);
268
269 ofem_brd_rev = (unsigned char)((karef_ps->boardinfo_ul & SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_REV_MASK)
270 >> SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_REV_SHIFT);
271
272 if (0xF != ofem_brd_id) {
273 ofem_id = (unsigned char)((ofem_ps->revision_ul &
274 SAND_HAL_KA_OF_OFEM_REVISION_IDENTIFICATION_MASK)
275 >> SAND_HAL_KA_OF_OFEM_REVISION_IDENTIFICATION_SHIFT);
276
277 ofem_rev = (unsigned char)((ofem_ps->revision_ul &
278 SAND_HAL_KA_OF_OFEM_REVISION_REVISION_MASK)
279 >> SAND_HAL_KA_OF_OFEM_REVISION_REVISION_SHIFT);
280 }
281
282 get_sys_info (&sysinfo);
283
284 sernum = sbcommon_get_serial_number();
285
286 printf ("Board: Sandburst Corporation Kamino Reference Design "
287 "Serial Number: %d\n", sernum);
288 printf ("%s\n", KAREF_U_BOOT_REL_STR);
289
290 printf ("Built %s %s by %s\n", __DATE__, __TIME__, BUILDUSER);
291 if (sbcommon_get_master()) {
292 printf("Slot 0 - Master\nSlave board");
293 if (sbcommon_secondary_present())
294 printf(" present\n");
295 else
296 printf(" not detected\n");
297 } else {
298 printf("Slot 1 - Slave\n\n");
299 }
300
301 printf ("ScanFPGA ID:\t0x%02X\tRev: 0x%02X\n", scan_id, scan_rev);
302 printf ("Board Rev:\t0x%02X\tID: 0x%02X\n", brd_rev, brd_id);
303 if(0xF != ofem_brd_id) {
304 printf("OFemFPGA ID:\t0x%02X\tRev: 0x%02X\n", ofem_id, ofem_rev);
305 printf("OFEM Board Rev:\t0x%02X\tID: 0x%02X\n", ofem_brd_id, ofem_brd_rev);
306 }
307
308 printf ("\tVCO: %lu MHz\n", sysinfo.freqVCOMhz / 1000000);
309 printf ("\tCPU: %lu MHz\n", sysinfo.freqProcessor / 1000000);
310 printf ("\tPLB: %lu MHz\n", sysinfo.freqPLB / 1000000);
311 printf ("\tOPB: %lu MHz\n", sysinfo.freqOPB / 1000000);
312 printf ("\tEPB: %lu MHz\n", sysinfo.freqEPB / 1000000);
313
314 /* Fix the ack in the bme 32 */
315 udelay(5000);
316 out32(CFG_BME32_BASE + 0x0000000C, 0x00000001);
317 asm("eieio");
318
319
320 return (0);
321}
322
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200323/*************************************************************************
324 * misc_init_f
325 *
326 * Initialize I2C bus one to gain access to the fans
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200327 ************************************************************************/
328int misc_init_f (void)
329{
330 /* Turn on i2c bus 1 */
331 puts ("I2C1: ");
332 i2c1_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
333 puts ("ready\n");
334
335 /* Turn on fans 3 & 4 */
336 sbcommon_fans();
337
338 return (0);
339}
Wolfgang Denk85faa8b2005-08-15 16:03:56 +0200340
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200341/*************************************************************************
342 * misc_init_r
343 *
344 * Do nothing.
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200345 ************************************************************************/
346int misc_init_r (void)
347{
348 unsigned short sernum;
349 char envstr[255];
350 KAREF_FPGA_REGS_ST *karef_ps;
351 OFEM_FPGA_REGS_ST *ofem_ps;
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200352
353 if(NULL != getenv("secondserial")) {
354 puts("secondserial is set, switching to second serial port\n");
355 setenv("stderr", "serial1");
356 setenv("stdout", "serial1");
357 setenv("stdin", "serial1");
358 }
359
360 setenv("ubrelver", KAREF_U_BOOT_REL_STR);
361
362 memset(envstr, 0, 255);
363 sprintf (envstr, "Built %s %s by %s", __DATE__, __TIME__, BUILDUSER);
364 setenv("bldstr", envstr);
365 saveenv();
366
367 if( getenv("autorecover")) {
368 setenv("autorecover", NULL);
369 saveenv();
370 sernum = sbcommon_get_serial_number();
371
372 printf("\nSetting up environment for automatic filesystem recovery\n");
373 /*
374 * Setup default bootargs
375 */
376 memset(envstr, 0, 255);
377
378 sprintf(envstr, "console=ttyS0,9600 root=/dev/ram0 "
379 "rw ip=10.100.70.%d:::255.255.0.0:karef%d:eth0:none idebus=33",
380 sernum, sernum);
381 setenv("bootargs", envstr);
382
383 /*
384 * Setup Default boot command
385 */
386 setenv("bootcmd", "fatload ide 0 8000000 uimage.karef;"
387 "fatload ide 0 8100000 pramdisk;"
388 "bootm 8000000 8100000");
389
390 printf("Done. Please type allow the system to continue to boot\n");
391 }
392
393 if( getenv("fakeled")) {
394 karef_ps = (KAREF_FPGA_REGS_ST *)CFG_KAREF_FPGA_BASE;
395 ofem_ps = (OFEM_FPGA_REGS_ST *)CFG_OFEM_FPGA_BASE;
396 ofem_ps->control_ul &= ~SAND_HAL_KA_SC_SCAN_CNTL_FAULT_LED_MASK;
397 karef_ps->control_ul &= ~SAND_HAL_KA_OF_OFEM_CNTL_FAULT_LED_MASK;
398 setenv("bootdelay", "-1");
399 saveenv();
400 printf("fakeled is set. use 'setenv fakeled ; setenv bootdelay 5 ; saveenv' to recover\n");
401 }
402
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200403 return (0);
404}
405
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200406/*************************************************************************
407 * ide_set_reset
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200408 ************************************************************************/
409#ifdef CONFIG_IDE_RESET
410void ide_set_reset(int on)
411{
412 KAREF_FPGA_REGS_ST *karef_ps;
413 /* TODO: ide reset */
414 karef_ps = (KAREF_FPGA_REGS_ST *)CFG_KAREF_FPGA_BASE;
415
416 if (on) {
417 karef_ps->reset_ul &= ~SAND_HAL_KA_SC_SCAN_RESET_CF_RESET_N_MASK;
418 } else {
419 karef_ps->reset_ul |= SAND_HAL_KA_SC_SCAN_RESET_CF_RESET_N_MASK;
420 }
421}
422#endif /* CONFIG_IDE_RESET */
423
424/*************************************************************************
425 * fpga_init
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200426 ************************************************************************/
427void fpga_init(void)
428{
429 KAREF_FPGA_REGS_ST *karef_ps;
430 OFEM_FPGA_REGS_ST *ofem_ps;
431 unsigned char ofem_id;
432 unsigned long tmp;
433
434 /* Ensure we have power all around */
435 udelay(500);
436
437 karef_ps = (KAREF_FPGA_REGS_ST *)CFG_KAREF_FPGA_BASE;
438 tmp =
439 SAND_HAL_KA_SC_SCAN_RESET_CF_RESET_N_MASK |
440 SAND_HAL_KA_SC_SCAN_RESET_BME_RESET_N_MASK |
441 SAND_HAL_KA_SC_SCAN_RESET_KA_RESET_N_MASK |
442 SAND_HAL_KA_SC_SCAN_RESET_SLAVE_RESET_N_MASK |
443 SAND_HAL_KA_SC_SCAN_RESET_OFEM_RESET_N_MASK |
444 SAND_HAL_KA_SC_SCAN_RESET_IFE_A_RESET_N_MASK |
445 SAND_HAL_KA_SC_SCAN_RESET_I2C_MUX1_RESET_N_MASK |
446 SAND_HAL_KA_SC_SCAN_RESET_PHY0_RESET_N_MASK |
447 SAND_HAL_KA_SC_SCAN_RESET_PHY1_RESET_N_MASK;
448
449 karef_ps->reset_ul = tmp;
450
451 /*
452 * Wait a bit to allow the ofem fpga to get its brains
453 */
454 udelay(5000);
455
456 /*
457 * Check to see if the ofem is there
458 */
459 ofem_id = (unsigned char)((karef_ps->boardinfo_ul & SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_ID_MASK)
460 >> SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_ID_SHIFT);
461 if(0xF != ofem_id) {
462 tmp =
463 SAND_HAL_KA_OF_OFEM_RESET_I2C_MUX0_RESET_N_MASK |
464 SAND_HAL_KA_OF_OFEM_RESET_LOCH0_RESET_N_MASK |
465 SAND_HAL_KA_OF_OFEM_RESET_MAC0_RESET_N_MASK;
466
467 ofem_ps = (OFEM_FPGA_REGS_ST *)CFG_OFEM_FPGA_BASE;
468 ofem_ps->reset_ul = tmp;
469
470 ofem_ps->control_ul |= 1 < SAND_HAL_KA_OF_OFEM_CNTL_FAULT_LED_SHIFT;
471 }
472
473 karef_ps->control_ul |= 1 << SAND_HAL_KA_SC_SCAN_CNTL_FAULT_LED_SHIFT;
474
475 asm("eieio");
476
477 return;
478}
479
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200480int karefSetupVars(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
481{
482 unsigned short sernum;
483 char envstr[255];
484
485 sernum = sbcommon_get_serial_number();
486
487 memset(envstr, 0, 255);
488 /*
489 * Setup our ip address
490 */
491 sprintf(envstr, "10.100.70.%d", sernum);
492
493 setenv("ipaddr", envstr);
494 /*
495 * Setup the host ip address
496 */
497 setenv("serverip", "10.100.17.10");
498
499 /*
500 * Setup default bootargs
501 */
502 memset(envstr, 0, 255);
503
504 sprintf(envstr, "console=ttyS0,9600 root=/dev/nfs "
505 "rw nfsroot=10.100.17.10:/home/metrobox/mbc70.%d "
506 "nfsaddrs=10.100.70.%d:10.100.17.10:10.100.1.1:"
507 "255.255.0.0:karef%d.sandburst.com:eth0:none idebus=33",
508 sernum, sernum, sernum);
509
510 setenv("bootargs_nfs", envstr);
511 setenv("bootargs", envstr);
512
513 /*
514 * Setup CF bootargs
515 */
516 memset(envstr, 0, 255);
517
518 sprintf(envstr, "console=ttyS0,9600 root=/dev/hda2 "
519 "rw ip=10.100.70.%d:::255.255.0.0:karef%d:eth0:none idebus=33",
520 sernum, sernum);
521
522 setenv("bootargs_cf", envstr);
523
524 /*
525 * Setup Default boot command
526 */
527 setenv("bootcmd_tftp", "tftp 8000000 uImage.karef;bootm 8000000");
528 setenv("bootcmd", "tftp 8000000 uImage.karef;bootm 8000000");
529
530 /*
531 * Setup compact flash boot command
532 */
533 setenv("bootcmd_cf", "fatload ide 0 8000000 uimage.karef;bootm 8000000");
534
535 saveenv();
536
537 return(1);
538}
539
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200540int karefRecover(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
541{
542 unsigned short sernum;
543 char envstr[255];
544
545 sernum = sbcommon_get_serial_number();
546
547 printf("\nSetting up environment for filesystem recovery\n");
548 /*
549 * Setup default bootargs
550 */
551 memset(envstr, 0, 255);
552
553 sprintf(envstr, "console=ttyS0,9600 root=/dev/ram0 "
554 "rw ip=10.100.70.%d:::255.255.0.0:karef%d:eth0:none",
555 sernum, sernum);
556 setenv("bootargs", envstr);
557
558 /*
559 * Setup Default boot command
560 */
561
562 setenv("bootcmd", "fatload ide 0 8000000 uimage.karef;"
563 "fatload ide 0 8100000 pramdisk;"
564 "bootm 8000000 8100000");
565
566 printf("Done. Please type boot<cr>.\nWhen the kernel has booted"
567 " please type fsrecover.sh<cr>\n");
568
569 return(1);
570}
571
Stefan Roese5ff4c3f2005-08-15 12:31:23 +0200572U_BOOT_CMD(kasetup, 1, 1, karefSetupVars,
573 "kasetup - Set environment to factory defaults\n", NULL);
574
575U_BOOT_CMD(karecover, 1, 1, karefRecover,
576 "karecover - Set environment to allow for fs recovery\n", NULL);