t3corp.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * (C) Copyright 2010
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  18. * MA 02111-1307 USA
  19. */
  20. #include <common.h>
  21. #include <asm/ppc440.h>
  22. #include <libfdt.h>
  23. #include <fdt_support.h>
  24. #include <i2c.h>
  25. #include <asm/processor.h>
  26. #include <asm/io.h>
  27. #include <asm/mmu.h>
  28. #include <asm/4xx_pcie.h>
  29. #include <asm/ppc4xx-gpio.h>
  30. int board_early_init_f(void)
  31. {
  32. /*
  33. * Setup the interrupt controller polarities, triggers, etc.
  34. */
  35. mtdcr(UIC0SR, 0xffffffff); /* clear all */
  36. mtdcr(UIC0ER, 0x00000000); /* disable all */
  37. mtdcr(UIC0CR, 0x00000005); /* ATI & UIC1 crit are critical */
  38. mtdcr(UIC0PR, 0xffffffff); /* per ref-board manual */
  39. mtdcr(UIC0TR, 0x00000000); /* per ref-board manual */
  40. mtdcr(UIC0VR, 0x00000000); /* int31 highest, base=0x000 */
  41. mtdcr(UIC0SR, 0xffffffff); /* clear all */
  42. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  43. mtdcr(UIC1ER, 0x00000000); /* disable all */
  44. mtdcr(UIC1CR, 0x00000000); /* all non-critical */
  45. mtdcr(UIC1PR, 0x7fffffff); /* per ref-board manual */
  46. mtdcr(UIC1TR, 0x00000000); /* per ref-board manual */
  47. mtdcr(UIC1VR, 0x00000000); /* int31 highest, base=0x000 */
  48. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  49. mtdcr(UIC2SR, 0xffffffff); /* clear all */
  50. mtdcr(UIC2ER, 0x00000000); /* disable all */
  51. mtdcr(UIC2CR, 0x00000000); /* all non-critical */
  52. mtdcr(UIC2PR, 0xffffffff); /* per ref-board manual */
  53. mtdcr(UIC2TR, 0x00000000); /* per ref-board manual */
  54. mtdcr(UIC2VR, 0x00000000); /* int31 highest, base=0x000 */
  55. mtdcr(UIC2SR, 0xffffffff); /* clear all */
  56. mtdcr(UIC3SR, 0xffffffff); /* clear all */
  57. mtdcr(UIC3ER, 0x00000000); /* disable all */
  58. mtdcr(UIC3CR, 0x00000000); /* all non-critical */
  59. mtdcr(UIC3PR, 0xffffffff); /* per ref-board manual */
  60. mtdcr(UIC3TR, 0x00000000); /* per ref-board manual */
  61. mtdcr(UIC3VR, 0x00000000); /* int31 highest, base=0x000 */
  62. mtdcr(UIC3SR, 0xffffffff); /* clear all */
  63. /*
  64. * Configure PFC (Pin Function Control) registers
  65. * enable GPIO 49-63
  66. * UART0: 4 pins
  67. */
  68. mtsdr(SDR0_PFC0, 0x00007fff);
  69. mtsdr(SDR0_PFC1, 0x00040000);
  70. /* Enable PCI host functionality in SDR0_PCI0 */
  71. mtsdr(SDR0_PCI0, 0xe0000000);
  72. mtsdr(SDR0_SRST1, 0); /* Pull AHB out of reset default=1 */
  73. /* Setup PLB4-AHB bridge based on the system address map */
  74. mtdcr(AHB_TOP, 0x8000004B);
  75. mtdcr(AHB_BOT, 0x8000004B);
  76. return 0;
  77. }
  78. int checkboard(void)
  79. {
  80. char *s = getenv("serial#");
  81. printf("Board: T3CORP");
  82. if (s != NULL) {
  83. puts(", serial# ");
  84. puts(s);
  85. }
  86. putc('\n');
  87. return 0;
  88. }
  89. int board_early_init_r(void)
  90. {
  91. /*
  92. * T3CORP has 64MBytes of NOR flash (Spansion 29GL512), but the
  93. * boot EBC mapping only supports a maximum of 16MBytes
  94. * (4.ff00.0000 - 4.ffff.ffff).
  95. * To solve this problem, the flash has to get remapped to another
  96. * EBC address which accepts bigger regions:
  97. *
  98. * 0xfn00.0000 -> 4.cn00.0000
  99. */
  100. /* Remap the NOR flash to 0xcn00.0000 ... 0xcfff.ffff */
  101. mtebc(PB0CR, CONFIG_SYS_FLASH_BASE_PHYS_L | EBC_BXCR_BS_64MB |
  102. EBC_BXCR_BU_RW | EBC_BXCR_BW_16BIT);
  103. /* Remove TLB entry of boot EBC mapping */
  104. remove_tlb(CONFIG_SYS_BOOT_BASE_ADDR, 16 << 20);
  105. /* Add TLB entry for 0xfn00.0000 -> 0x4.cn00.0000 */
  106. program_tlb(CONFIG_SYS_FLASH_BASE_PHYS, CONFIG_SYS_FLASH_BASE,
  107. CONFIG_SYS_FLASH_SIZE, TLB_WORD2_I_ENABLE);
  108. /*
  109. * Now accessing of the whole 64Mbytes of NOR flash at virtual address
  110. * 0xfc00.0000 is possible
  111. */
  112. /*
  113. * Clear potential errors resulting from auto-calibration.
  114. * If not done, then we could get an interrupt later on when
  115. * exceptions are enabled.
  116. */
  117. set_mcsr(get_mcsr());
  118. return 0;
  119. }
  120. int misc_init_r(void)
  121. {
  122. u32 sdr0_srst1 = 0;
  123. u32 eth_cfg;
  124. /*
  125. * Set EMAC mode/configuration (GMII, SGMII, RGMII...).
  126. * This is board specific, so let's do it here.
  127. */
  128. mfsdr(SDR0_ETH_CFG, eth_cfg);
  129. /* disable SGMII mode */
  130. eth_cfg &= ~(SDR0_ETH_CFG_SGMII2_ENABLE |
  131. SDR0_ETH_CFG_SGMII1_ENABLE |
  132. SDR0_ETH_CFG_SGMII0_ENABLE);
  133. /* Set the for 2 RGMII mode */
  134. /* GMC0 EMAC4_0, GMC0 EMAC4_1, RGMII Bridge 0 */
  135. eth_cfg &= ~SDR0_ETH_CFG_GMC0_BRIDGE_SEL;
  136. eth_cfg &= ~SDR0_ETH_CFG_GMC1_BRIDGE_SEL;
  137. mtsdr(SDR0_ETH_CFG, eth_cfg);
  138. /*
  139. * The AHB Bridge core is held in reset after power-on or reset
  140. * so enable it now
  141. */
  142. mfsdr(SDR0_SRST1, sdr0_srst1);
  143. sdr0_srst1 &= ~SDR0_SRST1_AHB;
  144. mtsdr(SDR0_SRST1, sdr0_srst1);
  145. return 0;
  146. }
  147. int board_pcie_last(void)
  148. {
  149. /*
  150. * Only PCIe0 for now, PCIe1 hangs on this board
  151. */
  152. return 0;
  153. }
  154. /*
  155. * Board specific WRDTR and CLKTR values used by the auto-
  156. * calibration code (4xx_ibm_ddr2_autocalib.c).
  157. */
  158. static struct sdram_timing board_scan_options[] = {
  159. {1, 2},
  160. {-1, -1}
  161. };
  162. struct sdram_timing *ddr_scan_option(struct sdram_timing *default_val)
  163. {
  164. return board_scan_options;
  165. }