blob: 55310d74567e297d769ba9ce2d983d3bc83da5aa [file] [log] [blame]
Stefan Roeseb79316f2005-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"
Peter Tyser561858e2008-11-03 09:30:59 -060029#include <timestamp.h>
Stefan Roeseb79316f2005-08-15 12:31:23 +020030#include <asm/processor.h>
31#include <asm/io.h>
32#include <spd_sdram.h>
33#include <i2c.h>
34#include "../common/sb_common.h"
35#include "../common/ppc440gx_i2c.h"
36
Stefan Roeseb79316f2005-08-15 12:31:23 +020037void fpga_init (void);
38
39KAREF_BOARD_ID_ST board_id_as[] =
40{
41 {"Undefined"}, /* Not specified */
42 {"Kamino Reference Design"},
43 {"Reserved"}, /* Reserved for future use */
44 {"Reserved"}, /* Reserved for future use */
45};
46
47KAREF_BOARD_ID_ST ofem_board_id_as[] =
48{
49 {"Undefined"},
50 {"1x10 + 10x2"},
51 {"Reserved"},
52 {"Reserved"},
53};
54
Stefan Roeseb79316f2005-08-15 12:31:23 +020055/*************************************************************************
56 * board_early_init_f
57 *
58 * Setup chip selects, initialize the Opto-FPGA, initialize
59 * interrupt polarity and triggers.
Stefan Roeseb79316f2005-08-15 12:31:23 +020060 ************************************************************************/
61int board_early_init_f (void)
62{
63 ppc440_gpio_regs_t *gpio_regs;
64
65 /* Enable GPIO interrupts */
66 mtsdr(sdr_pfc0, 0x00103E00);
67
68 /* Setup access for LEDs, and system topology info */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020069 gpio_regs = (ppc440_gpio_regs_t *)CONFIG_SYS_GPIO_BASE;
Stefan Roeseb79316f2005-08-15 12:31:23 +020070 gpio_regs->open_drain = SBCOMMON_GPIO_SYS_LEDS;
71 gpio_regs->tri_state = SBCOMMON_GPIO_DBGLEDS;
72
73 /* Turn on all the leds for now */
74 gpio_regs->out = SBCOMMON_GPIO_LEDS;
75
76 /*--------------------------------------------------------------------+
77 | Initialize EBC CONFIG
78 +-------------------------------------------------------------------*/
79 mtebc(xbcfg,
80 EBC_CFG_LE_UNLOCK | EBC_CFG_PTD_ENABLE |
81 EBC_CFG_RTC_64PERCLK | EBC_CFG_ATC_PREVIOUS |
82 EBC_CFG_DTC_PREVIOUS | EBC_CFG_CTC_PREVIOUS |
83 EBC_CFG_EMC_DEFAULT | EBC_CFG_PME_DISABLE |
84 EBC_CFG_PR_32);
85
86 /*--------------------------------------------------------------------+
87 | 1/2 MB FLASH. Initialize bank 0 with default values.
88 +-------------------------------------------------------------------*/
89 mtebc(pb0ap,
90 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) |
91 EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
92 EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
93 EBC_BXAP_WBF_ENCODE(1)| EBC_BXAP_TH_ENCODE(1) |
94 EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
95 EBC_BXAP_PEN_DISABLED);
96
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020097 mtebc(pb0cr, EBC_BXCR_BAS_ENCODE(CONFIG_SYS_FLASH_BASE) |
Stefan Roeseb79316f2005-08-15 12:31:23 +020098 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_8BIT);
99 /*--------------------------------------------------------------------+
100 | 8KB NVRAM/RTC. Initialize bank 1 with default values.
101 +-------------------------------------------------------------------*/
102 mtebc(pb1ap,
103 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(10) |
104 EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
105 EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
106 EBC_BXAP_WBF_ENCODE(1)| EBC_BXAP_TH_ENCODE(1) |
107 EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
108 EBC_BXAP_PEN_DISABLED);
109
110 mtebc(pb1cr, EBC_BXCR_BAS_ENCODE(0x48000000) |
111 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_8BIT);
112
113 /*--------------------------------------------------------------------+
114 | Compact Flash, uses 2 Chip Selects (2 & 6)
115 +-------------------------------------------------------------------*/
116 mtebc(pb2ap,
117 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) |
118 EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
119 EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
120 EBC_BXAP_WBF_ENCODE(0)| EBC_BXAP_TH_ENCODE(1) |
121 EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
122 EBC_BXAP_PEN_DISABLED);
123
124 mtebc(pb2cr, EBC_BXCR_BAS_ENCODE(0xF0000000) |
125 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_16BIT);
126
127 /*--------------------------------------------------------------------+
128 | KaRef Scan FPGA. Initialize bank 3 with default values.
129 +-------------------------------------------------------------------*/
130 mtebc(pb5ap,
131 EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
132 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
133 EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
134 EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
135 EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
136
137 mtebc(pb5cr, EBC_BXCR_BAS_ENCODE(0x48200000) |
138 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
139
140 /*--------------------------------------------------------------------+
141 | MAC A & B for Kamino. OFEM FPGA decodes the addresses
142 | Initialize bank 4 with default values.
143 +-------------------------------------------------------------------*/
144 mtebc(pb4ap,
145 EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
146 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
147 EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
148 EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
149 EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
150
151 mtebc(pb4cr, EBC_BXCR_BAS_ENCODE(0x48600000) |
152 EBC_BXCR_BS_2MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
153
154 /*--------------------------------------------------------------------+
155 | OFEM FPGA Initialize bank 5 with default values.
156 +-------------------------------------------------------------------*/
157 mtebc(pb3ap,
158 EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
159 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
160 EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
161 EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
162 EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
163
164
165 mtebc(pb3cr, EBC_BXCR_BAS_ENCODE(0x48400000) |
166 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
167
168
169 /*--------------------------------------------------------------------+
170 | Compact Flash, uses 2 Chip Selects (2 & 6)
171 +-------------------------------------------------------------------*/
172 mtebc(pb6ap,
173 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) |
174 EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
175 EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
176 EBC_BXAP_WBF_ENCODE(0)| EBC_BXAP_TH_ENCODE(1) |
177 EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
178 EBC_BXAP_PEN_DISABLED);
179
180 mtebc(pb6cr, EBC_BXCR_BAS_ENCODE(0xF0100000) |
181 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_16BIT);
182
183 /*--------------------------------------------------------------------+
184 | BME-32. Initialize bank 7 with default values.
185 +-------------------------------------------------------------------*/
186 mtebc(pb7ap,
187 EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
188 EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
189 EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
190 EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
191 EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
192
193 mtebc(pb7cr, EBC_BXCR_BAS_ENCODE(0x48500000) |
194 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
195
Stefan Roeseb79316f2005-08-15 12:31:23 +0200196 /*--------------------------------------------------------------------+
197 * Setup the interrupt controller polarities, triggers, etc.
198 +-------------------------------------------------------------------*/
Stefan Roese5de85142008-06-26 17:36:39 +0200199 /*
200 * Because of the interrupt handling rework to handle 440GX interrupts
201 * with the common code, we needed to change names of the UIC registers.
202 * Here the new relationship:
203 *
204 * U-Boot name 440GX name
205 * -----------------------
206 * UIC0 UICB0
207 * UIC1 UIC0
208 * UIC2 UIC1
209 * UIC3 UIC2
210 */
Stefan Roeseb79316f2005-08-15 12:31:23 +0200211 mtdcr (uic1sr, 0xffffffff); /* clear all */
212 mtdcr (uic1er, 0x00000000); /* disable all */
Stefan Roese5de85142008-06-26 17:36:39 +0200213 mtdcr (uic1cr, 0x00000000); /* all non- critical */
214 mtdcr (uic1pr, 0xfffffe03); /* polarity */
215 mtdcr (uic1tr, 0x01c00000); /* trigger edge vs level */
Stefan Roeseb79316f2005-08-15 12:31:23 +0200216 mtdcr (uic1vr, 0x00000001); /* int31 highest, base=0x000 */
217 mtdcr (uic1sr, 0xffffffff); /* clear all */
218
219 mtdcr (uic2sr, 0xffffffff); /* clear all */
220 mtdcr (uic2er, 0x00000000); /* disable all */
221 mtdcr (uic2cr, 0x00000000); /* all non-critical */
Stefan Roese5de85142008-06-26 17:36:39 +0200222 mtdcr (uic2pr, 0xffffc8ff); /* polarity */
223 mtdcr (uic2tr, 0x00ff0000); /* trigger edge vs level */
Stefan Roeseb79316f2005-08-15 12:31:23 +0200224 mtdcr (uic2vr, 0x00000001); /* int31 highest, base=0x000 */
225 mtdcr (uic2sr, 0xffffffff); /* clear all */
226
Stefan Roese5de85142008-06-26 17:36:39 +0200227 mtdcr (uic3sr, 0xffffffff); /* clear all */
228 mtdcr (uic3er, 0x00000000); /* disable all */
229 mtdcr (uic3cr, 0x00000000); /* all non-critical */
230 mtdcr (uic3pr, 0xffff83ff); /* polarity */
231 mtdcr (uic3tr, 0x00ff8c0f); /* trigger edge vs level */
232 mtdcr (uic3vr, 0x00000001); /* int31 highest, base=0x000 */
233 mtdcr (uic3sr, 0xffffffff); /* clear all */
234
235 mtdcr (uic0sr, 0xfc000000); /* clear all */
236 mtdcr (uic0er, 0x00000000); /* disable all */
237 mtdcr (uic0cr, 0x00000000); /* all non-critical */
238 mtdcr (uic0pr, 0xfc000000);
239 mtdcr (uic0tr, 0x00000000);
240 mtdcr (uic0vr, 0x00000001);
Stefan Roeseb79316f2005-08-15 12:31:23 +0200241
242 fpga_init();
243
244 return 0;
245}
246
247
248/*************************************************************************
249 * checkboard
250 *
251 * Dump pertinent info to the console
Stefan Roeseb79316f2005-08-15 12:31:23 +0200252 ************************************************************************/
253int checkboard (void)
254{
255 sys_info_t sysinfo;
256 unsigned char brd_rev, brd_id;
257 unsigned short sernum;
Wolfgang Denk2b792af2005-09-24 21:54:50 +0200258 unsigned char scan_rev, scan_id, ofem_rev=0, ofem_id=0;
Stefan Roeseb79316f2005-08-15 12:31:23 +0200259 unsigned char ofem_brd_rev, ofem_brd_id;
260 KAREF_FPGA_REGS_ST *karef_ps;
261 OFEM_FPGA_REGS_ST *ofem_ps;
262
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200263 karef_ps = (KAREF_FPGA_REGS_ST *)CONFIG_SYS_KAREF_FPGA_BASE;
264 ofem_ps = (OFEM_FPGA_REGS_ST *)CONFIG_SYS_OFEM_FPGA_BASE;
Stefan Roeseb79316f2005-08-15 12:31:23 +0200265
266 scan_id = (unsigned char)((karef_ps->revision_ul &
267 SAND_HAL_KA_SC_SCAN_REVISION_IDENTIFICATION_MASK)
268 >> SAND_HAL_KA_SC_SCAN_REVISION_IDENTIFICATION_SHIFT);
269
270 scan_rev = (unsigned char)((karef_ps->revision_ul & SAND_HAL_KA_SC_SCAN_REVISION_REVISION_MASK)
271 >> SAND_HAL_KA_SC_SCAN_REVISION_REVISION_SHIFT);
272
273 brd_rev = (unsigned char)((karef_ps->boardinfo_ul & SAND_HAL_KA_SC_SCAN_BRD_INFO_BRD_REV_MASK)
274 >> SAND_HAL_KA_SC_SCAN_BRD_INFO_BRD_REV_SHIFT);
275
276 brd_id = (unsigned char)((karef_ps->boardinfo_ul & SAND_HAL_KA_SC_SCAN_BRD_INFO_BRD_ID_MASK)
277 >> SAND_HAL_KA_SC_SCAN_BRD_INFO_BRD_ID_SHIFT);
278
279 ofem_brd_id = (unsigned char)((karef_ps->boardinfo_ul & SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_ID_MASK)
280 >> SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_ID_SHIFT);
281
282 ofem_brd_rev = (unsigned char)((karef_ps->boardinfo_ul & SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_REV_MASK)
283 >> SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_REV_SHIFT);
284
285 if (0xF != ofem_brd_id) {
286 ofem_id = (unsigned char)((ofem_ps->revision_ul &
287 SAND_HAL_KA_OF_OFEM_REVISION_IDENTIFICATION_MASK)
288 >> SAND_HAL_KA_OF_OFEM_REVISION_IDENTIFICATION_SHIFT);
289
290 ofem_rev = (unsigned char)((ofem_ps->revision_ul &
291 SAND_HAL_KA_OF_OFEM_REVISION_REVISION_MASK)
292 >> SAND_HAL_KA_OF_OFEM_REVISION_REVISION_SHIFT);
293 }
294
295 get_sys_info (&sysinfo);
296
297 sernum = sbcommon_get_serial_number();
298
299 printf ("Board: Sandburst Corporation Kamino Reference Design "
300 "Serial Number: %d\n", sernum);
301 printf ("%s\n", KAREF_U_BOOT_REL_STR);
302
Peter Tyser561858e2008-11-03 09:30:59 -0600303 printf ("Built %s %s by %s\n", U_BOOT_DATE, U_BOOT_TIME, BUILDUSER);
Stefan Roeseb79316f2005-08-15 12:31:23 +0200304 if (sbcommon_get_master()) {
305 printf("Slot 0 - Master\nSlave board");
306 if (sbcommon_secondary_present())
307 printf(" present\n");
308 else
309 printf(" not detected\n");
310 } else {
311 printf("Slot 1 - Slave\n\n");
312 }
313
314 printf ("ScanFPGA ID:\t0x%02X\tRev: 0x%02X\n", scan_id, scan_rev);
315 printf ("Board Rev:\t0x%02X\tID: 0x%02X\n", brd_rev, brd_id);
316 if(0xF != ofem_brd_id) {
317 printf("OFemFPGA ID:\t0x%02X\tRev: 0x%02X\n", ofem_id, ofem_rev);
318 printf("OFEM Board Rev:\t0x%02X\tID: 0x%02X\n", ofem_brd_id, ofem_brd_rev);
319 }
320
Stefan Roeseb79316f2005-08-15 12:31:23 +0200321 /* Fix the ack in the bme 32 */
322 udelay(5000);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200323 out32(CONFIG_SYS_BME32_BASE + 0x0000000C, 0x00000001);
Stefan Roeseb79316f2005-08-15 12:31:23 +0200324 asm("eieio");
325
326
327 return (0);
328}
329
Stefan Roeseb79316f2005-08-15 12:31:23 +0200330/*************************************************************************
331 * misc_init_f
332 *
333 * Initialize I2C bus one to gain access to the fans
Stefan Roeseb79316f2005-08-15 12:31:23 +0200334 ************************************************************************/
335int misc_init_f (void)
336{
337 /* Turn on i2c bus 1 */
338 puts ("I2C1: ");
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200339 i2c1_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
Stefan Roeseb79316f2005-08-15 12:31:23 +0200340 puts ("ready\n");
341
342 /* Turn on fans 3 & 4 */
343 sbcommon_fans();
344
345 return (0);
346}
Wolfgang Denk3d078ce2005-08-15 16:03:56 +0200347
Stefan Roeseb79316f2005-08-15 12:31:23 +0200348/*************************************************************************
349 * misc_init_r
350 *
351 * Do nothing.
Stefan Roeseb79316f2005-08-15 12:31:23 +0200352 ************************************************************************/
353int misc_init_r (void)
354{
355 unsigned short sernum;
356 char envstr[255];
Mike Frysingerd8d21e62009-02-16 18:03:14 -0500357 uchar enetaddr[6];
Stefan Roeseb79316f2005-08-15 12:31:23 +0200358 KAREF_FPGA_REGS_ST *karef_ps;
359 OFEM_FPGA_REGS_ST *ofem_ps;
Stefan Roeseb79316f2005-08-15 12:31:23 +0200360
361 if(NULL != getenv("secondserial")) {
362 puts("secondserial is set, switching to second serial port\n");
363 setenv("stderr", "serial1");
364 setenv("stdout", "serial1");
365 setenv("stdin", "serial1");
366 }
367
368 setenv("ubrelver", KAREF_U_BOOT_REL_STR);
369
370 memset(envstr, 0, 255);
Peter Tyser561858e2008-11-03 09:30:59 -0600371 sprintf (envstr, "Built %s %s by %s",
372 U_BOOT_DATE, U_BOOT_TIME, BUILDUSER);
Stefan Roeseb79316f2005-08-15 12:31:23 +0200373 setenv("bldstr", envstr);
374 saveenv();
375
376 if( getenv("autorecover")) {
377 setenv("autorecover", NULL);
378 saveenv();
379 sernum = sbcommon_get_serial_number();
380
381 printf("\nSetting up environment for automatic filesystem recovery\n");
382 /*
383 * Setup default bootargs
384 */
385 memset(envstr, 0, 255);
386
387 sprintf(envstr, "console=ttyS0,9600 root=/dev/ram0 "
388 "rw ip=10.100.70.%d:::255.255.0.0:karef%d:eth0:none idebus=33",
389 sernum, sernum);
390 setenv("bootargs", envstr);
391
392 /*
393 * Setup Default boot command
394 */
395 setenv("bootcmd", "fatload ide 0 8000000 uimage.karef;"
396 "fatload ide 0 8100000 pramdisk;"
397 "bootm 8000000 8100000");
398
399 printf("Done. Please type allow the system to continue to boot\n");
400 }
401
402 if( getenv("fakeled")) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200403 karef_ps = (KAREF_FPGA_REGS_ST *)CONFIG_SYS_KAREF_FPGA_BASE;
404 ofem_ps = (OFEM_FPGA_REGS_ST *)CONFIG_SYS_OFEM_FPGA_BASE;
Stefan Roeseb79316f2005-08-15 12:31:23 +0200405 ofem_ps->control_ul &= ~SAND_HAL_KA_SC_SCAN_CNTL_FAULT_LED_MASK;
406 karef_ps->control_ul &= ~SAND_HAL_KA_OF_OFEM_CNTL_FAULT_LED_MASK;
407 setenv("bootdelay", "-1");
408 saveenv();
409 printf("fakeled is set. use 'setenv fakeled ; setenv bootdelay 5 ; saveenv' to recover\n");
410 }
411
Mike Frysingerd8d21e62009-02-16 18:03:14 -0500412#ifdef CONFIG_HAS_ETH0
413 if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
414 board_get_enetaddr(0, enetaddr);
415 eth_putenv_enetaddr("ethaddr", enetaddr);
416 }
417#endif
418
419#ifdef CONFIG_HAS_ETH1
420 if (!eth_getenv_enetaddr("eth1addr", enetaddr)) {
421 board_get_enetaddr(1, enetaddr);
422 eth_putenv_enetaddr("eth1addr", enetaddr);
423 }
424#endif
425
426#ifdef CONFIG_HAS_ETH2
427 if (!eth_getenv_enetaddr("eth2addr", enetaddr)) {
428 board_get_enetaddr(2, enetaddr);
429 eth_putenv_enetaddr("eth2addr", enetaddr);
430 }
431#endif
432
433#ifdef CONFIG_HAS_ETH3
434 if (!eth_getenv_enetaddr("eth3addr", enetaddr)) {
435 board_get_enetaddr(3, enetaddr);
436 eth_putenv_enetaddr("eth3addr", enetaddr);
437 }
438#endif
439
Stefan Roeseb79316f2005-08-15 12:31:23 +0200440 return (0);
441}
442
Stefan Roeseb79316f2005-08-15 12:31:23 +0200443/*************************************************************************
444 * ide_set_reset
Stefan Roeseb79316f2005-08-15 12:31:23 +0200445 ************************************************************************/
446#ifdef CONFIG_IDE_RESET
447void ide_set_reset(int on)
448{
449 KAREF_FPGA_REGS_ST *karef_ps;
450 /* TODO: ide reset */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200451 karef_ps = (KAREF_FPGA_REGS_ST *)CONFIG_SYS_KAREF_FPGA_BASE;
Stefan Roeseb79316f2005-08-15 12:31:23 +0200452
453 if (on) {
454 karef_ps->reset_ul &= ~SAND_HAL_KA_SC_SCAN_RESET_CF_RESET_N_MASK;
455 } else {
456 karef_ps->reset_ul |= SAND_HAL_KA_SC_SCAN_RESET_CF_RESET_N_MASK;
457 }
458}
459#endif /* CONFIG_IDE_RESET */
460
461/*************************************************************************
462 * fpga_init
Stefan Roeseb79316f2005-08-15 12:31:23 +0200463 ************************************************************************/
464void fpga_init(void)
465{
466 KAREF_FPGA_REGS_ST *karef_ps;
467 OFEM_FPGA_REGS_ST *ofem_ps;
468 unsigned char ofem_id;
469 unsigned long tmp;
470
471 /* Ensure we have power all around */
472 udelay(500);
473
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200474 karef_ps = (KAREF_FPGA_REGS_ST *)CONFIG_SYS_KAREF_FPGA_BASE;
Stefan Roeseb79316f2005-08-15 12:31:23 +0200475 tmp =
476 SAND_HAL_KA_SC_SCAN_RESET_CF_RESET_N_MASK |
477 SAND_HAL_KA_SC_SCAN_RESET_BME_RESET_N_MASK |
478 SAND_HAL_KA_SC_SCAN_RESET_KA_RESET_N_MASK |
479 SAND_HAL_KA_SC_SCAN_RESET_SLAVE_RESET_N_MASK |
480 SAND_HAL_KA_SC_SCAN_RESET_OFEM_RESET_N_MASK |
481 SAND_HAL_KA_SC_SCAN_RESET_IFE_A_RESET_N_MASK |
482 SAND_HAL_KA_SC_SCAN_RESET_I2C_MUX1_RESET_N_MASK |
483 SAND_HAL_KA_SC_SCAN_RESET_PHY0_RESET_N_MASK |
484 SAND_HAL_KA_SC_SCAN_RESET_PHY1_RESET_N_MASK;
485
486 karef_ps->reset_ul = tmp;
487
488 /*
489 * Wait a bit to allow the ofem fpga to get its brains
490 */
491 udelay(5000);
492
493 /*
494 * Check to see if the ofem is there
495 */
496 ofem_id = (unsigned char)((karef_ps->boardinfo_ul & SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_ID_MASK)
497 >> SAND_HAL_KA_SC_SCAN_BRD_INFO_FEM_ID_SHIFT);
498 if(0xF != ofem_id) {
499 tmp =
500 SAND_HAL_KA_OF_OFEM_RESET_I2C_MUX0_RESET_N_MASK |
501 SAND_HAL_KA_OF_OFEM_RESET_LOCH0_RESET_N_MASK |
502 SAND_HAL_KA_OF_OFEM_RESET_MAC0_RESET_N_MASK;
503
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200504 ofem_ps = (OFEM_FPGA_REGS_ST *)CONFIG_SYS_OFEM_FPGA_BASE;
Stefan Roeseb79316f2005-08-15 12:31:23 +0200505 ofem_ps->reset_ul = tmp;
506
507 ofem_ps->control_ul |= 1 < SAND_HAL_KA_OF_OFEM_CNTL_FAULT_LED_SHIFT;
508 }
509
510 karef_ps->control_ul |= 1 << SAND_HAL_KA_SC_SCAN_CNTL_FAULT_LED_SHIFT;
511
512 asm("eieio");
513
514 return;
515}
516
Stefan Roeseb79316f2005-08-15 12:31:23 +0200517int karefSetupVars(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
518{
519 unsigned short sernum;
520 char envstr[255];
521
522 sernum = sbcommon_get_serial_number();
523
524 memset(envstr, 0, 255);
525 /*
526 * Setup our ip address
527 */
528 sprintf(envstr, "10.100.70.%d", sernum);
529
530 setenv("ipaddr", envstr);
531 /*
532 * Setup the host ip address
533 */
534 setenv("serverip", "10.100.17.10");
535
536 /*
537 * Setup default bootargs
538 */
539 memset(envstr, 0, 255);
540
541 sprintf(envstr, "console=ttyS0,9600 root=/dev/nfs "
542 "rw nfsroot=10.100.17.10:/home/metrobox/mbc70.%d "
543 "nfsaddrs=10.100.70.%d:10.100.17.10:10.100.1.1:"
544 "255.255.0.0:karef%d.sandburst.com:eth0:none idebus=33",
545 sernum, sernum, sernum);
546
547 setenv("bootargs_nfs", envstr);
548 setenv("bootargs", envstr);
549
550 /*
551 * Setup CF bootargs
552 */
553 memset(envstr, 0, 255);
554
555 sprintf(envstr, "console=ttyS0,9600 root=/dev/hda2 "
556 "rw ip=10.100.70.%d:::255.255.0.0:karef%d:eth0:none idebus=33",
557 sernum, sernum);
558
559 setenv("bootargs_cf", envstr);
560
561 /*
562 * Setup Default boot command
563 */
564 setenv("bootcmd_tftp", "tftp 8000000 uImage.karef;bootm 8000000");
565 setenv("bootcmd", "tftp 8000000 uImage.karef;bootm 8000000");
566
567 /*
568 * Setup compact flash boot command
569 */
570 setenv("bootcmd_cf", "fatload ide 0 8000000 uimage.karef;bootm 8000000");
571
572 saveenv();
573
574 return(1);
575}
576
Stefan Roeseb79316f2005-08-15 12:31:23 +0200577int karefRecover(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
578{
579 unsigned short sernum;
580 char envstr[255];
581
582 sernum = sbcommon_get_serial_number();
583
584 printf("\nSetting up environment for filesystem recovery\n");
585 /*
586 * Setup default bootargs
587 */
588 memset(envstr, 0, 255);
589
590 sprintf(envstr, "console=ttyS0,9600 root=/dev/ram0 "
591 "rw ip=10.100.70.%d:::255.255.0.0:karef%d:eth0:none",
592 sernum, sernum);
593 setenv("bootargs", envstr);
594
595 /*
596 * Setup Default boot command
597 */
598
599 setenv("bootcmd", "fatload ide 0 8000000 uimage.karef;"
600 "fatload ide 0 8100000 pramdisk;"
601 "bootm 8000000 8100000");
602
603 printf("Done. Please type boot<cr>.\nWhen the kernel has booted"
604 " please type fsrecover.sh<cr>\n");
605
606 return(1);
607}
608
Stefan Roeseb79316f2005-08-15 12:31:23 +0200609U_BOOT_CMD(kasetup, 1, 1, karefSetupVars,
Peter Tyser2fb26042009-01-27 18:03:12 -0600610 "Set environment to factory defaults", NULL);
Stefan Roeseb79316f2005-08-15 12:31:23 +0200611
612U_BOOT_CMD(karecover, 1, 1, karefRecover,
Peter Tyser2fb26042009-01-27 18:03:12 -0600613 "Set environment to allow for fs recovery", NULL);