taishan.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. /*
  2. * Copyright (C) 2004 PaulReynolds@lhsolutions.com
  3. *
  4. * (C) Copyright 2007
  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 <asm/processor.h>
  27. #include <spd_sdram.h>
  28. #include <ppc4xx_enet.h>
  29. #include <netdev.h>
  30. #ifdef CONFIG_SYS_INIT_SHOW_RESET_REG
  31. void show_reset_reg(void);
  32. #endif
  33. DECLARE_GLOBAL_DATA_PTR;
  34. int lcd_init(void);
  35. int board_early_init_f (void)
  36. {
  37. unsigned long reg;
  38. volatile unsigned int *GpioOdr;
  39. volatile unsigned int *GpioTcr;
  40. volatile unsigned int *GpioOr;
  41. /*-------------------------------------------------------------------------+
  42. | Initialize EBC CONFIG
  43. +-------------------------------------------------------------------------*/
  44. mtebc(xbcfg, EBC_CFG_LE_UNLOCK |
  45. EBC_CFG_PTD_ENABLE | EBC_CFG_RTC_64PERCLK |
  46. EBC_CFG_ATC_PREVIOUS | EBC_CFG_DTC_PREVIOUS |
  47. EBC_CFG_CTC_PREVIOUS | EBC_CFG_EMC_DEFAULT |
  48. EBC_CFG_PME_DISABLE | EBC_CFG_PR_32);
  49. /*-------------------------------------------------------------------------+
  50. | 64MB FLASH. Initialize bank 0 with default values.
  51. +-------------------------------------------------------------------------*/
  52. mtebc(pb0ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(15) |
  53. EBC_BXAP_BCE_DISABLE |
  54. EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_OEN_ENCODE(1) |
  55. EBC_BXAP_WBN_ENCODE(1) | EBC_BXAP_WBF_ENCODE(1) |
  56. EBC_BXAP_TH_ENCODE(3) | EBC_BXAP_RE_DISABLED |
  57. EBC_BXAP_BEM_WRITEONLY |
  58. EBC_BXAP_PEN_DISABLED);
  59. mtebc(pb0cr, EBC_BXCR_BAS_ENCODE(CONFIG_SYS_FLASH_BASE) |
  60. EBC_BXCR_BS_64MB | EBC_BXCR_BU_RW|EBC_BXCR_BW_32BIT);
  61. /*-------------------------------------------------------------------------+
  62. | FPGA. Initialize bank 1 with default values.
  63. +-------------------------------------------------------------------------*/
  64. mtebc(pb1ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(5) |
  65. EBC_BXAP_BCE_DISABLE |
  66. EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_OEN_ENCODE(1) |
  67. EBC_BXAP_WBN_ENCODE(1) | EBC_BXAP_WBF_ENCODE(1) |
  68. EBC_BXAP_TH_ENCODE(3) | EBC_BXAP_RE_DISABLED |
  69. EBC_BXAP_BEM_WRITEONLY |
  70. EBC_BXAP_PEN_DISABLED);
  71. mtebc(pb1cr, EBC_BXCR_BAS_ENCODE(0x41000000) |
  72. EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_8BIT);
  73. /*-------------------------------------------------------------------------+
  74. | LCM. Initialize bank 2 with default values.
  75. +-------------------------------------------------------------------------*/
  76. mtebc(pb2ap, EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(64) |
  77. EBC_BXAP_BCE_DISABLE |
  78. EBC_BXAP_CSN_ENCODE(3) | EBC_BXAP_OEN_ENCODE(3) |
  79. EBC_BXAP_WBN_ENCODE(3) | EBC_BXAP_WBF_ENCODE(3) |
  80. EBC_BXAP_TH_ENCODE(7) | EBC_BXAP_RE_DISABLED |
  81. EBC_BXAP_BEM_WRITEONLY |
  82. EBC_BXAP_PEN_DISABLED);
  83. mtebc(pb2cr, EBC_BXCR_BAS_ENCODE(0x42000000) |
  84. EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
  85. /*-------------------------------------------------------------------------+
  86. | TMP. Initialize bank 3 with default values.
  87. +-------------------------------------------------------------------------*/
  88. mtebc(pb3ap, EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(128) |
  89. EBC_BXAP_BCE_DISABLE |
  90. EBC_BXAP_CSN_ENCODE(3) | EBC_BXAP_OEN_ENCODE(3) |
  91. EBC_BXAP_WBN_ENCODE(3) | EBC_BXAP_WBF_ENCODE(3) |
  92. EBC_BXAP_TH_ENCODE(7) | EBC_BXAP_RE_DISABLED |
  93. EBC_BXAP_BEM_WRITEONLY |
  94. EBC_BXAP_PEN_DISABLED);
  95. mtebc(pb3cr, EBC_BXCR_BAS_ENCODE(0x48000000) |
  96. EBC_BXCR_BS_64MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
  97. /*-------------------------------------------------------------------------+
  98. | Connector 4~7. Initialize bank 3~ 7 with default values.
  99. +-------------------------------------------------------------------------*/
  100. mtebc(pb4ap,0);
  101. mtebc(pb4cr,0);
  102. mtebc(pb5ap,0);
  103. mtebc(pb5cr,0);
  104. mtebc(pb6ap,0);
  105. mtebc(pb6cr,0);
  106. mtebc(pb7ap,0);
  107. mtebc(pb7cr,0);
  108. /*--------------------------------------------------------------------
  109. * Setup the interrupt controller polarities, triggers, etc.
  110. *-------------------------------------------------------------------*/
  111. /*
  112. * Because of the interrupt handling rework to handle 440GX interrupts
  113. * with the common code, we needed to change names of the UIC registers.
  114. * Here the new relationship:
  115. *
  116. * U-Boot name 440GX name
  117. * -----------------------
  118. * UIC0 UICB0
  119. * UIC1 UIC0
  120. * UIC2 UIC1
  121. * UIC3 UIC2
  122. */
  123. mtdcr (uic1sr, 0xffffffff); /* clear all */
  124. mtdcr (uic1er, 0x00000000); /* disable all */
  125. mtdcr (uic1cr, 0x00000009); /* SMI & UIC1 crit are critical */
  126. mtdcr (uic1pr, 0xfffffe13); /* per ref-board manual */
  127. mtdcr (uic1tr, 0x01c00008); /* per ref-board manual */
  128. mtdcr (uic1vr, 0x00000001); /* int31 highest, base=0x000 */
  129. mtdcr (uic1sr, 0xffffffff); /* clear all */
  130. mtdcr (uic2sr, 0xffffffff); /* clear all */
  131. mtdcr (uic2er, 0x00000000); /* disable all */
  132. mtdcr (uic2cr, 0x00000000); /* all non-critical */
  133. mtdcr (uic2pr, 0xffffe0ff); /* per ref-board manual */
  134. mtdcr (uic2tr, 0x00ffc000); /* per ref-board manual */
  135. mtdcr (uic2vr, 0x00000001); /* int31 highest, base=0x000 */
  136. mtdcr (uic2sr, 0xffffffff); /* clear all */
  137. mtdcr (uic3sr, 0xffffffff); /* clear all */
  138. mtdcr (uic3er, 0x00000000); /* disable all */
  139. mtdcr (uic3cr, 0x00000000); /* all non-critical */
  140. mtdcr (uic3pr, 0xffffffff); /* per ref-board manual */
  141. mtdcr (uic3tr, 0x00ff8c0f); /* per ref-board manual */
  142. mtdcr (uic3vr, 0x00000001); /* int31 highest, base=0x000 */
  143. mtdcr (uic3sr, 0xffffffff); /* clear all */
  144. mtdcr (uic0sr, 0xfc000000); /* clear all */
  145. mtdcr (uic0er, 0x00000000); /* disable all */
  146. mtdcr (uic0cr, 0x00000000); /* all non-critical */
  147. mtdcr (uic0pr, 0xfc000000); /* */
  148. mtdcr (uic0tr, 0x00000000); /* */
  149. mtdcr (uic0vr, 0x00000001); /* */
  150. /* Enable two GPIO 10~11 and TraceA signal */
  151. mfsdr(sdr_pfc0,reg);
  152. reg |= 0x00300000;
  153. mtsdr(sdr_pfc0,reg);
  154. mfsdr(sdr_pfc1,reg);
  155. reg |= 0x00100000;
  156. mtsdr(sdr_pfc1,reg);
  157. /* Set GPIO 10 and 11 as output */
  158. GpioOdr = (volatile unsigned int*)(CONFIG_SYS_PERIPHERAL_BASE+0x718);
  159. GpioTcr = (volatile unsigned int*)(CONFIG_SYS_PERIPHERAL_BASE+0x704);
  160. GpioOr = (volatile unsigned int*)(CONFIG_SYS_PERIPHERAL_BASE+0x700);
  161. *GpioOdr &= ~(0x00300000);
  162. *GpioTcr |= 0x00300000;
  163. *GpioOr |= 0x00300000;
  164. return 0;
  165. }
  166. int misc_init_r(void)
  167. {
  168. lcd_init();
  169. return 0;
  170. }
  171. int checkboard (void)
  172. {
  173. char *s = getenv ("serial#");
  174. printf ("Board: Taishan - AMCC PPC440GX Evaluation Board");
  175. if (s != NULL) {
  176. puts (", serial# ");
  177. puts (s);
  178. }
  179. putc ('\n');
  180. #ifdef CONFIG_SYS_INIT_SHOW_RESET_REG
  181. show_reset_reg();
  182. #endif
  183. return (0);
  184. }
  185. /*************************************************************************
  186. * pci_pre_init
  187. *
  188. * This routine is called just prior to registering the hose and gives
  189. * the board the opportunity to check things. Returning a value of zero
  190. * indicates that things are bad & PCI initialization should be aborted.
  191. *
  192. * Different boards may wish to customize the pci controller structure
  193. * (add regions, override default access routines, etc) or perform
  194. * certain pre-initialization actions.
  195. *
  196. ************************************************************************/
  197. #if defined(CONFIG_PCI)
  198. int pci_pre_init(struct pci_controller * hose )
  199. {
  200. unsigned long strap;
  201. /*--------------------------------------------------------------------------+
  202. * The ocotea board is always configured as the host & requires the
  203. * PCI arbiter to be enabled.
  204. *--------------------------------------------------------------------------*/
  205. mfsdr(sdr_sdstp1, strap);
  206. if( (strap & SDR0_SDSTP1_PAE_MASK) == 0 ){
  207. printf("PCI: SDR0_STRP1[%08lX] - PCI Arbiter disabled.\n",strap);
  208. return 0;
  209. }
  210. return 1;
  211. }
  212. #endif /* defined(CONFIG_PCI) */
  213. /*************************************************************************
  214. * pci_target_init
  215. *
  216. * The bootstrap configuration provides default settings for the pci
  217. * inbound map (PIM). But the bootstrap config choices are limited and
  218. * may not be sufficient for a given board.
  219. *
  220. ************************************************************************/
  221. #if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT)
  222. void pci_target_init(struct pci_controller * hose )
  223. {
  224. /*--------------------------------------------------------------------------+
  225. * Disable everything
  226. *--------------------------------------------------------------------------*/
  227. out32r( PCIX0_PIM0SA, 0 ); /* disable */
  228. out32r( PCIX0_PIM1SA, 0 ); /* disable */
  229. out32r( PCIX0_PIM2SA, 0 ); /* disable */
  230. out32r( PCIX0_EROMBA, 0 ); /* disable expansion rom */
  231. /*--------------------------------------------------------------------------+
  232. * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440 strapping
  233. * options to not support sizes such as 128/256 MB.
  234. *--------------------------------------------------------------------------*/
  235. out32r( PCIX0_PIM0LAL, CONFIG_SYS_SDRAM_BASE );
  236. out32r( PCIX0_PIM0LAH, 0 );
  237. out32r( PCIX0_PIM0SA, ~(gd->ram_size - 1) | 1 );
  238. out32r( PCIX0_BAR0, 0 );
  239. /*--------------------------------------------------------------------------+
  240. * Program the board's subsystem id/vendor id
  241. *--------------------------------------------------------------------------*/
  242. out16r( PCIX0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID );
  243. out16r( PCIX0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_DEVICEID );
  244. out16r( PCIX0_CMD, in16r(PCIX0_CMD) | PCI_COMMAND_MEMORY );
  245. }
  246. #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) */
  247. /*************************************************************************
  248. * is_pci_host
  249. *
  250. * This routine is called to determine if a pci scan should be
  251. * performed. With various hardware environments (especially cPCI and
  252. * PPMC) it's insufficient to depend on the state of the arbiter enable
  253. * bit in the strap register, or generic host/adapter assumptions.
  254. *
  255. * Rather than hard-code a bad assumption in the general 440 code, the
  256. * 440 pci code requires the board to decide at runtime.
  257. *
  258. * Return 0 for adapter mode, non-zero for host (monarch) mode.
  259. *
  260. *
  261. ************************************************************************/
  262. #if defined(CONFIG_PCI)
  263. int is_pci_host(struct pci_controller *hose)
  264. {
  265. /* The ocotea board is always configured as host. */
  266. return(1);
  267. }
  268. #endif /* defined(CONFIG_PCI) */
  269. #ifdef CONFIG_POST
  270. /*
  271. * Returns 1 if keys pressed to start the power-on long-running tests
  272. * Called from board_init_f().
  273. */
  274. int post_hotkeys_pressed(void)
  275. {
  276. return (ctrlc());
  277. }
  278. #endif
  279. int board_eth_init(bd_t *bis)
  280. {
  281. cpu_eth_init(bis);
  282. return pci_eth_init(bis);
  283. }