xpedite1000.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * Copyright (C) 2003 Travis B. Sawyer <travis.sawyer@sandburst.com>
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <asm/processor.h>
  24. #include <spd_sdram.h>
  25. #include <i2c.h>
  26. #include <net.h>
  27. DECLARE_GLOBAL_DATA_PTR;
  28. int board_early_init_f(void)
  29. {
  30. unsigned long sdrreg;
  31. /*
  32. * Enable GPIO for pins 18 - 24
  33. * 18 = SEEPROM_WP
  34. * 19 = #M_RST
  35. * 20 = #MONARCH
  36. * 21 = #LED_ALARM
  37. * 22 = #LED_ACT
  38. * 23 = #LED_STATUS1
  39. * 24 = #LED_STATUS2
  40. */
  41. mfsdr(SDR0_PFC0, sdrreg);
  42. mtsdr(SDR0_PFC0, (sdrreg & ~SDR0_PFC0_TRE_ENABLE) | 0x00003e00);
  43. out32(CONFIG_SYS_GPIO_BASE + 0x018, (USR_LED0 | USR_LED1 | USR_LED2 | USR_LED3));
  44. LED0_OFF();
  45. LED1_OFF();
  46. LED2_OFF();
  47. LED3_OFF();
  48. /* Setup the external bus controller/chip selects */
  49. mtebc(PB0AP, 0x04055200); /* 16MB Strata FLASH */
  50. mtebc(PB0CR, 0xff098000); /* BAS=0xff0 16MB R/W 8-bit */
  51. mtebc(PB1AP, 0x04055200); /* 512KB Socketed AMD FLASH */
  52. mtebc(PB1CR, 0xfe018000); /* BAS=0xfe0 1MB R/W 8-bit */
  53. mtebc(PB6AP, 0x05006400); /* 32-64MB AMD MirrorBit FLASH */
  54. mtebc(PB6CR, 0xf00da000); /* BAS=0xf00 64MB R/W i6-bit */
  55. mtebc(PB7AP, 0x05006400); /* 32-64MB AMD MirrorBit FLASH */
  56. mtebc(PB7CR, 0xf40da000); /* BAS=0xf40 64MB R/W 16-bit */
  57. /*
  58. * Setup the interrupt controller polarities, triggers, etc.
  59. *
  60. * Because of the interrupt handling rework to handle 440GX interrupts
  61. * with the common code, we needed to change names of the UIC registers.
  62. * Here the new relationship:
  63. *
  64. * U-Boot name 440GX name
  65. * -----------------------
  66. * UIC0 UICB0
  67. * UIC1 UIC0
  68. * UIC2 UIC1
  69. * UIC3 UIC2
  70. */
  71. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  72. mtdcr(UIC1ER, 0x00000000); /* disable all */
  73. mtdcr(UIC1CR, 0x00000003); /* SMI & UIC1 crit are critical */
  74. mtdcr(UIC1PR, 0xfffffe00); /* per ref-board manual */
  75. mtdcr(UIC1TR, 0x01c00000); /* per ref-board manual */
  76. mtdcr(UIC1VR, 0x00000001); /* int31 highest, base=0x000 */
  77. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  78. mtdcr(UIC2SR, 0xffffffff); /* clear all */
  79. mtdcr(UIC2ER, 0x00000000); /* disable all */
  80. mtdcr(UIC2CR, 0x00000000); /* all non-critical */
  81. mtdcr(UIC2PR, 0xffffc0ff); /* per ref-board manual */
  82. mtdcr(UIC2TR, 0x00ff8000); /* per ref-board manual */
  83. mtdcr(UIC2VR, 0x00000001); /* int31 highest, base=0x000 */
  84. mtdcr(UIC2SR, 0xffffffff); /* clear all */
  85. mtdcr(UIC3SR, 0xffffffff); /* clear all */
  86. mtdcr(UIC3ER, 0x00000000); /* disable all */
  87. mtdcr(UIC3CR, 0x00000000); /* all non-critical */
  88. mtdcr(UIC3PR, 0xffffffff); /* per ref-board manual */
  89. mtdcr(UIC3TR, 0x00ff8c0f); /* per ref-board manual */
  90. mtdcr(UIC3VR, 0x00000001); /* int31 highest, base=0x000 */
  91. mtdcr(UIC3SR, 0xffffffff); /* clear all */
  92. mtdcr(UIC0SR, 0xfc000000); /* clear all */
  93. mtdcr(UIC0ER, 0x00000000); /* disable all */
  94. mtdcr(UIC0CR, 0x00000000); /* all non-critical */
  95. mtdcr(UIC0PR, 0xfc000000); /* */
  96. mtdcr(UIC0TR, 0x00000000); /* */
  97. mtdcr(UIC0VR, 0x00000001); /* */
  98. LED0_ON();
  99. return 0;
  100. }
  101. int checkboard(void)
  102. {
  103. char *s;
  104. printf("Board: X-ES %s PMC SBC\n", CONFIG_SYS_BOARD_NAME);
  105. printf(" ");
  106. s = getenv("board_rev");
  107. if (s)
  108. printf("Rev %s, ", s);
  109. s = getenv("serial#");
  110. if (s)
  111. printf("Serial# %s, ", s);
  112. s = getenv("board_cfg");
  113. if (s)
  114. printf("Cfg %s", s);
  115. printf("\n");
  116. return 0;
  117. }
  118. phys_size_t initdram(int board_type)
  119. {
  120. return spd_sdram();
  121. }
  122. /*
  123. * This routine is called just prior to registering the hose and gives
  124. * the board the opportunity to check things. Returning a value of zero
  125. * indicates that things are bad & PCI initialization should be aborted.
  126. *
  127. * Different boards may wish to customize the pci controller structure
  128. * (add regions, override default access routines, etc) or perform
  129. * certain pre-initialization actions.
  130. */
  131. #if defined(CONFIG_PCI)
  132. int pci_pre_init(struct pci_controller * hose)
  133. {
  134. unsigned long strap;
  135. /* See if we're supposed to setup the pci */
  136. mfsdr(SDR0_SDSTP1, strap);
  137. if ((strap & 0x00010000) == 0)
  138. return 0;
  139. #if defined(CONFIG_SYS_PCI_FORCE_PCI_CONV)
  140. /* Setup System Device Register PCIL0_XCR */
  141. mfsdr(SDR0_XCR, strap);
  142. strap &= 0x0f000000;
  143. mtsdr(SDR0_XCR, strap);
  144. #endif
  145. return 1;
  146. }
  147. #endif /* defined(CONFIG_PCI) */
  148. #if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT)
  149. /*
  150. * The bootstrap configuration provides default settings for the pci
  151. * inbound map (PIM). But the bootstrap config choices are limited and
  152. * may not be sufficient for a given board.
  153. */
  154. void pci_target_init(struct pci_controller * hose)
  155. {
  156. /* Disable everything */
  157. out32r(PCIL0_PIM0SA, 0);
  158. out32r(PCIL0_PIM1SA, 0);
  159. out32r(PCIL0_PIM2SA, 0);
  160. out32r(PCIL0_EROMBA, 0); /* disable expansion rom */
  161. /*
  162. * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440 strapping
  163. * options to not support sizes such as 128/256 MB.
  164. */
  165. out32r(PCIL0_PIM0LAL, CONFIG_SYS_SDRAM_BASE);
  166. out32r(PCIL0_PIM0LAH, 0);
  167. out32r(PCIL0_PIM0SA, ~(gd->ram_size - 1) | 1);
  168. out32r(PCIL0_BAR0, 0);
  169. /* Program the board's subsystem id/vendor id */
  170. out16r(PCIL0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID);
  171. out16r(PCIL0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
  172. out16r(PCIL0_CMD, in16r(PCIL0_CMD) | PCI_COMMAND_MEMORY);
  173. }
  174. #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) */
  175. #if defined(CONFIG_PCI)
  176. /*
  177. * This routine is called to determine if a pci scan should be
  178. * performed. With various hardware environments (especially cPCI and
  179. * PPMC) it's insufficient to depend on the state of the arbiter enable
  180. * bit in the strap register, or generic host/adapter assumptions.
  181. *
  182. * Rather than hard-code a bad assumption in the general 440 code, the
  183. * 440 pci code requires the board to decide at runtime.
  184. *
  185. * Return 0 for adapter mode, non-zero for host (monarch) mode.
  186. */
  187. int is_pci_host(struct pci_controller *hose)
  188. {
  189. return ((in32(CONFIG_SYS_GPIO_BASE + 0x1C) & 0x00000800) == 0);
  190. }
  191. #endif /* defined(CONFIG_PCI) */
  192. #ifdef CONFIG_POST
  193. /*
  194. * Returns 1 if keys pressed to start the power-on long-running tests
  195. * Called from board_init_f().
  196. */
  197. int post_hotkeys_pressed(void)
  198. {
  199. return ctrlc();
  200. }
  201. void post_word_store(ulong a)
  202. {
  203. volatile ulong *save_addr =
  204. (volatile ulong *)(CONFIG_SYS_POST_WORD_ADDR);
  205. *save_addr = a;
  206. }
  207. ulong post_word_load(void)
  208. {
  209. volatile ulong *save_addr =
  210. (volatile ulong *)(CONFIG_SYS_POST_WORD_ADDR);
  211. return *save_addr;
  212. }
  213. #endif