blob: 1b10aa759b156bc01b729ca77ba365689f6a4ef6 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Ashish Kumare84a3242017-08-31 16:12:54 +05302/*
Pramod Kumar5b595df2018-10-12 14:04:27 +00003 * Copyright 2017-2018 NXP
Ashish Kumare84a3242017-08-31 16:12:54 +05304 */
5#include <common.h>
Simon Glass7b51b572019-08-01 09:46:52 -06006#include <env.h>
Ashish Kumare84a3242017-08-31 16:12:54 +05307#include <i2c.h>
Simon Glass691d7192020-05-10 11:40:02 -06008#include <init.h>
Ashish Kumare84a3242017-08-31 16:12:54 +05309#include <malloc.h>
10#include <errno.h>
11#include <netdev.h>
12#include <fsl_ifc.h>
13#include <fsl_ddr.h>
14#include <fsl_sec.h>
15#include <asm/io.h>
16#include <fdt_support.h>
Masahiro Yamadab08c8c42018-03-05 01:20:11 +090017#include <linux/libfdt.h>
Ashish Kumare84a3242017-08-31 16:12:54 +053018#include <fsl-mc/fsl_mc.h>
Simon Glassf3998fd2019-08-02 09:44:25 -060019#include <env_internal.h>
Ashish Kumare84a3242017-08-31 16:12:54 +053020#include <asm/arch-fsl-layerscape/soc.h>
21#include <asm/arch/ppa.h>
Yangbo Lu44cdb5b2017-11-27 15:40:17 +080022#include <hwconfig.h>
Rajesh Bhagatef0789b2018-01-17 16:13:09 +053023#include <asm/arch/fsl_serdes.h>
24#include <asm/arch/soc.h>
Laurentiu Tudor5c6dc6c2019-07-30 17:29:58 +030025#include <asm/arch-fsl-layerscape/fsl_icid.h>
Ashish Kumare84a3242017-08-31 16:12:54 +053026
27#include "../common/qixis.h"
28#include "ls1088a_qixis.h"
Rajesh Bhagatef0789b2018-01-17 16:13:09 +053029#include "../common/vid.h"
30#include <fsl_immap.h>
Ashish Kumare84a3242017-08-31 16:12:54 +053031
32DECLARE_GLOBAL_DATA_PTR;
33
Pankit Garg1a12b4a2018-12-27 04:37:57 +000034#ifdef CONFIG_TARGET_LS1088AQDS
35#ifdef CONFIG_TFABOOT
36struct ifc_regs ifc_cfg_ifc_nor_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = {
37 {
38 "nor0",
39 CONFIG_SYS_NOR0_CSPR_EARLY,
40 CONFIG_SYS_NOR0_CSPR_EXT,
41 CONFIG_SYS_NOR_AMASK,
42 CONFIG_SYS_NOR_CSOR,
43 {
44 CONFIG_SYS_NOR_FTIM0,
45 CONFIG_SYS_NOR_FTIM1,
46 CONFIG_SYS_NOR_FTIM2,
47 CONFIG_SYS_NOR_FTIM3
48 },
49 0,
50 CONFIG_SYS_NOR0_CSPR,
51 0,
52 },
53 {
54 "nor1",
55 CONFIG_SYS_NOR1_CSPR_EARLY,
56 CONFIG_SYS_NOR0_CSPR_EXT,
57 CONFIG_SYS_NOR_AMASK_EARLY,
58 CONFIG_SYS_NOR_CSOR,
59 {
60 CONFIG_SYS_NOR_FTIM0,
61 CONFIG_SYS_NOR_FTIM1,
62 CONFIG_SYS_NOR_FTIM2,
63 CONFIG_SYS_NOR_FTIM3
64 },
65 0,
66 CONFIG_SYS_NOR1_CSPR,
67 CONFIG_SYS_NOR_AMASK,
68 },
69 {
70 "nand",
71 CONFIG_SYS_NAND_CSPR,
72 CONFIG_SYS_NAND_CSPR_EXT,
73 CONFIG_SYS_NAND_AMASK,
74 CONFIG_SYS_NAND_CSOR,
75 {
76 CONFIG_SYS_NAND_FTIM0,
77 CONFIG_SYS_NAND_FTIM1,
78 CONFIG_SYS_NAND_FTIM2,
79 CONFIG_SYS_NAND_FTIM3
80 },
81 },
82 {
83 "fpga",
84 CONFIG_SYS_FPGA_CSPR,
85 CONFIG_SYS_FPGA_CSPR_EXT,
86 SYS_FPGA_AMASK,
87 CONFIG_SYS_FPGA_CSOR,
88 {
89 SYS_FPGA_CS_FTIM0,
90 SYS_FPGA_CS_FTIM1,
91 SYS_FPGA_CS_FTIM2,
92 SYS_FPGA_CS_FTIM3
93 },
94 0,
95 SYS_FPGA_CSPR_FINAL,
96 0,
97 }
98};
99
100struct ifc_regs ifc_cfg_qspi_nor_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = {
101 {
102 "nand",
103 CONFIG_SYS_NAND_CSPR,
104 CONFIG_SYS_NAND_CSPR_EXT,
105 CONFIG_SYS_NAND_AMASK,
106 CONFIG_SYS_NAND_CSOR,
107 {
108 CONFIG_SYS_NAND_FTIM0,
109 CONFIG_SYS_NAND_FTIM1,
110 CONFIG_SYS_NAND_FTIM2,
111 CONFIG_SYS_NAND_FTIM3
112 },
113 },
114 {
115 "reserved",
116 },
117 {
118 "fpga",
119 CONFIG_SYS_FPGA_CSPR,
120 CONFIG_SYS_FPGA_CSPR_EXT,
121 SYS_FPGA_AMASK,
122 CONFIG_SYS_FPGA_CSOR,
123 {
124 SYS_FPGA_CS_FTIM0,
125 SYS_FPGA_CS_FTIM1,
126 SYS_FPGA_CS_FTIM2,
127 SYS_FPGA_CS_FTIM3
128 },
129 0,
130 SYS_FPGA_CSPR_FINAL,
131 0,
132 }
133};
134
135void ifc_cfg_boot_info(struct ifc_regs_info *regs_info)
136{
137 enum boot_src src = get_boot_src();
138
139 if (src == BOOT_SOURCE_QSPI_NOR)
140 regs_info->regs = ifc_cfg_qspi_nor_boot;
141 else
142 regs_info->regs = ifc_cfg_ifc_nor_boot;
143
144 regs_info->cs_size = CONFIG_SYS_FSL_IFC_BANK_COUNT;
145}
146#endif /* CONFIG_TFABOOT */
147#endif /* CONFIG_TARGET_LS1088AQDS */
148
Sumit Garg10e7eaf2018-01-06 09:04:24 +0530149int board_early_init_f(void)
150{
Ashish Kumar169d4932018-02-19 14:14:53 +0530151#if defined(CONFIG_SYS_I2C_EARLY_INIT) && defined(CONFIG_TARGET_LS1088AQDS)
152 i2c_early_init_f();
153#endif
Sumit Garg10e7eaf2018-01-06 09:04:24 +0530154 fsl_lsch3_early_init_f();
155 return 0;
156}
157
158#ifdef CONFIG_FSL_QIXIS
Ashish Kumare84a3242017-08-31 16:12:54 +0530159unsigned long long get_qixis_addr(void)
160{
161 unsigned long long addr;
162
163 if (gd->flags & GD_FLG_RELOC)
164 addr = QIXIS_BASE_PHYS;
165 else
166 addr = QIXIS_BASE_PHYS_EARLY;
167
168 /*
169 * IFC address under 256MB is mapped to 0x30000000, any address above
170 * is mapped to 0x5_10000000 up to 4GB.
171 */
172 addr = addr > 0x10000000 ? addr + 0x500000000ULL : addr + 0x30000000;
173
174 return addr;
175}
Sumit Garg10e7eaf2018-01-06 09:04:24 +0530176#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530177
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530178#if defined(CONFIG_VID)
179int init_func_vid(void)
180{
181 if (adjust_vdd(0) < 0)
182 printf("core voltage not adjusted\n");
183
184 return 0;
185}
186#endif
187
Pramod Kumar5b595df2018-10-12 14:04:27 +0000188int is_pb_board(void)
189{
190 u8 board_id;
191
192 board_id = QIXIS_READ(id);
193 if (board_id == LS1088ARDB_PB_BOARD)
194 return 1;
195 else
196 return 0;
197}
198
199int fixup_ls1088ardb_pb_banner(void *fdt)
200{
201 fdt_setprop_string(fdt, 0, "model", "LS1088ARDB-PB Board");
202
203 return 0;
204}
205
Sumit Garg10e7eaf2018-01-06 09:04:24 +0530206#if !defined(CONFIG_SPL_BUILD)
Ashish Kumare84a3242017-08-31 16:12:54 +0530207int checkboard(void)
208{
Pankit Garg143af3c2018-12-27 04:37:55 +0000209#ifdef CONFIG_TFABOOT
210 enum boot_src src = get_boot_src();
211#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530212 char buf[64];
213 u8 sw;
214 static const char *const freq[] = {"100", "125", "156.25",
215 "100 separate SSCG"};
216 int clock;
217
Ashish Kumar77697762017-08-31 16:12:55 +0530218#ifdef CONFIG_TARGET_LS1088AQDS
219 printf("Board: LS1088A-QDS, ");
220#else
Pramod Kumar5b595df2018-10-12 14:04:27 +0000221 if (is_pb_board())
222 printf("Board: LS1088ARDB-PB, ");
223 else
224 printf("Board: LS1088A-RDB, ");
Ashish Kumar77697762017-08-31 16:12:55 +0530225#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530226
227 sw = QIXIS_READ(arch);
228 printf("Board Arch: V%d, ", sw >> 4);
229
Ashish Kumar77697762017-08-31 16:12:55 +0530230#ifdef CONFIG_TARGET_LS1088AQDS
231 printf("Board version: %c, boot from ", (sw & 0xf) + 'A' - 1);
232#else
Ashish Kumare84a3242017-08-31 16:12:54 +0530233 printf("Board version: %c, boot from ", (sw & 0xf) + 'A');
Ashish Kumar77697762017-08-31 16:12:55 +0530234#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530235
236 memset((u8 *)buf, 0x00, ARRAY_SIZE(buf));
237
238 sw = QIXIS_READ(brdcfg[0]);
239 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
240
Pankit Garg143af3c2018-12-27 04:37:55 +0000241#ifdef CONFIG_TFABOOT
242 if (src == BOOT_SOURCE_SD_MMC)
243 puts("SD card\n");
244#else
Ashish Kumare84a3242017-08-31 16:12:54 +0530245#ifdef CONFIG_SD_BOOT
246 puts("SD card\n");
247#endif
Pankit Garg143af3c2018-12-27 04:37:55 +0000248#endif /* CONFIG_TFABOOT */
Ashish Kumare84a3242017-08-31 16:12:54 +0530249 switch (sw) {
Ashish Kumar77697762017-08-31 16:12:55 +0530250#ifdef CONFIG_TARGET_LS1088AQDS
Ashish Kumare84a3242017-08-31 16:12:54 +0530251 case 0:
Ashish Kumar77697762017-08-31 16:12:55 +0530252 case 1:
253 case 2:
254 case 3:
255 case 4:
256 case 5:
257 case 6:
258 case 7:
259 printf("vBank: %d\n", sw);
260 break;
261 case 8:
262 puts("PromJet\n");
263 break;
264 case 15:
265 puts("IFCCard\n");
266 break;
267 case 14:
268#else
269 case 0:
270#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530271 puts("QSPI:");
272 sw = QIXIS_READ(brdcfg[0]);
273 sw = (sw & QIXIS_QMAP_MASK) >> QIXIS_QMAP_SHIFT;
274 if (sw == 0 || sw == 4)
275 puts("0\n");
276 else if (sw == 1)
277 puts("1\n");
278 else
279 puts("EMU\n");
280 break;
281
282 default:
283 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
284 break;
285 }
286
Ashish Kumar77697762017-08-31 16:12:55 +0530287#ifdef CONFIG_TARGET_LS1088AQDS
288 printf("FPGA: v%d (%s), build %d",
289 (int)QIXIS_READ(scver), qixis_read_tag(buf),
290 (int)qixis_read_minor());
291 /* the timestamp string contains "\n" at the end */
292 printf(" on %s", qixis_read_time(buf));
293#else
Ashish Kumare84a3242017-08-31 16:12:54 +0530294 printf("CPLD: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata));
Ashish Kumar77697762017-08-31 16:12:55 +0530295#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530296
297 /*
298 * Display the actual SERDES reference clocks as configured by the
299 * dip switches on the board. Note that the SWx registers could
300 * technically be set to force the reference clocks to match the
301 * values that the SERDES expects (or vice versa). For now, however,
302 * we just display both values and hope the user notices when they
303 * don't match.
304 */
305 puts("SERDES1 Reference : ");
306 sw = QIXIS_READ(brdcfg[2]);
307 clock = (sw >> 6) & 3;
308 printf("Clock1 = %sMHz ", freq[clock]);
309 clock = (sw >> 4) & 3;
310 printf("Clock2 = %sMHz", freq[clock]);
311
312 puts("\nSERDES2 Reference : ");
313 clock = (sw >> 2) & 3;
314 printf("Clock1 = %sMHz ", freq[clock]);
315 clock = (sw >> 0) & 3;
316 printf("Clock2 = %sMHz\n", freq[clock]);
317
318 return 0;
319}
Ashish Kumard12b1662018-02-19 14:14:52 +0530320#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530321
322bool if_board_diff_clk(void)
323{
Ashish Kumar77697762017-08-31 16:12:55 +0530324#ifdef CONFIG_TARGET_LS1088AQDS
325 u8 diff_conf = QIXIS_READ(brdcfg[11]);
326 return diff_conf & 0x40;
327#else
Ashish Kumare84a3242017-08-31 16:12:54 +0530328 u8 diff_conf = QIXIS_READ(dutcfg[11]);
329 return diff_conf & 0x80;
Ashish Kumar77697762017-08-31 16:12:55 +0530330#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530331}
332
333unsigned long get_board_sys_clk(void)
334{
335 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
336
337 switch (sysclk_conf & 0x0f) {
338 case QIXIS_SYSCLK_83:
339 return 83333333;
340 case QIXIS_SYSCLK_100:
341 return 100000000;
342 case QIXIS_SYSCLK_125:
343 return 125000000;
344 case QIXIS_SYSCLK_133:
345 return 133333333;
346 case QIXIS_SYSCLK_150:
347 return 150000000;
348 case QIXIS_SYSCLK_160:
349 return 160000000;
350 case QIXIS_SYSCLK_166:
351 return 166666666;
352 }
353
354 return 66666666;
355}
356
357unsigned long get_board_ddr_clk(void)
358{
359 u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
360
361 if (if_board_diff_clk())
362 return get_board_sys_clk();
363 switch ((ddrclk_conf & 0x30) >> 4) {
364 case QIXIS_DDRCLK_100:
365 return 100000000;
366 case QIXIS_DDRCLK_125:
367 return 125000000;
368 case QIXIS_DDRCLK_133:
369 return 133333333;
370 }
371
372 return 66666666;
373}
374
375int select_i2c_ch_pca9547(u8 ch)
376{
377 int ret;
378
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800379#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530380 ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800381#else
382 struct udevice *dev;
383
384 ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, &dev);
385 if (!ret)
386 ret = dm_i2c_write(dev, 0, &ch, 1);
387#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530388 if (ret) {
389 puts("PCA: failed to select proper channel\n");
390 return ret;
391 }
392
393 return 0;
394}
395
Rajesh Bhagat980d61a2018-01-17 16:13:10 +0530396#if !defined(CONFIG_SPL_BUILD)
Ashish Kumare84a3242017-08-31 16:12:54 +0530397void board_retimer_init(void)
398{
399 u8 reg;
400
401 /* Retimer is connected to I2C1_CH5 */
402 select_i2c_ch_pca9547(I2C_MUX_CH5);
403
404 /* Access to Control/Shared register */
405 reg = 0x0;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800406#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530407 i2c_write(I2C_RETIMER_ADDR, 0xff, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800408#else
409 struct udevice *dev;
410
411 i2c_get_chip_for_busnum(0, I2C_RETIMER_ADDR, 1, &dev);
412 dm_i2c_write(dev, 0xff, &reg, 1);
413#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530414
415 /* Read device revision and ID */
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800416#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530417 i2c_read(I2C_RETIMER_ADDR, 1, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800418#else
419 dm_i2c_read(dev, 1, &reg, 1);
420#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530421 debug("Retimer version id = 0x%x\n", reg);
422
423 /* Enable Broadcast. All writes target all channel register sets */
424 reg = 0x0c;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800425#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530426 i2c_write(I2C_RETIMER_ADDR, 0xff, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800427#else
428 dm_i2c_write(dev, 0xff, &reg, 1);
429#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530430
431 /* Reset Channel Registers */
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800432#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530433 i2c_read(I2C_RETIMER_ADDR, 0, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800434#else
435 dm_i2c_read(dev, 0, &reg, 1);
436#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530437 reg |= 0x4;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800438#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530439 i2c_write(I2C_RETIMER_ADDR, 0, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800440#else
441 dm_i2c_write(dev, 0, &reg, 1);
442#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530443
444 /* Set data rate as 10.3125 Gbps */
445 reg = 0x90;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800446#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530447 i2c_write(I2C_RETIMER_ADDR, 0x60, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800448#else
449 dm_i2c_write(dev, 0x60, &reg, 1);
450#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530451 reg = 0xb3;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800452#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530453 i2c_write(I2C_RETIMER_ADDR, 0x61, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800454#else
455 dm_i2c_write(dev, 0x61, &reg, 1);
456#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530457 reg = 0x90;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800458#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530459 i2c_write(I2C_RETIMER_ADDR, 0x62, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800460#else
461 dm_i2c_write(dev, 0x62, &reg, 1);
462#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530463 reg = 0xb3;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800464#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530465 i2c_write(I2C_RETIMER_ADDR, 0x63, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800466#else
467 dm_i2c_write(dev, 0x63, &reg, 1);
468#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530469 reg = 0xcd;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800470#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530471 i2c_write(I2C_RETIMER_ADDR, 0x64, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800472#else
473 dm_i2c_write(dev, 0x64, &reg, 1);
474#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530475
476 /* Select VCO Divider to full rate (000) */
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800477#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530478 i2c_read(I2C_RETIMER_ADDR, 0x2F, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800479#else
480 dm_i2c_read(dev, 0x2F, &reg, 1);
481#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530482 reg &= 0x0f;
483 reg |= 0x70;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800484#ifndef CONFIG_DM_I2C
Ashish Kumare84a3242017-08-31 16:12:54 +0530485 i2c_write(I2C_RETIMER_ADDR, 0x2F, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800486#else
487 dm_i2c_write(dev, 0x2F, &reg, 1);
488#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530489
Ashish Kumar77697762017-08-31 16:12:55 +0530490#ifdef CONFIG_TARGET_LS1088AQDS
491 /* Retimer is connected to I2C1_CH5 */
492 select_i2c_ch_pca9547(I2C_MUX_CH5);
Ashish Kumare84a3242017-08-31 16:12:54 +0530493
Ashish Kumar77697762017-08-31 16:12:55 +0530494 /* Access to Control/Shared register */
495 reg = 0x0;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800496#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530497 i2c_write(I2C_RETIMER_ADDR2, 0xff, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800498#else
499 i2c_get_chip_for_busnum(0, I2C_RETIMER_ADDR2, 1, &dev);
500 dm_i2c_write(dev, 0xff, &reg, 1);
501#endif
Ashish Kumar77697762017-08-31 16:12:55 +0530502
503 /* Read device revision and ID */
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800504#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530505 i2c_read(I2C_RETIMER_ADDR2, 1, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800506#else
507 dm_i2c_read(dev, 1, &reg, 1);
508#endif
Ashish Kumar77697762017-08-31 16:12:55 +0530509 debug("Retimer version id = 0x%x\n", reg);
510
511 /* Enable Broadcast. All writes target all channel register sets */
512 reg = 0x0c;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800513#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530514 i2c_write(I2C_RETIMER_ADDR2, 0xff, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800515#else
516 dm_i2c_write(dev, 0xff, &reg, 1);
517#endif
Ashish Kumar77697762017-08-31 16:12:55 +0530518
519 /* Reset Channel Registers */
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800520#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530521 i2c_read(I2C_RETIMER_ADDR2, 0, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800522#else
523 dm_i2c_read(dev, 0, &reg, 1);
524#endif
Ashish Kumar77697762017-08-31 16:12:55 +0530525 reg |= 0x4;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800526#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530527 i2c_write(I2C_RETIMER_ADDR2, 0, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800528#else
529 dm_i2c_write(dev, 0, &reg, 1);
530#endif
Ashish Kumar77697762017-08-31 16:12:55 +0530531
532 /* Set data rate as 10.3125 Gbps */
533 reg = 0x90;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800534#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530535 i2c_write(I2C_RETIMER_ADDR2, 0x60, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800536#else
537 dm_i2c_write(dev, 0x60, &reg, 1);
538#endif
Ashish Kumar77697762017-08-31 16:12:55 +0530539 reg = 0xb3;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800540#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530541 i2c_write(I2C_RETIMER_ADDR2, 0x61, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800542#else
543 dm_i2c_write(dev, 0x61, &reg, 1);
544#endif
Ashish Kumar77697762017-08-31 16:12:55 +0530545 reg = 0x90;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800546#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530547 i2c_write(I2C_RETIMER_ADDR2, 0x62, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800548#else
549 dm_i2c_write(dev, 0x62, &reg, 1);
550#endif
Ashish Kumar77697762017-08-31 16:12:55 +0530551 reg = 0xb3;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800552#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530553 i2c_write(I2C_RETIMER_ADDR2, 0x63, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800554#else
555 dm_i2c_write(dev, 0x63, &reg, 1);
556#endif
Ashish Kumar77697762017-08-31 16:12:55 +0530557 reg = 0xcd;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800558#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530559 i2c_write(I2C_RETIMER_ADDR2, 0x64, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800560#else
561 dm_i2c_write(dev, 0x64, &reg, 1);
562#endif
Ashish Kumar77697762017-08-31 16:12:55 +0530563
564 /* Select VCO Divider to full rate (000) */
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800565#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530566 i2c_read(I2C_RETIMER_ADDR2, 0x2F, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800567#else
568 dm_i2c_read(dev, 0x2F, &reg, 1);
569#endif
Ashish Kumar77697762017-08-31 16:12:55 +0530570 reg &= 0x0f;
571 reg |= 0x70;
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800572#ifndef CONFIG_DM_I2C
Ashish Kumar77697762017-08-31 16:12:55 +0530573 i2c_write(I2C_RETIMER_ADDR2, 0x2F, 1, &reg, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800574#else
575 dm_i2c_write(dev, 0x2F, &reg, 1);
576#endif
577
Ashish Kumar77697762017-08-31 16:12:55 +0530578#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530579 /*return the default channel*/
580 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
581}
582
Yangbo Lu44cdb5b2017-11-27 15:40:17 +0800583#ifdef CONFIG_MISC_INIT_R
584int misc_init_r(void)
585{
586#ifdef CONFIG_TARGET_LS1088ARDB
587 u8 brdcfg5;
588
589 if (hwconfig("esdhc-force-sd")) {
590 brdcfg5 = QIXIS_READ(brdcfg[5]);
591 brdcfg5 &= ~BRDCFG5_SPISDHC_MASK;
592 brdcfg5 |= BRDCFG5_FORCE_SD;
593 QIXIS_WRITE(brdcfg[5], brdcfg5);
594 }
595#endif
Chuanhua Han17489902019-08-01 16:36:57 +0800596
597#ifdef CONFIG_TARGET_LS1088AQDS
598 u8 brdcfg4, brdcfg5;
599
600 if (hwconfig("dspi-on-board")) {
601 brdcfg4 = QIXIS_READ(brdcfg[4]);
602 brdcfg4 &= ~BRDCFG4_USBOSC_MASK;
603 brdcfg4 |= BRDCFG4_SPI;
604 QIXIS_WRITE(brdcfg[4], brdcfg4);
605
606 brdcfg5 = QIXIS_READ(brdcfg[5]);
607 brdcfg5 &= ~BRDCFG5_SPR_MASK;
608 brdcfg5 |= BRDCFG5_SPI_ON_BOARD;
609 QIXIS_WRITE(brdcfg[5], brdcfg5);
610 } else if (hwconfig("dspi-off-board")) {
611 brdcfg4 = QIXIS_READ(brdcfg[4]);
612 brdcfg4 &= ~BRDCFG4_USBOSC_MASK;
613 brdcfg4 |= BRDCFG4_SPI;
614 QIXIS_WRITE(brdcfg[4], brdcfg4);
615
616 brdcfg5 = QIXIS_READ(brdcfg[5]);
617 brdcfg5 &= ~BRDCFG5_SPR_MASK;
618 brdcfg5 |= BRDCFG5_SPI_OFF_BOARD;
619 QIXIS_WRITE(brdcfg[5], brdcfg5);
620 }
621#endif
Yangbo Lu44cdb5b2017-11-27 15:40:17 +0800622 return 0;
623}
624#endif
Rajesh Bhagat980d61a2018-01-17 16:13:10 +0530625#endif
Yangbo Lu44cdb5b2017-11-27 15:40:17 +0800626
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530627int i2c_multiplexer_select_vid_channel(u8 channel)
628{
629 return select_i2c_ch_pca9547(channel);
630}
631
632#ifdef CONFIG_TARGET_LS1088AQDS
633/* read the current value(SVDD) of the LTM Regulator Voltage */
634int get_serdes_volt(void)
635{
636 int ret, vcode = 0;
637 u8 chan = PWM_CHANNEL0;
638
639 /* Select the PAGE 0 using PMBus commands PAGE for VDD */
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800640#ifndef CONFIG_DM_I2C
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530641 ret = i2c_write(I2C_SVDD_MONITOR_ADDR,
642 PMBUS_CMD_PAGE, 1, &chan, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800643#else
644 struct udevice *dev;
645
646 ret = i2c_get_chip_for_busnum(0, I2C_SVDD_MONITOR_ADDR, 1, &dev);
647 if (!ret)
648 ret = dm_i2c_write(dev, PMBUS_CMD_PAGE,
649 &chan, 1);
650#endif
651
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530652 if (ret) {
653 printf("VID: failed to select VDD Page 0\n");
654 return ret;
655 }
656
657 /* Read the output voltage using PMBus command READ_VOUT */
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800658#ifndef CONFIG_DM_I2C
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530659 ret = i2c_read(I2C_SVDD_MONITOR_ADDR,
660 PMBUS_CMD_READ_VOUT, 1, (void *)&vcode, 2);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800661#else
662 dm_i2c_read(dev, PMBUS_CMD_READ_VOUT, (void *)&vcode, 2);
663#endif
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530664 if (ret) {
665 printf("VID: failed to read the volatge\n");
666 return ret;
667 }
668
669 return vcode;
670}
671
672int set_serdes_volt(int svdd)
673{
674 int ret, vdd_last;
675 u8 buff[5] = {0x04, PWM_CHANNEL0, PMBUS_CMD_VOUT_COMMAND,
676 svdd & 0xFF, (svdd & 0xFF00) >> 8};
677
678 /* Write the desired voltage code to the SVDD regulator */
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800679#ifndef CONFIG_DM_I2C
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530680 ret = i2c_write(I2C_SVDD_MONITOR_ADDR,
681 PMBUS_CMD_PAGE_PLUS_WRITE, 1, (void *)&buff, 5);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800682#else
683 struct udevice *dev;
684
685 ret = i2c_get_chip_for_busnum(0, I2C_SVDD_MONITOR_ADDR, 1, &dev);
686 if (!ret)
687 ret = dm_i2c_write(dev, PMBUS_CMD_PAGE_PLUS_WRITE,
688 (void *)&buff, 5);
689#endif
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530690 if (ret) {
691 printf("VID: I2C failed to write to the volatge regulator\n");
692 return -1;
693 }
694
695 /* Wait for the volatge to get to the desired value */
696 do {
697 vdd_last = get_serdes_volt();
698 if (vdd_last < 0) {
699 printf("VID: Couldn't read sensor abort VID adjust\n");
700 return -1;
701 }
702 } while (vdd_last != svdd);
703
704 return 1;
705}
706#else
707int get_serdes_volt(void)
708{
709 return 0;
710}
711
712int set_serdes_volt(int svdd)
713{
714 int ret;
715 u8 brdcfg4;
716
717 printf("SVDD changing of RDB\n");
718
719 /* Read the BRDCFG54 via CLPD */
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800720#ifndef CONFIG_DM_I2C
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530721 ret = i2c_read(CONFIG_SYS_I2C_FPGA_ADDR,
722 QIXIS_BRDCFG4_OFFSET, 1, (void *)&brdcfg4, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800723#else
724 struct udevice *dev;
725
726 ret = i2c_get_chip_for_busnum(0, CONFIG_SYS_I2C_FPGA_ADDR, 1, &dev);
727 if (!ret)
728 ret = dm_i2c_read(dev, QIXIS_BRDCFG4_OFFSET,
729 (void *)&brdcfg4, 1);
730#endif
731
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530732 if (ret) {
733 printf("VID: I2C failed to read the CPLD BRDCFG4\n");
734 return -1;
735 }
736
737 brdcfg4 = brdcfg4 | 0x08;
738
739 /* Write to the BRDCFG4 */
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800740#ifndef CONFIG_DM_I2C
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530741 ret = i2c_write(CONFIG_SYS_I2C_FPGA_ADDR,
742 QIXIS_BRDCFG4_OFFSET, 1, (void *)&brdcfg4, 1);
Chuanhua Han5dd043a2019-07-23 18:43:11 +0800743#else
744 ret = dm_i2c_write(dev, QIXIS_BRDCFG4_OFFSET,
745 (void *)&brdcfg4, 1);
746#endif
747
Rajesh Bhagatef0789b2018-01-17 16:13:09 +0530748 if (ret) {
749 debug("VID: I2C failed to set the SVDD CPLD BRDCFG4\n");
750 return -1;
751 }
752
753 /* Wait for the volatge to get to the desired value */
754 udelay(10000);
755
756 return 1;
757}
758#endif
759
760/* this function disables the SERDES, changes the SVDD Voltage and enables it*/
761int board_adjust_vdd(int vdd)
762{
763 int ret = 0;
764
765 debug("%s: vdd = %d\n", __func__, vdd);
766
767 /* Special settings to be performed when voltage is 900mV */
768 if (vdd == 900) {
769 ret = setup_serdes_volt(vdd);
770 if (ret < 0) {
771 ret = -1;
772 goto exit;
773 }
774 }
775exit:
776 return ret;
777}
778
Rajesh Bhagat980d61a2018-01-17 16:13:10 +0530779#if !defined(CONFIG_SPL_BUILD)
Ashish Kumare84a3242017-08-31 16:12:54 +0530780int board_init(void)
781{
782 init_final_memctl_regs();
783#if defined(CONFIG_TARGET_LS1088ARDB) && defined(CONFIG_FSL_MC_ENET)
784 u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE;
785#endif
786
787 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
788 board_retimer_init();
789
790#ifdef CONFIG_ENV_IS_NOWHERE
791 gd->env_addr = (ulong)&default_environment[0];
792#endif
793
794#if defined(CONFIG_TARGET_LS1088ARDB) && defined(CONFIG_FSL_MC_ENET)
795 /* invert AQR105 IRQ pins polarity */
796 out_le32(irq_ccsr + IRQCR_OFFSET / 4, AQR105_IRQ_MASK);
797#endif
798
Udit Agarwal30c41d22017-11-22 09:01:26 +0530799#ifdef CONFIG_FSL_CAAM
800 sec_init();
801#endif
Ashish Kumare84a3242017-08-31 16:12:54 +0530802#ifdef CONFIG_FSL_LS_PPA
803 ppa_init();
804#endif
Ioana Ciornei8b6558b2020-03-18 16:47:39 +0200805
806#if !defined(CONFIG_SYS_EARLY_PCI_INIT) && defined(CONFIG_DM_ETH)
807 pci_init();
808#endif
809
Ashish Kumare84a3242017-08-31 16:12:54 +0530810 return 0;
811}
812
Ashish Kumare84a3242017-08-31 16:12:54 +0530813void detail_board_ddr_info(void)
814{
815 puts("\nDDR ");
816 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
817 print_ddr_info(0);
818}
819
Ashish Kumare84a3242017-08-31 16:12:54 +0530820#ifdef CONFIG_FSL_MC_ENET
Mian Yousaf Kaukab41307802019-01-29 16:38:30 +0100821void board_quiesce_devices(void)
822{
823 fsl_mc_ldpaa_exit(gd->bd);
824}
825
Ashish Kumare84a3242017-08-31 16:12:54 +0530826void fdt_fixup_board_enet(void *fdt)
827{
828 int offset;
829
830 offset = fdt_path_offset(fdt, "/fsl-mc");
831
832 if (offset < 0)
Mian Yousaf Kaukab730bd562019-01-29 16:38:31 +0100833 offset = fdt_path_offset(fdt, "/soc/fsl-mc");
Ashish Kumare84a3242017-08-31 16:12:54 +0530834
835 if (offset < 0) {
836 printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
837 __func__, offset);
838 return;
839 }
840
Mian Yousaf Kaukab7e968042018-12-18 14:01:17 +0100841 if (get_mc_boot_status() == 0 &&
842 (is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0))
Ashish Kumare84a3242017-08-31 16:12:54 +0530843 fdt_status_okay(fdt, offset);
844 else
845 fdt_status_fail(fdt, offset);
846}
847#endif
848
849#ifdef CONFIG_OF_BOARD_SETUP
Ashish Kumar6b6b7e82017-11-09 11:14:24 +0530850void fsl_fdt_fixup_flash(void *fdt)
851{
852 int offset;
Pankit Garg143af3c2018-12-27 04:37:55 +0000853#ifdef CONFIG_TFABOOT
854 u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
855 u32 val;
856#endif
Ashish Kumar6b6b7e82017-11-09 11:14:24 +0530857
858/*
859 * IFC-NOR and QSPI are muxed on SoC.
860 * So disable IFC node in dts if QSPI is enabled or
861 * disable QSPI node in dts in case QSPI is not enabled.
862 */
863
Pankit Garg143af3c2018-12-27 04:37:55 +0000864#ifdef CONFIG_TFABOOT
865 enum boot_src src = get_boot_src();
866 bool disable_ifc = false;
867
868 switch (src) {
869 case BOOT_SOURCE_IFC_NOR:
870 disable_ifc = false;
871 break;
872 case BOOT_SOURCE_QSPI_NOR:
873 disable_ifc = true;
874 break;
875 default:
876 val = in_le32(dcfg_ccsr + DCFG_RCWSR15 / 4);
877 if (DCFG_RCWSR15_IFCGRPABASE_QSPI == (val & (u32)0x3))
878 disable_ifc = true;
879 break;
880 }
881
882 if (disable_ifc) {
883 offset = fdt_path_offset(fdt, "/soc/ifc/nor");
884
885 if (offset < 0)
886 offset = fdt_path_offset(fdt, "/ifc/nor");
887 } else {
888 offset = fdt_path_offset(fdt, "/soc/quadspi");
889
890 if (offset < 0)
891 offset = fdt_path_offset(fdt, "/quadspi");
892 }
893
894#else
Ashish Kumar6b6b7e82017-11-09 11:14:24 +0530895#ifdef CONFIG_FSL_QSPI
896 offset = fdt_path_offset(fdt, "/soc/ifc/nor");
897
898 if (offset < 0)
899 offset = fdt_path_offset(fdt, "/ifc/nor");
900#else
901 offset = fdt_path_offset(fdt, "/soc/quadspi");
902
903 if (offset < 0)
904 offset = fdt_path_offset(fdt, "/quadspi");
905#endif
Pankit Garg143af3c2018-12-27 04:37:55 +0000906#endif
Ashish Kumar6b6b7e82017-11-09 11:14:24 +0530907 if (offset < 0)
908 return;
909
910 fdt_status_disabled(fdt, offset);
911}
912
Ashish Kumare84a3242017-08-31 16:12:54 +0530913int ft_board_setup(void *blob, bd_t *bd)
914{
Mian Yousaf Kaukab41307802019-01-29 16:38:30 +0100915 int i;
Meenakshi Aggarwalcf0bbbd2019-05-23 15:13:43 +0530916 u16 mc_memory_bank = 0;
917
918 u64 *base;
919 u64 *size;
920 u64 mc_memory_base = 0;
921 u64 mc_memory_size = 0;
922 u16 total_memory_banks;
Ashish Kumare84a3242017-08-31 16:12:54 +0530923
924 ft_cpu_setup(blob, bd);
925
Meenakshi Aggarwalcf0bbbd2019-05-23 15:13:43 +0530926 fdt_fixup_mc_ddr(&mc_memory_base, &mc_memory_size);
927
928 if (mc_memory_base != 0)
929 mc_memory_bank++;
930
931 total_memory_banks = CONFIG_NR_DRAM_BANKS + mc_memory_bank;
932
933 base = calloc(total_memory_banks, sizeof(u64));
934 size = calloc(total_memory_banks, sizeof(u64));
935
Ashish Kumare84a3242017-08-31 16:12:54 +0530936 /* fixup DT for the two GPP DDR banks */
937 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
938 base[i] = gd->bd->bi_dram[i].start;
939 size[i] = gd->bd->bi_dram[i].size;
940 }
941
942#ifdef CONFIG_RESV_RAM
943 /* reduce size if reserved memory is within this bank */
944 if (gd->arch.resv_ram >= base[0] &&
945 gd->arch.resv_ram < base[0] + size[0])
946 size[0] = gd->arch.resv_ram - base[0];
947 else if (gd->arch.resv_ram >= base[1] &&
948 gd->arch.resv_ram < base[1] + size[1])
949 size[1] = gd->arch.resv_ram - base[1];
950#endif
951
Meenakshi Aggarwalcf0bbbd2019-05-23 15:13:43 +0530952 if (mc_memory_base != 0) {
953 for (i = 0; i <= total_memory_banks; i++) {
954 if (base[i] == 0 && size[i] == 0) {
955 base[i] = mc_memory_base;
956 size[i] = mc_memory_size;
957 break;
958 }
959 }
960 }
961
962 fdt_fixup_memory_banks(blob, base, size, total_memory_banks);
Ashish Kumare84a3242017-08-31 16:12:54 +0530963
Nipun Guptaa78df402018-08-20 16:01:14 +0530964 fdt_fsl_mc_fixup_iommu_map_entry(blob);
965
Ashish Kumar6b6b7e82017-11-09 11:14:24 +0530966 fsl_fdt_fixup_flash(blob);
967
Ashish Kumare84a3242017-08-31 16:12:54 +0530968#ifdef CONFIG_FSL_MC_ENET
969 fdt_fixup_board_enet(blob);
Ashish Kumare84a3242017-08-31 16:12:54 +0530970#endif
Laurentiu Tudor5c6dc6c2019-07-30 17:29:58 +0300971
972 fdt_fixup_icid(blob);
973
Pramod Kumar5b595df2018-10-12 14:04:27 +0000974 if (is_pb_board())
975 fixup_ls1088ardb_pb_banner(blob);
Ashish Kumare84a3242017-08-31 16:12:54 +0530976
977 return 0;
978}
979#endif
Sumit Garg10e7eaf2018-01-06 09:04:24 +0530980#endif /* defined(CONFIG_SPL_BUILD) */
Pankit Garg143af3c2018-12-27 04:37:55 +0000981
982#ifdef CONFIG_TFABOOT
983#ifdef CONFIG_MTD_NOR_FLASH
984int is_flash_available(void)
985{
986 char *env_hwconfig = env_get("hwconfig");
987 enum boot_src src = get_boot_src();
988 int is_nor_flash_available = 1;
989
990 switch (src) {
991 case BOOT_SOURCE_IFC_NOR:
992 is_nor_flash_available = 1;
993 break;
994 case BOOT_SOURCE_QSPI_NOR:
995 is_nor_flash_available = 0;
996 break;
997 /*
998 * In Case of SD boot,if qspi is defined in env_hwconfig
999 * disable nor flash probe.
1000 */
1001 default:
1002 if (hwconfig_f("qspi", env_hwconfig))
1003 is_nor_flash_available = 0;
1004 break;
1005 }
1006 return is_nor_flash_available;
1007}
1008#endif
1009
Tom Rinidbcb4da2019-11-18 20:02:08 -05001010#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
Pankit Garg143af3c2018-12-27 04:37:55 +00001011void *env_sf_get_env_addr(void)
1012{
1013 return (void *)(CONFIG_SYS_FSL_QSPI_BASE + CONFIG_ENV_OFFSET);
1014}
1015#endif
Tom Rinidbcb4da2019-11-18 20:02:08 -05001016#endif