c29xpcie.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * Copyright 2013 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/processor.h>
  8. #include <asm/mmu.h>
  9. #include <asm/cache.h>
  10. #include <asm/immap_85xx.h>
  11. #include <asm/io.h>
  12. #include <miiphy.h>
  13. #include <libfdt.h>
  14. #include <fdt_support.h>
  15. #include <fsl_mdio.h>
  16. #include <tsec.h>
  17. #include <mmc.h>
  18. #include <netdev.h>
  19. #include <pci.h>
  20. #include <fsl_ifc.h>
  21. #include <asm/fsl_pci.h>
  22. #include "cpld.h"
  23. DECLARE_GLOBAL_DATA_PTR;
  24. int checkboard(void)
  25. {
  26. struct cpu_type *cpu = gd->arch.cpu;
  27. struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
  28. printf("Board: %sPCIe, ", cpu->name);
  29. printf("CPLD Ver: 0x%02x\n", in_8(&cpld_data->cpldver));
  30. return 0;
  31. }
  32. int board_early_init_f(void)
  33. {
  34. struct fsl_ifc ifc = {(void *)CONFIG_SYS_IFC_ADDR, (void *)NULL};
  35. /* Clock configuration to access CPLD using IFC(GPCM) */
  36. setbits_be32(&ifc.gregs->ifc_gcr, 1 << IFC_GCR_TBCTL_TRN_TIME_SHIFT);
  37. return 0;
  38. }
  39. int board_early_init_r(void)
  40. {
  41. const unsigned long flashbase = CONFIG_SYS_FLASH_BASE;
  42. int flash_esel = find_tlb_idx((void *)flashbase, 1);
  43. /*
  44. * Remap Boot flash region to caching-inhibited
  45. * so that flash can be erased properly.
  46. */
  47. /* Flush d-cache and invalidate i-cache of any FLASH data */
  48. flush_dcache();
  49. invalidate_icache();
  50. if (flash_esel == -1) {
  51. /* very unlikely unless something is messed up */
  52. puts("Error: Could not find TLB for FLASH BASE\n");
  53. flash_esel = 1; /* give our best effort to continue */
  54. } else {
  55. /* invalidate existing TLB entry for flash */
  56. disable_tlb(flash_esel);
  57. }
  58. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  59. MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  60. 0, flash_esel, BOOKE_PAGESZ_64M, 1);
  61. return 0;
  62. }
  63. #ifdef CONFIG_PCI
  64. void pci_init_board(void)
  65. {
  66. fsl_pcie_init_board(0);
  67. }
  68. #endif /* ifdef CONFIG_PCI */
  69. int board_eth_init(bd_t *bis)
  70. {
  71. #ifdef CONFIG_TSEC_ENET
  72. struct fsl_pq_mdio_info mdio_info;
  73. struct tsec_info_struct tsec_info[2];
  74. int num = 0;
  75. #ifdef CONFIG_TSEC1
  76. SET_STD_TSEC_INFO(tsec_info[num], 1);
  77. num++;
  78. #endif
  79. #ifdef CONFIG_TSEC2
  80. SET_STD_TSEC_INFO(tsec_info[num], 2);
  81. num++;
  82. #endif
  83. if (!num) {
  84. printf("No TSECs initialized\n");
  85. return 0;
  86. }
  87. /* Register 1G MDIO bus */
  88. mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
  89. mdio_info.name = DEFAULT_MII_NAME;
  90. fsl_pq_mdio_init(bis, &mdio_info);
  91. tsec_eth_init(bis, tsec_info, num);
  92. #endif
  93. return pci_eth_init(bis);
  94. }
  95. #if defined(CONFIG_OF_BOARD_SETUP)
  96. void fdt_del_sec(void *blob, int offset)
  97. {
  98. int nodeoff = 0;
  99. while ((nodeoff = fdt_node_offset_by_compat_reg(blob, "fsl,sec-v6.0",
  100. CONFIG_SYS_CCSRBAR_PHYS + CONFIG_SYS_FSL_SEC_OFFSET
  101. + offset * CONFIG_SYS_FSL_SEC_IDX_OFFSET)) >= 0) {
  102. fdt_del_node(blob, nodeoff);
  103. offset++;
  104. }
  105. }
  106. int ft_board_setup(void *blob, bd_t *bd)
  107. {
  108. phys_addr_t base;
  109. phys_size_t size;
  110. struct cpu_type *cpu;
  111. cpu = gd->arch.cpu;
  112. ft_cpu_setup(blob, bd);
  113. base = getenv_bootm_low();
  114. size = getenv_bootm_size();
  115. #if defined(CONFIG_PCI)
  116. FT_FSL_PCI_SETUP;
  117. #endif
  118. fdt_fixup_memory(blob, (u64)base, (u64)size);
  119. if (cpu->soc_ver == SVR_C291)
  120. fdt_del_sec(blob, 1);
  121. else if (cpu->soc_ver == SVR_C292)
  122. fdt_del_sec(blob, 2);
  123. return 0;
  124. }
  125. #endif