p1023rdb.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright 2013 Freescale Semiconductor, Inc.
  3. *
  4. * Authors: Roy Zang <tie-fei.zang@freescale.com>
  5. * Chunhe Lan <Chunhe.Lan@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. DECLARE_GLOBAL_DATA_PTR;
  46. int board_early_init_f(void)
  47. {
  48. fsl_lbc_t *lbc = LBC_BASE_ADDR;
  49. /* Set ABSWP to implement conversion of addresses in the LBC */
  50. setbits_be32(&lbc->lbcr, CONFIG_SYS_LBC_LBCR);
  51. return 0;
  52. }
  53. int checkboard(void)
  54. {
  55. printf("Board: P1023 RDB\n");
  56. return 0;
  57. }
  58. #ifdef CONFIG_PCI
  59. void pci_init_board(void)
  60. {
  61. fsl_pcie_init_board(0);
  62. }
  63. #endif
  64. int board_early_init_r(void)
  65. {
  66. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  67. const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
  68. /*
  69. * Remap Boot flash + PROMJET region to caching-inhibited
  70. * so that flash can be erased properly.
  71. */
  72. /* Flush d-cache and invalidate i-cache of any FLASH data */
  73. flush_dcache();
  74. invalidate_icache();
  75. /* invalidate existing TLB entry for flash + promjet */
  76. disable_tlb(flash_esel);
  77. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  78. MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  79. 0, flash_esel, BOOKE_PAGESZ_256M, 1);
  80. setup_portals();
  81. return 0;
  82. }
  83. unsigned long get_board_sys_clk(ulong dummy)
  84. {
  85. return gd->bus_clk;
  86. }
  87. unsigned long get_board_ddr_clk(ulong dummy)
  88. {
  89. return gd->mem_clk;
  90. }
  91. int board_eth_init(bd_t *bis)
  92. {
  93. ccsr_gur_t *gur = (ccsr_gur_t *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  94. struct fsl_pq_mdio_info dtsec_mdio_info;
  95. /*
  96. * Need to set dTSEC 1 pin multiplexing to TSEC. The default setting
  97. * is not correct.
  98. */
  99. setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_TSEC1_1);
  100. dtsec_mdio_info.regs =
  101. (struct tsec_mii_mng *)CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR;
  102. dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
  103. /* Register the 1G MDIO bus */
  104. fsl_pq_mdio_init(bis, &dtsec_mdio_info);
  105. fm_info_set_phy_address(FM1_DTSEC1, CONFIG_SYS_FM1_DTSEC1_PHY_ADDR);
  106. fm_info_set_phy_address(FM1_DTSEC2, CONFIG_SYS_FM1_DTSEC2_PHY_ADDR);
  107. fm_info_set_mdio(FM1_DTSEC1,
  108. miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
  109. fm_info_set_mdio(FM1_DTSEC2,
  110. miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
  111. #ifdef CONFIG_FMAN_ENET
  112. cpu_eth_init(bis);
  113. #endif
  114. return pci_eth_init(bis);
  115. }
  116. #if defined(CONFIG_OF_BOARD_SETUP)
  117. void ft_board_setup(void *blob, bd_t *bd)
  118. {
  119. phys_addr_t base;
  120. phys_size_t size;
  121. ft_cpu_setup(blob, bd);
  122. base = getenv_bootm_low();
  123. size = getenv_bootm_size();
  124. fdt_fixup_memory(blob, (u64)base, (u64)size);
  125. #ifdef CONFIG_HAS_FSL_DR_USB
  126. fdt_fixup_dr_usb(blob, bd);
  127. #endif
  128. fdt_fixup_fman_ethernet(blob);
  129. }
  130. #endif