t104xrdb.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright 2013 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <netdev.h>
  9. #include <linux/compiler.h>
  10. #include <asm/mmu.h>
  11. #include <asm/processor.h>
  12. #include <asm/cache.h>
  13. #include <asm/immap_85xx.h>
  14. #include <asm/fsl_law.h>
  15. #include <asm/fsl_serdes.h>
  16. #include <asm/fsl_portals.h>
  17. #include <asm/fsl_liodn.h>
  18. #include <fm_eth.h>
  19. #include "../common/sleep.h"
  20. #include "t104xrdb.h"
  21. #include "cpld.h"
  22. DECLARE_GLOBAL_DATA_PTR;
  23. int checkboard(void)
  24. {
  25. struct cpu_type *cpu = gd->arch.cpu;
  26. u8 sw;
  27. #ifdef CONFIG_T104XD4RDB
  28. printf("Board: %sD4RDB\n", cpu->name);
  29. #else
  30. printf("Board: %sRDB\n", cpu->name);
  31. #endif
  32. printf("Board rev: 0x%02x CPLD ver: 0x%02x, ",
  33. CPLD_READ(hw_ver), CPLD_READ(sw_ver));
  34. sw = CPLD_READ(flash_ctl_status);
  35. sw = ((sw & CPLD_LBMAP_MASK) >> CPLD_LBMAP_SHIFT);
  36. printf("vBank: %d\n", sw);
  37. return 0;
  38. }
  39. int board_early_init_f(void)
  40. {
  41. #if defined(CONFIG_DEEP_SLEEP)
  42. if (is_warm_boot())
  43. fsl_dp_disable_console();
  44. #endif
  45. return 0;
  46. }
  47. int board_early_init_r(void)
  48. {
  49. #ifdef CONFIG_SYS_FLASH_BASE
  50. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  51. int flash_esel = find_tlb_idx((void *)flashbase, 1);
  52. /*
  53. * Remap Boot flash 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 */
  65. disable_tlb(flash_esel);
  66. }
  67. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  68. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  69. 0, flash_esel, BOOKE_PAGESZ_256M, 1);
  70. #endif
  71. set_liodns();
  72. #ifdef CONFIG_SYS_DPAA_QBMAN
  73. setup_portals();
  74. #endif
  75. return 0;
  76. }
  77. int misc_init_r(void)
  78. {
  79. ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  80. u32 srds_s1;
  81. srds_s1 = in_be32(&gur->rcwsr[4]) >> 24;
  82. printf("SERDES Reference : 0x%X\n", srds_s1);
  83. /* select SGMII*/
  84. if (srds_s1 == 0x86)
  85. CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
  86. MISC_CTL_SG_SEL);
  87. /* select SGMII and Aurora*/
  88. if (srds_s1 == 0x8E)
  89. CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
  90. MISC_CTL_SG_SEL | MISC_CTL_AURORA_SEL);
  91. #if defined(CONFIG_T1040D4RDB)
  92. /* Mask all CPLD interrupt sources, except QSGMII interrupts */
  93. if (CPLD_READ(sw_ver) < 0x03) {
  94. debug("CPLD SW version 0x%02x doesn't support int_mask\n",
  95. CPLD_READ(sw_ver));
  96. } else {
  97. CPLD_WRITE(int_mask, CPLD_INT_MASK_ALL &
  98. ~(CPLD_INT_MASK_QSGMII1 | CPLD_INT_MASK_QSGMII2));
  99. }
  100. #endif
  101. return 0;
  102. }
  103. int ft_board_setup(void *blob, bd_t *bd)
  104. {
  105. phys_addr_t base;
  106. phys_size_t size;
  107. ft_cpu_setup(blob, bd);
  108. base = getenv_bootm_low();
  109. size = getenv_bootm_size();
  110. fdt_fixup_memory(blob, (u64)base, (u64)size);
  111. #ifdef CONFIG_PCI
  112. pci_of_setup(blob, bd);
  113. #endif
  114. fdt_fixup_liodn(blob);
  115. #ifdef CONFIG_HAS_FSL_DR_USB
  116. fdt_fixup_dr_usb(blob, bd);
  117. #endif
  118. #ifdef CONFIG_SYS_DPAA_FMAN
  119. fdt_fixup_fman_ethernet(blob);
  120. #endif
  121. return 0;
  122. }