metrobox.c 18 KB

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