1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014 Freescale Semiconductor
14 #include <fdt_support.h>
15 #include <linux/libfdt.h>
16 #include <fsl-mc/fsl_mc.h>
17 #include <env_internal.h>
18 #include <asm/arch/soc.h>
20 DECLARE_GLOBAL_DATA_PTR;
24 init_final_memctl_regs();
26 #ifdef CONFIG_ENV_IS_NOWHERE
27 gd->env_addr = (ulong)&default_environment[0];
33 int board_early_init_f(void)
35 fsl_lsch3_early_init_f();
39 void detail_board_ddr_info(void)
42 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
44 #ifdef CONFIG_SYS_FSL_HAS_DP_DDR
45 if (soc_has_dp_ddr() && gd->bd->bi_dram[2].size) {
47 print_size(gd->bd->bi_dram[2].size, "");
48 print_ddr_info(CONFIG_DP_DDR_CTRL);
53 int board_eth_init(struct bd_info *bis)
57 #ifdef CONFIG_SMC91111
58 error = smc91111_initialize(0, CONFIG_SMC91111_BASE);
61 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
62 error = cpu_eth_init(bis);
67 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
68 void fdt_fixup_board_enet(void *fdt)
72 offset = fdt_path_offset(fdt, "/soc/fsl-mc");
75 * TODO: Remove this when backward compatibility
76 * with old DT node (/fsl-mc) is no longer needed.
79 offset = fdt_path_offset(fdt, "/fsl-mc");
82 printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
87 if (get_mc_boot_status() == 0 &&
88 (is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0))
89 fdt_status_okay(fdt, offset);
91 fdt_status_fail(fdt, offset);
94 void board_quiesce_devices(void)
96 fsl_mc_ldpaa_exit(gd->bd);
100 #ifdef CONFIG_OF_BOARD_SETUP
101 int ft_board_setup(void *blob, struct bd_info *bd)
103 u64 base[CONFIG_NR_DRAM_BANKS];
104 u64 size[CONFIG_NR_DRAM_BANKS];
106 ft_cpu_setup(blob, bd);
108 /* fixup DT for the two GPP DDR banks */
109 base[0] = gd->bd->bi_dram[0].start;
110 size[0] = gd->bd->bi_dram[0].size;
111 base[1] = gd->bd->bi_dram[1].start;
112 size[1] = gd->bd->bi_dram[1].size;
114 #ifdef CONFIG_RESV_RAM
115 /* reduce size if reserved memory is within this bank */
116 if (gd->arch.resv_ram >= base[0] &&
117 gd->arch.resv_ram < base[0] + size[0])
118 size[0] = gd->arch.resv_ram - base[0];
119 else if (gd->arch.resv_ram >= base[1] &&
120 gd->arch.resv_ram < base[1] + size[1])
121 size[1] = gd->arch.resv_ram - base[1];
124 fdt_fixup_memory_banks(blob, base, size, 2);
126 fdt_fsl_mc_fixup_iommu_map_entry(blob);
128 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
129 fdt_fixup_board_enet(blob);
136 #if defined(CONFIG_RESET_PHY_R)
142 #ifdef CONFIG_TFABOOT
143 void *env_sf_get_env_addr(void)
145 return (void *)(CONFIG_SYS_FSL_QSPI_BASE1 + CONFIG_ENV_OFFSET);