compactcenter.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*
  2. * (C) Copyright 2009
  3. * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de
  4. *
  5. * Based on board/amcc/canyonlands/canyonlands.c
  6. * (C) Copyright 2008
  7. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <ppc440.h>
  26. #include <libfdt.h>
  27. #include <fdt_support.h>
  28. #include <i2c.h>
  29. #include <asm/processor.h>
  30. #include <asm/io.h>
  31. #include <asm/mmu.h>
  32. #include <asm/4xx_pcie.h>
  33. #include <asm/gpio.h>
  34. extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
  35. DECLARE_GLOBAL_DATA_PTR;
  36. #define CONFIG_SYS_BCSR3_PCIE 0x10
  37. int board_early_init_f(void)
  38. {
  39. u32 pvr = get_pvr();
  40. /*
  41. * Setup the interrupt controller polarities, triggers, etc.
  42. */
  43. mtdcr(uic0sr, 0xffffffff); /* clear all */
  44. mtdcr(uic0er, 0x00000000); /* disable all */
  45. mtdcr(uic0cr, 0x00000005); /* ATI & UIC1 crit are critical */
  46. mtdcr(uic0pr, 0xffffffff); /* per ref-board manual */
  47. mtdcr(uic0tr, 0x00000000); /* per ref-board manual */
  48. mtdcr(uic0vr, 0x00000000); /* int31 highest, base=0x000 */
  49. mtdcr(uic0sr, 0xffffffff); /* clear all */
  50. mtdcr(uic1sr, 0xffffffff); /* clear all */
  51. mtdcr(uic1er, 0x00000000); /* disable all */
  52. mtdcr(uic1cr, 0x00000000); /* all non-critical */
  53. mtdcr(uic1pr, 0xffffffff); /* per ref-board manual */
  54. mtdcr(uic1tr, 0x00000000); /* per ref-board manual */
  55. mtdcr(uic1vr, 0x00000000); /* int31 highest, base=0x000 */
  56. mtdcr(uic1sr, 0xffffffff); /* clear all */
  57. mtdcr(uic2sr, 0xffffffff); /* clear all */
  58. mtdcr(uic2er, 0x00000000); /* disable all */
  59. mtdcr(uic2cr, 0x00000000); /* all non-critical */
  60. mtdcr(uic2pr, 0xffffffff); /* per ref-board manual */
  61. mtdcr(uic2tr, 0x00000000); /* per ref-board manual */
  62. mtdcr(uic2vr, 0x00000000); /* int31 highest, base=0x000 */
  63. mtdcr(uic2sr, 0xffffffff); /* clear all */
  64. mtdcr(uic3sr, 0xffffffff); /* clear all */
  65. mtdcr(uic3er, 0x00000000); /* disable all */
  66. mtdcr(uic3cr, 0x00000000); /* all non-critical */
  67. mtdcr(uic3pr, 0xffffffff); /* per ref-board manual */
  68. mtdcr(uic3tr, 0x00000000); /* per ref-board manual */
  69. mtdcr(uic3vr, 0x00000000); /* int31 highest, base=0x000 */
  70. mtdcr(uic3sr, 0xffffffff); /* clear all */
  71. /*
  72. * Configure PFC (Pin Function Control) registers
  73. * enable GPIO 49-63
  74. * UART0: 4 pins
  75. */
  76. mtsdr(SDR0_PFC0, 0x00007fff);
  77. mtsdr(SDR0_PFC1, 0x00040000);
  78. /* Enable PCI host functionality in SDR0_PCI0 */
  79. mtsdr(SDR0_PCI0, 0xe0000000);
  80. mtsdr(SDR0_SRST1, 0); /* Pull AHB out of reset default=1 */
  81. /* Setup PLB4-AHB bridge based on the system address map */
  82. mtdcr(AHB_TOP, 0x8000004B);
  83. mtdcr(AHB_BOT, 0x8000004B);
  84. if ((pvr == PVR_460EX_RA) || (pvr == PVR_460EX_SE_RA)) {
  85. /*
  86. * Configure USB-STP pins as alternate and not GPIO
  87. * It seems to be neccessary to configure the STP pins as GPIO
  88. * input at powerup (perhaps while USB reset is asserted). So
  89. * we configure those pins to their "real" function now.
  90. */
  91. gpio_config(16, GPIO_OUT, GPIO_ALT1, GPIO_OUT_1);
  92. gpio_config(19, GPIO_OUT, GPIO_ALT1, GPIO_OUT_1);
  93. }
  94. /* Trigger board component reset */
  95. out_le16((void *)CONFIG_SYS_IO_BASE, 0xffff);
  96. out_le16((void *)CONFIG_SYS_IO_BASE + 0x100, 0xffff);
  97. udelay(50);
  98. out_le16((void *)CONFIG_SYS_IO_BASE, 0xffbf);
  99. out_le16((void *)CONFIG_SYS_IO_BASE + 0x100, 0xffbf);
  100. udelay(50);
  101. out_le16((void *)CONFIG_SYS_IO_BASE, 0xffff);
  102. out_le16((void *)CONFIG_SYS_IO_BASE + 0x100, 0xffff);
  103. return 0;
  104. }
  105. int get_cpu_num(void)
  106. {
  107. int cpu = NA_OR_UNKNOWN_CPU;
  108. return cpu;
  109. }
  110. int checkboard(void)
  111. {
  112. char *s = getenv("serial#");
  113. #ifdef CONFIG_DEVCONCENTER
  114. printf("Board: DevCon-Center");
  115. #else
  116. printf("Board: CompactCenter");
  117. #endif
  118. if (s != NULL) {
  119. puts(", serial# ");
  120. puts(s);
  121. }
  122. putc('\n');
  123. return 0;
  124. }
  125. /*
  126. * pci_target_init
  127. *
  128. * The bootstrap configuration provides default settings for the pci
  129. * inbound map (PIM). But the bootstrap config choices are limited and
  130. * may not be sufficient for a given board.
  131. */
  132. #if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT)
  133. void pci_target_init(struct pci_controller *hose)
  134. {
  135. /*
  136. * Disable everything
  137. */
  138. out_le32((void *)PCIX0_PIM0SA, 0); /* disable */
  139. out_le32((void *)PCIX0_PIM1SA, 0); /* disable */
  140. out_le32((void *)PCIX0_PIM2SA, 0); /* disable */
  141. out_le32((void *)PCIX0_EROMBA, 0); /* disable expansion rom */
  142. /*
  143. * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440
  144. * strapping options to not support sizes such as 128/256 MB.
  145. */
  146. out_le32((void *)PCIX0_PIM0LAL, CONFIG_SYS_SDRAM_BASE);
  147. out_le32((void *)PCIX0_PIM0LAH, 0);
  148. out_le32((void *)PCIX0_PIM0SA, ~(gd->ram_size - 1) | 1);
  149. out_le32((void *)PCIX0_BAR0, 0);
  150. /*
  151. * Program the board's subsystem id/vendor id
  152. */
  153. out_le16((void *)PCIX0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID);
  154. out_le16((void *)PCIX0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
  155. out_le16((void *)PCIX0_CMD, in16r(PCIX0_CMD) | PCI_COMMAND_MEMORY);
  156. }
  157. #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) */
  158. #if defined(CONFIG_PCI)
  159. /*
  160. * is_pci_host
  161. *
  162. * This routine is called to determine if a pci scan should be
  163. * performed. With various hardware environments (especially cPCI and
  164. * PPMC) it's insufficient to depend on the state of the arbiter enable
  165. * bit in the strap register, or generic host/adapter assumptions.
  166. *
  167. * Rather than hard-code a bad assumption in the general 440 code, the
  168. * 440 pci code requires the board to decide at runtime.
  169. *
  170. * Return 0 for adapter mode, non-zero for host (monarch) mode.
  171. */
  172. int is_pci_host(struct pci_controller *hose)
  173. {
  174. /* Board is always configured as host. */
  175. return 1;
  176. }
  177. #endif /* CONFIG_PCI */
  178. int board_early_init_r(void)
  179. {
  180. /*
  181. * CompactCenter has 64MBytes, DevCon-Center 128MBytes of NOR FLASH
  182. * (Spansion 29GL512), but the boot EBC mapping only supports a maximum
  183. * of 16MBytes (4.ff00.0000 - 4.ffff.ffff).
  184. * To solve this problem, the FLASH has to get remapped to another
  185. * EBC address which accepts bigger regions:
  186. *
  187. * 0xfn00.0000 -> 4.cn00.0000
  188. */
  189. u32 bxcr_bw = (CONFIG_SYS_FLASH_SIZE == 128 << 20) ?
  190. EBC_BXCR_BS_128MB : EBC_BXCR_BS_64MB;
  191. /* Remap the NOR FLASH to 0xcn00.0000 ... 0xcfff.ffff */
  192. mtebc(pb0cr, CONFIG_SYS_FLASH_BASE_PHYS_L
  193. | bxcr_bw
  194. | EBC_BXCR_BU_RW
  195. | EBC_BXCR_BW_16BIT);
  196. /* Remove TLB entry of boot EBC mapping */
  197. remove_tlb(CONFIG_SYS_BOOT_BASE_ADDR, 16 << 20);
  198. /* Add TLB entry for 0xfn00.0000 -> 0x4.cn00.0000 */
  199. program_tlb(CONFIG_SYS_FLASH_BASE_PHYS, CONFIG_SYS_FLASH_BASE,
  200. CONFIG_SYS_FLASH_SIZE, TLB_WORD2_I_ENABLE);
  201. /*
  202. * Now accessing of the whole 64Mbytes of NOR FLASH at virtual address
  203. * 0xfc00.0000 is possible
  204. */
  205. /*
  206. * Clear potential errors resulting from auto-calibration.
  207. * If not done, then we could get an interrupt later on when
  208. * exceptions are enabled.
  209. */
  210. set_mcsr(get_mcsr());
  211. return 0;
  212. }
  213. int misc_init_r(void)
  214. {
  215. u32 sdr0_srst1 = 0;
  216. u32 eth_cfg;
  217. u32 pvr = get_pvr();
  218. /*
  219. * Set EMAC mode/configuration (GMII, SGMII, RGMII...).
  220. * This is board specific, so let's do it here.
  221. */
  222. mfsdr(SDR0_ETH_CFG, eth_cfg);
  223. /* disable SGMII mode */
  224. eth_cfg &= ~(SDR0_ETH_CFG_SGMII2_ENABLE |
  225. SDR0_ETH_CFG_SGMII1_ENABLE |
  226. SDR0_ETH_CFG_SGMII0_ENABLE);
  227. /* Set the for 2 RGMII mode */
  228. /* GMC0 EMAC4_0, GMC0 EMAC4_1, RGMII Bridge 0 */
  229. eth_cfg &= ~SDR0_ETH_CFG_GMC0_BRIDGE_SEL;
  230. if ((pvr == PVR_460EX_RA) || (pvr == PVR_460EX_SE_RA))
  231. eth_cfg |= SDR0_ETH_CFG_GMC1_BRIDGE_SEL;
  232. else
  233. eth_cfg &= ~SDR0_ETH_CFG_GMC1_BRIDGE_SEL;
  234. mtsdr(SDR0_ETH_CFG, eth_cfg);
  235. /*
  236. * The AHB Bridge core is held in reset after power-on or reset
  237. * so enable it now
  238. */
  239. mfsdr(SDR0_SRST1, sdr0_srst1);
  240. sdr0_srst1 &= ~SDR0_SRST1_AHB;
  241. mtsdr(SDR0_SRST1, sdr0_srst1);
  242. return 0;
  243. }
  244. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
  245. extern void __ft_board_setup(void *blob, bd_t *bd);
  246. void ft_board_setup(void *blob, bd_t *bd)
  247. {
  248. __ft_board_setup(blob, bd);
  249. fdt_find_and_setprop(blob, "/plb/pciex@d00000000", "status",
  250. "disabled", sizeof("disabled"), 1);
  251. fdt_find_and_setprop(blob, "/plb/sata@bffd1000", "status",
  252. "disabled", sizeof("disabled"), 1);
  253. }
  254. #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */