intip.c 5.9 KB

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