1e84a324bSAshish Kumar /* 2e84a324bSAshish Kumar * Copyright 2017 NXP 3e84a324bSAshish Kumar * 4e84a324bSAshish Kumar * SPDX-License-Identifier: GPL-2.0+ 5e84a324bSAshish Kumar */ 6e84a324bSAshish Kumar #include <common.h> 7e84a324bSAshish Kumar #include <i2c.h> 8e84a324bSAshish Kumar #include <malloc.h> 9e84a324bSAshish Kumar #include <errno.h> 10e84a324bSAshish Kumar #include <netdev.h> 11e84a324bSAshish Kumar #include <fsl_ifc.h> 12e84a324bSAshish Kumar #include <fsl_ddr.h> 13e84a324bSAshish Kumar #include <fsl_sec.h> 14e84a324bSAshish Kumar #include <asm/io.h> 15e84a324bSAshish Kumar #include <fdt_support.h> 16e84a324bSAshish Kumar #include <libfdt.h> 17e84a324bSAshish Kumar #include <fsl-mc/fsl_mc.h> 18e84a324bSAshish Kumar #include <environment.h> 19e84a324bSAshish Kumar #include <asm/arch-fsl-layerscape/soc.h> 20e84a324bSAshish Kumar #include <asm/arch/ppa.h> 21e84a324bSAshish Kumar 22e84a324bSAshish Kumar #include "../common/qixis.h" 23e84a324bSAshish Kumar #include "ls1088a_qixis.h" 24e84a324bSAshish Kumar 25e84a324bSAshish Kumar DECLARE_GLOBAL_DATA_PTR; 26e84a324bSAshish Kumar 27e84a324bSAshish Kumar unsigned long long get_qixis_addr(void) 28e84a324bSAshish Kumar { 29e84a324bSAshish Kumar unsigned long long addr; 30e84a324bSAshish Kumar 31e84a324bSAshish Kumar if (gd->flags & GD_FLG_RELOC) 32e84a324bSAshish Kumar addr = QIXIS_BASE_PHYS; 33e84a324bSAshish Kumar else 34e84a324bSAshish Kumar addr = QIXIS_BASE_PHYS_EARLY; 35e84a324bSAshish Kumar 36e84a324bSAshish Kumar /* 37e84a324bSAshish Kumar * IFC address under 256MB is mapped to 0x30000000, any address above 38e84a324bSAshish Kumar * is mapped to 0x5_10000000 up to 4GB. 39e84a324bSAshish Kumar */ 40e84a324bSAshish Kumar addr = addr > 0x10000000 ? addr + 0x500000000ULL : addr + 0x30000000; 41e84a324bSAshish Kumar 42e84a324bSAshish Kumar return addr; 43e84a324bSAshish Kumar } 44e84a324bSAshish Kumar 45e84a324bSAshish Kumar int checkboard(void) 46e84a324bSAshish Kumar { 47e84a324bSAshish Kumar char buf[64]; 48e84a324bSAshish Kumar u8 sw; 49e84a324bSAshish Kumar static const char *const freq[] = {"100", "125", "156.25", 50e84a324bSAshish Kumar "100 separate SSCG"}; 51e84a324bSAshish Kumar int clock; 52e84a324bSAshish Kumar 53*7769776aSAshish Kumar #ifdef CONFIG_TARGET_LS1088AQDS 54*7769776aSAshish Kumar printf("Board: LS1088A-QDS, "); 55*7769776aSAshish Kumar #else 56e84a324bSAshish Kumar printf("Board: LS1088A-RDB, "); 57*7769776aSAshish Kumar #endif 58e84a324bSAshish Kumar 59e84a324bSAshish Kumar sw = QIXIS_READ(arch); 60e84a324bSAshish Kumar printf("Board Arch: V%d, ", sw >> 4); 61e84a324bSAshish Kumar 62*7769776aSAshish Kumar #ifdef CONFIG_TARGET_LS1088AQDS 63*7769776aSAshish Kumar printf("Board version: %c, boot from ", (sw & 0xf) + 'A' - 1); 64*7769776aSAshish Kumar #else 65e84a324bSAshish Kumar printf("Board version: %c, boot from ", (sw & 0xf) + 'A'); 66*7769776aSAshish Kumar #endif 67e84a324bSAshish Kumar 68e84a324bSAshish Kumar memset((u8 *)buf, 0x00, ARRAY_SIZE(buf)); 69e84a324bSAshish Kumar 70e84a324bSAshish Kumar sw = QIXIS_READ(brdcfg[0]); 71e84a324bSAshish Kumar sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT; 72e84a324bSAshish Kumar 73e84a324bSAshish Kumar #ifdef CONFIG_SD_BOOT 74e84a324bSAshish Kumar puts("SD card\n"); 75e84a324bSAshish Kumar #endif 76e84a324bSAshish Kumar switch (sw) { 77*7769776aSAshish Kumar #ifdef CONFIG_TARGET_LS1088AQDS 78e84a324bSAshish Kumar case 0: 79*7769776aSAshish Kumar case 1: 80*7769776aSAshish Kumar case 2: 81*7769776aSAshish Kumar case 3: 82*7769776aSAshish Kumar case 4: 83*7769776aSAshish Kumar case 5: 84*7769776aSAshish Kumar case 6: 85*7769776aSAshish Kumar case 7: 86*7769776aSAshish Kumar printf("vBank: %d\n", sw); 87*7769776aSAshish Kumar break; 88*7769776aSAshish Kumar case 8: 89*7769776aSAshish Kumar puts("PromJet\n"); 90*7769776aSAshish Kumar break; 91*7769776aSAshish Kumar case 15: 92*7769776aSAshish Kumar puts("IFCCard\n"); 93*7769776aSAshish Kumar break; 94*7769776aSAshish Kumar case 14: 95*7769776aSAshish Kumar #else 96*7769776aSAshish Kumar case 0: 97*7769776aSAshish Kumar #endif 98e84a324bSAshish Kumar puts("QSPI:"); 99e84a324bSAshish Kumar sw = QIXIS_READ(brdcfg[0]); 100e84a324bSAshish Kumar sw = (sw & QIXIS_QMAP_MASK) >> QIXIS_QMAP_SHIFT; 101e84a324bSAshish Kumar if (sw == 0 || sw == 4) 102e84a324bSAshish Kumar puts("0\n"); 103e84a324bSAshish Kumar else if (sw == 1) 104e84a324bSAshish Kumar puts("1\n"); 105e84a324bSAshish Kumar else 106e84a324bSAshish Kumar puts("EMU\n"); 107e84a324bSAshish Kumar break; 108e84a324bSAshish Kumar 109e84a324bSAshish Kumar default: 110e84a324bSAshish Kumar printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH); 111e84a324bSAshish Kumar break; 112e84a324bSAshish Kumar } 113e84a324bSAshish Kumar 114*7769776aSAshish Kumar #ifdef CONFIG_TARGET_LS1088AQDS 115*7769776aSAshish Kumar printf("FPGA: v%d (%s), build %d", 116*7769776aSAshish Kumar (int)QIXIS_READ(scver), qixis_read_tag(buf), 117*7769776aSAshish Kumar (int)qixis_read_minor()); 118*7769776aSAshish Kumar /* the timestamp string contains "\n" at the end */ 119*7769776aSAshish Kumar printf(" on %s", qixis_read_time(buf)); 120*7769776aSAshish Kumar #else 121e84a324bSAshish Kumar printf("CPLD: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata)); 122*7769776aSAshish Kumar #endif 123e84a324bSAshish Kumar 124e84a324bSAshish Kumar /* 125e84a324bSAshish Kumar * Display the actual SERDES reference clocks as configured by the 126e84a324bSAshish Kumar * dip switches on the board. Note that the SWx registers could 127e84a324bSAshish Kumar * technically be set to force the reference clocks to match the 128e84a324bSAshish Kumar * values that the SERDES expects (or vice versa). For now, however, 129e84a324bSAshish Kumar * we just display both values and hope the user notices when they 130e84a324bSAshish Kumar * don't match. 131e84a324bSAshish Kumar */ 132e84a324bSAshish Kumar puts("SERDES1 Reference : "); 133e84a324bSAshish Kumar sw = QIXIS_READ(brdcfg[2]); 134e84a324bSAshish Kumar clock = (sw >> 6) & 3; 135e84a324bSAshish Kumar printf("Clock1 = %sMHz ", freq[clock]); 136e84a324bSAshish Kumar clock = (sw >> 4) & 3; 137e84a324bSAshish Kumar printf("Clock2 = %sMHz", freq[clock]); 138e84a324bSAshish Kumar 139e84a324bSAshish Kumar puts("\nSERDES2 Reference : "); 140e84a324bSAshish Kumar clock = (sw >> 2) & 3; 141e84a324bSAshish Kumar printf("Clock1 = %sMHz ", freq[clock]); 142e84a324bSAshish Kumar clock = (sw >> 0) & 3; 143e84a324bSAshish Kumar printf("Clock2 = %sMHz\n", freq[clock]); 144e84a324bSAshish Kumar 145e84a324bSAshish Kumar return 0; 146e84a324bSAshish Kumar } 147e84a324bSAshish Kumar 148e84a324bSAshish Kumar bool if_board_diff_clk(void) 149e84a324bSAshish Kumar { 150*7769776aSAshish Kumar #ifdef CONFIG_TARGET_LS1088AQDS 151*7769776aSAshish Kumar u8 diff_conf = QIXIS_READ(brdcfg[11]); 152*7769776aSAshish Kumar return diff_conf & 0x40; 153*7769776aSAshish Kumar #else 154e84a324bSAshish Kumar u8 diff_conf = QIXIS_READ(dutcfg[11]); 155e84a324bSAshish Kumar return diff_conf & 0x80; 156*7769776aSAshish Kumar #endif 157e84a324bSAshish Kumar } 158e84a324bSAshish Kumar 159e84a324bSAshish Kumar unsigned long get_board_sys_clk(void) 160e84a324bSAshish Kumar { 161e84a324bSAshish Kumar u8 sysclk_conf = QIXIS_READ(brdcfg[1]); 162e84a324bSAshish Kumar 163e84a324bSAshish Kumar switch (sysclk_conf & 0x0f) { 164e84a324bSAshish Kumar case QIXIS_SYSCLK_83: 165e84a324bSAshish Kumar return 83333333; 166e84a324bSAshish Kumar case QIXIS_SYSCLK_100: 167e84a324bSAshish Kumar return 100000000; 168e84a324bSAshish Kumar case QIXIS_SYSCLK_125: 169e84a324bSAshish Kumar return 125000000; 170e84a324bSAshish Kumar case QIXIS_SYSCLK_133: 171e84a324bSAshish Kumar return 133333333; 172e84a324bSAshish Kumar case QIXIS_SYSCLK_150: 173e84a324bSAshish Kumar return 150000000; 174e84a324bSAshish Kumar case QIXIS_SYSCLK_160: 175e84a324bSAshish Kumar return 160000000; 176e84a324bSAshish Kumar case QIXIS_SYSCLK_166: 177e84a324bSAshish Kumar return 166666666; 178e84a324bSAshish Kumar } 179e84a324bSAshish Kumar 180e84a324bSAshish Kumar return 66666666; 181e84a324bSAshish Kumar } 182e84a324bSAshish Kumar 183e84a324bSAshish Kumar unsigned long get_board_ddr_clk(void) 184e84a324bSAshish Kumar { 185e84a324bSAshish Kumar u8 ddrclk_conf = QIXIS_READ(brdcfg[1]); 186e84a324bSAshish Kumar 187e84a324bSAshish Kumar if (if_board_diff_clk()) 188e84a324bSAshish Kumar return get_board_sys_clk(); 189e84a324bSAshish Kumar switch ((ddrclk_conf & 0x30) >> 4) { 190e84a324bSAshish Kumar case QIXIS_DDRCLK_100: 191e84a324bSAshish Kumar return 100000000; 192e84a324bSAshish Kumar case QIXIS_DDRCLK_125: 193e84a324bSAshish Kumar return 125000000; 194e84a324bSAshish Kumar case QIXIS_DDRCLK_133: 195e84a324bSAshish Kumar return 133333333; 196e84a324bSAshish Kumar } 197e84a324bSAshish Kumar 198e84a324bSAshish Kumar return 66666666; 199e84a324bSAshish Kumar } 200e84a324bSAshish Kumar 201e84a324bSAshish Kumar int select_i2c_ch_pca9547(u8 ch) 202e84a324bSAshish Kumar { 203e84a324bSAshish Kumar int ret; 204e84a324bSAshish Kumar 205e84a324bSAshish Kumar ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1); 206e84a324bSAshish Kumar if (ret) { 207e84a324bSAshish Kumar puts("PCA: failed to select proper channel\n"); 208e84a324bSAshish Kumar return ret; 209e84a324bSAshish Kumar } 210e84a324bSAshish Kumar 211e84a324bSAshish Kumar return 0; 212e84a324bSAshish Kumar } 213e84a324bSAshish Kumar 214e84a324bSAshish Kumar void board_retimer_init(void) 215e84a324bSAshish Kumar { 216e84a324bSAshish Kumar u8 reg; 217e84a324bSAshish Kumar 218e84a324bSAshish Kumar /* Retimer is connected to I2C1_CH5 */ 219e84a324bSAshish Kumar select_i2c_ch_pca9547(I2C_MUX_CH5); 220e84a324bSAshish Kumar 221e84a324bSAshish Kumar /* Access to Control/Shared register */ 222e84a324bSAshish Kumar reg = 0x0; 223e84a324bSAshish Kumar i2c_write(I2C_RETIMER_ADDR, 0xff, 1, ®, 1); 224e84a324bSAshish Kumar 225e84a324bSAshish Kumar /* Read device revision and ID */ 226e84a324bSAshish Kumar i2c_read(I2C_RETIMER_ADDR, 1, 1, ®, 1); 227e84a324bSAshish Kumar debug("Retimer version id = 0x%x\n", reg); 228e84a324bSAshish Kumar 229e84a324bSAshish Kumar /* Enable Broadcast. All writes target all channel register sets */ 230e84a324bSAshish Kumar reg = 0x0c; 231e84a324bSAshish Kumar i2c_write(I2C_RETIMER_ADDR, 0xff, 1, ®, 1); 232e84a324bSAshish Kumar 233e84a324bSAshish Kumar /* Reset Channel Registers */ 234e84a324bSAshish Kumar i2c_read(I2C_RETIMER_ADDR, 0, 1, ®, 1); 235e84a324bSAshish Kumar reg |= 0x4; 236e84a324bSAshish Kumar i2c_write(I2C_RETIMER_ADDR, 0, 1, ®, 1); 237e84a324bSAshish Kumar 238e84a324bSAshish Kumar /* Set data rate as 10.3125 Gbps */ 239e84a324bSAshish Kumar reg = 0x90; 240e84a324bSAshish Kumar i2c_write(I2C_RETIMER_ADDR, 0x60, 1, ®, 1); 241e84a324bSAshish Kumar reg = 0xb3; 242e84a324bSAshish Kumar i2c_write(I2C_RETIMER_ADDR, 0x61, 1, ®, 1); 243e84a324bSAshish Kumar reg = 0x90; 244e84a324bSAshish Kumar i2c_write(I2C_RETIMER_ADDR, 0x62, 1, ®, 1); 245e84a324bSAshish Kumar reg = 0xb3; 246e84a324bSAshish Kumar i2c_write(I2C_RETIMER_ADDR, 0x63, 1, ®, 1); 247e84a324bSAshish Kumar reg = 0xcd; 248e84a324bSAshish Kumar i2c_write(I2C_RETIMER_ADDR, 0x64, 1, ®, 1); 249e84a324bSAshish Kumar 250e84a324bSAshish Kumar /* Select VCO Divider to full rate (000) */ 251e84a324bSAshish Kumar i2c_read(I2C_RETIMER_ADDR, 0x2F, 1, ®, 1); 252e84a324bSAshish Kumar reg &= 0x0f; 253e84a324bSAshish Kumar reg |= 0x70; 254e84a324bSAshish Kumar i2c_write(I2C_RETIMER_ADDR, 0x2F, 1, ®, 1); 255e84a324bSAshish Kumar 256*7769776aSAshish Kumar #ifdef CONFIG_TARGET_LS1088AQDS 257*7769776aSAshish Kumar /* Retimer is connected to I2C1_CH5 */ 258*7769776aSAshish Kumar select_i2c_ch_pca9547(I2C_MUX_CH5); 259e84a324bSAshish Kumar 260*7769776aSAshish Kumar /* Access to Control/Shared register */ 261*7769776aSAshish Kumar reg = 0x0; 262*7769776aSAshish Kumar i2c_write(I2C_RETIMER_ADDR2, 0xff, 1, ®, 1); 263*7769776aSAshish Kumar 264*7769776aSAshish Kumar /* Read device revision and ID */ 265*7769776aSAshish Kumar i2c_read(I2C_RETIMER_ADDR2, 1, 1, ®, 1); 266*7769776aSAshish Kumar debug("Retimer version id = 0x%x\n", reg); 267*7769776aSAshish Kumar 268*7769776aSAshish Kumar /* Enable Broadcast. All writes target all channel register sets */ 269*7769776aSAshish Kumar reg = 0x0c; 270*7769776aSAshish Kumar i2c_write(I2C_RETIMER_ADDR2, 0xff, 1, ®, 1); 271*7769776aSAshish Kumar 272*7769776aSAshish Kumar /* Reset Channel Registers */ 273*7769776aSAshish Kumar i2c_read(I2C_RETIMER_ADDR2, 0, 1, ®, 1); 274*7769776aSAshish Kumar reg |= 0x4; 275*7769776aSAshish Kumar i2c_write(I2C_RETIMER_ADDR2, 0, 1, ®, 1); 276*7769776aSAshish Kumar 277*7769776aSAshish Kumar /* Set data rate as 10.3125 Gbps */ 278*7769776aSAshish Kumar reg = 0x90; 279*7769776aSAshish Kumar i2c_write(I2C_RETIMER_ADDR2, 0x60, 1, ®, 1); 280*7769776aSAshish Kumar reg = 0xb3; 281*7769776aSAshish Kumar i2c_write(I2C_RETIMER_ADDR2, 0x61, 1, ®, 1); 282*7769776aSAshish Kumar reg = 0x90; 283*7769776aSAshish Kumar i2c_write(I2C_RETIMER_ADDR2, 0x62, 1, ®, 1); 284*7769776aSAshish Kumar reg = 0xb3; 285*7769776aSAshish Kumar i2c_write(I2C_RETIMER_ADDR2, 0x63, 1, ®, 1); 286*7769776aSAshish Kumar reg = 0xcd; 287*7769776aSAshish Kumar i2c_write(I2C_RETIMER_ADDR2, 0x64, 1, ®, 1); 288*7769776aSAshish Kumar 289*7769776aSAshish Kumar /* Select VCO Divider to full rate (000) */ 290*7769776aSAshish Kumar i2c_read(I2C_RETIMER_ADDR2, 0x2F, 1, ®, 1); 291*7769776aSAshish Kumar reg &= 0x0f; 292*7769776aSAshish Kumar reg |= 0x70; 293*7769776aSAshish Kumar i2c_write(I2C_RETIMER_ADDR2, 0x2F, 1, ®, 1); 294*7769776aSAshish Kumar #endif 295e84a324bSAshish Kumar /*return the default channel*/ 296e84a324bSAshish Kumar select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT); 297e84a324bSAshish Kumar } 298e84a324bSAshish Kumar 299e84a324bSAshish Kumar int board_init(void) 300e84a324bSAshish Kumar { 301e84a324bSAshish Kumar init_final_memctl_regs(); 302e84a324bSAshish Kumar #if defined(CONFIG_TARGET_LS1088ARDB) && defined(CONFIG_FSL_MC_ENET) 303e84a324bSAshish Kumar u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE; 304e84a324bSAshish Kumar #endif 305e84a324bSAshish Kumar 306e84a324bSAshish Kumar select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT); 307e84a324bSAshish Kumar board_retimer_init(); 308e84a324bSAshish Kumar 309e84a324bSAshish Kumar #ifdef CONFIG_ENV_IS_NOWHERE 310e84a324bSAshish Kumar gd->env_addr = (ulong)&default_environment[0]; 311e84a324bSAshish Kumar #endif 312e84a324bSAshish Kumar 313e84a324bSAshish Kumar #if defined(CONFIG_TARGET_LS1088ARDB) && defined(CONFIG_FSL_MC_ENET) 314e84a324bSAshish Kumar /* invert AQR105 IRQ pins polarity */ 315e84a324bSAshish Kumar out_le32(irq_ccsr + IRQCR_OFFSET / 4, AQR105_IRQ_MASK); 316e84a324bSAshish Kumar #endif 317e84a324bSAshish Kumar 318e84a324bSAshish Kumar #ifdef CONFIG_FSL_LS_PPA 319e84a324bSAshish Kumar ppa_init(); 320e84a324bSAshish Kumar #endif 321e84a324bSAshish Kumar return 0; 322e84a324bSAshish Kumar } 323e84a324bSAshish Kumar 324e84a324bSAshish Kumar int board_early_init_f(void) 325e84a324bSAshish Kumar { 326e84a324bSAshish Kumar fsl_lsch3_early_init_f(); 327e84a324bSAshish Kumar return 0; 328e84a324bSAshish Kumar } 329e84a324bSAshish Kumar 330e84a324bSAshish Kumar void detail_board_ddr_info(void) 331e84a324bSAshish Kumar { 332e84a324bSAshish Kumar puts("\nDDR "); 333e84a324bSAshish Kumar print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, ""); 334e84a324bSAshish Kumar print_ddr_info(0); 335e84a324bSAshish Kumar } 336e84a324bSAshish Kumar 337e84a324bSAshish Kumar #if defined(CONFIG_ARCH_MISC_INIT) 338e84a324bSAshish Kumar int arch_misc_init(void) 339e84a324bSAshish Kumar { 340e84a324bSAshish Kumar #ifdef CONFIG_FSL_CAAM 341e84a324bSAshish Kumar sec_init(); 342e84a324bSAshish Kumar #endif 343e84a324bSAshish Kumar return 0; 344e84a324bSAshish Kumar } 345e84a324bSAshish Kumar #endif 346e84a324bSAshish Kumar 347e84a324bSAshish Kumar #ifdef CONFIG_FSL_MC_ENET 348e84a324bSAshish Kumar void fdt_fixup_board_enet(void *fdt) 349e84a324bSAshish Kumar { 350e84a324bSAshish Kumar int offset; 351e84a324bSAshish Kumar 352e84a324bSAshish Kumar offset = fdt_path_offset(fdt, "/fsl-mc"); 353e84a324bSAshish Kumar 354e84a324bSAshish Kumar if (offset < 0) 355e84a324bSAshish Kumar offset = fdt_path_offset(fdt, "/fsl,dprc@0"); 356e84a324bSAshish Kumar 357e84a324bSAshish Kumar if (offset < 0) { 358e84a324bSAshish Kumar printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n", 359e84a324bSAshish Kumar __func__, offset); 360e84a324bSAshish Kumar return; 361e84a324bSAshish Kumar } 362e84a324bSAshish Kumar 363e84a324bSAshish Kumar if (get_mc_boot_status() == 0) 364e84a324bSAshish Kumar fdt_status_okay(fdt, offset); 365e84a324bSAshish Kumar else 366e84a324bSAshish Kumar fdt_status_fail(fdt, offset); 367e84a324bSAshish Kumar } 368e84a324bSAshish Kumar #endif 369e84a324bSAshish Kumar 370e84a324bSAshish Kumar #ifdef CONFIG_OF_BOARD_SETUP 371e84a324bSAshish Kumar int ft_board_setup(void *blob, bd_t *bd) 372e84a324bSAshish Kumar { 373e84a324bSAshish Kumar int err, i; 374e84a324bSAshish Kumar u64 base[CONFIG_NR_DRAM_BANKS]; 375e84a324bSAshish Kumar u64 size[CONFIG_NR_DRAM_BANKS]; 376e84a324bSAshish Kumar 377e84a324bSAshish Kumar ft_cpu_setup(blob, bd); 378e84a324bSAshish Kumar 379e84a324bSAshish Kumar /* fixup DT for the two GPP DDR banks */ 380e84a324bSAshish Kumar for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { 381e84a324bSAshish Kumar base[i] = gd->bd->bi_dram[i].start; 382e84a324bSAshish Kumar size[i] = gd->bd->bi_dram[i].size; 383e84a324bSAshish Kumar } 384e84a324bSAshish Kumar 385e84a324bSAshish Kumar #ifdef CONFIG_RESV_RAM 386e84a324bSAshish Kumar /* reduce size if reserved memory is within this bank */ 387e84a324bSAshish Kumar if (gd->arch.resv_ram >= base[0] && 388e84a324bSAshish Kumar gd->arch.resv_ram < base[0] + size[0]) 389e84a324bSAshish Kumar size[0] = gd->arch.resv_ram - base[0]; 390e84a324bSAshish Kumar else if (gd->arch.resv_ram >= base[1] && 391e84a324bSAshish Kumar gd->arch.resv_ram < base[1] + size[1]) 392e84a324bSAshish Kumar size[1] = gd->arch.resv_ram - base[1]; 393e84a324bSAshish Kumar #endif 394e84a324bSAshish Kumar 395e84a324bSAshish Kumar fdt_fixup_memory_banks(blob, base, size, CONFIG_NR_DRAM_BANKS); 396e84a324bSAshish Kumar 397e84a324bSAshish Kumar #ifdef CONFIG_FSL_MC_ENET 398e84a324bSAshish Kumar fdt_fixup_board_enet(blob); 399e84a324bSAshish Kumar err = fsl_mc_ldpaa_exit(bd); 400e84a324bSAshish Kumar if (err) 401e84a324bSAshish Kumar return err; 402e84a324bSAshish Kumar #endif 403e84a324bSAshish Kumar 404e84a324bSAshish Kumar return 0; 405e84a324bSAshish Kumar } 406e84a324bSAshish Kumar #endif 407