metrobox.c 19 KB

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