p1023rds.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * Copyright 2010-2011 Freescale Semiconductor, Inc.
  3. *
  4. * Authors: Roy Zang <tie-fei.zang@freescale.com>
  5. * Chunhe Lan <b25806@freescale.com>
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <command.h>
  27. #include <pci.h>
  28. #include <asm/io.h>
  29. #include <asm/cache.h>
  30. #include <asm/processor.h>
  31. #include <asm/mmu.h>
  32. #include <asm/immap_85xx.h>
  33. #include <asm/fsl_pci.h>
  34. #include <asm/fsl_ddr_sdram.h>
  35. #include <asm/fsl_portals.h>
  36. #include <libfdt.h>
  37. #include <fdt_support.h>
  38. #include <netdev.h>
  39. #include <malloc.h>
  40. #include <fm_eth.h>
  41. #include <fsl_mdio.h>
  42. #include <miiphy.h>
  43. #include <phy.h>
  44. #include <asm/fsl_dtsec.h>
  45. #include "bcsr.h"
  46. DECLARE_GLOBAL_DATA_PTR;
  47. int board_early_init_f(void)
  48. {
  49. fsl_lbc_t *lbc = LBC_BASE_ADDR;
  50. /* Set ABSWP to implement conversion of addresses in the LBC */
  51. setbits_be32(&lbc->lbcr, CONFIG_SYS_LBC_LBCR);
  52. return 0;
  53. }
  54. int checkboard(void)
  55. {
  56. u8 *bcsr = (u8 *)BCSR_ACCESS_REG_ADDR;
  57. printf("Board: P1023 RDS\n");
  58. clrbits_8(&bcsr[15], BCSR15_I2C_BUS0_SEG_CLR);
  59. setbits_8(&bcsr[15], BCSR15_I2C_BUS0_SEG0);
  60. return 0;
  61. }
  62. /* Fixed sdram init -- doesn't use serial presence detect. */
  63. phys_size_t fixed_sdram(void)
  64. {
  65. #ifndef CONFIG_SYS_RAMBOOT
  66. ccsr_ddr_t *ddr = (ccsr_ddr_t *)CONFIG_SYS_MPC85xx_DDR_ADDR;
  67. set_next_law(0, LAW_SIZE_2G, LAW_TRGT_IF_DDR_1);
  68. out_be32(&ddr->cs0_bnds, CONFIG_SYS_DDR_CS0_BNDS);
  69. out_be32(&ddr->cs0_config, CONFIG_SYS_DDR_CS0_CONFIG);
  70. out_be32(&ddr->cs1_bnds, CONFIG_SYS_DDR_CS1_BNDS);
  71. out_be32(&ddr->cs1_config, CONFIG_SYS_DDR_CS1_CONFIG);
  72. out_be32(&ddr->timing_cfg_3, CONFIG_SYS_DDR_TIMING_3);
  73. out_be32(&ddr->timing_cfg_0, CONFIG_SYS_DDR_TIMING_0);
  74. out_be32(&ddr->timing_cfg_1, CONFIG_SYS_DDR_TIMING_1);
  75. out_be32(&ddr->timing_cfg_2, CONFIG_SYS_DDR_TIMING_2);
  76. out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_CONTROL2);
  77. out_be32(&ddr->sdram_mode, CONFIG_SYS_DDR_MODE_1);
  78. out_be32(&ddr->sdram_mode_2, CONFIG_SYS_DDR_MODE_2);
  79. out_be32(&ddr->sdram_interval, CONFIG_SYS_DDR_INTERVAL);
  80. out_be32(&ddr->sdram_data_init, CONFIG_SYS_DDR_DATA_INIT);
  81. out_be32(&ddr->sdram_clk_cntl, CONFIG_SYS_DDR_CLK_CTRL);
  82. out_be32(&ddr->timing_cfg_4, CONFIG_SYS_DDR_TIMING_4);
  83. out_be32(&ddr->timing_cfg_5, CONFIG_SYS_DDR_TIMING_5);
  84. out_be32(&ddr->ddr_zq_cntl, CONFIG_SYS_DDR_ZQ_CNTL);
  85. out_be32(&ddr->ddr_wrlvl_cntl, CONFIG_SYS_DDR_WRLVL_CNTL);
  86. out_be32(&ddr->ddr_cdr1, CONFIG_SYS_DDR_CDR_1);
  87. out_be32(&ddr->ddr_cdr2, CONFIG_SYS_DDR_CDR_2);
  88. out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_CONTROL);
  89. #endif
  90. return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024ul;
  91. }
  92. #ifdef CONFIG_PCI
  93. void pci_init_board(void)
  94. {
  95. fsl_pcie_init_board(0);
  96. }
  97. #endif
  98. int board_early_init_r(void)
  99. {
  100. const unsigned int flashbase = CONFIG_SYS_BCSR_BASE;
  101. const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
  102. /*
  103. * Remap Boot flash + BCSR region to caching-inhibited
  104. * so that flash can be erased properly.
  105. */
  106. /* Flush d-cache and invalidate i-cache of any FLASH data */
  107. flush_dcache();
  108. invalidate_icache();
  109. /* invalidate existing TLB entry for flash + bcsr */
  110. disable_tlb(flash_esel);
  111. set_tlb(1, flashbase, CONFIG_SYS_BCSR_BASE_PHYS,
  112. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  113. 0, flash_esel, BOOKE_PAGESZ_256M, 1);
  114. setup_portals();
  115. return 0;
  116. }
  117. unsigned long get_board_sys_clk(ulong dummy)
  118. {
  119. return gd->bus_clk;
  120. }
  121. unsigned long get_board_ddr_clk(ulong dummy)
  122. {
  123. return gd->mem_clk;
  124. }
  125. int board_eth_init(bd_t *bis)
  126. {
  127. u8 *bcsr = (u8 *)BCSR_ACCESS_REG_ADDR;
  128. ccsr_gur_t *gur = (ccsr_gur_t *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  129. struct fsl_pq_mdio_info dtsec_mdio_info;
  130. /*
  131. * Need to set dTSEC 1 pin multiplexing to TSEC. The default setting
  132. * is not correct.
  133. */
  134. setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_TSEC1_1);
  135. dtsec_mdio_info.regs =
  136. (struct tsec_mii_mng *)CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR;
  137. dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
  138. /* Register the 1G MDIO bus */
  139. fsl_pq_mdio_init(bis, &dtsec_mdio_info);
  140. fm_info_set_phy_address(FM1_DTSEC1, CONFIG_SYS_FM1_DTSEC1_PHY_ADDR);
  141. fm_info_set_phy_address(FM1_DTSEC2, CONFIG_SYS_FM1_DTSEC2_PHY_ADDR);
  142. fm_info_set_mdio(FM1_DTSEC1,
  143. miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
  144. fm_info_set_mdio(FM1_DTSEC2,
  145. miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
  146. /* Make SERDES connected to SGMII by cleaing bcsr19[7] */
  147. if (fm_info_get_enet_if(FM1_DTSEC1) == PHY_INTERFACE_MODE_SGMII)
  148. clrbits_8(&bcsr[19], BCSR19_SGMII_SEL_L);
  149. #ifdef CONFIG_FMAN_ENET
  150. cpu_eth_init(bis);
  151. #endif
  152. return pci_eth_init(bis);
  153. }
  154. #if defined(CONFIG_OF_BOARD_SETUP)
  155. void ft_board_setup(void *blob, bd_t *bd)
  156. {
  157. phys_addr_t base;
  158. phys_size_t size;
  159. ft_cpu_setup(blob, bd);
  160. base = getenv_bootm_low();
  161. size = getenv_bootm_size();
  162. fdt_fixup_memory(blob, (u64)base, (u64)size);
  163. /* By default NOR is on, and NAND is disabled */
  164. #ifdef CONFIG_NAND_U_BOOT
  165. do_fixup_by_path_string(blob, "nor_flash", "status", "disabled");
  166. do_fixup_by_path_string(blob, "nand_flash", "status", "okay");
  167. #endif
  168. fdt_fixup_fman_ethernet(blob);
  169. }
  170. #endif