ls1046ardb.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2016 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <i2c.h>
  7. #include <fdt_support.h>
  8. #include <asm/io.h>
  9. #include <asm/arch/clock.h>
  10. #include <asm/arch/fsl_serdes.h>
  11. #include <asm/arch/ppa.h>
  12. #include <asm/arch/soc.h>
  13. #include <hwconfig.h>
  14. #include <ahci.h>
  15. #include <mmc.h>
  16. #include <scsi.h>
  17. #include <fm_eth.h>
  18. #include <fsl_csu.h>
  19. #include <fsl_esdhc.h>
  20. #include <power/mc34vr500_pmic.h>
  21. #include "cpld.h"
  22. #include <fsl_sec.h>
  23. DECLARE_GLOBAL_DATA_PTR;
  24. int board_early_init_f(void)
  25. {
  26. fsl_lsch2_early_init_f();
  27. return 0;
  28. }
  29. #ifndef CONFIG_SPL_BUILD
  30. int checkboard(void)
  31. {
  32. static const char *freq[2] = {"100.00MHZ", "156.25MHZ"};
  33. u8 cfg_rcw_src1, cfg_rcw_src2;
  34. u16 cfg_rcw_src;
  35. u8 sd1refclk_sel;
  36. puts("Board: LS1046ARDB, boot from ");
  37. cfg_rcw_src1 = CPLD_READ(cfg_rcw_src1);
  38. cfg_rcw_src2 = CPLD_READ(cfg_rcw_src2);
  39. cpld_rev_bit(&cfg_rcw_src1);
  40. cfg_rcw_src = cfg_rcw_src1;
  41. cfg_rcw_src = (cfg_rcw_src << 1) | cfg_rcw_src2;
  42. if (cfg_rcw_src == 0x44)
  43. printf("QSPI vBank %d\n", CPLD_READ(vbank));
  44. else if (cfg_rcw_src == 0x40)
  45. puts("SD\n");
  46. else
  47. puts("Invalid setting of SW5\n");
  48. printf("CPLD: V%x.%x\nPCBA: V%x.0\n", CPLD_READ(cpld_ver),
  49. CPLD_READ(cpld_ver_sub), CPLD_READ(pcba_ver));
  50. puts("SERDES Reference Clocks:\n");
  51. sd1refclk_sel = CPLD_READ(sd1refclk_sel);
  52. printf("SD1_CLK1 = %s, SD1_CLK2 = %s\n", freq[sd1refclk_sel], freq[0]);
  53. return 0;
  54. }
  55. int board_init(void)
  56. {
  57. struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
  58. #ifdef CONFIG_SECURE_BOOT
  59. /*
  60. * In case of Secure Boot, the IBR configures the SMMU
  61. * to allow only Secure transactions.
  62. * SMMU must be reset in bypass mode.
  63. * Set the ClientPD bit and Clear the USFCFG Bit
  64. */
  65. u32 val;
  66. val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
  67. out_le32(SMMU_SCR0, val);
  68. val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
  69. out_le32(SMMU_NSCR0, val);
  70. #endif
  71. #ifdef CONFIG_FSL_CAAM
  72. sec_init();
  73. #endif
  74. #ifdef CONFIG_FSL_LS_PPA
  75. ppa_init();
  76. #endif
  77. /* invert AQR105 IRQ pins polarity */
  78. out_be32(&scfg->intpcr, AQR105_IRQ_MASK);
  79. return 0;
  80. }
  81. int board_setup_core_volt(u32 vdd)
  82. {
  83. bool en_0v9;
  84. en_0v9 = (vdd == 900) ? true : false;
  85. cpld_select_core_volt(en_0v9);
  86. return 0;
  87. }
  88. int get_serdes_volt(void)
  89. {
  90. return mc34vr500_get_sw_volt(SW4);
  91. }
  92. int set_serdes_volt(int svdd)
  93. {
  94. return mc34vr500_set_sw_volt(SW4, svdd);
  95. }
  96. int power_init_board(void)
  97. {
  98. int ret;
  99. ret = power_mc34vr500_init(0);
  100. if (ret)
  101. return ret;
  102. setup_chip_volt();
  103. return 0;
  104. }
  105. void config_board_mux(void)
  106. {
  107. #ifdef CONFIG_HAS_FSL_XHCI_USB
  108. struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
  109. u32 usb_pwrfault;
  110. /* USB3 is not used, configure mux to IIC4_SCL/IIC4_SDA */
  111. out_be32(&scfg->rcwpmuxcr0, 0x3300);
  112. out_be32(&scfg->usbdrvvbus_selcr, SCFG_USBDRVVBUS_SELCR_USB1);
  113. usb_pwrfault = (SCFG_USBPWRFAULT_DEDICATED <<
  114. SCFG_USBPWRFAULT_USB3_SHIFT) |
  115. (SCFG_USBPWRFAULT_DEDICATED <<
  116. SCFG_USBPWRFAULT_USB2_SHIFT) |
  117. (SCFG_USBPWRFAULT_SHARED <<
  118. SCFG_USBPWRFAULT_USB1_SHIFT);
  119. out_be32(&scfg->usbpwrfault_selcr, usb_pwrfault);
  120. #endif
  121. }
  122. #ifdef CONFIG_MISC_INIT_R
  123. int misc_init_r(void)
  124. {
  125. config_board_mux();
  126. return 0;
  127. }
  128. #endif
  129. int ft_board_setup(void *blob, bd_t *bd)
  130. {
  131. u64 base[CONFIG_NR_DRAM_BANKS];
  132. u64 size[CONFIG_NR_DRAM_BANKS];
  133. /* fixup DT for the two DDR banks */
  134. base[0] = gd->bd->bi_dram[0].start;
  135. size[0] = gd->bd->bi_dram[0].size;
  136. base[1] = gd->bd->bi_dram[1].start;
  137. size[1] = gd->bd->bi_dram[1].size;
  138. fdt_fixup_memory_banks(blob, base, size, 2);
  139. ft_cpu_setup(blob, bd);
  140. #ifdef CONFIG_SYS_DPAA_FMAN
  141. fdt_fixup_fman_ethernet(blob);
  142. #endif
  143. return 0;
  144. }
  145. #endif