blob: e20267f27ce06d35d40d1f1737198062fc9e73a2 [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>
York Sune12abcb2015-03-20 19:28:24 -07008#include <malloc.h>
9#include <errno.h>
10#include <netdev.h>
11#include <fsl_ifc.h>
12#include <fsl_ddr.h>
13#include <asm/io.h>
Yangbo Lucf005552015-05-28 14:53:55 +053014#include <hwconfig.h>
York Sune12abcb2015-03-20 19:28:24 -070015#include <fdt_support.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090016#include <linux/libfdt.h>
York Sune12abcb2015-03-20 19:28:24 -070017#include <fsl-mc/fsl_mc.h>
Simon Glass9d1f6192019-08-02 09:44:25 -060018#include <env_internal.h>
Alexander Graf34f8e972016-11-17 01:02:59 +010019#include <efi_loader.h>
York Sune12abcb2015-03-20 19:28:24 -070020#include <i2c.h>
York Sun729f2d12017-03-06 09:02:34 -080021#include <asm/arch/mmu.h>
Mingkai Hu0e58b512015-10-26 19:47:50 +080022#include <asm/arch/soc.h>
Santan Kumarc61c6992017-03-07 11:21:03 +053023#include <asm/arch/ppa.h>
Saksham Jainc0c38d22016-03-23 16:24:35 +053024#include <fsl_sec.h>
York Sune12abcb2015-03-20 19:28:24 -070025
Priyanka Jain6720d0a2017-04-28 10:41:34 +053026#ifdef CONFIG_FSL_QIXIS
York Sune12abcb2015-03-20 19:28:24 -070027#include "../common/qixis.h"
Prabhakar Kushwaha122bcfd2015-11-09 16:42:07 +053028#include "ls2080ardb_qixis.h"
Priyanka Jain6720d0a2017-04-28 10:41:34 +053029#endif
Rai Harninder6aa1f3b2016-03-23 17:04:38 +053030#include "../common/vid.h"
York Sune12abcb2015-03-20 19:28:24 -070031
Yangbo Lucf005552015-05-28 14:53:55 +053032#define PIN_MUX_SEL_SDHC 0x00
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +080033#define PIN_MUX_SEL_DSPI 0x0a
Yangbo Lucf005552015-05-28 14:53:55 +053034
35#define SET_SDHC_MUX_SEL(reg, value) ((reg & 0xf0) | value)
York Sune12abcb2015-03-20 19:28:24 -070036DECLARE_GLOBAL_DATA_PTR;
37
Yangbo Lucf005552015-05-28 14:53:55 +053038enum {
39 MUX_TYPE_SDHC,
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +080040 MUX_TYPE_DSPI,
Yangbo Lucf005552015-05-28 14:53:55 +053041};
42
York Sune12abcb2015-03-20 19:28:24 -070043unsigned long long get_qixis_addr(void)
44{
45 unsigned long long addr;
46
47 if (gd->flags & GD_FLG_RELOC)
48 addr = QIXIS_BASE_PHYS;
49 else
50 addr = QIXIS_BASE_PHYS_EARLY;
51
52 /*
53 * IFC address under 256MB is mapped to 0x30000000, any address above
54 * is mapped to 0x5_10000000 up to 4GB.
55 */
56 addr = addr > 0x10000000 ? addr + 0x500000000ULL : addr + 0x30000000;
57
58 return addr;
59}
60
61int checkboard(void)
62{
Priyanka Jain6720d0a2017-04-28 10:41:34 +053063#ifdef CONFIG_FSL_QIXIS
York Sune12abcb2015-03-20 19:28:24 -070064 u8 sw;
Priyanka Jain6720d0a2017-04-28 10:41:34 +053065#endif
Prabhakar Kushwaha67f2e9c2015-05-28 14:54:07 +053066 char buf[15];
67
68 cpu_name(buf);
69 printf("Board: %s-RDB, ", buf);
York Sune12abcb2015-03-20 19:28:24 -070070
Priyanka Jain75cd67f2017-04-27 15:08:07 +053071#ifdef CONFIG_TARGET_LS2081ARDB
Priyanka Jain6720d0a2017-04-28 10:41:34 +053072#ifdef CONFIG_FSL_QIXIS
York Sune12abcb2015-03-20 19:28:24 -070073 sw = QIXIS_READ(arch);
Priyanka Jain75cd67f2017-04-27 15:08:07 +053074 printf("Board version: %c, ", (sw & 0xf) + 'A');
75
76 sw = QIXIS_READ(brdcfg[0]);
Priyanka Jain75985792018-01-08 12:20:42 +053077 sw = (sw >> QIXIS_QMAP_SHIFT) & QIXIS_QMAP_MASK;
Priyanka Jain75cd67f2017-04-27 15:08:07 +053078 switch (sw) {
79 case 0:
80 puts("boot from QSPI DEV#0\n");
81 puts("QSPI_CSA_1 mapped to QSPI DEV#1\n");
82 break;
83 case 1:
84 puts("boot from QSPI DEV#1\n");
85 puts("QSPI_CSA_1 mapped to QSPI DEV#0\n");
86 break;
87 case 2:
88 puts("boot from QSPI EMU\n");
89 puts("QSPI_CSA_1 mapped to QSPI DEV#0\n");
90 break;
91 case 3:
92 puts("boot from QSPI EMU\n");
93 puts("QSPI_CSA_1 mapped to QSPI DEV#1\n");
94 break;
95 case 4:
96 puts("boot from QSPI DEV#0\n");
97 puts("QSPI_CSA_1 mapped to QSPI EMU\n");
98 break;
99 default:
100 printf("invalid setting of SW%u\n", sw);
101 break;
102 }
Priyanka Jain6e9d2952018-01-08 12:59:31 +0530103 printf("FPGA: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata));
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530104#endif
105 puts("SERDES1 Reference : ");
106 printf("Clock1 = 100MHz ");
107 printf("Clock2 = 161.13MHz");
108#else
109#ifdef CONFIG_FSL_QIXIS
110 sw = QIXIS_READ(arch);
111 printf("Board Arch: V%d, ", sw >> 4);
Prabhakar Kushwaha8368a592015-05-28 14:54:04 +0530112 printf("Board version: %c, boot from ", (sw & 0xf) + 'A');
York Sune12abcb2015-03-20 19:28:24 -0700113
114 sw = QIXIS_READ(brdcfg[0]);
115 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
116
117 if (sw < 0x8)
118 printf("vBank: %d\n", sw);
119 else if (sw == 0x9)
120 puts("NAND\n");
121 else
122 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
123
124 printf("FPGA: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata));
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530125#endif
York Sune12abcb2015-03-20 19:28:24 -0700126 puts("SERDES1 Reference : ");
127 printf("Clock1 = 156.25MHz ");
128 printf("Clock2 = 156.25MHz");
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530129#endif
York Sune12abcb2015-03-20 19:28:24 -0700130
131 puts("\nSERDES2 Reference : ");
132 printf("Clock1 = 100MHz ");
133 printf("Clock2 = 100MHz\n");
134
135 return 0;
136}
137
138unsigned long get_board_sys_clk(void)
139{
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530140#ifdef CONFIG_FSL_QIXIS
York Sune12abcb2015-03-20 19:28:24 -0700141 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
142
143 switch (sysclk_conf & 0x0F) {
144 case QIXIS_SYSCLK_83:
145 return 83333333;
146 case QIXIS_SYSCLK_100:
147 return 100000000;
148 case QIXIS_SYSCLK_125:
149 return 125000000;
150 case QIXIS_SYSCLK_133:
151 return 133333333;
152 case QIXIS_SYSCLK_150:
153 return 150000000;
154 case QIXIS_SYSCLK_160:
155 return 160000000;
156 case QIXIS_SYSCLK_166:
157 return 166666666;
158 }
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530159#endif
160 return 100000000;
York Sune12abcb2015-03-20 19:28:24 -0700161}
162
163int select_i2c_ch_pca9547(u8 ch)
164{
165 int ret;
166
Chuanhua Hane9f2f9a2019-07-22 16:36:42 +0800167#ifndef CONFIG_DM_I2C
York Sune12abcb2015-03-20 19:28:24 -0700168 ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
Chuanhua Hane9f2f9a2019-07-22 16:36:42 +0800169#else
170 struct udevice *dev;
171
172 ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, &dev);
173 if (!ret)
174 ret = dm_i2c_write(dev, 0, &ch, 1);
175#endif
176
York Sune12abcb2015-03-20 19:28:24 -0700177 if (ret) {
178 puts("PCA: failed to select proper channel\n");
179 return ret;
180 }
181
182 return 0;
183}
184
Rai Harninder6aa1f3b2016-03-23 17:04:38 +0530185int i2c_multiplexer_select_vid_channel(u8 channel)
186{
187 return select_i2c_ch_pca9547(channel);
188}
189
Yangbo Lucf005552015-05-28 14:53:55 +0530190int config_board_mux(int ctrl_type)
191{
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530192#ifdef CONFIG_FSL_QIXIS
Yangbo Lucf005552015-05-28 14:53:55 +0530193 u8 reg5;
194
195 reg5 = QIXIS_READ(brdcfg[5]);
196
197 switch (ctrl_type) {
198 case MUX_TYPE_SDHC:
199 reg5 = SET_SDHC_MUX_SEL(reg5, PIN_MUX_SEL_SDHC);
200 break;
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800201 case MUX_TYPE_DSPI:
202 reg5 = SET_SDHC_MUX_SEL(reg5, PIN_MUX_SEL_DSPI);
203 break;
Yangbo Lucf005552015-05-28 14:53:55 +0530204 default:
205 printf("Wrong mux interface type\n");
206 return -1;
207 }
208
209 QIXIS_WRITE(brdcfg[5], reg5);
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530210#endif
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800211 return 0;
212}
213
214int board_init(void)
215{
York Sun8cbc1952016-05-26 13:59:03 -0700216#ifdef CONFIG_FSL_MC_ENET
Shaohui Xie8c7ce822016-01-28 15:38:15 +0800217 u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE;
York Sun8cbc1952016-05-26 13:59:03 -0700218#endif
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800219
220 init_final_memctl_regs();
221
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800222#ifdef CONFIG_ENV_IS_NOWHERE
223 gd->env_addr = (ulong)&default_environment[0];
224#endif
225 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
226
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530227#ifdef CONFIG_FSL_QIXIS
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800228 QIXIS_WRITE(rst_ctl, QIXIS_RST_CTL_RESET_EN);
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530229#endif
Udit Agarwalc83ea8a2017-08-16 07:13:29 -0400230
231#ifdef CONFIG_FSL_CAAM
232 sec_init();
233#endif
Santan Kumarc61c6992017-03-07 11:21:03 +0530234#ifdef CONFIG_FSL_LS_PPA
235 ppa_init();
236#endif
237
York Sun8cbc1952016-05-26 13:59:03 -0700238#ifdef CONFIG_FSL_MC_ENET
Shaohui Xie8c7ce822016-01-28 15:38:15 +0800239 /* invert AQR405 IRQ pins polarity */
240 out_le32(irq_ccsr + IRQCR_OFFSET / 4, AQR405_IRQ_MASK);
York Sun8cbc1952016-05-26 13:59:03 -0700241#endif
Udit Agarwal62ed9a82017-02-03 22:53:38 +0530242#ifdef CONFIG_FSL_CAAM
243 sec_init();
244#endif
Shaohui Xie8c7ce822016-01-28 15:38:15 +0800245
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800246 return 0;
247}
248
249int board_early_init_f(void)
250{
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530251#ifdef CONFIG_SYS_I2C_EARLY_INIT
252 i2c_early_init_f();
253#endif
Haikun.Wang@freescale.comb8a258c2015-06-26 19:58:24 +0800254 fsl_lsch3_early_init_f();
Yangbo Lucf005552015-05-28 14:53:55 +0530255 return 0;
256}
257
258int misc_init_r(void)
259{
Santan Kumar0ce3f402017-06-15 17:07:01 +0530260 char *env_hwconfig;
261 u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
262 u32 val;
Priyanka Jain0915dda2017-09-15 10:19:48 +0530263 struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
264 u32 svr = gur_in32(&gur->svr);
Santan Kumar0ce3f402017-06-15 17:07:01 +0530265
266 val = in_le32(dcfg_ccsr + DCFG_RCWSR13 / 4);
267
Simon Glass64b723f2017-08-03 12:22:12 -0600268 env_hwconfig = env_get("hwconfig");
Santan Kumar0ce3f402017-06-15 17:07:01 +0530269
270 if (hwconfig_f("dspi", env_hwconfig) &&
271 DCFG_RCWSR13_DSPI == (val & (u32)(0xf << 8)))
272 config_board_mux(MUX_TYPE_DSPI);
273 else
274 config_board_mux(MUX_TYPE_SDHC);
275
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530276 /*
Santan Kumar20e7f5a2017-06-09 11:48:05 +0530277 * LS2081ARDB RevF board has smart voltage translator
Priyanka Jaind1587182017-04-25 10:12:31 +0530278 * which needs to be programmed to enable high speed SD interface
279 * by setting GPIO4_10 output to zero
280 */
Santan Kumar20e7f5a2017-06-09 11:48:05 +0530281#ifdef CONFIG_TARGET_LS2081ARDB
Priyanka Jaind1587182017-04-25 10:12:31 +0530282 out_le32(GPIO4_GPDIR_ADDR, (1 << 21 |
283 in_le32(GPIO4_GPDIR_ADDR)));
284 out_le32(GPIO4_GPDAT_ADDR, (~(1 << 21) &
285 in_le32(GPIO4_GPDAT_ADDR)));
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530286#endif
Yangbo Lucf005552015-05-28 14:53:55 +0530287 if (hwconfig("sdhc"))
288 config_board_mux(MUX_TYPE_SDHC);
289
Rai Harninder6aa1f3b2016-03-23 17:04:38 +0530290 if (adjust_vdd(0))
291 printf("Warning: Adjusting core voltage failed.\n");
Priyanka Jain0915dda2017-09-15 10:19:48 +0530292 /*
293 * Default value of board env is based on filename which is
294 * ls2080ardb. Modify board env for other supported SoCs
295 */
296 if ((SVR_SOC_VER(svr) == SVR_LS2088A) ||
297 (SVR_SOC_VER(svr) == SVR_LS2048A))
298 env_set("board", "ls2088ardb");
299 else if ((SVR_SOC_VER(svr) == SVR_LS2081A) ||
300 (SVR_SOC_VER(svr) == SVR_LS2041A))
301 env_set("board", "ls2081ardb");
Rai Harninder6aa1f3b2016-03-23 17:04:38 +0530302
Yangbo Lucf005552015-05-28 14:53:55 +0530303 return 0;
304}
305
York Sune12abcb2015-03-20 19:28:24 -0700306void detail_board_ddr_info(void)
307{
308 puts("\nDDR ");
309 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
310 print_ddr_info(0);
Prabhakar Kushwaha122bcfd2015-11-09 16:42:07 +0530311#ifdef CONFIG_SYS_FSL_HAS_DP_DDR
York Suncbe8e1c2016-04-04 11:41:26 -0700312 if (soc_has_dp_ddr() && gd->bd->bi_dram[2].size) {
York Sune12abcb2015-03-20 19:28:24 -0700313 puts("\nDP-DDR ");
314 print_size(gd->bd->bi_dram[2].size, "");
315 print_ddr_info(CONFIG_DP_DDR_CTRL);
316 }
Prabhakar Kushwaha122bcfd2015-11-09 16:42:07 +0530317#endif
York Sune12abcb2015-03-20 19:28:24 -0700318}
319
York Sune12abcb2015-03-20 19:28:24 -0700320#if defined(CONFIG_ARCH_MISC_INIT)
321int arch_misc_init(void)
322{
York Sune12abcb2015-03-20 19:28:24 -0700323 return 0;
324}
325#endif
326
York Sune12abcb2015-03-20 19:28:24 -0700327#ifdef CONFIG_FSL_MC_ENET
328void fdt_fixup_board_enet(void *fdt)
329{
330 int offset;
331
Stuart Yodera3466152016-03-02 16:37:13 -0600332 offset = fdt_path_offset(fdt, "/soc/fsl-mc");
York Sune12abcb2015-03-20 19:28:24 -0700333
334 if (offset < 0)
Stuart Yodera3466152016-03-02 16:37:13 -0600335 offset = fdt_path_offset(fdt, "/fsl-mc");
York Sune12abcb2015-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 Kaukab97124652018-12-18 14:01:17 +0100343 if (get_mc_boot_status() == 0 &&
344 (is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0))
York Sune12abcb2015-03-20 19:28:24 -0700345 fdt_status_okay(fdt, offset);
346 else
347 fdt_status_fail(fdt, offset);
348}
Alexander Graf2ebeb442016-11-17 01:02:57 +0100349
350void board_quiesce_devices(void)
351{
352 fsl_mc_ldpaa_exit(gd->bd);
353}
York Sune12abcb2015-03-20 19:28:24 -0700354#endif
355
356#ifdef CONFIG_OF_BOARD_SETUP
Santan Kumar39ea8bf2017-07-05 18:05:08 +0530357void fsl_fdt_fixup_flash(void *fdt)
358{
359 int offset;
Rajesh Bhagatd5691be2018-12-27 04:37:59 +0000360#ifdef CONFIG_TFABOOT
361 u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
362 u32 val;
363#endif
Santan Kumar39ea8bf2017-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 Bhagatd5691be2018-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 Kumar39ea8bf2017-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 Bhagatd5691be2018-12-27 04:37:59 +0000412#endif
413
Santan Kumar39ea8bf2017-07-05 18:05:08 +0530414 if (offset < 0)
415 return;
416
417 fdt_status_disabled(fdt, offset);
418}
419
York Sune12abcb2015-03-20 19:28:24 -0700420int ft_board_setup(void *blob, bd_t *bd)
421{
Meenakshi Aggarwald67ae482019-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 Sune12abcb2015-03-20 19:28:24 -0700430
431 ft_cpu_setup(blob, bd);
432
Meenakshi Aggarwald67ae482019-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 Sharma0b10a1a2015-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 Sun4de24ef2017-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 Aggarwald67ae482019-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 Sune12abcb2015-03-20 19:28:24 -0700470
Nipun Guptad6912642018-08-20 16:01:14 +0530471 fdt_fsl_mc_fixup_iommu_map_entry(blob);
472
Sriram Dash9fd465c2016-09-16 17:12:15 +0530473 fsl_fdt_fixup_dr_usb(blob, bd);
Sriram Dash01820952016-06-13 09:58:36 +0530474
Santan Kumar39ea8bf2017-07-05 18:05:08 +0530475 fsl_fdt_fixup_flash(blob);
476
York Sune12abcb2015-03-20 19:28:24 -0700477#ifdef CONFIG_FSL_MC_ENET
478 fdt_fixup_board_enet(blob);
York Sune12abcb2015-03-20 19:28:24 -0700479#endif
480
481 return 0;
482}
483#endif
484
485void qixis_dump_switch(void)
486{
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530487#ifdef CONFIG_FSL_QIXIS
York Sune12abcb2015-03-20 19:28:24 -0700488 int i, nr_of_cfgsw;
489
490 QIXIS_WRITE(cms[0], 0x00);
491 nr_of_cfgsw = QIXIS_READ(cms[1]);
492
493 puts("DIP switch settings dump:\n");
494 for (i = 1; i <= nr_of_cfgsw; i++) {
495 QIXIS_WRITE(cms[0], i);
496 printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1]));
497 }
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530498#endif
York Sune12abcb2015-03-20 19:28:24 -0700499}
York Sunac192a92015-05-28 14:54:09 +0530500
501/*
502 * Board rev C and earlier has duplicated I2C addresses for 2nd controller.
503 * Both slots has 0x54, resulting 2nd slot unusable.
504 */
505void update_spd_address(unsigned int ctrl_num,
506 unsigned int slot,
507 unsigned int *addr)
508{
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530509#ifndef CONFIG_TARGET_LS2081ARDB
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530510#ifdef CONFIG_FSL_QIXIS
York Sunac192a92015-05-28 14:54:09 +0530511 u8 sw;
512
513 sw = QIXIS_READ(arch);
514 if ((sw & 0xf) < 0x3) {
515 if (ctrl_num == 1 && slot == 0)
516 *addr = SPD_EEPROM_ADDRESS4;
517 else if (ctrl_num == 1 && slot == 1)
518 *addr = SPD_EEPROM_ADDRESS3;
519 }
Priyanka Jain6720d0a2017-04-28 10:41:34 +0530520#endif
Priyanka Jain75cd67f2017-04-27 15:08:07 +0530521#endif
York Sunac192a92015-05-28 14:54:09 +0530522}