p1_p2_rdb.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. * Copyright 2009-2010 Freescale Semiconductor, Inc.
  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 <command.h>
  24. #include <asm/processor.h>
  25. #include <asm/mmu.h>
  26. #include <asm/cache.h>
  27. #include <asm/immap_85xx.h>
  28. #include <asm/io.h>
  29. #include <miiphy.h>
  30. #include <libfdt.h>
  31. #include <fdt_support.h>
  32. #include <tsec.h>
  33. #include <vsc7385.h>
  34. #include <netdev.h>
  35. #include <rtc.h>
  36. DECLARE_GLOBAL_DATA_PTR;
  37. #define VSC7385_RST_SET 0x00080000
  38. #define SLIC_RST_SET 0x00040000
  39. #define SGMII_PHY_RST_SET 0x00020000
  40. #define PCIE_RST_SET 0x00010000
  41. #define RGMII_PHY_RST_SET 0x02000000
  42. #define USB_RST_CLR 0x04000000
  43. #define GPIO_DIR 0x060f0000
  44. #define BOARD_PERI_RST_SET VSC7385_RST_SET | SLIC_RST_SET | \
  45. SGMII_PHY_RST_SET | PCIE_RST_SET | \
  46. RGMII_PHY_RST_SET
  47. #define SYSCLK_MASK 0x00200000
  48. #define BOARDREV_MASK 0x10100000
  49. #define BOARDREV_B 0x10100000
  50. #define BOARDREV_C 0x00100000
  51. #define BOARDREV_D 0x00000000
  52. #define SYSCLK_66 66666666
  53. #define SYSCLK_50 50000000
  54. #define SYSCLK_100 100000000
  55. unsigned long get_board_sys_clk(ulong dummy)
  56. {
  57. volatile ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
  58. u32 val_gpdat, sysclk_gpio, board_rev_gpio;
  59. val_gpdat = in_be32(&pgpio->gpdat);
  60. sysclk_gpio = val_gpdat & SYSCLK_MASK;
  61. board_rev_gpio = val_gpdat & BOARDREV_MASK;
  62. if (board_rev_gpio == BOARDREV_C) {
  63. if(sysclk_gpio == 0)
  64. return SYSCLK_66;
  65. else
  66. return SYSCLK_100;
  67. } else if (board_rev_gpio == BOARDREV_B) {
  68. if(sysclk_gpio == 0)
  69. return SYSCLK_66;
  70. else
  71. return SYSCLK_50;
  72. } else if (board_rev_gpio == BOARDREV_D) {
  73. if(sysclk_gpio == 0)
  74. return SYSCLK_66;
  75. else
  76. return SYSCLK_100;
  77. }
  78. return 0;
  79. }
  80. #ifdef CONFIG_MMC
  81. int board_early_init_f (void)
  82. {
  83. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  84. setbits_be32(&gur->pmuxcr,
  85. (MPC85xx_PMUXCR_SDHC_CD |
  86. MPC85xx_PMUXCR_SDHC_WP));
  87. return 0;
  88. }
  89. #endif
  90. int checkboard (void)
  91. {
  92. u32 val_gpdat, board_rev_gpio;
  93. volatile ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
  94. char board_rev = 0;
  95. struct cpu_type *cpu;
  96. val_gpdat = in_be32(&pgpio->gpdat);
  97. board_rev_gpio = val_gpdat & BOARDREV_MASK;
  98. if (board_rev_gpio == BOARDREV_C)
  99. board_rev = 'C';
  100. else if (board_rev_gpio == BOARDREV_B)
  101. board_rev = 'B';
  102. else if (board_rev_gpio == BOARDREV_D)
  103. board_rev = 'D';
  104. else
  105. panic ("Unexpected Board REV %x detected!!\n", board_rev_gpio);
  106. cpu = gd->cpu;
  107. printf ("Board: %sRDB Rev%c\n", cpu->name, board_rev);
  108. setbits_be32(&pgpio->gpdir, GPIO_DIR);
  109. /*
  110. * Bringing the following peripherals out of reset via GPIOs
  111. * 0 = reset and 1 = out of reset
  112. * GPIO12 - Reset to Ethernet Switch
  113. * GPIO13 - Reset to SLIC/SLAC devices
  114. * GPIO14 - Reset to SGMII_PHY_N
  115. * GPIO15 - Reset to PCIe slots
  116. * GPIO6 - Reset to RGMII PHY
  117. * GPIO5 - Reset to USB3300 devices 1 = reset and 0 = out of reset
  118. */
  119. clrsetbits_be32(&pgpio->gpdat, USB_RST_CLR, BOARD_PERI_RST_SET);
  120. return 0;
  121. }
  122. int board_early_init_r(void)
  123. {
  124. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  125. const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
  126. /*
  127. * Remap Boot flash region to caching-inhibited
  128. * so that flash can be erased properly.
  129. */
  130. /* Flush d-cache and invalidate i-cache of any FLASH data */
  131. flush_dcache();
  132. invalidate_icache();
  133. /* invalidate existing TLB entry for flash */
  134. disable_tlb(flash_esel);
  135. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  136. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  137. 0, flash_esel, BOOKE_PAGESZ_16M, 1);
  138. rtc_reset();
  139. return 0;
  140. }
  141. #ifdef CONFIG_TSEC_ENET
  142. int board_eth_init(bd_t *bis)
  143. {
  144. struct tsec_info_struct tsec_info[4];
  145. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  146. int num = 0;
  147. char *tmp;
  148. u32 pordevsr;
  149. unsigned int vscfw_addr;
  150. #ifdef CONFIG_TSEC1
  151. SET_STD_TSEC_INFO(tsec_info[num], 1);
  152. num++;
  153. #endif
  154. #ifdef CONFIG_TSEC2
  155. SET_STD_TSEC_INFO(tsec_info[num], 2);
  156. num++;
  157. #endif
  158. #ifdef CONFIG_TSEC3
  159. SET_STD_TSEC_INFO(tsec_info[num], 3);
  160. pordevsr = in_be32(&gur->pordevsr);
  161. if (!(pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS))
  162. tsec_info[num].flags |= TSEC_SGMII;
  163. num++;
  164. #endif
  165. if (!num) {
  166. printf("No TSECs initialized\n");
  167. return 0;
  168. }
  169. #ifdef CONFIG_VSC7385_ENET
  170. /* If a VSC7385 microcode image is present, then upload it. */
  171. if ((tmp = getenv ("vscfw_addr")) != NULL) {
  172. vscfw_addr = simple_strtoul (tmp, NULL, 16);
  173. printf("uploading VSC7385 microcode from %x\n", vscfw_addr);
  174. if (vsc7385_upload_firmware((void *) vscfw_addr,
  175. CONFIG_VSC7385_IMAGE_SIZE))
  176. puts("Failure uploading VSC7385 microcode.\n");
  177. } else
  178. puts("No address specified for VSC7385 microcode.\n");
  179. #endif
  180. tsec_eth_init(bis, tsec_info, num);
  181. return pci_eth_init(bis);
  182. }
  183. #endif
  184. #if defined(CONFIG_OF_BOARD_SETUP)
  185. extern void ft_pci_board_setup(void *blob);
  186. void ft_board_setup(void *blob, bd_t *bd)
  187. {
  188. phys_addr_t base;
  189. phys_size_t size;
  190. ft_cpu_setup(blob, bd);
  191. base = getenv_bootm_low();
  192. size = getenv_bootm_size();
  193. ft_pci_board_setup(blob);
  194. fdt_fixup_memory(blob, (u64)base, (u64)size);
  195. }
  196. #endif
  197. #ifdef CONFIG_MP
  198. extern void cpu_mp_lmb_reserve(struct lmb *lmb);
  199. void board_lmb_reserve(struct lmb *lmb)
  200. {
  201. cpu_mp_lmb_reserve(lmb);
  202. }
  203. #endif