taishan.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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(EBC0_CFG, 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(SDR0_PFC0,reg);
  152. reg |= 0x00300000;
  153. mtsdr(SDR0_PFC0,reg);
  154. mfsdr(SDR0_PFC1,reg);
  155. reg |= 0x00100000;
  156. mtsdr(SDR0_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(SDR0_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( PCIL0_PIM0SA, 0 ); /* disable */
  228. out32r( PCIL0_PIM1SA, 0 ); /* disable */
  229. out32r( PCIL0_PIM2SA, 0 ); /* disable */
  230. out32r( PCIL0_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( PCIL0_PIM0LAL, CONFIG_SYS_SDRAM_BASE );
  236. out32r( PCIL0_PIM0LAH, 0 );
  237. out32r( PCIL0_PIM0SA, ~(gd->ram_size - 1) | 1 );
  238. out32r( PCIL0_BAR0, 0 );
  239. /*--------------------------------------------------------------------------+
  240. * Program the board's subsystem id/vendor id
  241. *--------------------------------------------------------------------------*/
  242. out16r( PCIL0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID );
  243. out16r( PCIL0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_DEVICEID );
  244. out16r( PCIL0_CMD, in16r(PCIL0_CMD) | PCI_COMMAND_MEMORY );
  245. }
  246. #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) */
  247. #ifdef CONFIG_POST
  248. /*
  249. * Returns 1 if keys pressed to start the power-on long-running tests
  250. * Called from board_init_f().
  251. */
  252. int post_hotkeys_pressed(void)
  253. {
  254. return (ctrlc());
  255. }
  256. #endif
  257. int board_eth_init(bd_t *bis)
  258. {
  259. cpu_eth_init(bis);
  260. return pci_eth_init(bis);
  261. }