taishan.c 11 KB

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