ls1043ardb.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. * Copyright 2015 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <i2c.h>
  8. #include <asm/io.h>
  9. #include <asm/arch/clock.h>
  10. #include <asm/arch/fsl_serdes.h>
  11. #include <asm/arch/soc.h>
  12. #include <fdt_support.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_esdhc.h>
  19. #include <fsl_ifc.h>
  20. #include <fsl_sec.h>
  21. #include "cpld.h"
  22. #ifdef CONFIG_U_QE
  23. #include <fsl_qe.h>
  24. #endif
  25. #ifdef CONFIG_FSL_LS_PPA
  26. #include <asm/arch/ppa.h>
  27. #endif
  28. DECLARE_GLOBAL_DATA_PTR;
  29. int checkboard(void)
  30. {
  31. static const char *freq[2] = {"100.00MHZ", "156.25MHZ"};
  32. #ifndef CONFIG_SD_BOOT
  33. u8 cfg_rcw_src1, cfg_rcw_src2;
  34. u16 cfg_rcw_src;
  35. #endif
  36. u8 sd1refclk_sel;
  37. printf("Board: LS1043ARDB, boot from ");
  38. #ifdef CONFIG_SD_BOOT
  39. puts("SD\n");
  40. #else
  41. cfg_rcw_src1 = CPLD_READ(cfg_rcw_src1);
  42. cfg_rcw_src2 = CPLD_READ(cfg_rcw_src2);
  43. cpld_rev_bit(&cfg_rcw_src1);
  44. cfg_rcw_src = cfg_rcw_src1;
  45. cfg_rcw_src = (cfg_rcw_src << 1) | cfg_rcw_src2;
  46. if (cfg_rcw_src == 0x25)
  47. printf("vBank %d\n", CPLD_READ(vbank));
  48. else if (cfg_rcw_src == 0x106)
  49. puts("NAND\n");
  50. else
  51. printf("Invalid setting of SW4\n");
  52. #endif
  53. printf("CPLD: V%x.%x\nPCBA: V%x.0\n", CPLD_READ(cpld_ver),
  54. CPLD_READ(cpld_ver_sub), CPLD_READ(pcba_ver));
  55. puts("SERDES Reference Clocks:\n");
  56. sd1refclk_sel = CPLD_READ(sd1refclk_sel);
  57. printf("SD1_CLK1 = %s, SD1_CLK2 = %s\n", freq[sd1refclk_sel], freq[0]);
  58. return 0;
  59. }
  60. int dram_init(void)
  61. {
  62. gd->ram_size = initdram(0);
  63. return 0;
  64. }
  65. int board_early_init_f(void)
  66. {
  67. fsl_lsch2_early_init_f();
  68. return 0;
  69. }
  70. int board_init(void)
  71. {
  72. struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
  73. #ifdef CONFIG_SYS_FSL_ERRATUM_A010315
  74. erratum_a010315();
  75. #endif
  76. #ifdef CONFIG_FSL_IFC
  77. init_final_memctl_regs();
  78. #endif
  79. #ifdef CONFIG_SECURE_BOOT
  80. /* In case of Secure Boot, the IBR configures the SMMU
  81. * to allow only Secure transactions.
  82. * SMMU must be reset in bypass mode.
  83. * Set the ClientPD bit and Clear the USFCFG Bit
  84. */
  85. u32 val;
  86. val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
  87. out_le32(SMMU_SCR0, val);
  88. val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
  89. out_le32(SMMU_NSCR0, val);
  90. #endif
  91. #ifdef CONFIG_FSL_CAAM
  92. sec_init();
  93. #endif
  94. #ifdef CONFIG_FSL_LS_PPA
  95. ppa_init();
  96. #endif
  97. #ifdef CONFIG_U_QE
  98. u_qe_init();
  99. #endif
  100. /* invert AQR105 IRQ pins polarity */
  101. out_be32(&scfg->intpcr, AQR105_IRQ_MASK);
  102. return 0;
  103. }
  104. int config_board_mux(void)
  105. {
  106. struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
  107. u32 usb_pwrfault;
  108. if (hwconfig("qe-hdlc")) {
  109. out_be32(&scfg->rcwpmuxcr0,
  110. (in_be32(&scfg->rcwpmuxcr0) & ~0xff00) | 0x6600);
  111. printf("Assign to qe-hdlc clk, rcwpmuxcr0=%x\n",
  112. in_be32(&scfg->rcwpmuxcr0));
  113. } else {
  114. #ifdef CONFIG_HAS_FSL_XHCI_USB
  115. out_be32(&scfg->rcwpmuxcr0, 0x3333);
  116. out_be32(&scfg->usbdrvvbus_selcr, SCFG_USBDRVVBUS_SELCR_USB1);
  117. usb_pwrfault = (SCFG_USBPWRFAULT_DEDICATED <<
  118. SCFG_USBPWRFAULT_USB3_SHIFT) |
  119. (SCFG_USBPWRFAULT_DEDICATED <<
  120. SCFG_USBPWRFAULT_USB2_SHIFT) |
  121. (SCFG_USBPWRFAULT_SHARED <<
  122. SCFG_USBPWRFAULT_USB1_SHIFT);
  123. out_be32(&scfg->usbpwrfault_selcr, usb_pwrfault);
  124. #endif
  125. }
  126. return 0;
  127. }
  128. #if defined(CONFIG_MISC_INIT_R)
  129. int misc_init_r(void)
  130. {
  131. config_board_mux();
  132. return 0;
  133. }
  134. #endif
  135. void fdt_del_qe(void *blob)
  136. {
  137. int nodeoff = 0;
  138. while ((nodeoff = fdt_node_offset_by_compatible(blob, 0,
  139. "fsl,qe")) >= 0) {
  140. fdt_del_node(blob, nodeoff);
  141. }
  142. }
  143. int ft_board_setup(void *blob, bd_t *bd)
  144. {
  145. u64 base[CONFIG_NR_DRAM_BANKS];
  146. u64 size[CONFIG_NR_DRAM_BANKS];
  147. /* fixup DT for the two DDR banks */
  148. base[0] = gd->bd->bi_dram[0].start;
  149. size[0] = gd->bd->bi_dram[0].size;
  150. base[1] = gd->bd->bi_dram[1].start;
  151. size[1] = gd->bd->bi_dram[1].size;
  152. fdt_fixup_memory_banks(blob, base, size, 2);
  153. ft_cpu_setup(blob, bd);
  154. #ifdef CONFIG_SYS_DPAA_FMAN
  155. fdt_fixup_fman_ethernet(blob);
  156. #endif
  157. /*
  158. * qe-hdlc and usb multi-use the pins,
  159. * when set hwconfig to qe-hdlc, delete usb node.
  160. */
  161. if (hwconfig("qe-hdlc"))
  162. #ifdef CONFIG_HAS_FSL_XHCI_USB
  163. fdt_del_node_and_alias(blob, "usb1");
  164. #endif
  165. /*
  166. * qe just support qe-uart and qe-hdlc,
  167. * if qe-uart and qe-hdlc are not set in hwconfig,
  168. * delete qe node.
  169. */
  170. if (!hwconfig("qe-uart") && !hwconfig("qe-hdlc"))
  171. fdt_del_qe(blob);
  172. return 0;
  173. }
  174. u8 flash_read8(void *addr)
  175. {
  176. return __raw_readb(addr + 1);
  177. }
  178. void flash_write16(u16 val, void *addr)
  179. {
  180. u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
  181. __raw_writew(shftval, addr);
  182. }
  183. u16 flash_read16(void *addr)
  184. {
  185. u16 val = __raw_readw(addr);
  186. return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00);
  187. }