ocotea.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. /*
  2. * Copyright (C) 2004 PaulReynolds@lhsolutions.com
  3. *
  4. * (C) Copyright 2005
  5. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include "ocotea.h"
  27. #include <asm/processor.h>
  28. #include <spd_sdram.h>
  29. #include <ppc4xx_enet.h>
  30. DECLARE_GLOBAL_DATA_PTR;
  31. #define BOOT_SMALL_FLASH 32 /* 00100000 */
  32. #define FLASH_ONBD_N 2 /* 00000010 */
  33. #define FLASH_SRAM_SEL 1 /* 00000001 */
  34. long int fixed_sdram (void);
  35. void fpga_init (void);
  36. int board_early_init_f (void)
  37. {
  38. unsigned long mfr;
  39. unsigned char *fpga_base = (unsigned char *) CFG_FPGA_BASE;
  40. unsigned char switch_status;
  41. unsigned long cs0_base;
  42. unsigned long cs0_size;
  43. unsigned long cs0_twt;
  44. unsigned long cs2_base;
  45. unsigned long cs2_size;
  46. unsigned long cs2_twt;
  47. /*-------------------------------------------------------------------------+
  48. | Initialize EBC CONFIG
  49. +-------------------------------------------------------------------------*/
  50. mtebc(xbcfg, EBC_CFG_LE_UNLOCK |
  51. EBC_CFG_PTD_ENABLE | EBC_CFG_RTC_64PERCLK |
  52. EBC_CFG_ATC_PREVIOUS | EBC_CFG_DTC_PREVIOUS |
  53. EBC_CFG_CTC_PREVIOUS | EBC_CFG_EMC_NONDEFAULT |
  54. EBC_CFG_PME_DISABLE | EBC_CFG_PR_32);
  55. /*-------------------------------------------------------------------------+
  56. | FPGA. Initialize bank 7 with default values.
  57. +-------------------------------------------------------------------------*/
  58. mtebc(pb7ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)|
  59. EBC_BXAP_BCE_DISABLE|
  60. EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
  61. EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
  62. EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
  63. EBC_BXAP_BEM_WRITEONLY|
  64. EBC_BXAP_PEN_DISABLED);
  65. mtebc(pb7cr, EBC_BXCR_BAS_ENCODE(0x48300000)|
  66. EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
  67. /* read FPGA base register FPGA_REG0 */
  68. switch_status = *fpga_base;
  69. if (switch_status & 0x40) {
  70. cs0_base = 0xFFE00000;
  71. cs0_size = EBC_BXCR_BS_2MB;
  72. cs0_twt = 8;
  73. cs2_base = 0xFF800000;
  74. cs2_size = EBC_BXCR_BS_4MB;
  75. cs2_twt = 10;
  76. } else {
  77. cs0_base = 0xFFC00000;
  78. cs0_size = EBC_BXCR_BS_4MB;
  79. cs0_twt = 10;
  80. cs2_base = 0xFF800000;
  81. cs2_size = EBC_BXCR_BS_2MB;
  82. cs2_twt = 8;
  83. }
  84. /*-------------------------------------------------------------------------+
  85. | 1 MB FLASH / 1 MB SRAM. Initialize bank 0 with default values.
  86. +-------------------------------------------------------------------------*/
  87. mtebc(pb0ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs0_twt)|
  88. EBC_BXAP_BCE_DISABLE|
  89. EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
  90. EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
  91. EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
  92. EBC_BXAP_BEM_WRITEONLY|
  93. EBC_BXAP_PEN_DISABLED);
  94. mtebc(pb0cr, EBC_BXCR_BAS_ENCODE(cs0_base)|
  95. cs0_size|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
  96. /*-------------------------------------------------------------------------+
  97. | 8KB NVRAM/RTC. Initialize bank 1 with default values.
  98. +-------------------------------------------------------------------------*/
  99. mtebc(pb1ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(10)|
  100. EBC_BXAP_BCE_DISABLE|
  101. EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
  102. EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
  103. EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
  104. EBC_BXAP_BEM_WRITEONLY|
  105. EBC_BXAP_PEN_DISABLED);
  106. mtebc(pb1cr, EBC_BXCR_BAS_ENCODE(0x48000000)|
  107. EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
  108. /*-------------------------------------------------------------------------+
  109. | 4 MB FLASH. Initialize bank 2 with default values.
  110. +-------------------------------------------------------------------------*/
  111. mtebc(pb2ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs2_twt)|
  112. EBC_BXAP_BCE_DISABLE|
  113. EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
  114. EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
  115. EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
  116. EBC_BXAP_BEM_WRITEONLY|
  117. EBC_BXAP_PEN_DISABLED);
  118. mtebc(pb2cr, EBC_BXCR_BAS_ENCODE(cs2_base)|
  119. cs2_size|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
  120. /*-------------------------------------------------------------------------+
  121. | FPGA. Initialize bank 7 with default values.
  122. +-------------------------------------------------------------------------*/
  123. mtebc(pb7ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)|
  124. EBC_BXAP_BCE_DISABLE|
  125. EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
  126. EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
  127. EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
  128. EBC_BXAP_BEM_WRITEONLY|
  129. EBC_BXAP_PEN_DISABLED);
  130. mtebc(pb7cr, EBC_BXCR_BAS_ENCODE(0x48300000)|
  131. EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
  132. /*--------------------------------------------------------------------
  133. * Setup the interrupt controller polarities, triggers, etc.
  134. *-------------------------------------------------------------------*/
  135. mtdcr (uic0sr, 0xffffffff); /* clear all */
  136. mtdcr (uic0er, 0x00000000); /* disable all */
  137. mtdcr (uic0cr, 0x00000009); /* SMI & UIC1 crit are critical */
  138. mtdcr (uic0pr, 0xfffffe13); /* per ref-board manual */
  139. mtdcr (uic0tr, 0x01c00008); /* per ref-board manual */
  140. mtdcr (uic0vr, 0x00000001); /* int31 highest, base=0x000 */
  141. mtdcr (uic0sr, 0xffffffff); /* clear all */
  142. mtdcr (uic1sr, 0xffffffff); /* clear all */
  143. mtdcr (uic1er, 0x00000000); /* disable all */
  144. mtdcr (uic1cr, 0x00000000); /* all non-critical */
  145. mtdcr (uic1pr, 0xffffe0ff); /* per ref-board manual */
  146. mtdcr (uic1tr, 0x00ffc000); /* per ref-board manual */
  147. mtdcr (uic1vr, 0x00000001); /* int31 highest, base=0x000 */
  148. mtdcr (uic1sr, 0xffffffff); /* clear all */
  149. mtdcr (uic2sr, 0xffffffff); /* clear all */
  150. mtdcr (uic2er, 0x00000000); /* disable all */
  151. mtdcr (uic2cr, 0x00000000); /* all non-critical */
  152. mtdcr (uic2pr, 0xffffffff); /* per ref-board manual */
  153. mtdcr (uic2tr, 0x00ff8c0f); /* per ref-board manual */
  154. mtdcr (uic2vr, 0x00000001); /* int31 highest, base=0x000 */
  155. mtdcr (uic2sr, 0xffffffff); /* clear all */
  156. mtdcr (uicb0sr, 0xfc000000); /* clear all */
  157. mtdcr (uicb0er, 0x00000000); /* disable all */
  158. mtdcr (uicb0cr, 0x00000000); /* all non-critical */
  159. mtdcr (uicb0pr, 0xfc000000); /* */
  160. mtdcr (uicb0tr, 0x00000000); /* */
  161. mtdcr (uicb0vr, 0x00000001); /* */
  162. mfsdr (sdr_mfr, mfr);
  163. mfr &= ~SDR0_MFR_ECS_MASK;
  164. /* mtsdr(sdr_mfr, mfr); */
  165. fpga_init();
  166. return 0;
  167. }
  168. int checkboard (void)
  169. {
  170. char *s = getenv ("serial#");
  171. printf ("Board: Ocotea - AMCC PPC440GX Evaluation Board");
  172. if (s != NULL) {
  173. puts (", serial# ");
  174. puts (s);
  175. }
  176. putc ('\n');
  177. return (0);
  178. }
  179. long int initdram (int board_type)
  180. {
  181. long dram_size = 0;
  182. #if defined(CONFIG_SPD_EEPROM)
  183. dram_size = spd_sdram ();
  184. #else
  185. dram_size = fixed_sdram ();
  186. #endif
  187. return dram_size;
  188. }
  189. #if defined(CFG_DRAM_TEST)
  190. int testdram (void)
  191. {
  192. uint *pstart = (uint *) 0x00000000;
  193. uint *pend = (uint *) 0x08000000;
  194. uint *p;
  195. for (p = pstart; p < pend; p++)
  196. *p = 0xaaaaaaaa;
  197. for (p = pstart; p < pend; p++) {
  198. if (*p != 0xaaaaaaaa) {
  199. printf ("SDRAM test fails at: %08x\n", (uint) p);
  200. return 1;
  201. }
  202. }
  203. for (p = pstart; p < pend; p++)
  204. *p = 0x55555555;
  205. for (p = pstart; p < pend; p++) {
  206. if (*p != 0x55555555) {
  207. printf ("SDRAM test fails at: %08x\n", (uint) p);
  208. return 1;
  209. }
  210. }
  211. return 0;
  212. }
  213. #endif
  214. #if !defined(CONFIG_SPD_EEPROM)
  215. /*************************************************************************
  216. * fixed sdram init -- doesn't use serial presence detect.
  217. *
  218. * Assumes: 128 MB, non-ECC, non-registered
  219. * PLB @ 133 MHz
  220. *
  221. ************************************************************************/
  222. long int fixed_sdram (void)
  223. {
  224. uint reg;
  225. /*--------------------------------------------------------------------
  226. * Setup some default
  227. *------------------------------------------------------------------*/
  228. mtsdram (mem_uabba, 0x00000000); /* ubba=0 (default) */
  229. mtsdram (mem_slio, 0x00000000); /* rdre=0 wrre=0 rarw=0 */
  230. mtsdram (mem_devopt, 0x00000000); /* dll=0 ds=0 (normal) */
  231. mtsdram (mem_wddctr, 0x00000000); /* wrcp=0 dcd=0 */
  232. mtsdram (mem_clktr, 0x40000000); /* clkp=1 (90 deg wr) dcdt=0 */
  233. /*--------------------------------------------------------------------
  234. * Setup for board-specific specific mem
  235. *------------------------------------------------------------------*/
  236. /*
  237. * Following for CAS Latency = 2.5 @ 133 MHz PLB
  238. */
  239. mtsdram (mem_b0cr, 0x000a4001); /* SDBA=0x000 128MB, Mode 3, enabled */
  240. mtsdram (mem_tr0, 0x410a4012); /* WR=2 WD=1 CL=2.5 PA=3 CP=4 LD=2 */
  241. /* RA=10 RD=3 */
  242. mtsdram (mem_tr1, 0x8080082f); /* SS=T2 SL=STAGE 3 CD=1 CT=0x02f */
  243. mtsdram (mem_rtr, 0x08200000); /* Rate 15.625 ns @ 133 MHz PLB */
  244. mtsdram (mem_cfg1, 0x00000000); /* Self-refresh exit, disable PM */
  245. udelay (400); /* Delay 200 usecs (min) */
  246. /*--------------------------------------------------------------------
  247. * Enable the controller, then wait for DCEN to complete
  248. *------------------------------------------------------------------*/
  249. mtsdram (mem_cfg0, 0x86000000); /* DCEN=1, PMUD=1, 64-bit */
  250. for (;;) {
  251. mfsdram (mem_mcsts, reg);
  252. if (reg & 0x80000000)
  253. break;
  254. }
  255. return (128 * 1024 * 1024); /* 128 MB */
  256. }
  257. #endif /* !defined(CONFIG_SPD_EEPROM) */
  258. /*************************************************************************
  259. * pci_pre_init
  260. *
  261. * This routine is called just prior to registering the hose and gives
  262. * the board the opportunity to check things. Returning a value of zero
  263. * indicates that things are bad & PCI initialization should be aborted.
  264. *
  265. * Different boards may wish to customize the pci controller structure
  266. * (add regions, override default access routines, etc) or perform
  267. * certain pre-initialization actions.
  268. *
  269. ************************************************************************/
  270. #if defined(CONFIG_PCI)
  271. int pci_pre_init(struct pci_controller * hose )
  272. {
  273. unsigned long strap;
  274. /*--------------------------------------------------------------------------+
  275. * The ocotea board is always configured as the host & requires the
  276. * PCI arbiter to be enabled.
  277. *--------------------------------------------------------------------------*/
  278. mfsdr(sdr_sdstp1, strap);
  279. if( (strap & SDR0_SDSTP1_PAE_MASK) == 0 ){
  280. printf("PCI: SDR0_STRP1[%08lX] - PCI Arbiter disabled.\n",strap);
  281. return 0;
  282. }
  283. return 1;
  284. }
  285. #endif /* defined(CONFIG_PCI) */
  286. /*************************************************************************
  287. * pci_target_init
  288. *
  289. * The bootstrap configuration provides default settings for the pci
  290. * inbound map (PIM). But the bootstrap config choices are limited and
  291. * may not be sufficient for a given board.
  292. *
  293. ************************************************************************/
  294. #if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
  295. void pci_target_init(struct pci_controller * hose )
  296. {
  297. /*--------------------------------------------------------------------------+
  298. * Disable everything
  299. *--------------------------------------------------------------------------*/
  300. out32r( PCIX0_PIM0SA, 0 ); /* disable */
  301. out32r( PCIX0_PIM1SA, 0 ); /* disable */
  302. out32r( PCIX0_PIM2SA, 0 ); /* disable */
  303. out32r( PCIX0_EROMBA, 0 ); /* disable expansion rom */
  304. /*--------------------------------------------------------------------------+
  305. * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440 strapping
  306. * options to not support sizes such as 128/256 MB.
  307. *--------------------------------------------------------------------------*/
  308. out32r( PCIX0_PIM0LAL, CFG_SDRAM_BASE );
  309. out32r( PCIX0_PIM0LAH, 0 );
  310. out32r( PCIX0_PIM0SA, ~(gd->ram_size - 1) | 1 );
  311. out32r( PCIX0_BAR0, 0 );
  312. /*--------------------------------------------------------------------------+
  313. * Program the board's subsystem id/vendor id
  314. *--------------------------------------------------------------------------*/
  315. out16r( PCIX0_SBSYSVID, CFG_PCI_SUBSYS_VENDORID );
  316. out16r( PCIX0_SBSYSID, CFG_PCI_SUBSYS_DEVICEID );
  317. out16r( PCIX0_CMD, in16r(PCIX0_CMD) | PCI_COMMAND_MEMORY );
  318. }
  319. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) */
  320. /*************************************************************************
  321. * is_pci_host
  322. *
  323. * This routine is called to determine if a pci scan should be
  324. * performed. With various hardware environments (especially cPCI and
  325. * PPMC) it's insufficient to depend on the state of the arbiter enable
  326. * bit in the strap register, or generic host/adapter assumptions.
  327. *
  328. * Rather than hard-code a bad assumption in the general 440 code, the
  329. * 440 pci code requires the board to decide at runtime.
  330. *
  331. * Return 0 for adapter mode, non-zero for host (monarch) mode.
  332. *
  333. *
  334. ************************************************************************/
  335. #if defined(CONFIG_PCI)
  336. int is_pci_host(struct pci_controller *hose)
  337. {
  338. /* The ocotea board is always configured as host. */
  339. return(1);
  340. }
  341. #endif /* defined(CONFIG_PCI) */
  342. void fpga_init(void)
  343. {
  344. unsigned long group;
  345. unsigned long sdr0_pfc0;
  346. unsigned long sdr0_pfc1;
  347. unsigned long sdr0_cust0;
  348. unsigned long pvr;
  349. mfsdr (sdr_pfc0, sdr0_pfc0);
  350. mfsdr (sdr_pfc1, sdr0_pfc1);
  351. group = SDR0_PFC1_EPS_DECODE(sdr0_pfc1);
  352. pvr = get_pvr ();
  353. sdr0_pfc0 = (sdr0_pfc0 & ~SDR0_PFC0_GEIE_MASK) | SDR0_PFC0_GEIE_TRE;
  354. if ( ((pvr == PVR_440GX_RA) || (pvr == PVR_440GX_RB)) && ((group == 4) || (group == 5))) {
  355. sdr0_pfc0 = (sdr0_pfc0 & ~SDR0_PFC0_TRE_MASK) | SDR0_PFC0_TRE_DISABLE;
  356. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_EMS;
  357. out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) |
  358. FPGA_REG2_EXT_INTFACE_ENABLE);
  359. mtsdr (sdr_pfc0, sdr0_pfc0);
  360. mtsdr (sdr_pfc1, sdr0_pfc1);
  361. } else {
  362. sdr0_pfc0 = (sdr0_pfc0 & ~SDR0_PFC0_TRE_MASK) | SDR0_PFC0_TRE_ENABLE;
  363. switch (group)
  364. {
  365. case 0:
  366. case 1:
  367. case 2:
  368. /* CPU trace A */
  369. out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) |
  370. FPGA_REG2_EXT_INTFACE_ENABLE);
  371. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_EMS;
  372. mtsdr (sdr_pfc0, sdr0_pfc0);
  373. mtsdr (sdr_pfc1, sdr0_pfc1);
  374. break;
  375. case 3:
  376. case 4:
  377. case 5:
  378. case 6:
  379. /* CPU trace B - Over EBMI */
  380. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_CPUTRACE;
  381. mtsdr (sdr_pfc0, sdr0_pfc0);
  382. mtsdr (sdr_pfc1, sdr0_pfc1);
  383. out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) |
  384. FPGA_REG2_EXT_INTFACE_DISABLE);
  385. break;
  386. }
  387. }
  388. /* Initialize the ethernet specific functions in the fpga */
  389. mfsdr(sdr_pfc1, sdr0_pfc1);
  390. mfsdr(sdr_cust0, sdr0_cust0);
  391. if ( (SDR0_PFC1_EPS_DECODE(sdr0_pfc1) == 4) &&
  392. ((SDR0_CUST0_RGMII2_DECODE(sdr0_cust0) == RGMII_FER_GMII) ||
  393. (SDR0_CUST0_RGMII2_DECODE(sdr0_cust0) == RGMII_FER_TBI)))
  394. {
  395. if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER1)
  396. {
  397. out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK1) |
  398. FPGA_REG3_ENET_GROUP7);
  399. }
  400. else
  401. {
  402. if (SDR0_CUST0_RGMII2_DECODE(sdr0_cust0) == RGMII_FER_GMII)
  403. {
  404. out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK2) |
  405. FPGA_REG3_ENET_GROUP7);
  406. }
  407. else
  408. {
  409. out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK2) |
  410. FPGA_REG3_ENET_GROUP8);
  411. }
  412. }
  413. }
  414. else
  415. {
  416. if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER1)
  417. {
  418. out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK1) |
  419. FPGA_REG3_ENET_ENCODE1(SDR0_PFC1_EPS_DECODE(sdr0_pfc1)));
  420. }
  421. else
  422. {
  423. out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK2) |
  424. FPGA_REG3_ENET_ENCODE2(SDR0_PFC1_EPS_DECODE(sdr0_pfc1)));
  425. }
  426. }
  427. out8(FPGA_REG4, FPGA_REG4_GPHY_MODE10 |
  428. FPGA_REG4_GPHY_MODE100 | FPGA_REG4_GPHY_MODE1000 |
  429. FPGA_REG4_GPHY_FRC_DPLX | FPGA_REG4_CONNECT_PHYS);
  430. /* reset the gigabyte phy if necessary */
  431. if (SDR0_PFC1_EPS_DECODE(sdr0_pfc1) >= 3)
  432. {
  433. if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER1)
  434. {
  435. out8(FPGA_REG3, in8(FPGA_REG3) & ~FPGA_REG3_GIGABIT_RESET_DISABLE);
  436. udelay(10000);
  437. out8(FPGA_REG3, in8(FPGA_REG3) | FPGA_REG3_GIGABIT_RESET_DISABLE);
  438. }
  439. else
  440. {
  441. out8(FPGA_REG2, in8(FPGA_REG2) & ~FPGA_REG2_GIGABIT_RESET_DISABLE);
  442. udelay(10000);
  443. out8(FPGA_REG2, in8(FPGA_REG2) | FPGA_REG2_GIGABIT_RESET_DISABLE);
  444. }
  445. }
  446. /*
  447. * new Ocotea with Rev. F (pass 3) chips has SMII PHY reset
  448. */
  449. if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER2) {
  450. out8(FPGA_REG2, in8(FPGA_REG2) & ~FPGA_REG2_SMII_RESET_DISABLE);
  451. udelay(10000);
  452. out8(FPGA_REG2, in8(FPGA_REG2) | FPGA_REG2_SMII_RESET_DISABLE);
  453. }
  454. /* Turn off the LED's */
  455. out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_STAT_MASK) |
  456. FPGA_REG3_STAT_LED8_DISAB | FPGA_REG3_STAT_LED4_DISAB |
  457. FPGA_REG3_STAT_LED2_DISAB | FPGA_REG3_STAT_LED1_DISAB);
  458. return;
  459. }
  460. #ifdef CONFIG_POST
  461. /*
  462. * Returns 1 if keys pressed to start the power-on long-running tests
  463. * Called from board_init_f().
  464. */
  465. int post_hotkeys_pressed(void)
  466. {
  467. return (ctrlc());
  468. }
  469. #endif