1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Copyright 2014 Freescale Semiconductor 4 */ 5 #include <common.h> 6 #include <malloc.h> 7 #include <errno.h> 8 #include <netdev.h> 9 #include <fsl_ifc.h> 10 #include <fsl_ddr.h> 11 #include <asm/io.h> 12 #include <fdt_support.h> 13 #include <linux/libfdt.h> 14 #include <fsl-mc/fsl_mc.h> 15 #include <environment.h> 16 #include <asm/arch/soc.h> 17 18 DECLARE_GLOBAL_DATA_PTR; 19 20 int board_init(void) 21 { 22 init_final_memctl_regs(); 23 24 #ifdef CONFIG_ENV_IS_NOWHERE 25 gd->env_addr = (ulong)&default_environment[0]; 26 #endif 27 28 return 0; 29 } 30 31 int board_early_init_f(void) 32 { 33 fsl_lsch3_early_init_f(); 34 return 0; 35 } 36 37 void detail_board_ddr_info(void) 38 { 39 puts("\nDDR "); 40 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, ""); 41 print_ddr_info(0); 42 #ifdef CONFIG_SYS_FSL_HAS_DP_DDR 43 if (soc_has_dp_ddr() && gd->bd->bi_dram[2].size) { 44 puts("\nDP-DDR "); 45 print_size(gd->bd->bi_dram[2].size, ""); 46 print_ddr_info(CONFIG_DP_DDR_CTRL); 47 } 48 #endif 49 } 50 51 #if defined(CONFIG_ARCH_MISC_INIT) 52 int arch_misc_init(void) 53 { 54 return 0; 55 } 56 #endif 57 58 int board_eth_init(bd_t *bis) 59 { 60 int error = 0; 61 62 #ifdef CONFIG_SMC91111 63 error = smc91111_initialize(0, CONFIG_SMC91111_BASE); 64 #endif 65 66 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD) 67 error = cpu_eth_init(bis); 68 #endif 69 return error; 70 } 71 72 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD) 73 void fdt_fixup_board_enet(void *fdt) 74 { 75 int offset; 76 77 offset = fdt_path_offset(fdt, "/soc/fsl-mc"); 78 79 /* 80 * TODO: Remove this when backward compatibility 81 * with old DT node (/fsl-mc) is no longer needed. 82 */ 83 if (offset < 0) 84 offset = fdt_path_offset(fdt, "/fsl-mc"); 85 86 if (offset < 0) { 87 printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n", 88 __func__, offset); 89 return; 90 } 91 92 if (get_mc_boot_status() == 0 && 93 (is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0)) 94 fdt_status_okay(fdt, offset); 95 else 96 fdt_status_fail(fdt, offset); 97 } 98 99 void board_quiesce_devices(void) 100 { 101 fsl_mc_ldpaa_exit(gd->bd); 102 } 103 #endif 104 105 #ifdef CONFIG_OF_BOARD_SETUP 106 int ft_board_setup(void *blob, bd_t *bd) 107 { 108 u64 base[CONFIG_NR_DRAM_BANKS]; 109 u64 size[CONFIG_NR_DRAM_BANKS]; 110 111 ft_cpu_setup(blob, bd); 112 113 /* fixup DT for the two GPP DDR banks */ 114 base[0] = gd->bd->bi_dram[0].start; 115 size[0] = gd->bd->bi_dram[0].size; 116 base[1] = gd->bd->bi_dram[1].start; 117 size[1] = gd->bd->bi_dram[1].size; 118 119 #ifdef CONFIG_RESV_RAM 120 /* reduce size if reserved memory is within this bank */ 121 if (gd->arch.resv_ram >= base[0] && 122 gd->arch.resv_ram < base[0] + size[0]) 123 size[0] = gd->arch.resv_ram - base[0]; 124 else if (gd->arch.resv_ram >= base[1] && 125 gd->arch.resv_ram < base[1] + size[1]) 126 size[1] = gd->arch.resv_ram - base[1]; 127 #endif 128 129 fdt_fixup_memory_banks(blob, base, size, 2); 130 131 fdt_fsl_mc_fixup_iommu_map_entry(blob); 132 133 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD) 134 fdt_fixup_board_enet(blob); 135 #endif 136 137 return 0; 138 } 139 #endif 140 141 #if defined(CONFIG_RESET_PHY_R) 142 void reset_phy(void) 143 { 144 } 145 #endif 146 147 #ifdef CONFIG_TFABOOT 148 void *env_sf_get_env_addr(void) 149 { 150 return (void *)(CONFIG_SYS_FSL_QSPI_BASE1 + CONFIG_ENV_OFFSET); 151 } 152 #endif 153