blob: c5ae02bc93f30f3bfcf21d76b95c25bf4c632173 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
York Sune2b65ea2015-03-20 19:28:24 -07002/*
3 * Copyright 2015 Freescale Semiconductor
Alison Wanga7943fd2018-06-18 20:25:05 +08004 * Copyright 2017 NXP
York Sune2b65ea2015-03-20 19:28:24 -07005 */
6#include <common.h>
Simon Glass9fb625c2019-08-01 09:46:51 -06007#include <env.h>
Simon Glass691d7192020-05-10 11:40:02 -06008#include <init.h>
York Sune2b65ea2015-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 Glass401d1c42020-10-30 21:38:53 -060014#include <asm/global_data.h>
York Sune2b65ea2015-03-20 19:28:24 -070015#include <asm/io.h>
Yangbo Lu5a4d7442015-05-28 14:53:55 +053016#include <hwconfig.h>
York Sune2b65ea2015-03-20 19:28:24 -070017#include <fdt_support.h>
Masahiro Yamadab08c8c42018-03-05 01:20:11 +090018#include <linux/libfdt.h>
York Sune2b65ea2015-03-20 19:28:24 -070019#include <fsl-mc/fsl_mc.h>
Simon Glassf3998fd2019-08-02 09:44:25 -060020#include <env_internal.h>
Alexander Graf215b1fb2016-11-17 01:02:59 +010021#include <efi_loader.h>
York Sune2b65ea2015-03-20 19:28:24 -070022#include <i2c.h>
York Sun4961eaf2017-03-06 09:02:34 -080023#include <asm/arch/mmu.h>
Mingkai Hu9f3183d2015-10-26 19:47:50 +080024#include <asm/arch/soc.h>
Santan Kumar54ad7b52017-03-07 11:21:03 +053025#include <asm/arch/ppa.h>
Saksham Jainfcfdb6d2016-03-23 16:24:35 +053026#include <fsl_sec.h>
Laurentiu Tudore33938a2019-10-18 09:01:54 +000027#include <asm/arch-fsl-layerscape/fsl_icid.h>
York Sune2b65ea2015-03-20 19:28:24 -070028
Priyanka Jaind1418c12017-04-28 10:41:34 +053029#ifdef CONFIG_FSL_QIXIS
York Sune2b65ea2015-03-20 19:28:24 -070030#include "../common/qixis.h"
Prabhakar Kushwaha44937212015-11-09 16:42:07 +053031#include "ls2080ardb_qixis.h"
Priyanka Jaind1418c12017-04-28 10:41:34 +053032#endif
Rai Harnindered2530d2016-03-23 17:04:38 +053033#include "../common/vid.h"
York Sune2b65ea2015-03-20 19:28:24 -070034
Yangbo Lu5a4d7442015-05-28 14:53:55 +053035#define PIN_MUX_SEL_SDHC 0x00
Haikun.Wang@freescale.com5989df72015-06-26 19:58:24 +080036#define PIN_MUX_SEL_DSPI 0x0a
Yangbo Lu5a4d7442015-05-28 14:53:55 +053037
38#define SET_SDHC_MUX_SEL(reg, value) ((reg & 0xf0) | value)
York Sune2b65ea2015-03-20 19:28:24 -070039DECLARE_GLOBAL_DATA_PTR;
40
Yangbo Lu5a4d7442015-05-28 14:53:55 +053041enum {
42 MUX_TYPE_SDHC,
Haikun.Wang@freescale.com5989df72015-06-26 19:58:24 +080043 MUX_TYPE_DSPI,
Yangbo Lu5a4d7442015-05-28 14:53:55 +053044};
45
York Sune2b65ea2015-03-20 19:28:24 -070046unsigned long long get_qixis_addr(void)
47{
48 unsigned long long addr;
49
50 if (gd->flags & GD_FLG_RELOC)
51 addr = QIXIS_BASE_PHYS;
52 else
53 addr = QIXIS_BASE_PHYS_EARLY;
54
55 /*
56 * IFC address under 256MB is mapped to 0x30000000, any address above
57 * is mapped to 0x5_10000000 up to 4GB.
58 */
59 addr = addr > 0x10000000 ? addr + 0x500000000ULL : addr + 0x30000000;
60
61 return addr;
62}
63
64int checkboard(void)
65{
Priyanka Jaind1418c12017-04-28 10:41:34 +053066#ifdef CONFIG_FSL_QIXIS
York Sune2b65ea2015-03-20 19:28:24 -070067 u8 sw;
Priyanka Jaind1418c12017-04-28 10:41:34 +053068#endif
Prabhakar Kushwahaff1b8e32015-05-28 14:54:07 +053069 char buf[15];
70
71 cpu_name(buf);
72 printf("Board: %s-RDB, ", buf);
York Sune2b65ea2015-03-20 19:28:24 -070073
Priyanka Jain3049a582017-04-27 15:08:07 +053074#ifdef CONFIG_TARGET_LS2081ARDB
75#ifdef CONFIG_FSL_QIXIS
76 sw = QIXIS_READ(arch);
Priyanka Jain3049a582017-04-27 15:08:07 +053077 printf("Board version: %c, ", (sw & 0xf) + 'A');
78
79 sw = QIXIS_READ(brdcfg[0]);
Priyanka Jainda28a032018-01-08 12:20:42 +053080 sw = (sw >> QIXIS_QMAP_SHIFT) & QIXIS_QMAP_MASK;
Priyanka Jain3049a582017-04-27 15:08:07 +053081 switch (sw) {
82 case 0:
83 puts("boot from QSPI DEV#0\n");
84 puts("QSPI_CSA_1 mapped to QSPI DEV#1\n");
85 break;
86 case 1:
87 puts("boot from QSPI DEV#1\n");
88 puts("QSPI_CSA_1 mapped to QSPI DEV#0\n");
89 break;
90 case 2:
91 puts("boot from QSPI EMU\n");
92 puts("QSPI_CSA_1 mapped to QSPI DEV#0\n");
93 break;
94 case 3:
95 puts("boot from QSPI EMU\n");
96 puts("QSPI_CSA_1 mapped to QSPI DEV#1\n");
97 break;
98 case 4:
99 puts("boot from QSPI DEV#0\n");
100 puts("QSPI_CSA_1 mapped to QSPI EMU\n");
101 break;
102 default:
103 printf("invalid setting of SW%u\n", sw);
104 break;
105 }
Priyanka Jainf436fbf2018-01-08 12:59:31 +0530106 printf("FPGA: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata));
Priyanka Jain3049a582017-04-27 15:08:07 +0530107#endif
108 puts("SERDES1 Reference : ");
109 printf("Clock1 = 100MHz ");
110 printf("Clock2 = 161.13MHz");
111#else
Priyanka Jaind1418c12017-04-28 10:41:34 +0530112#ifdef CONFIG_FSL_QIXIS
York Sune2b65ea2015-03-20 19:28:24 -0700113 sw = QIXIS_READ(arch);
York Sune2b65ea2015-03-20 19:28:24 -0700114 printf("Board Arch: V%d, ", sw >> 4);
Prabhakar Kushwaha27df54b2015-05-28 14:54:04 +0530115 printf("Board version: %c, boot from ", (sw & 0xf) + 'A');
York Sune2b65ea2015-03-20 19:28:24 -0700116
117 sw = QIXIS_READ(brdcfg[0]);
118 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
119
120 if (sw < 0x8)
121 printf("vBank: %d\n", sw);
122 else if (sw == 0x9)
123 puts("NAND\n");
124 else
125 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
126
127 printf("FPGA: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata));
Priyanka Jaind1418c12017-04-28 10:41:34 +0530128#endif
York Sune2b65ea2015-03-20 19:28:24 -0700129 puts("SERDES1 Reference : ");
130 printf("Clock1 = 156.25MHz ");
131 printf("Clock2 = 156.25MHz");
Priyanka Jain3049a582017-04-27 15:08:07 +0530132#endif
York Sune2b65ea2015-03-20 19:28:24 -0700133
134 puts("\nSERDES2 Reference : ");
135 printf("Clock1 = 100MHz ");
136 printf("Clock2 = 100MHz\n");
137
138 return 0;
139}
140
141unsigned long get_board_sys_clk(void)
142{
Priyanka Jaind1418c12017-04-28 10:41:34 +0530143#ifdef CONFIG_FSL_QIXIS
York Sune2b65ea2015-03-20 19:28:24 -0700144 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
145
146 switch (sysclk_conf & 0x0F) {
147 case QIXIS_SYSCLK_83:
148 return 83333333;
149 case QIXIS_SYSCLK_100:
150 return 100000000;
151 case QIXIS_SYSCLK_125:
152 return 125000000;
153 case QIXIS_SYSCLK_133:
154 return 133333333;
155 case QIXIS_SYSCLK_150:
156 return 150000000;
157 case QIXIS_SYSCLK_160:
158 return 160000000;
159 case QIXIS_SYSCLK_166:
160 return 166666666;
161 }
Priyanka Jaind1418c12017-04-28 10:41:34 +0530162#endif
163 return 100000000;
York Sune2b65ea2015-03-20 19:28:24 -0700164}
165
166int select_i2c_ch_pca9547(u8 ch)
167{
168 int ret;
169
Igor Opaniuk2147a162021-02-09 13:52:45 +0200170#if !CONFIG_IS_ENABLED(DM_I2C)
York Sune2b65ea2015-03-20 19:28:24 -0700171 ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
Chuanhua Han654e4e72019-07-22 16:36:42 +0800172#else
173 struct udevice *dev;
174
175 ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, &dev);
176 if (!ret)
177 ret = dm_i2c_write(dev, 0, &ch, 1);
178#endif
179
York Sune2b65ea2015-03-20 19:28:24 -0700180 if (ret) {
181 puts("PCA: failed to select proper channel\n");
182 return ret;
183 }
184
185 return 0;
186}
187
Rai Harnindered2530d2016-03-23 17:04:38 +0530188int i2c_multiplexer_select_vid_channel(u8 channel)
189{
190 return select_i2c_ch_pca9547(channel);
191}
192
Haikun.Wang@freescale.com5989df72015-06-26 19:58:24 +0800193int config_board_mux(int ctrl_type)
194{
Priyanka Jaind1418c12017-04-28 10:41:34 +0530195#ifdef CONFIG_FSL_QIXIS
Haikun.Wang@freescale.com5989df72015-06-26 19:58:24 +0800196 u8 reg5;
197
198 reg5 = QIXIS_READ(brdcfg[5]);
199
200 switch (ctrl_type) {
201 case MUX_TYPE_SDHC:
202 reg5 = SET_SDHC_MUX_SEL(reg5, PIN_MUX_SEL_SDHC);
203 break;
204 case MUX_TYPE_DSPI:
205 reg5 = SET_SDHC_MUX_SEL(reg5, PIN_MUX_SEL_DSPI);
206 break;
207 default:
208 printf("Wrong mux interface type\n");
209 return -1;
210 }
211
212 QIXIS_WRITE(brdcfg[5], reg5);
Priyanka Jaind1418c12017-04-28 10:41:34 +0530213#endif
Haikun.Wang@freescale.com5989df72015-06-26 19:58:24 +0800214 return 0;
215}
216
York Sune2b65ea2015-03-20 19:28:24 -0700217int board_init(void)
218{
York Sun931e8752016-05-26 13:59:03 -0700219#ifdef CONFIG_FSL_MC_ENET
Shaohui Xieabc7d0f2016-01-28 15:38:15 +0800220 u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE;
York Sun931e8752016-05-26 13:59:03 -0700221#endif
Haikun.Wang@freescale.com5989df72015-06-26 19:58:24 +0800222
York Sune2b65ea2015-03-20 19:28:24 -0700223 init_final_memctl_regs();
224
225#ifdef CONFIG_ENV_IS_NOWHERE
226 gd->env_addr = (ulong)&default_environment[0];
227#endif
228 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
229
Priyanka Jaind1418c12017-04-28 10:41:34 +0530230#ifdef CONFIG_FSL_QIXIS
York Sune2b65ea2015-03-20 19:28:24 -0700231 QIXIS_WRITE(rst_ctl, QIXIS_RST_CTL_RESET_EN);
Priyanka Jaind1418c12017-04-28 10:41:34 +0530232#endif
Udit Agarwal15e7c682017-08-16 07:13:29 -0400233
234#ifdef CONFIG_FSL_CAAM
235 sec_init();
236#endif
Santan Kumar54ad7b52017-03-07 11:21:03 +0530237#ifdef CONFIG_FSL_LS_PPA
238 ppa_init();
239#endif
240
York Sun931e8752016-05-26 13:59:03 -0700241#ifdef CONFIG_FSL_MC_ENET
Shaohui Xieabc7d0f2016-01-28 15:38:15 +0800242 /* invert AQR405 IRQ pins polarity */
243 out_le32(irq_ccsr + IRQCR_OFFSET / 4, AQR405_IRQ_MASK);
York Sun931e8752016-05-26 13:59:03 -0700244#endif
Udit Agarwala8c6fd42017-02-03 22:53:38 +0530245#ifdef CONFIG_FSL_CAAM
246 sec_init();
247#endif
Shaohui Xieabc7d0f2016-01-28 15:38:15 +0800248
Ioana Ciornei8da10582020-03-18 16:47:40 +0200249#if !defined(CONFIG_SYS_EARLY_PCI_INIT) && defined(CONFIG_DM_ETH)
250 pci_init();
251#endif
252
York Sune2b65ea2015-03-20 19:28:24 -0700253 return 0;
254}
255
256int board_early_init_f(void)
257{
Priyanka Jain3049a582017-04-27 15:08:07 +0530258#ifdef CONFIG_SYS_I2C_EARLY_INIT
259 i2c_early_init_f();
260#endif
York Sune2b65ea2015-03-20 19:28:24 -0700261 fsl_lsch3_early_init_f();
262 return 0;
263}
264
Yangbo Lu5a4d7442015-05-28 14:53:55 +0530265int misc_init_r(void)
266{
Santan Kumar263536a2017-06-15 17:07:01 +0530267 char *env_hwconfig;
268 u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
269 u32 val;
Priyanka Jainb5dfd472017-09-15 10:19:48 +0530270 struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
271 u32 svr = gur_in32(&gur->svr);
Santan Kumar263536a2017-06-15 17:07:01 +0530272
273 val = in_le32(dcfg_ccsr + DCFG_RCWSR13 / 4);
274
Simon Glass00caae62017-08-03 12:22:12 -0600275 env_hwconfig = env_get("hwconfig");
Santan Kumar263536a2017-06-15 17:07:01 +0530276
277 if (hwconfig_f("dspi", env_hwconfig) &&
278 DCFG_RCWSR13_DSPI == (val & (u32)(0xf << 8)))
279 config_board_mux(MUX_TYPE_DSPI);
280 else
281 config_board_mux(MUX_TYPE_SDHC);
282
Priyanka Jain3049a582017-04-27 15:08:07 +0530283 /*
Santan Kumar6cc914e2017-06-09 11:48:05 +0530284 * LS2081ARDB RevF board has smart voltage translator
Priyanka Jain51934052017-04-25 10:12:31 +0530285 * which needs to be programmed to enable high speed SD interface
286 * by setting GPIO4_10 output to zero
287 */
Santan Kumar6cc914e2017-06-09 11:48:05 +0530288#ifdef CONFIG_TARGET_LS2081ARDB
Priyanka Jain51934052017-04-25 10:12:31 +0530289 out_le32(GPIO4_GPDIR_ADDR, (1 << 21 |
290 in_le32(GPIO4_GPDIR_ADDR)));
291 out_le32(GPIO4_GPDAT_ADDR, (~(1 << 21) &
292 in_le32(GPIO4_GPDAT_ADDR)));
Priyanka Jain51934052017-04-25 10:12:31 +0530293#endif
Yangbo Lu5a4d7442015-05-28 14:53:55 +0530294 if (hwconfig("sdhc"))
295 config_board_mux(MUX_TYPE_SDHC);
296
Rai Harnindered2530d2016-03-23 17:04:38 +0530297 if (adjust_vdd(0))
298 printf("Warning: Adjusting core voltage failed.\n");
Priyanka Jainb5dfd472017-09-15 10:19:48 +0530299 /*
300 * Default value of board env is based on filename which is
301 * ls2080ardb. Modify board env for other supported SoCs
302 */
303 if ((SVR_SOC_VER(svr) == SVR_LS2088A) ||
304 (SVR_SOC_VER(svr) == SVR_LS2048A))
305 env_set("board", "ls2088ardb");
306 else if ((SVR_SOC_VER(svr) == SVR_LS2081A) ||
307 (SVR_SOC_VER(svr) == SVR_LS2041A))
308 env_set("board", "ls2081ardb");
Rai Harnindered2530d2016-03-23 17:04:38 +0530309
Yangbo Lu5a4d7442015-05-28 14:53:55 +0530310 return 0;
311}
312
York Sune2b65ea2015-03-20 19:28:24 -0700313void detail_board_ddr_info(void)
314{
315 puts("\nDDR ");
316 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
317 print_ddr_info(0);
Prabhakar Kushwaha44937212015-11-09 16:42:07 +0530318#ifdef CONFIG_SYS_FSL_HAS_DP_DDR
York Sun3c1d2182016-04-04 11:41:26 -0700319 if (soc_has_dp_ddr() && gd->bd->bi_dram[2].size) {
York Sune2b65ea2015-03-20 19:28:24 -0700320 puts("\nDP-DDR ");
321 print_size(gd->bd->bi_dram[2].size, "");
322 print_ddr_info(CONFIG_DP_DDR_CTRL);
323 }
Prabhakar Kushwaha44937212015-11-09 16:42:07 +0530324#endif
York Sune2b65ea2015-03-20 19:28:24 -0700325}
326
York Sune2b65ea2015-03-20 19:28:24 -0700327#ifdef CONFIG_FSL_MC_ENET
328void fdt_fixup_board_enet(void *fdt)
329{
330 int offset;
331
Stuart Yodere91f1de2016-03-02 16:37:13 -0600332 offset = fdt_path_offset(fdt, "/soc/fsl-mc");
York Sune2b65ea2015-03-20 19:28:24 -0700333
334 if (offset < 0)
Stuart Yodere91f1de2016-03-02 16:37:13 -0600335 offset = fdt_path_offset(fdt, "/fsl-mc");
York Sune2b65ea2015-03-20 19:28:24 -0700336
337 if (offset < 0) {
338 printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
339 __func__, offset);
340 return;
341 }
342
Mian Yousaf Kaukab7e968042018-12-18 14:01:17 +0100343 if (get_mc_boot_status() == 0 &&
344 (is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0))
York Sune2b65ea2015-03-20 19:28:24 -0700345 fdt_status_okay(fdt, offset);
346 else
347 fdt_status_fail(fdt, offset);
348}
Alexander Grafb7b84102016-11-17 01:02:57 +0100349
350void board_quiesce_devices(void)
351{
352 fsl_mc_ldpaa_exit(gd->bd);
353}
York Sune2b65ea2015-03-20 19:28:24 -0700354#endif
355
356#ifdef CONFIG_OF_BOARD_SETUP
Santan Kumar7794d9a2017-07-05 18:05:08 +0530357void fsl_fdt_fixup_flash(void *fdt)
358{
359 int offset;
Rajesh Bhagat9570df02018-12-27 04:37:59 +0000360#ifdef CONFIG_TFABOOT
361 u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
362 u32 val;
363#endif
Santan Kumar7794d9a2017-07-05 18:05:08 +0530364
365/*
366 * IFC and QSPI are muxed on board.
367 * So disable IFC node in dts if QSPI is enabled or
368 * disable QSPI node in dts in case QSPI is not enabled.
369 */
Rajesh Bhagat9570df02018-12-27 04:37:59 +0000370#ifdef CONFIG_TFABOOT
371 enum boot_src src = get_boot_src();
372 bool disable_ifc = false;
373
374 switch (src) {
375 case BOOT_SOURCE_IFC_NOR:
376 disable_ifc = false;
377 break;
378 case BOOT_SOURCE_QSPI_NOR:
379 disable_ifc = true;
380 break;
381 default:
382 val = in_le32(dcfg_ccsr + DCFG_RCWSR15 / 4);
383 if (DCFG_RCWSR15_IFCGRPABASE_QSPI == (val & (u32)0x3))
384 disable_ifc = true;
385 break;
386 }
387
388 if (disable_ifc) {
389 offset = fdt_path_offset(fdt, "/soc/ifc");
390
391 if (offset < 0)
392 offset = fdt_path_offset(fdt, "/ifc");
393 } else {
394 offset = fdt_path_offset(fdt, "/soc/quadspi");
395
396 if (offset < 0)
397 offset = fdt_path_offset(fdt, "/quadspi");
398 }
399
400#else
Santan Kumar7794d9a2017-07-05 18:05:08 +0530401#ifdef CONFIG_FSL_QSPI
402 offset = fdt_path_offset(fdt, "/soc/ifc");
403
404 if (offset < 0)
405 offset = fdt_path_offset(fdt, "/ifc");
406#else
407 offset = fdt_path_offset(fdt, "/soc/quadspi");
408
409 if (offset < 0)
410 offset = fdt_path_offset(fdt, "/quadspi");
411#endif
Rajesh Bhagat9570df02018-12-27 04:37:59 +0000412#endif
413
Santan Kumar7794d9a2017-07-05 18:05:08 +0530414 if (offset < 0)
415 return;
416
417 fdt_status_disabled(fdt, offset);
418}
419
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +0900420int ft_board_setup(void *blob, struct bd_info *bd)
York Sune2b65ea2015-03-20 19:28:24 -0700421{
Meenakshi Aggarwalcf0bbbd2019-05-23 15:13:43 +0530422 int i;
423 u16 mc_memory_bank = 0;
424
425 u64 *base;
426 u64 *size;
427 u64 mc_memory_base = 0;
428 u64 mc_memory_size = 0;
429 u16 total_memory_banks;
York Sune2b65ea2015-03-20 19:28:24 -0700430
431 ft_cpu_setup(blob, bd);
432
Meenakshi Aggarwalcf0bbbd2019-05-23 15:13:43 +0530433 fdt_fixup_mc_ddr(&mc_memory_base, &mc_memory_size);
434
435 if (mc_memory_base != 0)
436 mc_memory_bank++;
437
438 total_memory_banks = CONFIG_NR_DRAM_BANKS + mc_memory_bank;
439
440 base = calloc(total_memory_banks, sizeof(u64));
441 size = calloc(total_memory_banks, sizeof(u64));
442
Bhupesh Sharmaa2dc8182015-05-28 14:54:10 +0530443 /* fixup DT for the two GPP DDR banks */
444 base[0] = gd->bd->bi_dram[0].start;
445 size[0] = gd->bd->bi_dram[0].size;
446 base[1] = gd->bd->bi_dram[1].start;
447 size[1] = gd->bd->bi_dram[1].size;
448
York Sun36cc0de2017-03-06 09:02:28 -0800449#ifdef CONFIG_RESV_RAM
450 /* reduce size if reserved memory is within this bank */
451 if (gd->arch.resv_ram >= base[0] &&
452 gd->arch.resv_ram < base[0] + size[0])
453 size[0] = gd->arch.resv_ram - base[0];
454 else if (gd->arch.resv_ram >= base[1] &&
455 gd->arch.resv_ram < base[1] + size[1])
456 size[1] = gd->arch.resv_ram - base[1];
457#endif
458
Meenakshi Aggarwalcf0bbbd2019-05-23 15:13:43 +0530459 if (mc_memory_base != 0) {
460 for (i = 0; i <= total_memory_banks; i++) {
461 if (base[i] == 0 && size[i] == 0) {
462 base[i] = mc_memory_base;
463 size[i] = mc_memory_size;
464 break;
465 }
466 }
467 }
468
469 fdt_fixup_memory_banks(blob, base, size, total_memory_banks);
York Sune2b65ea2015-03-20 19:28:24 -0700470
Nipun Guptaa78df402018-08-20 16:01:14 +0530471 fdt_fsl_mc_fixup_iommu_map_entry(blob);
472
Sriram Dasha5c289b2016-09-16 17:12:15 +0530473 fsl_fdt_fixup_dr_usb(blob, bd);
Sriram Dashef53b8c2016-06-13 09:58:36 +0530474
Santan Kumar7794d9a2017-07-05 18:05:08 +0530475 fsl_fdt_fixup_flash(blob);
476
York Sune2b65ea2015-03-20 19:28:24 -0700477#ifdef CONFIG_FSL_MC_ENET
478 fdt_fixup_board_enet(blob);
York Sune2b65ea2015-03-20 19:28:24 -0700479#endif
480
Laurentiu Tudore33938a2019-10-18 09:01:54 +0000481 fdt_fixup_icid(blob);
482
York Sune2b65ea2015-03-20 19:28:24 -0700483 return 0;
484}
485#endif
486
487void qixis_dump_switch(void)
488{
Priyanka Jaind1418c12017-04-28 10:41:34 +0530489#ifdef CONFIG_FSL_QIXIS
York Sune2b65ea2015-03-20 19:28:24 -0700490 int i, nr_of_cfgsw;
491
492 QIXIS_WRITE(cms[0], 0x00);
493 nr_of_cfgsw = QIXIS_READ(cms[1]);
494
495 puts("DIP switch settings dump:\n");
496 for (i = 1; i <= nr_of_cfgsw; i++) {
497 QIXIS_WRITE(cms[0], i);
498 printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1]));
499 }
Priyanka Jaind1418c12017-04-28 10:41:34 +0530500#endif
York Sune2b65ea2015-03-20 19:28:24 -0700501}
York Sunfc7b3852015-05-28 14:54:09 +0530502
503/*
504 * Board rev C and earlier has duplicated I2C addresses for 2nd controller.
505 * Both slots has 0x54, resulting 2nd slot unusable.
506 */
507void update_spd_address(unsigned int ctrl_num,
508 unsigned int slot,
509 unsigned int *addr)
510{
Priyanka Jain3049a582017-04-27 15:08:07 +0530511#ifndef CONFIG_TARGET_LS2081ARDB
Priyanka Jaind1418c12017-04-28 10:41:34 +0530512#ifdef CONFIG_FSL_QIXIS
York Sunfc7b3852015-05-28 14:54:09 +0530513 u8 sw;
514
515 sw = QIXIS_READ(arch);
516 if ((sw & 0xf) < 0x3) {
517 if (ctrl_num == 1 && slot == 0)
518 *addr = SPD_EEPROM_ADDRESS4;
519 else if (ctrl_num == 1 && slot == 1)
520 *addr = SPD_EEPROM_ADDRESS3;
521 }
Priyanka Jaind1418c12017-04-28 10:41:34 +0530522#endif
Priyanka Jain3049a582017-04-27 15:08:07 +0530523#endif
York Sunfc7b3852015-05-28 14:54:09 +0530524}