t104xrdb.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2013 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <command.h>
  7. #include <env.h>
  8. #include <fdt_support.h>
  9. #include <hwconfig.h>
  10. #include <image.h>
  11. #include <init.h>
  12. #include <log.h>
  13. #include <netdev.h>
  14. #include <linux/compiler.h>
  15. #include <asm/mmu.h>
  16. #include <asm/processor.h>
  17. #include <asm/cache.h>
  18. #include <asm/immap_85xx.h>
  19. #include <asm/fsl_fdt.h>
  20. #include <asm/fsl_law.h>
  21. #include <asm/fsl_serdes.h>
  22. #include <asm/fsl_liodn.h>
  23. #include <fm_eth.h>
  24. #include "../common/sleep.h"
  25. #include "t104xrdb.h"
  26. #include "cpld.h"
  27. DECLARE_GLOBAL_DATA_PTR;
  28. int checkboard(void)
  29. {
  30. struct cpu_type *cpu = gd->arch.cpu;
  31. u8 sw;
  32. #if defined(CONFIG_TARGET_T1040D4RDB) || defined(CONFIG_TARGET_T1042D4RDB)
  33. printf("Board: %sD4RDB\n", cpu->name);
  34. #else
  35. printf("Board: %sRDB\n", cpu->name);
  36. #endif
  37. printf("Board rev: 0x%02x CPLD ver: 0x%02x, ",
  38. CPLD_READ(hw_ver), CPLD_READ(sw_ver));
  39. sw = CPLD_READ(flash_ctl_status);
  40. sw = ((sw & CPLD_LBMAP_MASK) >> CPLD_LBMAP_SHIFT);
  41. printf("vBank: %d\n", sw);
  42. return 0;
  43. }
  44. int board_early_init_f(void)
  45. {
  46. #if defined(CONFIG_DEEP_SLEEP)
  47. if (is_warm_boot())
  48. fsl_dp_disable_console();
  49. #endif
  50. return 0;
  51. }
  52. int board_early_init_r(void)
  53. {
  54. #ifdef CONFIG_SYS_FLASH_BASE
  55. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  56. int flash_esel = find_tlb_idx((void *)flashbase, 1);
  57. /*
  58. * Remap Boot flash region to caching-inhibited
  59. * so that flash can be erased properly.
  60. */
  61. /* Flush d-cache and invalidate i-cache of any FLASH data */
  62. flush_dcache();
  63. invalidate_icache();
  64. if (flash_esel == -1) {
  65. /* very unlikely unless something is messed up */
  66. puts("Error: Could not find TLB for FLASH BASE\n");
  67. flash_esel = 2; /* give our best effort to continue */
  68. } else {
  69. /* invalidate existing TLB entry for flash */
  70. disable_tlb(flash_esel);
  71. }
  72. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  73. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  74. 0, flash_esel, BOOKE_PAGESZ_256M, 1);
  75. #endif
  76. return 0;
  77. }
  78. int misc_init_r(void)
  79. {
  80. ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  81. u32 srds_s1;
  82. srds_s1 = in_be32(&gur->rcwsr[4]) >> 24;
  83. printf("SERDES Reference : 0x%X\n", srds_s1);
  84. /* select SGMII*/
  85. if (srds_s1 == 0x86)
  86. CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
  87. MISC_CTL_SG_SEL);
  88. /* select SGMII and Aurora*/
  89. if (srds_s1 == 0x8E)
  90. CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
  91. MISC_CTL_SG_SEL | MISC_CTL_AURORA_SEL);
  92. #if defined(CONFIG_TARGET_T1040D4RDB)
  93. if (hwconfig("qe-tdm")) {
  94. CPLD_WRITE(sfp_ctl_status, CPLD_READ(sfp_ctl_status) |
  95. MISC_MUX_QE_TDM);
  96. printf("QECSR : 0x%02x, mux to qe-tdm\n",
  97. CPLD_READ(sfp_ctl_status));
  98. }
  99. /* Mask all CPLD interrupt sources, except QSGMII interrupts */
  100. if (CPLD_READ(sw_ver) < 0x03) {
  101. debug("CPLD SW version 0x%02x doesn't support int_mask\n",
  102. CPLD_READ(sw_ver));
  103. } else {
  104. CPLD_WRITE(int_mask, CPLD_INT_MASK_ALL &
  105. ~(CPLD_INT_MASK_QSGMII1 | CPLD_INT_MASK_QSGMII2));
  106. }
  107. #endif
  108. return 0;
  109. }
  110. int ft_board_setup(void *blob, bd_t *bd)
  111. {
  112. phys_addr_t base;
  113. phys_size_t size;
  114. ft_cpu_setup(blob, bd);
  115. base = env_get_bootm_low();
  116. size = env_get_bootm_size();
  117. fdt_fixup_memory(blob, (u64)base, (u64)size);
  118. #ifdef CONFIG_PCI
  119. pci_of_setup(blob, bd);
  120. #endif
  121. fdt_fixup_liodn(blob);
  122. #ifdef CONFIG_HAS_FSL_DR_USB
  123. fsl_fdt_fixup_dr_usb(blob, bd);
  124. #endif
  125. #ifdef CONFIG_SYS_DPAA_FMAN
  126. #ifndef CONFIG_DM_ETH
  127. fdt_fixup_fman_ethernet(blob);
  128. #endif
  129. #endif
  130. if (hwconfig("qe-tdm"))
  131. fdt_del_diu(blob);
  132. return 0;
  133. }