p1_p2_rdb.c 6.1 KB

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