taishan.c 11 KB

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