blob: 6504cf768f191d21de5daa0a1eab37bf318b786c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
York Sune12abcb2015-03-20 19:28:24 -07002/*
3 * Copyright 2015 Freescale Semiconductor
Alison Wang160a4352018-06-18 20:25:05 +08004 * Copyright 2017 NXP
York Sune12abcb2015-03-20 19:28:24 -07005 */
6#include <common.h>
Simon Glass5e6201b2019-08-01 09:46:51 -06007#include <env.h>
Simon Glass97589732020-05-10 11:40:02 -06008#include <init.h>
York Sune12abcb2015-03-20 19:28:24 -07009#include <malloc.h>
10#include <errno.h>
11#include <netdev.h>
12#include <fsl_ifc.h>
13#include <fsl_ddr.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060014#include <asm/global_data.h>
York Sune12abcb2015-03-20 19:28:24 -070015#include <asm/io.h>
Yangbo Lucf005552015-05-28 14:53:55 +053016#include <hwconfig.h>
York Sune12abcb2015-03-20 19:28:24 -070017#include <fdt_support.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090018#include <linux/libfdt.h>
York Sune12abcb2015-03-20 19:28:24 -070019#include <fsl-mc/fsl_mc.h>
Simon Glass9d1f6192019-08-02 09:44:25 -060020#include <env_internal.h>
Alexander Graf34f8e972016-11-17 01:02:59 +010021#include <efi_loader.h>
York Sune12abcb2015-03-20 19:28:24 -070022#include <i2c.h>
York Sun729f2d12017-03-06 09:02:34 -080023#include <asm/arch/mmu.h>
Mingkai Hu0e58b512015-10-26 19:47:50 +080024#include <asm/arch/soc.h>
Santan Kumarc61c6992017-03-07 11:21:03 +053025#include <asm/arch/ppa.h>
Saksham Jainc0c38d22016-03-23 16:24:35 +053026#include <fsl_sec.h>
Laurentiu Tudor4adff392019-10-18 09:01:54 +000027#include <asm/arch-fsl-layerscape/fsl_icid.h>
Stephen Carlson4e979ac2021-06-22 16:42:02 -070028#include "../common/i2c_mux.h"
York Sune12abcb2015-03-20 19:28:24 -070029
Priyanka Jain6720d0a2017-04-28 10:41:34 +053030#ifdef CONFIG_FSL_QIXIS
York Sune12abcb2015-03-20 19:28:24 -070031#include "../common/qixis.h"
Prabhakar Kushwaha122bcfd2015-11-09 16:42:07 +053032#include "ls2080ardb_qixis.h"
Priyanka Jain6720d0a2017-04-28 10:41:34 +053033#endif
Rai Harninder6aa1f3b2016-03-23 17:04:38 +053034#include "../common/vid.h"
York Sune12abcb2015-03-20 19:28:24 -070035
Yangbo Lucf005552015-05-28 14:53:55 +053036#define PIN_MUX_SEL_SDHC 0x00
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +080037#define PIN_MUX_SEL_DSPI 0x0a
Yangbo Lucf005552015-05-28 14:53:55 +053038
39#define SET_SDHC_MUX_SEL(reg, value) ((reg & 0xf0) | value)
York Sune12abcb2015-03-20 19:28:24 -070040DECLARE_GLOBAL_DATA_PTR;
41
Yangbo Lucf005552015-05-28 14:53:55 +053042enum {
43 MUX_TYPE_SDHC,
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +080044 MUX_TYPE_DSPI,
Yangbo Lucf005552015-05-28 14:53:55 +053045};
46
Stephen Carlsonc3301a22021-02-08 11:11:29 +010047#ifdef CONFIG_VID
48u16 soc_get_fuse_vid(int vid_index)
49{
50 static const u16 vdd[32] = {
51 10500,
52 0, /* reserved */
53 9750,
54 0, /* reserved */
55 9500,
56 0, /* reserved */
57 0, /* reserved */
58 0, /* reserved */
59 9000, /* reserved */
60 0, /* reserved */
61 0, /* reserved */
62 0, /* reserved */
63 0, /* reserved */
64 0, /* reserved */
65 0, /* reserved */
66 0, /* reserved */
67 10000, /* 1.0000V */
68 0, /* reserved */
69 10250,
70 0, /* reserved */
71 10500,
72 0, /* reserved */
73 0, /* reserved */
74 0, /* reserved */
75 0, /* reserved */
76 0, /* reserved */
77 0, /* reserved */
78 0, /* reserved */
79 0, /* reserved */
80 0, /* reserved */
81 0, /* reserved */
82 0, /* reserved */
83 };
84
85 return vdd[vid_index];
86};
87#endif
88
York Sune12abcb2015-03-20 19:28:24 -070089unsigned long long get_qixis_addr(void)
90{
91 unsigned long long addr;
92
93 if (gd->flags & GD_FLG_RELOC)
94 addr = QIXIS_BASE_PHYS;
95 else
96 addr = QIXIS_BASE_PHYS_EARLY;
97
98 /*
99 * IFC address under 256MB is mapped to 0x30000000, any address above
100 * is mapped to 0x5_10000000 up to 4GB.
101 */
102 addr = addr > 0x10000000 ? addr + 0x500000000ULL : addr + 0x30000000;
103
104 return addr;
105}
106
107int checkboard(void)
108{
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530109#ifdef CONFIG_FSL_QIXIS
York Sune12abcb2015-03-20 19:28:24 -0700110 u8 sw;
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530111#endif
Prabhakar Kushwaha67f2e9c2015-05-28 14:54:07 +0530112 char buf[15];
113
114 cpu_name(buf);
115 printf("Board: %s-RDB, ", buf);
York Sune12abcb2015-03-20 19:28:24 -0700116
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530117#ifdef CONFIG_TARGET_LS2081ARDB
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530118#ifdef CONFIG_FSL_QIXIS
York Sune12abcb2015-03-20 19:28:24 -0700119 sw = QIXIS_READ(arch);
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530120 printf("Board version: %c, ", (sw & 0xf) + 'A');
121
122 sw = QIXIS_READ(brdcfg[0]);
Priyanka Jain75985792018-01-08 12:20:42 +0530123 sw = (sw >> QIXIS_QMAP_SHIFT) & QIXIS_QMAP_MASK;
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530124 switch (sw) {
125 case 0:
126 puts("boot from QSPI DEV#0\n");
127 puts("QSPI_CSA_1 mapped to QSPI DEV#1\n");
128 break;
129 case 1:
130 puts("boot from QSPI DEV#1\n");
131 puts("QSPI_CSA_1 mapped to QSPI DEV#0\n");
132 break;
133 case 2:
134 puts("boot from QSPI EMU\n");
135 puts("QSPI_CSA_1 mapped to QSPI DEV#0\n");
136 break;
137 case 3:
138 puts("boot from QSPI EMU\n");
139 puts("QSPI_CSA_1 mapped to QSPI DEV#1\n");
140 break;
141 case 4:
142 puts("boot from QSPI DEV#0\n");
143 puts("QSPI_CSA_1 mapped to QSPI EMU\n");
144 break;
145 default:
146 printf("invalid setting of SW%u\n", sw);
147 break;
148 }
Priyanka Jain6e9d2952018-01-08 12:59:31 +0530149 printf("FPGA: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata));
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530150#endif
151 puts("SERDES1 Reference : ");
152 printf("Clock1 = 100MHz ");
153 printf("Clock2 = 161.13MHz");
154#else
155#ifdef CONFIG_FSL_QIXIS
156 sw = QIXIS_READ(arch);
157 printf("Board Arch: V%d, ", sw >> 4);
Prabhakar Kushwaha8368a592015-05-28 14:54:04 +0530158 printf("Board version: %c, boot from ", (sw & 0xf) + 'A');
York Sune12abcb2015-03-20 19:28:24 -0700159
160 sw = QIXIS_READ(brdcfg[0]);
161 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
162
163 if (sw < 0x8)
164 printf("vBank: %d\n", sw);
165 else if (sw == 0x9)
166 puts("NAND\n");
167 else
168 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
169
170 printf("FPGA: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata));
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530171#endif
York Sune12abcb2015-03-20 19:28:24 -0700172 puts("SERDES1 Reference : ");
173 printf("Clock1 = 156.25MHz ");
174 printf("Clock2 = 156.25MHz");
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530175#endif
York Sune12abcb2015-03-20 19:28:24 -0700176
177 puts("\nSERDES2 Reference : ");
178 printf("Clock1 = 100MHz ");
179 printf("Clock2 = 100MHz\n");
180
181 return 0;
182}
183
184unsigned long get_board_sys_clk(void)
185{
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530186#ifdef CONFIG_FSL_QIXIS
York Sune12abcb2015-03-20 19:28:24 -0700187 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
188
189 switch (sysclk_conf & 0x0F) {
190 case QIXIS_SYSCLK_83:
191 return 83333333;
192 case QIXIS_SYSCLK_100:
193 return 100000000;
194 case QIXIS_SYSCLK_125:
195 return 125000000;
196 case QIXIS_SYSCLK_133:
197 return 133333333;
198 case QIXIS_SYSCLK_150:
199 return 150000000;
200 case QIXIS_SYSCLK_160:
201 return 160000000;
202 case QIXIS_SYSCLK_166:
203 return 166666666;
204 }
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530205#endif
206 return 100000000;
York Sune12abcb2015-03-20 19:28:24 -0700207}
208
Rai Harninder6aa1f3b2016-03-23 17:04:38 +0530209int i2c_multiplexer_select_vid_channel(u8 channel)
210{
Stephen Carlson4e979ac2021-06-22 16:42:02 -0700211 return select_i2c_ch_pca9547(channel, 0);
Rai Harninder6aa1f3b2016-03-23 17:04:38 +0530212}
213
Yangbo Lucf005552015-05-28 14:53:55 +0530214int config_board_mux(int ctrl_type)
215{
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530216#ifdef CONFIG_FSL_QIXIS
Yangbo Lucf005552015-05-28 14:53:55 +0530217 u8 reg5;
218
219 reg5 = QIXIS_READ(brdcfg[5]);
220
221 switch (ctrl_type) {
222 case MUX_TYPE_SDHC:
223 reg5 = SET_SDHC_MUX_SEL(reg5, PIN_MUX_SEL_SDHC);
224 break;
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800225 case MUX_TYPE_DSPI:
226 reg5 = SET_SDHC_MUX_SEL(reg5, PIN_MUX_SEL_DSPI);
227 break;
Yangbo Lucf005552015-05-28 14:53:55 +0530228 default:
229 printf("Wrong mux interface type\n");
230 return -1;
231 }
232
233 QIXIS_WRITE(brdcfg[5], reg5);
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530234#endif
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800235 return 0;
236}
237
238int board_init(void)
239{
York Sun8cbc1952016-05-26 13:59:03 -0700240#ifdef CONFIG_FSL_MC_ENET
Shaohui Xie8c7ce822016-01-28 15:38:15 +0800241 u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE;
York Sun8cbc1952016-05-26 13:59:03 -0700242#endif
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800243
244 init_final_memctl_regs();
245
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800246#ifdef CONFIG_ENV_IS_NOWHERE
247 gd->env_addr = (ulong)&default_environment[0];
248#endif
Stephen Carlson4e979ac2021-06-22 16:42:02 -0700249 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800250
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530251#ifdef CONFIG_FSL_QIXIS
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800252 QIXIS_WRITE(rst_ctl, QIXIS_RST_CTL_RESET_EN);
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530253#endif
Udit Agarwalc83ea8a2017-08-16 07:13:29 -0400254
255#ifdef CONFIG_FSL_CAAM
256 sec_init();
257#endif
Santan Kumarc61c6992017-03-07 11:21:03 +0530258#ifdef CONFIG_FSL_LS_PPA
259 ppa_init();
260#endif
261
York Sun8cbc1952016-05-26 13:59:03 -0700262#ifdef CONFIG_FSL_MC_ENET
Shaohui Xie8c7ce822016-01-28 15:38:15 +0800263 /* invert AQR405 IRQ pins polarity */
264 out_le32(irq_ccsr + IRQCR_OFFSET / 4, AQR405_IRQ_MASK);
York Sun8cbc1952016-05-26 13:59:03 -0700265#endif
Udit Agarwal62ed9a82017-02-03 22:53:38 +0530266#ifdef CONFIG_FSL_CAAM
267 sec_init();
268#endif
Shaohui Xie8c7ce822016-01-28 15:38:15 +0800269
Ioana Ciorneicfa114a2020-03-18 16:47:40 +0200270#if !defined(CONFIG_SYS_EARLY_PCI_INIT) && defined(CONFIG_DM_ETH)
271 pci_init();
272#endif
273
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800274 return 0;
275}
276
277int board_early_init_f(void)
278{
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530279#ifdef CONFIG_SYS_I2C_EARLY_INIT
280 i2c_early_init_f();
281#endif
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800282 fsl_lsch3_early_init_f();
Yangbo Lucf005552015-05-28 14:53:55 +0530283 return 0;
284}
285
286int misc_init_r(void)
287{
Santan Kumar0ce3f402017-06-15 17:07:01 +0530288 char *env_hwconfig;
289 u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
290 u32 val;
Priyanka Jain0915dda2017-09-15 10:19:48 +0530291 struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
292 u32 svr = gur_in32(&gur->svr);
Santan Kumar0ce3f402017-06-15 17:07:01 +0530293
294 val = in_le32(dcfg_ccsr + DCFG_RCWSR13 / 4);
295
Simon Glass64b723f2017-08-03 12:22:12 -0600296 env_hwconfig = env_get("hwconfig");
Santan Kumar0ce3f402017-06-15 17:07:01 +0530297
298 if (hwconfig_f("dspi", env_hwconfig) &&
299 DCFG_RCWSR13_DSPI == (val & (u32)(0xf << 8)))
300 config_board_mux(MUX_TYPE_DSPI);
301 else
302 config_board_mux(MUX_TYPE_SDHC);
303
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530304 /*
Santan Kumar20e7f5a2017-06-09 11:48:05 +0530305 * LS2081ARDB RevF board has smart voltage translator
Priyanka Jaind1587182017-04-25 10:12:31 +0530306 * which needs to be programmed to enable high speed SD interface
307 * by setting GPIO4_10 output to zero
308 */
Santan Kumar20e7f5a2017-06-09 11:48:05 +0530309#ifdef CONFIG_TARGET_LS2081ARDB
Priyanka Jaind1587182017-04-25 10:12:31 +0530310 out_le32(GPIO4_GPDIR_ADDR, (1 << 21 |
311 in_le32(GPIO4_GPDIR_ADDR)));
312 out_le32(GPIO4_GPDAT_ADDR, (~(1 << 21) &
313 in_le32(GPIO4_GPDAT_ADDR)));
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530314#endif
Yangbo Lucf005552015-05-28 14:53:55 +0530315 if (hwconfig("sdhc"))
316 config_board_mux(MUX_TYPE_SDHC);
317
Rai Harninder6aa1f3b2016-03-23 17:04:38 +0530318 if (adjust_vdd(0))
319 printf("Warning: Adjusting core voltage failed.\n");
Priyanka Jain0915dda2017-09-15 10:19:48 +0530320 /*
321 * Default value of board env is based on filename which is
322 * ls2080ardb. Modify board env for other supported SoCs
323 */
324 if ((SVR_SOC_VER(svr) == SVR_LS2088A) ||
325 (SVR_SOC_VER(svr) == SVR_LS2048A))
326 env_set("board", "ls2088ardb");
327 else if ((SVR_SOC_VER(svr) == SVR_LS2081A) ||
328 (SVR_SOC_VER(svr) == SVR_LS2041A))
329 env_set("board", "ls2081ardb");
Rai Harninder6aa1f3b2016-03-23 17:04:38 +0530330
Yangbo Lucf005552015-05-28 14:53:55 +0530331 return 0;
332}
333
York Sune12abcb2015-03-20 19:28:24 -0700334void detail_board_ddr_info(void)
335{
336 puts("\nDDR ");
337 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
338 print_ddr_info(0);
Prabhakar Kushwaha122bcfd2015-11-09 16:42:07 +0530339#ifdef CONFIG_SYS_FSL_HAS_DP_DDR
York Suncbe8e1c2016-04-04 11:41:26 -0700340 if (soc_has_dp_ddr() && gd->bd->bi_dram[2].size) {
York Sune12abcb2015-03-20 19:28:24 -0700341 puts("\nDP-DDR ");
342 print_size(gd->bd->bi_dram[2].size, "");
343 print_ddr_info(CONFIG_DP_DDR_CTRL);
344 }
Prabhakar Kushwaha122bcfd2015-11-09 16:42:07 +0530345#endif
York Sune12abcb2015-03-20 19:28:24 -0700346}
347
York Sune12abcb2015-03-20 19:28:24 -0700348#ifdef CONFIG_FSL_MC_ENET
349void fdt_fixup_board_enet(void *fdt)
350{
351 int offset;
352
Stuart Yodera3466152016-03-02 16:37:13 -0600353 offset = fdt_path_offset(fdt, "/soc/fsl-mc");
York Sune12abcb2015-03-20 19:28:24 -0700354
355 if (offset < 0)
Stuart Yodera3466152016-03-02 16:37:13 -0600356 offset = fdt_path_offset(fdt, "/fsl-mc");
York Sune12abcb2015-03-20 19:28:24 -0700357
358 if (offset < 0) {
359 printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
360 __func__, offset);
361 return;
362 }
363
Mian Yousaf Kaukab97124652018-12-18 14:01:17 +0100364 if (get_mc_boot_status() == 0 &&
365 (is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0))
York Sune12abcb2015-03-20 19:28:24 -0700366 fdt_status_okay(fdt, offset);
367 else
368 fdt_status_fail(fdt, offset);
369}
Alexander Graf2ebeb442016-11-17 01:02:57 +0100370
371void board_quiesce_devices(void)
372{
373 fsl_mc_ldpaa_exit(gd->bd);
374}
York Sune12abcb2015-03-20 19:28:24 -0700375#endif
376
377#ifdef CONFIG_OF_BOARD_SETUP
Santan Kumar39ea8bf2017-07-05 18:05:08 +0530378void fsl_fdt_fixup_flash(void *fdt)
379{
380 int offset;
Rajesh Bhagatd5691be2018-12-27 04:37:59 +0000381#ifdef CONFIG_TFABOOT
382 u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
383 u32 val;
384#endif
Santan Kumar39ea8bf2017-07-05 18:05:08 +0530385
386/*
387 * IFC and QSPI are muxed on board.
388 * So disable IFC node in dts if QSPI is enabled or
389 * disable QSPI node in dts in case QSPI is not enabled.
390 */
Rajesh Bhagatd5691be2018-12-27 04:37:59 +0000391#ifdef CONFIG_TFABOOT
392 enum boot_src src = get_boot_src();
393 bool disable_ifc = false;
394
395 switch (src) {
396 case BOOT_SOURCE_IFC_NOR:
397 disable_ifc = false;
398 break;
399 case BOOT_SOURCE_QSPI_NOR:
400 disable_ifc = true;
401 break;
402 default:
403 val = in_le32(dcfg_ccsr + DCFG_RCWSR15 / 4);
404 if (DCFG_RCWSR15_IFCGRPABASE_QSPI == (val & (u32)0x3))
405 disable_ifc = true;
406 break;
407 }
408
409 if (disable_ifc) {
410 offset = fdt_path_offset(fdt, "/soc/ifc");
411
412 if (offset < 0)
413 offset = fdt_path_offset(fdt, "/ifc");
414 } else {
415 offset = fdt_path_offset(fdt, "/soc/quadspi");
416
417 if (offset < 0)
418 offset = fdt_path_offset(fdt, "/quadspi");
419 }
420
421#else
Santan Kumar39ea8bf2017-07-05 18:05:08 +0530422#ifdef CONFIG_FSL_QSPI
423 offset = fdt_path_offset(fdt, "/soc/ifc");
424
425 if (offset < 0)
426 offset = fdt_path_offset(fdt, "/ifc");
427#else
428 offset = fdt_path_offset(fdt, "/soc/quadspi");
429
430 if (offset < 0)
431 offset = fdt_path_offset(fdt, "/quadspi");
432#endif
Rajesh Bhagatd5691be2018-12-27 04:37:59 +0000433#endif
434
Santan Kumar39ea8bf2017-07-05 18:05:08 +0530435 if (offset < 0)
436 return;
437
438 fdt_status_disabled(fdt, offset);
439}
440
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900441int ft_board_setup(void *blob, struct bd_info *bd)
York Sune12abcb2015-03-20 19:28:24 -0700442{
Meenakshi Aggarwald67ae482019-05-23 15:13:43 +0530443 int i;
444 u16 mc_memory_bank = 0;
445
446 u64 *base;
447 u64 *size;
448 u64 mc_memory_base = 0;
449 u64 mc_memory_size = 0;
450 u16 total_memory_banks;
York Sune12abcb2015-03-20 19:28:24 -0700451
452 ft_cpu_setup(blob, bd);
453
Meenakshi Aggarwald67ae482019-05-23 15:13:43 +0530454 fdt_fixup_mc_ddr(&mc_memory_base, &mc_memory_size);
455
456 if (mc_memory_base != 0)
457 mc_memory_bank++;
458
459 total_memory_banks = CONFIG_NR_DRAM_BANKS + mc_memory_bank;
460
461 base = calloc(total_memory_banks, sizeof(u64));
462 size = calloc(total_memory_banks, sizeof(u64));
463
Bhupesh Sharma0b10a1a2015-05-28 14:54:10 +0530464 /* fixup DT for the two GPP DDR banks */
465 base[0] = gd->bd->bi_dram[0].start;
466 size[0] = gd->bd->bi_dram[0].size;
467 base[1] = gd->bd->bi_dram[1].start;
468 size[1] = gd->bd->bi_dram[1].size;
469
York Sun4de24ef2017-03-06 09:02:28 -0800470#ifdef CONFIG_RESV_RAM
471 /* reduce size if reserved memory is within this bank */
472 if (gd->arch.resv_ram >= base[0] &&
473 gd->arch.resv_ram < base[0] + size[0])
474 size[0] = gd->arch.resv_ram - base[0];
475 else if (gd->arch.resv_ram >= base[1] &&
476 gd->arch.resv_ram < base[1] + size[1])
477 size[1] = gd->arch.resv_ram - base[1];
478#endif
479
Meenakshi Aggarwald67ae482019-05-23 15:13:43 +0530480 if (mc_memory_base != 0) {
481 for (i = 0; i <= total_memory_banks; i++) {
482 if (base[i] == 0 && size[i] == 0) {
483 base[i] = mc_memory_base;
484 size[i] = mc_memory_size;
485 break;
486 }
487 }
488 }
489
490 fdt_fixup_memory_banks(blob, base, size, total_memory_banks);
York Sune12abcb2015-03-20 19:28:24 -0700491
Nipun Guptad6912642018-08-20 16:01:14 +0530492 fdt_fsl_mc_fixup_iommu_map_entry(blob);
493
Sriram Dash9fd465c2016-09-16 17:12:15 +0530494 fsl_fdt_fixup_dr_usb(blob, bd);
Sriram Dash01820952016-06-13 09:58:36 +0530495
Santan Kumar39ea8bf2017-07-05 18:05:08 +0530496 fsl_fdt_fixup_flash(blob);
497
York Sune12abcb2015-03-20 19:28:24 -0700498#ifdef CONFIG_FSL_MC_ENET
499 fdt_fixup_board_enet(blob);
York Sune12abcb2015-03-20 19:28:24 -0700500#endif
501
Laurentiu Tudor4adff392019-10-18 09:01:54 +0000502 fdt_fixup_icid(blob);
503
York Sune12abcb2015-03-20 19:28:24 -0700504 return 0;
505}
506#endif
507
508void qixis_dump_switch(void)
509{
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530510#ifdef CONFIG_FSL_QIXIS
York Sune12abcb2015-03-20 19:28:24 -0700511 int i, nr_of_cfgsw;
512
513 QIXIS_WRITE(cms[0], 0x00);
514 nr_of_cfgsw = QIXIS_READ(cms[1]);
515
516 puts("DIP switch settings dump:\n");
517 for (i = 1; i <= nr_of_cfgsw; i++) {
518 QIXIS_WRITE(cms[0], i);
519 printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1]));
520 }
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530521#endif
York Sune12abcb2015-03-20 19:28:24 -0700522}
York Sunac192a92015-05-28 14:54:09 +0530523
524/*
525 * Board rev C and earlier has duplicated I2C addresses for 2nd controller.
526 * Both slots has 0x54, resulting 2nd slot unusable.
527 */
528void update_spd_address(unsigned int ctrl_num,
529 unsigned int slot,
530 unsigned int *addr)
531{
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530532#ifndef CONFIG_TARGET_LS2081ARDB
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530533#ifdef CONFIG_FSL_QIXIS
York Sunac192a92015-05-28 14:54:09 +0530534 u8 sw;
535
536 sw = QIXIS_READ(arch);
537 if ((sw & 0xf) < 0x3) {
538 if (ctrl_num == 1 && slot == 0)
539 *addr = SPD_EEPROM_ADDRESS4;
540 else if (ctrl_num == 1 && slot == 1)
541 *addr = SPD_EEPROM_ADDRESS3;
542 }
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530543#endif
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530544#endif
York Sunac192a92015-05-28 14:54:09 +0530545}