1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2017-2018 NXP
6 #include <clock_legacy.h>
17 #include <asm/global_data.h>
19 #include <fdt_support.h>
20 #include <linux/delay.h>
21 #include <linux/libfdt.h>
22 #include <fsl-mc/fsl_mc.h>
23 #include <env_internal.h>
24 #include <asm/arch-fsl-layerscape/soc.h>
25 #include <asm/arch/ppa.h>
27 #include <asm/arch/fsl_serdes.h>
28 #include <asm/arch/soc.h>
29 #include <asm/arch-fsl-layerscape/fsl_icid.h>
30 #include "../common/i2c_mux.h"
32 #include "../common/qixis.h"
33 #include "ls1088a_qixis.h"
34 #include "../common/vid.h"
35 #include <fsl_immap.h>
37 DECLARE_GLOBAL_DATA_PTR;
39 #ifdef CONFIG_TARGET_LS1088AQDS
41 struct ifc_regs ifc_cfg_ifc_nor_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = {
44 CONFIG_SYS_NOR0_CSPR_EARLY,
45 CONFIG_SYS_NOR0_CSPR_EXT,
60 CONFIG_SYS_NOR1_CSPR_EARLY,
61 CONFIG_SYS_NOR0_CSPR_EXT,
62 CONFIG_SYS_NOR_AMASK_EARLY,
77 CONFIG_SYS_NAND_CSPR_EXT,
78 CONFIG_SYS_NAND_AMASK,
81 CONFIG_SYS_NAND_FTIM0,
82 CONFIG_SYS_NAND_FTIM1,
83 CONFIG_SYS_NAND_FTIM2,
90 CONFIG_SYS_FPGA_CSPR_EXT,
105 struct ifc_regs ifc_cfg_qspi_nor_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = {
108 CONFIG_SYS_NAND_CSPR,
109 CONFIG_SYS_NAND_CSPR_EXT,
110 CONFIG_SYS_NAND_AMASK,
111 CONFIG_SYS_NAND_CSOR,
113 CONFIG_SYS_NAND_FTIM0,
114 CONFIG_SYS_NAND_FTIM1,
115 CONFIG_SYS_NAND_FTIM2,
116 CONFIG_SYS_NAND_FTIM3
124 CONFIG_SYS_FPGA_CSPR,
125 CONFIG_SYS_FPGA_CSPR_EXT,
127 CONFIG_SYS_FPGA_CSOR,
140 void ifc_cfg_boot_info(struct ifc_regs_info *regs_info)
142 enum boot_src src = get_boot_src();
144 if (src == BOOT_SOURCE_QSPI_NOR)
145 regs_info->regs = ifc_cfg_qspi_nor_boot;
147 regs_info->regs = ifc_cfg_ifc_nor_boot;
149 regs_info->cs_size = CONFIG_SYS_FSL_IFC_BANK_COUNT;
151 #endif /* CONFIG_TFABOOT */
152 #endif /* CONFIG_TARGET_LS1088AQDS */
154 int board_early_init_f(void)
156 #if defined(CONFIG_SYS_I2C_EARLY_INIT) && defined(CONFIG_TARGET_LS1088AQDS)
159 fsl_lsch3_early_init_f();
163 #ifdef CONFIG_FSL_QIXIS
164 unsigned long long get_qixis_addr(void)
166 unsigned long long addr;
168 if (gd->flags & GD_FLG_RELOC)
169 addr = QIXIS_BASE_PHYS;
171 addr = QIXIS_BASE_PHYS_EARLY;
174 * IFC address under 256MB is mapped to 0x30000000, any address above
175 * is mapped to 0x5_10000000 up to 4GB.
177 addr = addr > 0x10000000 ? addr + 0x500000000ULL : addr + 0x30000000;
183 #if defined(CONFIG_VID)
184 int init_func_vid(void)
186 if (adjust_vdd(0) < 0)
187 printf("core voltage not adjusted\n");
192 u16 soc_get_fuse_vid(int vid_index)
194 static const u16 vdd[32] = {
229 return vdd[vid_index];
233 int is_pb_board(void)
237 board_id = QIXIS_READ(id);
238 if (board_id == LS1088ARDB_PB_BOARD)
244 int fixup_ls1088ardb_pb_banner(void *fdt)
246 fdt_setprop_string(fdt, 0, "model", "LS1088ARDB-PB Board");
251 #if !defined(CONFIG_SPL_BUILD)
254 #ifdef CONFIG_TFABOOT
255 enum boot_src src = get_boot_src();
259 static const char *const freq[] = {"100", "125", "156.25",
260 "100 separate SSCG"};
263 #ifdef CONFIG_TARGET_LS1088AQDS
264 printf("Board: LS1088A-QDS, ");
267 printf("Board: LS1088ARDB-PB, ");
269 printf("Board: LS1088A-RDB, ");
272 sw = QIXIS_READ(arch);
273 printf("Board Arch: V%d, ", sw >> 4);
275 #ifdef CONFIG_TARGET_LS1088AQDS
276 printf("Board version: %c, boot from ", (sw & 0xf) + 'A' - 1);
278 printf("Board version: %c, boot from ", (sw & 0xf) + 'A');
281 memset((u8 *)buf, 0x00, ARRAY_SIZE(buf));
283 sw = QIXIS_READ(brdcfg[0]);
284 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
286 #ifdef CONFIG_TFABOOT
287 if (src == BOOT_SOURCE_SD_MMC)
290 #ifdef CONFIG_SD_BOOT
293 #endif /* CONFIG_TFABOOT */
295 #ifdef CONFIG_TARGET_LS1088AQDS
304 printf("vBank: %d\n", sw);
317 sw = QIXIS_READ(brdcfg[0]);
318 sw = (sw & QIXIS_QMAP_MASK) >> QIXIS_QMAP_SHIFT;
319 if (sw == 0 || sw == 4)
328 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
332 #ifdef CONFIG_TARGET_LS1088AQDS
333 printf("FPGA: v%d (%s), build %d",
334 (int)QIXIS_READ(scver), qixis_read_tag(buf),
335 (int)qixis_read_minor());
336 /* the timestamp string contains "\n" at the end */
337 printf(" on %s", qixis_read_time(buf));
339 printf("CPLD: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata));
343 * Display the actual SERDES reference clocks as configured by the
344 * dip switches on the board. Note that the SWx registers could
345 * technically be set to force the reference clocks to match the
346 * values that the SERDES expects (or vice versa). For now, however,
347 * we just display both values and hope the user notices when they
350 puts("SERDES1 Reference : ");
351 sw = QIXIS_READ(brdcfg[2]);
352 clock = (sw >> 6) & 3;
353 printf("Clock1 = %sMHz ", freq[clock]);
354 clock = (sw >> 4) & 3;
355 printf("Clock2 = %sMHz", freq[clock]);
357 puts("\nSERDES2 Reference : ");
358 clock = (sw >> 2) & 3;
359 printf("Clock1 = %sMHz ", freq[clock]);
360 clock = (sw >> 0) & 3;
361 printf("Clock2 = %sMHz\n", freq[clock]);
367 bool if_board_diff_clk(void)
369 #ifdef CONFIG_TARGET_LS1088AQDS
370 u8 diff_conf = QIXIS_READ(brdcfg[11]);
371 return diff_conf & 0x40;
373 u8 diff_conf = QIXIS_READ(dutcfg[11]);
374 return diff_conf & 0x80;
378 #ifdef CONFIG_DYNAMIC_SYS_CLK_FREQ
379 unsigned long get_board_sys_clk(void)
381 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
383 switch (sysclk_conf & 0x0f) {
384 case QIXIS_SYSCLK_83:
386 case QIXIS_SYSCLK_100:
388 case QIXIS_SYSCLK_125:
390 case QIXIS_SYSCLK_133:
392 case QIXIS_SYSCLK_150:
394 case QIXIS_SYSCLK_160:
396 case QIXIS_SYSCLK_166:
404 #ifdef CONFIG_DYNAMIC_DDR_CLK_FREQ
405 unsigned long get_board_ddr_clk(void)
407 u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
409 if (if_board_diff_clk())
410 return get_board_sys_clk();
411 switch ((ddrclk_conf & 0x30) >> 4) {
412 case QIXIS_DDRCLK_100:
414 case QIXIS_DDRCLK_125:
416 case QIXIS_DDRCLK_133:
424 #if !defined(CONFIG_SPL_BUILD)
425 void board_retimer_init(void)
429 /* Retimer is connected to I2C1_CH5 */
430 select_i2c_ch_pca9547(I2C_MUX_CH5, 0);
432 /* Access to Control/Shared register */
434 #if !CONFIG_IS_ENABLED(DM_I2C)
435 i2c_write(I2C_RETIMER_ADDR, 0xff, 1, ®, 1);
439 i2c_get_chip_for_busnum(0, I2C_RETIMER_ADDR, 1, &dev);
440 dm_i2c_write(dev, 0xff, ®, 1);
443 /* Read device revision and ID */
444 #if !CONFIG_IS_ENABLED(DM_I2C)
445 i2c_read(I2C_RETIMER_ADDR, 1, 1, ®, 1);
447 dm_i2c_read(dev, 1, ®, 1);
449 debug("Retimer version id = 0x%x\n", reg);
451 /* Enable Broadcast. All writes target all channel register sets */
453 #if !CONFIG_IS_ENABLED(DM_I2C)
454 i2c_write(I2C_RETIMER_ADDR, 0xff, 1, ®, 1);
456 dm_i2c_write(dev, 0xff, ®, 1);
459 /* Reset Channel Registers */
460 #if !CONFIG_IS_ENABLED(DM_I2C)
461 i2c_read(I2C_RETIMER_ADDR, 0, 1, ®, 1);
463 dm_i2c_read(dev, 0, ®, 1);
466 #if !CONFIG_IS_ENABLED(DM_I2C)
467 i2c_write(I2C_RETIMER_ADDR, 0, 1, ®, 1);
469 dm_i2c_write(dev, 0, ®, 1);
472 /* Set data rate as 10.3125 Gbps */
474 #if !CONFIG_IS_ENABLED(DM_I2C)
475 i2c_write(I2C_RETIMER_ADDR, 0x60, 1, ®, 1);
477 dm_i2c_write(dev, 0x60, ®, 1);
480 #if !CONFIG_IS_ENABLED(DM_I2C)
481 i2c_write(I2C_RETIMER_ADDR, 0x61, 1, ®, 1);
483 dm_i2c_write(dev, 0x61, ®, 1);
486 #if !CONFIG_IS_ENABLED(DM_I2C)
487 i2c_write(I2C_RETIMER_ADDR, 0x62, 1, ®, 1);
489 dm_i2c_write(dev, 0x62, ®, 1);
492 #if !CONFIG_IS_ENABLED(DM_I2C)
493 i2c_write(I2C_RETIMER_ADDR, 0x63, 1, ®, 1);
495 dm_i2c_write(dev, 0x63, ®, 1);
498 #if !CONFIG_IS_ENABLED(DM_I2C)
499 i2c_write(I2C_RETIMER_ADDR, 0x64, 1, ®, 1);
501 dm_i2c_write(dev, 0x64, ®, 1);
504 /* Select VCO Divider to full rate (000) */
505 #if !CONFIG_IS_ENABLED(DM_I2C)
506 i2c_read(I2C_RETIMER_ADDR, 0x2F, 1, ®, 1);
508 dm_i2c_read(dev, 0x2F, ®, 1);
512 #if !CONFIG_IS_ENABLED(DM_I2C)
513 i2c_write(I2C_RETIMER_ADDR, 0x2F, 1, ®, 1);
515 dm_i2c_write(dev, 0x2F, ®, 1);
518 #ifdef CONFIG_TARGET_LS1088AQDS
519 /* Retimer is connected to I2C1_CH5 */
520 select_i2c_ch_pca9547(I2C_MUX_CH5, 0);
522 /* Access to Control/Shared register */
524 #if !CONFIG_IS_ENABLED(DM_I2C)
525 i2c_write(I2C_RETIMER_ADDR2, 0xff, 1, ®, 1);
527 i2c_get_chip_for_busnum(0, I2C_RETIMER_ADDR2, 1, &dev);
528 dm_i2c_write(dev, 0xff, ®, 1);
531 /* Read device revision and ID */
532 #if !CONFIG_IS_ENABLED(DM_I2C)
533 i2c_read(I2C_RETIMER_ADDR2, 1, 1, ®, 1);
535 dm_i2c_read(dev, 1, ®, 1);
537 debug("Retimer version id = 0x%x\n", reg);
539 /* Enable Broadcast. All writes target all channel register sets */
541 #if !CONFIG_IS_ENABLED(DM_I2C)
542 i2c_write(I2C_RETIMER_ADDR2, 0xff, 1, ®, 1);
544 dm_i2c_write(dev, 0xff, ®, 1);
547 /* Reset Channel Registers */
548 #if !CONFIG_IS_ENABLED(DM_I2C)
549 i2c_read(I2C_RETIMER_ADDR2, 0, 1, ®, 1);
551 dm_i2c_read(dev, 0, ®, 1);
554 #if !CONFIG_IS_ENABLED(DM_I2C)
555 i2c_write(I2C_RETIMER_ADDR2, 0, 1, ®, 1);
557 dm_i2c_write(dev, 0, ®, 1);
560 /* Set data rate as 10.3125 Gbps */
562 #if !CONFIG_IS_ENABLED(DM_I2C)
563 i2c_write(I2C_RETIMER_ADDR2, 0x60, 1, ®, 1);
565 dm_i2c_write(dev, 0x60, ®, 1);
568 #if !CONFIG_IS_ENABLED(DM_I2C)
569 i2c_write(I2C_RETIMER_ADDR2, 0x61, 1, ®, 1);
571 dm_i2c_write(dev, 0x61, ®, 1);
574 #if !CONFIG_IS_ENABLED(DM_I2C)
575 i2c_write(I2C_RETIMER_ADDR2, 0x62, 1, ®, 1);
577 dm_i2c_write(dev, 0x62, ®, 1);
580 #if !CONFIG_IS_ENABLED(DM_I2C)
581 i2c_write(I2C_RETIMER_ADDR2, 0x63, 1, ®, 1);
583 dm_i2c_write(dev, 0x63, ®, 1);
586 #if !CONFIG_IS_ENABLED(DM_I2C)
587 i2c_write(I2C_RETIMER_ADDR2, 0x64, 1, ®, 1);
589 dm_i2c_write(dev, 0x64, ®, 1);
592 /* Select VCO Divider to full rate (000) */
593 #if !CONFIG_IS_ENABLED(DM_I2C)
594 i2c_read(I2C_RETIMER_ADDR2, 0x2F, 1, ®, 1);
596 dm_i2c_read(dev, 0x2F, ®, 1);
600 #if !CONFIG_IS_ENABLED(DM_I2C)
601 i2c_write(I2C_RETIMER_ADDR2, 0x2F, 1, ®, 1);
603 dm_i2c_write(dev, 0x2F, ®, 1);
607 /*return the default channel*/
608 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
611 #ifdef CONFIG_MISC_INIT_R
612 int misc_init_r(void)
614 #ifdef CONFIG_TARGET_LS1088ARDB
617 if (hwconfig("esdhc-force-sd")) {
618 brdcfg5 = QIXIS_READ(brdcfg[5]);
619 brdcfg5 &= ~BRDCFG5_SPISDHC_MASK;
620 brdcfg5 |= BRDCFG5_FORCE_SD;
621 QIXIS_WRITE(brdcfg[5], brdcfg5);
625 #ifdef CONFIG_TARGET_LS1088AQDS
628 if (hwconfig("dspi-on-board")) {
629 brdcfg4 = QIXIS_READ(brdcfg[4]);
630 brdcfg4 &= ~BRDCFG4_USBOSC_MASK;
631 brdcfg4 |= BRDCFG4_SPI;
632 QIXIS_WRITE(brdcfg[4], brdcfg4);
634 brdcfg5 = QIXIS_READ(brdcfg[5]);
635 brdcfg5 &= ~BRDCFG5_SPR_MASK;
636 brdcfg5 |= BRDCFG5_SPI_ON_BOARD;
637 QIXIS_WRITE(brdcfg[5], brdcfg5);
638 } else if (hwconfig("dspi-off-board")) {
639 brdcfg4 = QIXIS_READ(brdcfg[4]);
640 brdcfg4 &= ~BRDCFG4_USBOSC_MASK;
641 brdcfg4 |= BRDCFG4_SPI;
642 QIXIS_WRITE(brdcfg[4], brdcfg4);
644 brdcfg5 = QIXIS_READ(brdcfg[5]);
645 brdcfg5 &= ~BRDCFG5_SPR_MASK;
646 brdcfg5 |= BRDCFG5_SPI_OFF_BOARD;
647 QIXIS_WRITE(brdcfg[5], brdcfg5);
655 int i2c_multiplexer_select_vid_channel(u8 channel)
657 return select_i2c_ch_pca9547(channel, 0);
660 #ifdef CONFIG_TARGET_LS1088AQDS
661 /* read the current value(SVDD) of the LTM Regulator Voltage */
662 int get_serdes_volt(void)
665 u8 chan = PWM_CHANNEL0;
667 /* Select the PAGE 0 using PMBus commands PAGE for VDD */
668 #if !CONFIG_IS_ENABLED(DM_I2C)
669 ret = i2c_write(I2C_SVDD_MONITOR_ADDR,
670 PMBUS_CMD_PAGE, 1, &chan, 1);
674 ret = i2c_get_chip_for_busnum(0, I2C_SVDD_MONITOR_ADDR, 1, &dev);
676 ret = dm_i2c_write(dev, PMBUS_CMD_PAGE,
681 printf("VID: failed to select VDD Page 0\n");
685 /* Read the output voltage using PMBus command READ_VOUT */
686 #if !CONFIG_IS_ENABLED(DM_I2C)
687 ret = i2c_read(I2C_SVDD_MONITOR_ADDR,
688 PMBUS_CMD_READ_VOUT, 1, (void *)&vcode, 2);
690 dm_i2c_read(dev, PMBUS_CMD_READ_VOUT, (void *)&vcode, 2);
693 printf("VID: failed to read the volatge\n");
700 int set_serdes_volt(int svdd)
703 u8 buff[5] = {0x04, PWM_CHANNEL0, PMBUS_CMD_VOUT_COMMAND,
704 svdd & 0xFF, (svdd & 0xFF00) >> 8};
706 /* Write the desired voltage code to the SVDD regulator */
707 #if !CONFIG_IS_ENABLED(DM_I2C)
708 ret = i2c_write(I2C_SVDD_MONITOR_ADDR,
709 PMBUS_CMD_PAGE_PLUS_WRITE, 1, (void *)&buff, 5);
713 ret = i2c_get_chip_for_busnum(0, I2C_SVDD_MONITOR_ADDR, 1, &dev);
715 ret = dm_i2c_write(dev, PMBUS_CMD_PAGE_PLUS_WRITE,
719 printf("VID: I2C failed to write to the volatge regulator\n");
723 /* Wait for the volatge to get to the desired value */
725 vdd_last = get_serdes_volt();
727 printf("VID: Couldn't read sensor abort VID adjust\n");
730 } while (vdd_last != svdd);
735 int get_serdes_volt(void)
740 int set_serdes_volt(int svdd)
745 printf("SVDD changing of RDB\n");
747 /* Read the BRDCFG54 via CLPD */
748 #if !CONFIG_IS_ENABLED(DM_I2C)
749 ret = i2c_read(CONFIG_SYS_I2C_FPGA_ADDR,
750 QIXIS_BRDCFG4_OFFSET, 1, (void *)&brdcfg4, 1);
754 ret = i2c_get_chip_for_busnum(0, CONFIG_SYS_I2C_FPGA_ADDR, 1, &dev);
756 ret = dm_i2c_read(dev, QIXIS_BRDCFG4_OFFSET,
757 (void *)&brdcfg4, 1);
761 printf("VID: I2C failed to read the CPLD BRDCFG4\n");
765 brdcfg4 = brdcfg4 | 0x08;
767 /* Write to the BRDCFG4 */
768 #if !CONFIG_IS_ENABLED(DM_I2C)
769 ret = i2c_write(CONFIG_SYS_I2C_FPGA_ADDR,
770 QIXIS_BRDCFG4_OFFSET, 1, (void *)&brdcfg4, 1);
772 ret = dm_i2c_write(dev, QIXIS_BRDCFG4_OFFSET,
773 (void *)&brdcfg4, 1);
777 debug("VID: I2C failed to set the SVDD CPLD BRDCFG4\n");
781 /* Wait for the volatge to get to the desired value */
788 /* this function disables the SERDES, changes the SVDD Voltage and enables it*/
789 int board_adjust_vdd(int vdd)
793 debug("%s: vdd = %d\n", __func__, vdd);
795 /* Special settings to be performed when voltage is 900mV */
797 ret = setup_serdes_volt(vdd);
807 #if !defined(CONFIG_SPL_BUILD)
810 init_final_memctl_regs();
811 #if defined(CONFIG_TARGET_LS1088ARDB) && defined(CONFIG_FSL_MC_ENET)
812 u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE;
815 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
816 board_retimer_init();
818 #if defined(CONFIG_TARGET_LS1088ARDB) && defined(CONFIG_FSL_MC_ENET)
819 /* invert AQR105 IRQ pins polarity */
820 out_le32(irq_ccsr + IRQCR_OFFSET / 4, AQR105_IRQ_MASK);
823 #ifdef CONFIG_FSL_CAAM
826 #ifdef CONFIG_FSL_LS_PPA
830 #if !defined(CONFIG_SYS_EARLY_PCI_INIT) && defined(CONFIG_DM_ETH)
837 void detail_board_ddr_info(void)
840 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
844 #ifdef CONFIG_FSL_MC_ENET
845 void board_quiesce_devices(void)
847 fsl_mc_ldpaa_exit(gd->bd);
850 void fdt_fixup_board_enet(void *fdt)
854 offset = fdt_path_offset(fdt, "/fsl-mc");
857 offset = fdt_path_offset(fdt, "/soc/fsl-mc");
860 printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
865 if (get_mc_boot_status() == 0 &&
866 (is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0))
867 fdt_status_okay(fdt, offset);
869 fdt_status_fail(fdt, offset);
873 #ifdef CONFIG_OF_BOARD_SETUP
874 void fsl_fdt_fixup_flash(void *fdt)
877 #ifdef CONFIG_TFABOOT
878 u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
883 * IFC-NOR and QSPI are muxed on SoC.
884 * So disable IFC node in dts if QSPI is enabled or
885 * disable QSPI node in dts in case QSPI is not enabled.
888 #ifdef CONFIG_TFABOOT
889 enum boot_src src = get_boot_src();
890 bool disable_ifc = false;
893 case BOOT_SOURCE_IFC_NOR:
896 case BOOT_SOURCE_QSPI_NOR:
900 val = in_le32(dcfg_ccsr + DCFG_RCWSR15 / 4);
901 if (DCFG_RCWSR15_IFCGRPABASE_QSPI == (val & (u32)0x3))
907 offset = fdt_path_offset(fdt, "/soc/ifc/nor");
910 offset = fdt_path_offset(fdt, "/ifc/nor");
912 offset = fdt_path_offset(fdt, "/soc/quadspi");
915 offset = fdt_path_offset(fdt, "/quadspi");
919 #ifdef CONFIG_FSL_QSPI
920 offset = fdt_path_offset(fdt, "/soc/ifc/nor");
923 offset = fdt_path_offset(fdt, "/ifc/nor");
925 offset = fdt_path_offset(fdt, "/soc/quadspi");
928 offset = fdt_path_offset(fdt, "/quadspi");
934 fdt_status_disabled(fdt, offset);
937 int ft_board_setup(void *blob, struct bd_info *bd)
940 u16 mc_memory_bank = 0;
944 u64 mc_memory_base = 0;
945 u64 mc_memory_size = 0;
946 u16 total_memory_banks;
948 ft_cpu_setup(blob, bd);
950 fdt_fixup_mc_ddr(&mc_memory_base, &mc_memory_size);
952 if (mc_memory_base != 0)
955 total_memory_banks = CONFIG_NR_DRAM_BANKS + mc_memory_bank;
957 base = calloc(total_memory_banks, sizeof(u64));
958 size = calloc(total_memory_banks, sizeof(u64));
960 /* fixup DT for the two GPP DDR banks */
961 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
962 base[i] = gd->bd->bi_dram[i].start;
963 size[i] = gd->bd->bi_dram[i].size;
966 #ifdef CONFIG_RESV_RAM
967 /* reduce size if reserved memory is within this bank */
968 if (gd->arch.resv_ram >= base[0] &&
969 gd->arch.resv_ram < base[0] + size[0])
970 size[0] = gd->arch.resv_ram - base[0];
971 else if (gd->arch.resv_ram >= base[1] &&
972 gd->arch.resv_ram < base[1] + size[1])
973 size[1] = gd->arch.resv_ram - base[1];
976 if (mc_memory_base != 0) {
977 for (i = 0; i <= total_memory_banks; i++) {
978 if (base[i] == 0 && size[i] == 0) {
979 base[i] = mc_memory_base;
980 size[i] = mc_memory_size;
986 fdt_fixup_memory_banks(blob, base, size, total_memory_banks);
988 fdt_fsl_mc_fixup_iommu_map_entry(blob);
990 fsl_fdt_fixup_flash(blob);
992 #ifdef CONFIG_FSL_MC_ENET
993 fdt_fixup_board_enet(blob);
996 fdt_fixup_icid(blob);
999 fixup_ls1088ardb_pb_banner(blob);
1004 #endif /* defined(CONFIG_SPL_BUILD) */
1006 #ifdef CONFIG_TFABOOT
1007 #ifdef CONFIG_MTD_NOR_FLASH
1008 int is_flash_available(void)
1010 char *env_hwconfig = env_get("hwconfig");
1011 enum boot_src src = get_boot_src();
1012 int is_nor_flash_available = 1;
1015 case BOOT_SOURCE_IFC_NOR:
1016 is_nor_flash_available = 1;
1018 case BOOT_SOURCE_QSPI_NOR:
1019 is_nor_flash_available = 0;
1022 * In Case of SD boot,if qspi is defined in env_hwconfig
1023 * disable nor flash probe.
1026 if (hwconfig_f("qspi", env_hwconfig))
1027 is_nor_flash_available = 0;
1030 return is_nor_flash_available;
1034 #ifdef CONFIG_ENV_IS_IN_SPI_FLASH
1035 void *env_sf_get_env_addr(void)
1037 return (void *)(CONFIG_SYS_FSL_QSPI_BASE + CONFIG_ENV_OFFSET);