intip.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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 <asm/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/ppc4xx-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. /*
  40. * Setup the interrupt controller polarities, triggers, etc.
  41. */
  42. mtdcr(UIC0SR, 0xffffffff); /* clear all */
  43. mtdcr(UIC0ER, 0x00000000); /* disable all */
  44. mtdcr(UIC0CR, 0x00000005); /* ATI & UIC1 crit are critical */
  45. mtdcr(UIC0PR, 0xffffffff); /* per ref-board manual */
  46. mtdcr(UIC0TR, 0x00000000); /* per ref-board manual */
  47. mtdcr(UIC0VR, 0x00000000); /* int31 highest, base=0x000 */
  48. mtdcr(UIC0SR, 0xffffffff); /* clear all */
  49. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  50. mtdcr(UIC1ER, 0x00000000); /* disable all */
  51. mtdcr(UIC1CR, 0x00000000); /* all non-critical */
  52. mtdcr(UIC1PR, 0xffffffff); /* per ref-board manual */
  53. mtdcr(UIC1TR, 0x00000000); /* per ref-board manual */
  54. mtdcr(UIC1VR, 0x00000000); /* int31 highest, base=0x000 */
  55. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  56. mtdcr(UIC2SR, 0xffffffff); /* clear all */
  57. mtdcr(UIC2ER, 0x00000000); /* disable all */
  58. mtdcr(UIC2CR, 0x00000000); /* all non-critical */
  59. mtdcr(UIC2PR, 0xffffffff); /* per ref-board manual */
  60. mtdcr(UIC2TR, 0x00000000); /* per ref-board manual */
  61. mtdcr(UIC2VR, 0x00000000); /* int31 highest, base=0x000 */
  62. mtdcr(UIC2SR, 0xffffffff); /* clear all */
  63. mtdcr(UIC3SR, 0xffffffff); /* clear all */
  64. mtdcr(UIC3ER, 0x00000000); /* disable all */
  65. mtdcr(UIC3CR, 0x00000000); /* all non-critical */
  66. mtdcr(UIC3PR, 0xffffffff); /* per ref-board manual */
  67. mtdcr(UIC3TR, 0x00000000); /* per ref-board manual */
  68. mtdcr(UIC3VR, 0x00000000); /* int31 highest, base=0x000 */
  69. mtdcr(UIC3SR, 0xffffffff); /* clear all */
  70. /*
  71. * Configure PFC (Pin Function Control) registers
  72. * enable GPIO 49-63
  73. * UART0: 4 pins
  74. */
  75. mtsdr(SDR0_PFC0, 0x00007fff);
  76. mtsdr(SDR0_PFC1, 0x00040000);
  77. /* Enable PCI host functionality in SDR0_PCI0 */
  78. mtsdr(SDR0_PCI0, 0xe0000000);
  79. mtsdr(SDR0_SRST1, 0); /* Pull AHB out of reset default=1 */
  80. /* Setup PLB4-AHB bridge based on the system address map */
  81. mtdcr(AHB_TOP, 0x8000004B);
  82. mtdcr(AHB_BOT, 0x8000004B);
  83. /*
  84. * Configure USB-STP pins as alternate and not GPIO
  85. * It seems to be neccessary to configure the STP pins as GPIO
  86. * input at powerup (perhaps while USB reset is asserted). So
  87. * we configure those pins to their "real" function now.
  88. */
  89. gpio_config(16, GPIO_OUT, GPIO_ALT1, GPIO_OUT_1);
  90. gpio_config(19, GPIO_OUT, GPIO_ALT1, GPIO_OUT_1);
  91. /* Trigger board component reset */
  92. out_le16((void *)CONFIG_SYS_IO_BASE, 0xffff);
  93. out_le16((void *)CONFIG_SYS_IO_BASE + 0x100, 0xffff);
  94. udelay(50);
  95. out_le16((void *)CONFIG_SYS_IO_BASE, 0xffbf);
  96. out_le16((void *)CONFIG_SYS_IO_BASE + 0x100, 0xffbf);
  97. udelay(50);
  98. out_le16((void *)CONFIG_SYS_IO_BASE, 0xffff);
  99. out_le16((void *)CONFIG_SYS_IO_BASE + 0x100, 0xffff);
  100. return 0;
  101. }
  102. int get_cpu_num(void)
  103. {
  104. int cpu = NA_OR_UNKNOWN_CPU;
  105. return cpu;
  106. }
  107. int checkboard(void)
  108. {
  109. char *s = getenv("serial#");
  110. #ifdef CONFIG_DEVCONCENTER
  111. printf("Board: DevCon-Center");
  112. #else
  113. printf("Board: Intip");
  114. #endif
  115. if (s != NULL) {
  116. puts(", serial# ");
  117. puts(s);
  118. }
  119. putc('\n');
  120. return 0;
  121. }
  122. int board_early_init_r(void)
  123. {
  124. /*
  125. * CompactCenter has 64MBytes, DevCon-Center 128MBytes of NOR FLASH
  126. * (Spansion 29GL512), but the boot EBC mapping only supports a maximum
  127. * of 16MBytes (4.ff00.0000 - 4.ffff.ffff).
  128. * To solve this problem, the FLASH has to get remapped to another
  129. * EBC address which accepts bigger regions:
  130. *
  131. * 0xfn00.0000 -> 4.cn00.0000
  132. */
  133. u32 bxcr_bw = (CONFIG_SYS_FLASH_SIZE == 128 << 20) ?
  134. EBC_BXCR_BS_128MB : EBC_BXCR_BS_64MB;
  135. /* Remap the NOR FLASH to 0xcn00.0000 ... 0xcfff.ffff */
  136. mtebc(PB0CR, CONFIG_SYS_FLASH_BASE_PHYS_L
  137. | bxcr_bw
  138. | EBC_BXCR_BU_RW
  139. | EBC_BXCR_BW_16BIT);
  140. /* Remove TLB entry of boot EBC mapping */
  141. remove_tlb(CONFIG_SYS_BOOT_BASE_ADDR, 16 << 20);
  142. /* Add TLB entry for 0xfn00.0000 -> 0x4.cn00.0000 */
  143. program_tlb(CONFIG_SYS_FLASH_BASE_PHYS, CONFIG_SYS_FLASH_BASE,
  144. CONFIG_SYS_FLASH_SIZE, TLB_WORD2_I_ENABLE);
  145. /*
  146. * Now accessing of the whole 64Mbytes of NOR FLASH at virtual address
  147. * 0xfc00.0000 is possible
  148. */
  149. /*
  150. * Clear potential errors resulting from auto-calibration.
  151. * If not done, then we could get an interrupt later on when
  152. * exceptions are enabled.
  153. */
  154. set_mcsr(get_mcsr());
  155. return 0;
  156. }
  157. int misc_init_r(void)
  158. {
  159. u32 sdr0_srst1 = 0;
  160. u32 eth_cfg;
  161. /*
  162. * Set EMAC mode/configuration (GMII, SGMII, RGMII...).
  163. * This is board specific, so let's do it here.
  164. */
  165. mfsdr(SDR0_ETH_CFG, eth_cfg);
  166. /* disable SGMII mode */
  167. eth_cfg &= ~(SDR0_ETH_CFG_SGMII2_ENABLE |
  168. SDR0_ETH_CFG_SGMII1_ENABLE |
  169. SDR0_ETH_CFG_SGMII0_ENABLE);
  170. /* Set the for 2 RGMII mode */
  171. /* GMC0 EMAC4_0, GMC0 EMAC4_1, RGMII Bridge 0 */
  172. eth_cfg &= ~SDR0_ETH_CFG_GMC0_BRIDGE_SEL;
  173. eth_cfg |= SDR0_ETH_CFG_GMC1_BRIDGE_SEL;
  174. mtsdr(SDR0_ETH_CFG, eth_cfg);
  175. /*
  176. * The AHB Bridge core is held in reset after power-on or reset
  177. * so enable it now
  178. */
  179. mfsdr(SDR0_SRST1, sdr0_srst1);
  180. sdr0_srst1 &= ~SDR0_SRST1_AHB;
  181. mtsdr(SDR0_SRST1, sdr0_srst1);
  182. return 0;
  183. }
  184. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
  185. extern void __ft_board_setup(void *blob, bd_t *bd);
  186. void ft_board_setup(void *blob, bd_t *bd)
  187. {
  188. __ft_board_setup(blob, bd);
  189. fdt_find_and_setprop(blob, "/plb/pciex@d00000000", "status",
  190. "disabled", sizeof("disabled"), 1);
  191. fdt_find_and_setprop(blob, "/plb/sata@bffd1000", "status",
  192. "disabled", sizeof("disabled"), 1);
  193. }
  194. #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */