metrobox.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. /*
  2. * Copyright (c) 2005
  3. * Travis B. Sawyer, Sandburst Corporation, tsawyer@sandburst.com
  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. #include <config.h>
  24. #include <common.h>
  25. #include <command.h>
  26. #include "metrobox.h"
  27. #include "metrobox_version.h"
  28. #include <asm/processor.h>
  29. #include <asm/io.h>
  30. #include <spd_sdram.h>
  31. #include <i2c.h>
  32. #include "../common/ppc440gx_i2c.h"
  33. #include "../common/sb_common.h"
  34. void fpga_init (void);
  35. METROBOX_BOARD_ID_ST board_id_as[] =
  36. { {"Undefined"}, /* Not specified */
  37. {"2x10Gb"}, /* 2 ports, 10 GbE */
  38. {"20x1Gb"}, /* 20 ports, 1 GbE */
  39. {"Reserved"}, /* Reserved for future use */
  40. };
  41. /*************************************************************************
  42. * board_early_init_f
  43. *
  44. * Setup chip selects, initialize the Opto-FPGA, initialize
  45. * interrupt polarity and triggers.
  46. ************************************************************************/
  47. int board_early_init_f (void)
  48. {
  49. ppc440_gpio_regs_t *gpio_regs;
  50. /* Enable GPIO interrupts */
  51. mtsdr(sdr_pfc0, 0x00103E00);
  52. /* Setup access for LEDs, and system topology info */
  53. gpio_regs = (ppc440_gpio_regs_t *)CFG_GPIO_BASE;
  54. gpio_regs->open_drain = SBCOMMON_GPIO_SYS_LEDS;
  55. gpio_regs->tri_state = SBCOMMON_GPIO_DBGLEDS;
  56. /* Turn on all the leds for now */
  57. gpio_regs->out = SBCOMMON_GPIO_LEDS;
  58. /*--------------------------------------------------------------------+
  59. | Initialize EBC CONFIG
  60. +-------------------------------------------------------------------*/
  61. mtebc(xbcfg,
  62. EBC_CFG_LE_UNLOCK | EBC_CFG_PTD_ENABLE |
  63. EBC_CFG_RTC_64PERCLK | EBC_CFG_ATC_PREVIOUS |
  64. EBC_CFG_DTC_PREVIOUS | EBC_CFG_CTC_PREVIOUS |
  65. EBC_CFG_EMC_DEFAULT | EBC_CFG_PME_DISABLE |
  66. EBC_CFG_PR_32);
  67. /*--------------------------------------------------------------------+
  68. | 1/2 MB FLASH. Initialize bank 0 with default values.
  69. +-------------------------------------------------------------------*/
  70. mtebc(pb0ap,
  71. EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) |
  72. EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
  73. EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
  74. EBC_BXAP_WBF_ENCODE(1)| EBC_BXAP_TH_ENCODE(1) |
  75. EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
  76. EBC_BXAP_PEN_DISABLED);
  77. mtebc(pb0cr, EBC_BXCR_BAS_ENCODE(CFG_FLASH_BASE) |
  78. EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_8BIT);
  79. /*--------------------------------------------------------------------+
  80. | 8KB NVRAM/RTC. Initialize bank 1 with default values.
  81. +-------------------------------------------------------------------*/
  82. mtebc(pb1ap,
  83. EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(10) |
  84. EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
  85. EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
  86. EBC_BXAP_WBF_ENCODE(1)| EBC_BXAP_TH_ENCODE(1) |
  87. EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
  88. EBC_BXAP_PEN_DISABLED);
  89. mtebc(pb1cr, EBC_BXCR_BAS_ENCODE(0x48000000) |
  90. EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_8BIT);
  91. /*--------------------------------------------------------------------+
  92. | Compact Flash, uses 2 Chip Selects (2 & 6)
  93. +-------------------------------------------------------------------*/
  94. mtebc(pb2ap,
  95. EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) |
  96. EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
  97. EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
  98. EBC_BXAP_WBF_ENCODE(0)| EBC_BXAP_TH_ENCODE(1) |
  99. EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
  100. EBC_BXAP_PEN_DISABLED);
  101. mtebc(pb2cr, EBC_BXCR_BAS_ENCODE(0xF0000000) |
  102. EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_16BIT);
  103. /*--------------------------------------------------------------------+
  104. | OPTO & OFEM FPGA. Initialize bank 3 with default values.
  105. +-------------------------------------------------------------------*/
  106. mtebc(pb3ap,
  107. EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
  108. EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
  109. EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
  110. EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
  111. EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
  112. mtebc(pb3cr, EBC_BXCR_BAS_ENCODE(0x48200000) |
  113. EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
  114. /*--------------------------------------------------------------------+
  115. | MAC A for metrobox
  116. | MAC A & B for Kamino. OFEM FPGA decodes the addresses
  117. | Initialize bank 4 with default values.
  118. +-------------------------------------------------------------------*/
  119. mtebc(pb4ap,
  120. EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
  121. EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
  122. EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
  123. EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
  124. EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
  125. mtebc(pb4cr, EBC_BXCR_BAS_ENCODE(0x48600000) |
  126. EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
  127. /*--------------------------------------------------------------------+
  128. | Metrobox MAC B Initialize bank 5 with default values.
  129. | KA REF FPGA Initialize bank 5 with default values.
  130. +-------------------------------------------------------------------*/
  131. mtebc(pb5ap,
  132. EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
  133. EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
  134. EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
  135. EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
  136. EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
  137. mtebc(pb5cr, EBC_BXCR_BAS_ENCODE(0x48700000) |
  138. EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
  139. /*--------------------------------------------------------------------+
  140. | Compact Flash, uses 2 Chip Selects (2 & 6)
  141. +-------------------------------------------------------------------*/
  142. mtebc(pb6ap,
  143. EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(8) |
  144. EBC_BXAP_BCE_DISABLE | EBC_BXAP_CSN_ENCODE(1) |
  145. EBC_BXAP_OEN_ENCODE(1)| EBC_BXAP_WBN_ENCODE(1) |
  146. EBC_BXAP_WBF_ENCODE(0)| EBC_BXAP_TH_ENCODE(1) |
  147. EBC_BXAP_RE_DISABLED | EBC_BXAP_BEM_WRITEONLY |
  148. EBC_BXAP_PEN_DISABLED);
  149. mtebc(pb6cr, EBC_BXCR_BAS_ENCODE(0xF0100000) |
  150. EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_16BIT);
  151. /*--------------------------------------------------------------------+
  152. | BME-32. Initialize bank 7 with default values.
  153. +-------------------------------------------------------------------*/
  154. mtebc(pb7ap,
  155. EBC_BXAP_RE_ENABLED | EBC_BXAP_SOR_NONDELAYED |
  156. EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(3) |
  157. EBC_BXAP_TH_ENCODE(1) | EBC_BXAP_WBF_ENCODE(0) |
  158. EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_PEN_DISABLED |
  159. EBC_BXAP_OEN_ENCODE(1) | EBC_BXAP_BEM_RW);
  160. mtebc(pb7cr, EBC_BXCR_BAS_ENCODE(0x48500000) |
  161. EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
  162. /*--------------------------------------------------------------------+
  163. * Setup the interrupt controller polarities, triggers, etc.
  164. +-------------------------------------------------------------------*/
  165. mtdcr (uic0sr, 0xffffffff); /* clear all */
  166. mtdcr (uic0er, 0x00000000); /* disable all */
  167. mtdcr (uic0cr, 0x00000000); /* all non- critical */
  168. mtdcr (uic0pr, 0xfffffe03); /* polarity */
  169. mtdcr (uic0tr, 0x01c00000); /* trigger edge vs level */
  170. mtdcr (uic0vr, 0x00000001); /* int31 highest, base=0x000 */
  171. mtdcr (uic0sr, 0xffffffff); /* clear all */
  172. mtdcr (uic1sr, 0xffffffff); /* clear all */
  173. mtdcr (uic1er, 0x00000000); /* disable all */
  174. mtdcr (uic1cr, 0x00000000); /* all non-critical */
  175. mtdcr (uic1pr, 0xffffc8ff); /* polarity */
  176. mtdcr (uic1tr, 0x00ff0000); /* trigger edge vs level */
  177. mtdcr (uic1vr, 0x00000001); /* int31 highest, base=0x000 */
  178. mtdcr (uic1sr, 0xffffffff); /* clear all */
  179. mtdcr (uic2sr, 0xffffffff); /* clear all */
  180. mtdcr (uic2er, 0x00000000); /* disable all */
  181. mtdcr (uic2cr, 0x00000000); /* all non-critical */
  182. mtdcr (uic2pr, 0xffff83ff); /* polarity */
  183. mtdcr (uic2tr, 0x00ff8c0f); /* trigger edge vs level */
  184. mtdcr (uic2vr, 0x00000001); /* int31 highest, base=0x000 */
  185. mtdcr (uic2sr, 0xffffffff); /* clear all */
  186. mtdcr (uicb0sr, 0xfc000000); /* clear all */
  187. mtdcr (uicb0er, 0x00000000); /* disable all */
  188. mtdcr (uicb0cr, 0x00000000); /* all non-critical */
  189. mtdcr (uicb0pr, 0xfc000000);
  190. mtdcr (uicb0tr, 0x00000000);
  191. mtdcr (uicb0vr, 0x00000001);
  192. fpga_init();
  193. return 0;
  194. }
  195. /*************************************************************************
  196. * checkboard
  197. *
  198. * Dump pertinent info to the console
  199. ************************************************************************/
  200. int checkboard (void)
  201. {
  202. sys_info_t sysinfo;
  203. unsigned char brd_rev, brd_id;
  204. unsigned short sernum;
  205. unsigned char opto_rev, opto_id;
  206. OPTO_FPGA_REGS_ST *opto_ps;
  207. opto_ps = (OPTO_FPGA_REGS_ST *)CFG_FPGA_BASE;
  208. opto_rev = (unsigned char)((opto_ps->revision_ul &
  209. SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_MASK)
  210. >> SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_SHIFT);
  211. opto_id = (unsigned char)((opto_ps->revision_ul &
  212. SAND_HAL_XC_XCVR_CNTL_REVISION_IDENTIFICATION_MASK)
  213. >> SAND_HAL_XC_XCVR_CNTL_REVISION_IDENTIFICATION_SHIFT);
  214. brd_rev = (unsigned char)((opto_ps->boardinfo_ul &
  215. SAND_HAL_XC_XCVR_CNTL_BRD_INFO_BRD_REV_MASK)
  216. >> SAND_HAL_XC_XCVR_CNTL_BRD_INFO_BRD_REV_SHIFT);
  217. brd_id = (unsigned char)((opto_ps->boardinfo_ul &
  218. SAND_HAL_XC_XCVR_CNTL_BRD_INFO_BRD_ID_MASK)
  219. >> SAND_HAL_XC_XCVR_CNTL_BRD_INFO_BRD_ID_SHIFT);
  220. get_sys_info (&sysinfo);
  221. sernum = sbcommon_get_serial_number();
  222. printf ("Board: Sandburst Corporation MetroBox Serial Number: %d\n", sernum);
  223. printf ("%s\n", METROBOX_U_BOOT_REL_STR);
  224. printf ("Built %s %s by %s\n", __DATE__, __TIME__, BUILDUSER);
  225. if (sbcommon_get_master()) {
  226. printf("Slot 0 - Master\nSlave board");
  227. if (sbcommon_secondary_present())
  228. printf(" present\n");
  229. else
  230. printf(" not detected\n");
  231. } else {
  232. printf("Slot 1 - Slave\n\n");
  233. }
  234. printf ("OptoFPGA ID:\t0x%02X\tRev: 0x%02X\n", opto_id, opto_rev);
  235. printf ("Board Rev:\t0x%02X\tID: %s\n", brd_rev, (char *)board_id_as[brd_id]);
  236. /* Fix the ack in the bme 32 */
  237. udelay(5000);
  238. out32(CFG_BME32_BASE + 0x0000000C, 0x00000001);
  239. asm("eieio");
  240. return (0);
  241. }
  242. /*************************************************************************
  243. * misc_init_f
  244. *
  245. * Initialize I2C bus one to gain access to the fans
  246. ************************************************************************/
  247. int misc_init_f (void)
  248. {
  249. /* Turn on i2c bus 1 */
  250. puts ("I2C1: ");
  251. i2c1_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  252. puts ("ready\n");
  253. /* Turn on fans */
  254. sbcommon_fans();
  255. return (0);
  256. }
  257. /*************************************************************************
  258. * misc_init_r
  259. *
  260. * Do nothing.
  261. ************************************************************************/
  262. int misc_init_r (void)
  263. {
  264. unsigned short sernum;
  265. char envstr[255];
  266. unsigned char opto_rev;
  267. OPTO_FPGA_REGS_ST *opto_ps;
  268. opto_ps = (OPTO_FPGA_REGS_ST *)CFG_FPGA_BASE;
  269. if(NULL != getenv("secondserial")) {
  270. puts("secondserial is set, switching to second serial port\n");
  271. setenv("stderr", "serial1");
  272. setenv("stdout", "serial1");
  273. setenv("stdin", "serial1");
  274. }
  275. setenv("ubrelver", METROBOX_U_BOOT_REL_STR);
  276. memset(envstr, 0, 255);
  277. sprintf (envstr, "Built %s %s by %s", __DATE__, __TIME__, BUILDUSER);
  278. setenv("bldstr", envstr);
  279. saveenv();
  280. if( getenv("autorecover")) {
  281. setenv("autorecover", NULL);
  282. saveenv();
  283. sernum = sbcommon_get_serial_number();
  284. printf("\nSetting up environment for automatic filesystem recovery\n");
  285. /*
  286. * Setup default bootargs
  287. */
  288. memset(envstr, 0, 255);
  289. sprintf(envstr, "console=ttyS0,9600 root=/dev/ram0 "
  290. "rw ip=10.100.60.%d:::255.255.0.0:metrobox%d:eth0:none idebus=33",
  291. sernum, sernum);
  292. setenv("bootargs", envstr);
  293. /*
  294. * Setup Default boot command
  295. */
  296. setenv("bootcmd", "fatload ide 0 8000000 pimage.metrobox;"
  297. "fatload ide 0 8100000 pramdisk;"
  298. "bootm 8000000 8100000");
  299. printf("Done. Please type allow the system to continue to boot\n");
  300. }
  301. if( getenv("fakeled")) {
  302. setenv("bootdelay", "-1");
  303. saveenv();
  304. printf("fakeled is set. use 'setenv fakeled ; setenv bootdelay 5 ; saveenv' to recover\n");
  305. opto_rev = (unsigned char)((opto_ps->revision_ul &
  306. SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_MASK)
  307. >> SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_SHIFT);
  308. if(0x12 <= opto_rev) {
  309. opto_ps->control_ul &= ~ SAND_HAL_XC_XCVR_CNTL_CNTL_ERROR_LED_MASK;
  310. }
  311. }
  312. return (0);
  313. }
  314. /*************************************************************************
  315. * ide_set_reset
  316. ************************************************************************/
  317. #ifdef CONFIG_IDE_RESET
  318. void ide_set_reset(int on)
  319. {
  320. OPTO_FPGA_REGS_ST *opto_ps;
  321. opto_ps = (OPTO_FPGA_REGS_ST *)CFG_FPGA_BASE;
  322. if (on) { /* assert RESET */
  323. opto_ps->reset_ul &= ~SAND_HAL_XC_XCVR_CNTL_RESET_CF_RESET_N_MASK;
  324. } else { /* release RESET */
  325. opto_ps->reset_ul |= SAND_HAL_XC_XCVR_CNTL_RESET_CF_RESET_N_MASK;
  326. }
  327. }
  328. #endif /* CONFIG_IDE_RESET */
  329. /*************************************************************************
  330. * fpga_init
  331. ************************************************************************/
  332. void fpga_init(void)
  333. {
  334. OPTO_FPGA_REGS_ST *opto_ps;
  335. unsigned char opto_rev;
  336. unsigned long tmp;
  337. /* Ensure we have power all around */
  338. udelay(500);
  339. /*
  340. * Take appropriate hw bits out of reset
  341. */
  342. opto_ps = (OPTO_FPGA_REGS_ST *)CFG_FPGA_BASE;
  343. tmp =
  344. SAND_HAL_XC_XCVR_CNTL_RESET_MAC1_RESET_N_MASK |
  345. SAND_HAL_XC_XCVR_CNTL_RESET_MAC0_RESET_N_MASK |
  346. SAND_HAL_XC_XCVR_CNTL_RESET_BME_RESET_N_MASK |
  347. SAND_HAL_XC_XCVR_CNTL_RESET_ACE_RESET_N_MASK |
  348. SAND_HAL_XC_XCVR_CNTL_RESET_CF_RESET_N_MASK |
  349. SAND_HAL_XC_XCVR_CNTL_RESET_QE_A_RESET_N_MASK |
  350. SAND_HAL_XC_XCVR_CNTL_RESET_IFE_A_RESET_N_MASK |
  351. SAND_HAL_XC_XCVR_CNTL_RESET_EFE_A_RESET_N_MASK |
  352. SAND_HAL_XC_XCVR_CNTL_RESET_QE_B_RESET_N_MASK |
  353. SAND_HAL_XC_XCVR_CNTL_RESET_IFE_B_RESET_N_MASK |
  354. SAND_HAL_XC_XCVR_CNTL_RESET_EFE_B_RESET_N_MASK |
  355. SAND_HAL_XC_XCVR_CNTL_RESET_LOCK1_RESET_N_MASK |
  356. SAND_HAL_XC_XCVR_CNTL_RESET_LOCK0_RESET_N_MASK |
  357. SAND_HAL_XC_XCVR_CNTL_RESET_I2C_MUX1_RESET_N_MASK |
  358. SAND_HAL_XC_XCVR_CNTL_RESET_I2C_MUX0_RESET_N_MASK |
  359. SAND_HAL_XC_XCVR_CNTL_RESET_PHY0_RESET_N_MASK |
  360. SAND_HAL_XC_XCVR_CNTL_RESET_PHY1_RESET_N_MASK |
  361. SAND_HAL_XC_XCVR_CNTL_RESET_SLAVE_RESET_N_MASK;
  362. opto_ps->reset_ul = tmp;
  363. /*
  364. * Turn on the 'Slow Blink' for the System Error Led.
  365. * Ensure FPGA rev is up to at least rev 0x12
  366. */
  367. opto_rev = (unsigned char)((opto_ps->revision_ul &
  368. SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_MASK)
  369. >> SAND_HAL_XC_XCVR_CNTL_REVISION_REVISION_SHIFT);
  370. if(0x12 <= opto_rev) {
  371. opto_ps->control_ul |= 1 << SAND_HAL_XC_XCVR_CNTL_CNTL_ERROR_LED_SHIFT;
  372. }
  373. asm("eieio");
  374. return;
  375. }
  376. int metroboxSetupVars(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  377. {
  378. unsigned short sernum;
  379. char envstr[255];
  380. sernum = sbcommon_get_serial_number();
  381. memset(envstr, 0, 255);
  382. /*
  383. * Setup our ip address
  384. */
  385. sprintf(envstr, "10.100.60.%d", sernum);
  386. setenv("ipaddr", envstr);
  387. /*
  388. * Setup the host ip address
  389. */
  390. setenv("serverip", "10.100.17.10");
  391. /*
  392. * Setup default bootargs
  393. */
  394. memset(envstr, 0, 255);
  395. sprintf(envstr, "console=ttyS0,9600 root=/dev/nfs "
  396. "rw nfsroot=10.100.17.10:/home/metrobox/mbc%d "
  397. "nfsaddrs=10.100.60.%d:10.100.17.10:10.100.1.1"
  398. ":255.255.0.0:metrobox%d.sandburst.com:eth0:none idebus=33",
  399. sernum, sernum, sernum);
  400. setenv("bootargs_nfs", envstr);
  401. setenv("bootargs", envstr);
  402. /*
  403. * Setup CF bootargs
  404. */
  405. memset(envstr, 0, 255);
  406. sprintf(envstr, "console=ttyS0,9600 root=/dev/hda2 "
  407. "rw ip=10.100.60.%d:::255.255.0.0:metrobox%d:eth0:none idebus=33",
  408. sernum, sernum);
  409. setenv("bootargs_cf", envstr);
  410. /*
  411. * Setup Default boot command
  412. */
  413. setenv("bootcmd_tftp", "tftp 8000000 pImage.metrobox;bootm 8000000");
  414. setenv("bootcmd", "tftp 8000000 pImage.metrobox;bootm 8000000");
  415. /*
  416. * Setup compact flash boot command
  417. */
  418. setenv("bootcmd_cf", "fatload ide 0 8000000 pimage.metrobox;bootm 8000000");
  419. saveenv();
  420. return(1);
  421. }
  422. int metroboxRecover(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  423. {
  424. unsigned short sernum;
  425. char envstr[255];
  426. sernum = sbcommon_get_serial_number();
  427. printf("\nSetting up environment for filesystem recovery\n");
  428. /*
  429. * Setup default bootargs
  430. */
  431. memset(envstr, 0, 255);
  432. sprintf(envstr, "console=ttyS0,9600 root=/dev/ram0 "
  433. "rw ip=10.100.60.%d:::255.255.0.0:metrobox%d:eth0:none",
  434. sernum, sernum);
  435. setenv("bootargs", envstr);
  436. /*
  437. * Setup Default boot command
  438. */
  439. setenv("bootcmd", "fatload ide 0 8000000 pimage.metrobox;"
  440. "fatload ide 0 8100000 pramdisk;"
  441. "bootm 8000000 8100000");
  442. printf("Done. Please type boot<cr>.\nWhen the kernel has booted"
  443. " please type fsrecover.sh<cr>\n");
  444. return(1);
  445. }
  446. U_BOOT_CMD(mbsetup, 1, 1, metroboxSetupVars,
  447. "mbsetup - Set environment to factory defaults\n", NULL);
  448. U_BOOT_CMD(mbrecover, 1, 1, metroboxRecover,
  449. "mbrecover - Set environment to allow for fs recovery\n", NULL);