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. #define BOOT_SMALL_FLASH 32 /* 00100000 */
  31. #define FLASH_ONBD_N 2 /* 00000010 */
  32. #define FLASH_SRAM_SEL 1 /* 00000001 */
  33. long int fixed_sdram (void);
  34. void fpga_init (void);
  35. int board_early_init_f (void)
  36. {
  37. unsigned long mfr;
  38. unsigned char *fpga_base = (unsigned char *) CFG_FPGA_BASE;
  39. unsigned char switch_status;
  40. unsigned long cs0_base;
  41. unsigned long cs0_size;
  42. unsigned long cs0_twt;
  43. unsigned long cs2_base;
  44. unsigned long cs2_size;
  45. unsigned long cs2_twt;
  46. /*-------------------------------------------------------------------------+
  47. | Initialize EBC CONFIG
  48. +-------------------------------------------------------------------------*/
  49. mtebc(xbcfg, EBC_CFG_LE_UNLOCK |
  50. EBC_CFG_PTD_ENABLE | EBC_CFG_RTC_64PERCLK |
  51. EBC_CFG_ATC_PREVIOUS | EBC_CFG_DTC_PREVIOUS |
  52. EBC_CFG_CTC_PREVIOUS | EBC_CFG_EMC_NONDEFAULT |
  53. EBC_CFG_PME_DISABLE | EBC_CFG_PR_32);
  54. /*-------------------------------------------------------------------------+
  55. | FPGA. Initialize bank 7 with default values.
  56. +-------------------------------------------------------------------------*/
  57. mtebc(pb7ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)|
  58. EBC_BXAP_BCE_DISABLE|
  59. EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
  60. EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
  61. EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
  62. EBC_BXAP_BEM_WRITEONLY|
  63. EBC_BXAP_PEN_DISABLED);
  64. mtebc(pb7cr, EBC_BXCR_BAS_ENCODE(0x48300000)|
  65. EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
  66. /* read FPGA base register FPGA_REG0 */
  67. switch_status = *fpga_base;
  68. if (switch_status & 0x40) {
  69. cs0_base = 0xFFE00000;
  70. cs0_size = EBC_BXCR_BS_2MB;
  71. cs0_twt = 8;
  72. cs2_base = 0xFF800000;
  73. cs2_size = EBC_BXCR_BS_4MB;
  74. cs2_twt = 10;
  75. } else {
  76. cs0_base = 0xFFC00000;
  77. cs0_size = EBC_BXCR_BS_4MB;
  78. cs0_twt = 10;
  79. cs2_base = 0xFF800000;
  80. cs2_size = EBC_BXCR_BS_2MB;
  81. cs2_twt = 8;
  82. }
  83. /*-------------------------------------------------------------------------+
  84. | 1 MB FLASH / 1 MB SRAM. Initialize bank 0 with default values.
  85. +-------------------------------------------------------------------------*/
  86. mtebc(pb0ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs0_twt)|
  87. EBC_BXAP_BCE_DISABLE|
  88. EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
  89. EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
  90. EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
  91. EBC_BXAP_BEM_WRITEONLY|
  92. EBC_BXAP_PEN_DISABLED);
  93. mtebc(pb0cr, EBC_BXCR_BAS_ENCODE(cs0_base)|
  94. cs0_size|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
  95. /*-------------------------------------------------------------------------+
  96. | 8KB NVRAM/RTC. Initialize bank 1 with default values.
  97. +-------------------------------------------------------------------------*/
  98. mtebc(pb1ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(10)|
  99. EBC_BXAP_BCE_DISABLE|
  100. EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
  101. EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
  102. EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
  103. EBC_BXAP_BEM_WRITEONLY|
  104. EBC_BXAP_PEN_DISABLED);
  105. mtebc(pb1cr, EBC_BXCR_BAS_ENCODE(0x48000000)|
  106. EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
  107. /*-------------------------------------------------------------------------+
  108. | 4 MB FLASH. Initialize bank 2 with default values.
  109. +-------------------------------------------------------------------------*/
  110. mtebc(pb2ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs2_twt)|
  111. EBC_BXAP_BCE_DISABLE|
  112. EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
  113. EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
  114. EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
  115. EBC_BXAP_BEM_WRITEONLY|
  116. EBC_BXAP_PEN_DISABLED);
  117. mtebc(pb2cr, EBC_BXCR_BAS_ENCODE(cs2_base)|
  118. cs2_size|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
  119. /*-------------------------------------------------------------------------+
  120. | FPGA. Initialize bank 7 with default values.
  121. +-------------------------------------------------------------------------*/
  122. mtebc(pb7ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)|
  123. EBC_BXAP_BCE_DISABLE|
  124. EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
  125. EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
  126. EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
  127. EBC_BXAP_BEM_WRITEONLY|
  128. EBC_BXAP_PEN_DISABLED);
  129. mtebc(pb7cr, EBC_BXCR_BAS_ENCODE(0x48300000)|
  130. EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
  131. /*--------------------------------------------------------------------
  132. * Setup the interrupt controller polarities, triggers, etc.
  133. *-------------------------------------------------------------------*/
  134. mtdcr (uic0sr, 0xffffffff); /* clear all */
  135. mtdcr (uic0er, 0x00000000); /* disable all */
  136. mtdcr (uic0cr, 0x00000009); /* SMI & UIC1 crit are critical */
  137. mtdcr (uic0pr, 0xfffffe13); /* per ref-board manual */
  138. mtdcr (uic0tr, 0x01c00008); /* per ref-board manual */
  139. mtdcr (uic0vr, 0x00000001); /* int31 highest, base=0x000 */
  140. mtdcr (uic0sr, 0xffffffff); /* clear all */
  141. mtdcr (uic1sr, 0xffffffff); /* clear all */
  142. mtdcr (uic1er, 0x00000000); /* disable all */
  143. mtdcr (uic1cr, 0x00000000); /* all non-critical */
  144. mtdcr (uic1pr, 0xffffe0ff); /* per ref-board manual */
  145. mtdcr (uic1tr, 0x00ffc000); /* per ref-board manual */
  146. mtdcr (uic1vr, 0x00000001); /* int31 highest, base=0x000 */
  147. mtdcr (uic1sr, 0xffffffff); /* clear all */
  148. mtdcr (uic2sr, 0xffffffff); /* clear all */
  149. mtdcr (uic2er, 0x00000000); /* disable all */
  150. mtdcr (uic2cr, 0x00000000); /* all non-critical */
  151. mtdcr (uic2pr, 0xffffffff); /* per ref-board manual */
  152. mtdcr (uic2tr, 0x00ff8c0f); /* per ref-board manual */
  153. mtdcr (uic2vr, 0x00000001); /* int31 highest, base=0x000 */
  154. mtdcr (uic2sr, 0xffffffff); /* clear all */
  155. mtdcr (uicb0sr, 0xfc000000); /* clear all */
  156. mtdcr (uicb0er, 0x00000000); /* disable all */
  157. mtdcr (uicb0cr, 0x00000000); /* all non-critical */
  158. mtdcr (uicb0pr, 0xfc000000); /* */
  159. mtdcr (uicb0tr, 0x00000000); /* */
  160. mtdcr (uicb0vr, 0x00000001); /* */
  161. mfsdr (sdr_mfr, mfr);
  162. mfr &= ~SDR0_MFR_ECS_MASK;
  163. /* mtsdr(sdr_mfr, mfr); */
  164. fpga_init();
  165. return 0;
  166. }
  167. int checkboard (void)
  168. {
  169. char *s = getenv ("serial#");
  170. printf ("Board: Ocotea - AMCC PPC440GX Evaluation Board");
  171. if (s != NULL) {
  172. puts (", serial# ");
  173. puts (s);
  174. }
  175. putc ('\n');
  176. return (0);
  177. }
  178. long int initdram (int board_type)
  179. {
  180. long dram_size = 0;
  181. #if defined(CONFIG_SPD_EEPROM)
  182. dram_size = spd_sdram (0);
  183. #else
  184. dram_size = fixed_sdram ();
  185. #endif
  186. return dram_size;
  187. }
  188. #if defined(CFG_DRAM_TEST)
  189. int testdram (void)
  190. {
  191. uint *pstart = (uint *) 0x00000000;
  192. uint *pend = (uint *) 0x08000000;
  193. uint *p;
  194. for (p = pstart; p < pend; p++)
  195. *p = 0xaaaaaaaa;
  196. for (p = pstart; p < pend; p++) {
  197. if (*p != 0xaaaaaaaa) {
  198. printf ("SDRAM test fails at: %08x\n", (uint) p);
  199. return 1;
  200. }
  201. }
  202. for (p = pstart; p < pend; p++)
  203. *p = 0x55555555;
  204. for (p = pstart; p < pend; p++) {
  205. if (*p != 0x55555555) {
  206. printf ("SDRAM test fails at: %08x\n", (uint) p);
  207. return 1;
  208. }
  209. }
  210. return 0;
  211. }
  212. #endif
  213. #if !defined(CONFIG_SPD_EEPROM)
  214. /*************************************************************************
  215. * fixed sdram init -- doesn't use serial presence detect.
  216. *
  217. * Assumes: 128 MB, non-ECC, non-registered
  218. * PLB @ 133 MHz
  219. *
  220. ************************************************************************/
  221. long int fixed_sdram (void)
  222. {
  223. uint reg;
  224. /*--------------------------------------------------------------------
  225. * Setup some default
  226. *------------------------------------------------------------------*/
  227. mtsdram (mem_uabba, 0x00000000); /* ubba=0 (default) */
  228. mtsdram (mem_slio, 0x00000000); /* rdre=0 wrre=0 rarw=0 */
  229. mtsdram (mem_devopt, 0x00000000); /* dll=0 ds=0 (normal) */
  230. mtsdram (mem_wddctr, 0x00000000); /* wrcp=0 dcd=0 */
  231. mtsdram (mem_clktr, 0x40000000); /* clkp=1 (90 deg wr) dcdt=0 */
  232. /*--------------------------------------------------------------------
  233. * Setup for board-specific specific mem
  234. *------------------------------------------------------------------*/
  235. /*
  236. * Following for CAS Latency = 2.5 @ 133 MHz PLB
  237. */
  238. mtsdram (mem_b0cr, 0x000a4001); /* SDBA=0x000 128MB, Mode 3, enabled */
  239. mtsdram (mem_tr0, 0x410a4012); /* WR=2 WD=1 CL=2.5 PA=3 CP=4 LD=2 */
  240. /* RA=10 RD=3 */
  241. mtsdram (mem_tr1, 0x8080082f); /* SS=T2 SL=STAGE 3 CD=1 CT=0x02f */
  242. mtsdram (mem_rtr, 0x08200000); /* Rate 15.625 ns @ 133 MHz PLB */
  243. mtsdram (mem_cfg1, 0x00000000); /* Self-refresh exit, disable PM */
  244. udelay (400); /* Delay 200 usecs (min) */
  245. /*--------------------------------------------------------------------
  246. * Enable the controller, then wait for DCEN to complete
  247. *------------------------------------------------------------------*/
  248. mtsdram (mem_cfg0, 0x86000000); /* DCEN=1, PMUD=1, 64-bit */
  249. for (;;) {
  250. mfsdram (mem_mcsts, reg);
  251. if (reg & 0x80000000)
  252. break;
  253. }
  254. return (128 * 1024 * 1024); /* 128 MB */
  255. }
  256. #endif /* !defined(CONFIG_SPD_EEPROM) */
  257. /*************************************************************************
  258. * pci_pre_init
  259. *
  260. * This routine is called just prior to registering the hose and gives
  261. * the board the opportunity to check things. Returning a value of zero
  262. * indicates that things are bad & PCI initialization should be aborted.
  263. *
  264. * Different boards may wish to customize the pci controller structure
  265. * (add regions, override default access routines, etc) or perform
  266. * certain pre-initialization actions.
  267. *
  268. ************************************************************************/
  269. #if defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT)
  270. int pci_pre_init(struct pci_controller * hose )
  271. {
  272. unsigned long strap;
  273. /*--------------------------------------------------------------------------+
  274. * The ocotea board is always configured as the host & requires the
  275. * PCI arbiter to be enabled.
  276. *--------------------------------------------------------------------------*/
  277. mfsdr(sdr_sdstp1, strap);
  278. if( (strap & SDR0_SDSTP1_PAE_MASK) == 0 ){
  279. printf("PCI: SDR0_STRP1[%08lX] - PCI Arbiter disabled.\n",strap);
  280. return 0;
  281. }
  282. return 1;
  283. }
  284. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT) */
  285. /*************************************************************************
  286. * pci_target_init
  287. *
  288. * The bootstrap configuration provides default settings for the pci
  289. * inbound map (PIM). But the bootstrap config choices are limited and
  290. * may not be sufficient for a given board.
  291. *
  292. ************************************************************************/
  293. #if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
  294. void pci_target_init(struct pci_controller * hose )
  295. {
  296. DECLARE_GLOBAL_DATA_PTR;
  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