p1023rdb.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <command.h>
  11. #include <pci.h>
  12. #include <asm/io.h>
  13. #include <asm/cache.h>
  14. #include <asm/processor.h>
  15. #include <asm/mmu.h>
  16. #include <asm/immap_85xx.h>
  17. #include <asm/fsl_pci.h>
  18. #include <fsl_ddr_sdram.h>
  19. #include <asm/fsl_portals.h>
  20. #include <libfdt.h>
  21. #include <fdt_support.h>
  22. #include <netdev.h>
  23. #include <malloc.h>
  24. #include <fm_eth.h>
  25. #include <fsl_mdio.h>
  26. #include <miiphy.h>
  27. #include <phy.h>
  28. #include <fsl_dtsec.h>
  29. DECLARE_GLOBAL_DATA_PTR;
  30. int board_early_init_f(void)
  31. {
  32. fsl_lbc_t *lbc = LBC_BASE_ADDR;
  33. /* Set ABSWP to implement conversion of addresses in the LBC */
  34. setbits_be32(&lbc->lbcr, CONFIG_SYS_LBC_LBCR);
  35. return 0;
  36. }
  37. int checkboard(void)
  38. {
  39. printf("Board: P1023 RDB\n");
  40. return 0;
  41. }
  42. #ifdef CONFIG_PCI
  43. void pci_init_board(void)
  44. {
  45. fsl_pcie_init_board(0);
  46. }
  47. #endif
  48. int board_early_init_r(void)
  49. {
  50. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  51. int flash_esel = find_tlb_idx((void *)flashbase, 1);
  52. /*
  53. * Remap Boot flash + PROMJET region to caching-inhibited
  54. * so that flash can be erased properly.
  55. */
  56. /* Flush d-cache and invalidate i-cache of any FLASH data */
  57. flush_dcache();
  58. invalidate_icache();
  59. if (flash_esel == -1) {
  60. /* very unlikely unless something is messed up */
  61. puts("Error: Could not find TLB for FLASH BASE\n");
  62. flash_esel = 2; /* give our best effort to continue */
  63. } else {
  64. /* invalidate existing TLB entry for flash + promjet */
  65. disable_tlb(flash_esel);
  66. }
  67. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  68. MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  69. 0, flash_esel, BOOKE_PAGESZ_256M, 1);
  70. setup_portals();
  71. return 0;
  72. }
  73. unsigned long get_board_sys_clk(ulong dummy)
  74. {
  75. return gd->bus_clk;
  76. }
  77. unsigned long get_board_ddr_clk(ulong dummy)
  78. {
  79. return gd->mem_clk;
  80. }
  81. int board_eth_init(bd_t *bis)
  82. {
  83. ccsr_gur_t *gur = (ccsr_gur_t *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  84. struct fsl_pq_mdio_info dtsec_mdio_info;
  85. /*
  86. * Need to set dTSEC 1 pin multiplexing to TSEC. The default setting
  87. * is not correct.
  88. */
  89. setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_TSEC1_1);
  90. dtsec_mdio_info.regs =
  91. (struct tsec_mii_mng *)CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR;
  92. dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
  93. /* Register the 1G MDIO bus */
  94. fsl_pq_mdio_init(bis, &dtsec_mdio_info);
  95. fm_info_set_phy_address(FM1_DTSEC1, CONFIG_SYS_FM1_DTSEC1_PHY_ADDR);
  96. fm_info_set_phy_address(FM1_DTSEC2, CONFIG_SYS_FM1_DTSEC2_PHY_ADDR);
  97. fm_info_set_mdio(FM1_DTSEC1,
  98. miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
  99. fm_info_set_mdio(FM1_DTSEC2,
  100. miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
  101. #ifdef CONFIG_FMAN_ENET
  102. cpu_eth_init(bis);
  103. #endif
  104. return pci_eth_init(bis);
  105. }
  106. #if defined(CONFIG_OF_BOARD_SETUP)
  107. int ft_board_setup(void *blob, bd_t *bd)
  108. {
  109. phys_addr_t base;
  110. phys_size_t size;
  111. ft_cpu_setup(blob, bd);
  112. base = getenv_bootm_low();
  113. size = getenv_bootm_size();
  114. fdt_fixup_memory(blob, (u64)base, (u64)size);
  115. #ifdef CONFIG_HAS_FSL_DR_USB
  116. fsl_fdt_fixup_dr_usb(blob, bd);
  117. #endif
  118. fdt_fixup_fman_ethernet(blob);
  119. return 0;
  120. }
  121. #endif