blob: 13359f947bb56a83562166a804b0f944a8f81b47 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Shaohui Xiedd335672015-11-11 17:58:37 +08002/*
3 * Copyright 2015 Freescale Semiconductor, Inc.
Biwen Lib41f6ba2020-07-02 11:13:03 +08004 * Copyright 2019-2020 NXP
Shaohui Xiedd335672015-11-11 17:58:37 +08005 */
6
7#include <common.h>
Tom Rini8c70baa2021-12-14 13:36:40 -05008#include <clock_legacy.h>
Shaohui Xiedd335672015-11-11 17:58:37 +08009#include <i2c.h>
10#include <fdt_support.h>
Simon Glass0e0ac202017-04-06 12:47:04 -060011#include <fsl_ddr_sdram.h>
Simon Glass97589732020-05-10 11:40:02 -060012#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060013#include <log.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060014#include <asm/global_data.h>
Shaohui Xiedd335672015-11-11 17:58:37 +080015#include <asm/io.h>
16#include <asm/arch/clock.h>
17#include <asm/arch/fsl_serdes.h>
Hou Zhiqiang09fd9452017-04-14 14:48:21 +080018#include <asm/arch/ppa.h>
Shaohui Xiedd335672015-11-11 17:58:37 +080019#include <asm/arch/fdt.h>
York Sun729f2d12017-03-06 09:02:34 -080020#include <asm/arch/mmu.h>
Rajesh Bhagat90bde112018-11-05 18:02:48 +000021#include <asm/arch/cpu.h>
Shaohui Xiedd335672015-11-11 17:58:37 +080022#include <asm/arch/soc.h>
Laurentiu Tudor22012d52018-08-27 17:33:59 +030023#include <asm/arch-fsl-layerscape/fsl_icid.h>
Shaohui Xiedd335672015-11-11 17:58:37 +080024#include <ahci.h>
25#include <hwconfig.h>
26#include <mmc.h>
27#include <scsi.h>
28#include <fm_eth.h>
Shaohui Xiedd335672015-11-11 17:58:37 +080029#include <fsl_esdhc.h>
30#include <fsl_ifc.h>
31#include <spl.h>
Stephen Carlson7ee444a2021-06-22 16:39:31 -070032#include "../common/i2c_mux.h"
Shaohui Xiedd335672015-11-11 17:58:37 +080033
34#include "../common/qixis.h"
35#include "ls1043aqds_qixis.h"
36
37DECLARE_GLOBAL_DATA_PTR;
38
39enum {
40 MUX_TYPE_GPIO,
41};
42
43/* LS1043AQDS serdes mux */
44#define CFG_SD_MUX1_SLOT2 0x0 /* SLOT2 TX/RX0 */
45#define CFG_SD_MUX1_SLOT1 0x1 /* SLOT1 TX/RX1 */
46#define CFG_SD_MUX2_SLOT3 0x0 /* SLOT3 TX/RX0 */
47#define CFG_SD_MUX2_SLOT1 0x1 /* SLOT1 TX/RX2 */
48#define CFG_SD_MUX3_SLOT4 0x0 /* SLOT4 TX/RX0 */
49#define CFG_SD_MUX3_MUX4 0x1 /* MUX4 */
50#define CFG_SD_MUX4_SLOT3 0x0 /* SLOT3 TX/RX1 */
51#define CFG_SD_MUX4_SLOT1 0x1 /* SLOT1 TX/RX3 */
Shaohui Xiedb1ab382016-01-21 17:14:53 +080052#define CFG_UART_MUX_MASK 0x6
53#define CFG_UART_MUX_SHIFT 1
54#define CFG_LPUART_EN 0x1
Shaohui Xiedd335672015-11-11 17:58:37 +080055
Rajesh Bhagat90bde112018-11-05 18:02:48 +000056#ifdef CONFIG_TFABOOT
57struct ifc_regs ifc_cfg_nor_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = {
58 {
59 "nor0",
60 CONFIG_SYS_NOR0_CSPR,
61 CONFIG_SYS_NOR0_CSPR_EXT,
62 CONFIG_SYS_NOR_AMASK,
63 CONFIG_SYS_NOR_CSOR,
64 {
65 CONFIG_SYS_NOR_FTIM0,
66 CONFIG_SYS_NOR_FTIM1,
67 CONFIG_SYS_NOR_FTIM2,
68 CONFIG_SYS_NOR_FTIM3
69 },
70
71 },
72 {
73 "nor1",
74 CONFIG_SYS_NOR1_CSPR,
75 CONFIG_SYS_NOR1_CSPR_EXT,
76 CONFIG_SYS_NOR_AMASK,
77 CONFIG_SYS_NOR_CSOR,
78 {
79 CONFIG_SYS_NOR_FTIM0,
80 CONFIG_SYS_NOR_FTIM1,
81 CONFIG_SYS_NOR_FTIM2,
82 CONFIG_SYS_NOR_FTIM3
83 },
84 },
85 {
86 "nand",
87 CONFIG_SYS_NAND_CSPR,
88 CONFIG_SYS_NAND_CSPR_EXT,
89 CONFIG_SYS_NAND_AMASK,
90 CONFIG_SYS_NAND_CSOR,
91 {
92 CONFIG_SYS_NAND_FTIM0,
93 CONFIG_SYS_NAND_FTIM1,
94 CONFIG_SYS_NAND_FTIM2,
95 CONFIG_SYS_NAND_FTIM3
96 },
97 },
98 {
99 "fpga",
100 CONFIG_SYS_FPGA_CSPR,
101 CONFIG_SYS_FPGA_CSPR_EXT,
102 CONFIG_SYS_FPGA_AMASK,
103 CONFIG_SYS_FPGA_CSOR,
104 {
105 CONFIG_SYS_FPGA_FTIM0,
106 CONFIG_SYS_FPGA_FTIM1,
107 CONFIG_SYS_FPGA_FTIM2,
108 CONFIG_SYS_FPGA_FTIM3
109 },
110 }
111};
112
113struct ifc_regs ifc_cfg_nand_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = {
114 {
115 "nand",
116 CONFIG_SYS_NAND_CSPR,
117 CONFIG_SYS_NAND_CSPR_EXT,
118 CONFIG_SYS_NAND_AMASK,
119 CONFIG_SYS_NAND_CSOR,
120 {
121 CONFIG_SYS_NAND_FTIM0,
122 CONFIG_SYS_NAND_FTIM1,
123 CONFIG_SYS_NAND_FTIM2,
124 CONFIG_SYS_NAND_FTIM3
125 },
126 },
127 {
128 "nor0",
129 CONFIG_SYS_NOR0_CSPR,
130 CONFIG_SYS_NOR0_CSPR_EXT,
131 CONFIG_SYS_NOR_AMASK,
132 CONFIG_SYS_NOR_CSOR,
133 {
134 CONFIG_SYS_NOR_FTIM0,
135 CONFIG_SYS_NOR_FTIM1,
136 CONFIG_SYS_NOR_FTIM2,
137 CONFIG_SYS_NOR_FTIM3
138 },
139 },
140 {
141 "nor1",
142 CONFIG_SYS_NOR1_CSPR,
143 CONFIG_SYS_NOR1_CSPR_EXT,
144 CONFIG_SYS_NOR_AMASK,
145 CONFIG_SYS_NOR_CSOR,
146 {
147 CONFIG_SYS_NOR_FTIM0,
148 CONFIG_SYS_NOR_FTIM1,
149 CONFIG_SYS_NOR_FTIM2,
150 CONFIG_SYS_NOR_FTIM3
151 },
152 },
153 {
154 "fpga",
155 CONFIG_SYS_FPGA_CSPR,
156 CONFIG_SYS_FPGA_CSPR_EXT,
157 CONFIG_SYS_FPGA_AMASK,
158 CONFIG_SYS_FPGA_CSOR,
159 {
160 CONFIG_SYS_FPGA_FTIM0,
161 CONFIG_SYS_FPGA_FTIM1,
162 CONFIG_SYS_FPGA_FTIM2,
163 CONFIG_SYS_FPGA_FTIM3
164 },
165 }
166};
167
168void ifc_cfg_boot_info(struct ifc_regs_info *regs_info)
169{
170 enum boot_src src = get_boot_src();
171
172 if (src == BOOT_SOURCE_IFC_NAND)
173 regs_info->regs = ifc_cfg_nand_boot;
174 else
175 regs_info->regs = ifc_cfg_nor_boot;
176 regs_info->cs_size = CONFIG_SYS_FSL_IFC_BANK_COUNT;
177}
178#endif
179
Shaohui Xiedd335672015-11-11 17:58:37 +0800180int checkboard(void)
181{
Rajesh Bhagat90bde112018-11-05 18:02:48 +0000182#ifdef CONFIG_TFABOOT
183 enum boot_src src = get_boot_src();
184#endif
Shaohui Xiedd335672015-11-11 17:58:37 +0800185 char buf[64];
Qianyu Gong68d75202016-06-13 11:20:30 +0800186#ifndef CONFIG_SD_BOOT
Shaohui Xiedd335672015-11-11 17:58:37 +0800187 u8 sw;
188#endif
189
190 puts("Board: LS1043AQDS, boot from ");
191
Rajesh Bhagat90bde112018-11-05 18:02:48 +0000192#ifdef CONFIG_TFABOOT
193 if (src == BOOT_SOURCE_SD_MMC)
194 puts("SD\n");
195 else {
196#endif
197
Shaohui Xiedd335672015-11-11 17:58:37 +0800198#ifdef CONFIG_SD_BOOT
199 puts("SD\n");
200#else
201 sw = QIXIS_READ(brdcfg[0]);
202 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
203
204 if (sw < 0x8)
205 printf("vBank: %d\n", sw);
206 else if (sw == 0x8)
207 puts("PromJet\n");
208 else if (sw == 0x9)
209 puts("NAND\n");
Qianyu Gong68d75202016-06-13 11:20:30 +0800210 else if (sw == 0xF)
211 printf("QSPI\n");
Shaohui Xiedd335672015-11-11 17:58:37 +0800212 else
213 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
214#endif
215
Rajesh Bhagat90bde112018-11-05 18:02:48 +0000216#ifdef CONFIG_TFABOOT
217 }
218#endif
Shaohui Xiedd335672015-11-11 17:58:37 +0800219 printf("Sys ID: 0x%02x, Sys Ver: 0x%02x\n",
220 QIXIS_READ(id), QIXIS_READ(arch));
221
222 printf("FPGA: v%d (%s), build %d\n",
223 (int)QIXIS_READ(scver), qixis_read_tag(buf),
224 (int)qixis_read_minor());
225
226 return 0;
227}
228
229bool if_board_diff_clk(void)
230{
231 u8 diff_conf = QIXIS_READ(brdcfg[11]);
232
233 return diff_conf & 0x40;
234}
235
236unsigned long get_board_sys_clk(void)
237{
238 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
239
240 switch (sysclk_conf & 0x0f) {
241 case QIXIS_SYSCLK_64:
242 return 64000000;
243 case QIXIS_SYSCLK_83:
244 return 83333333;
245 case QIXIS_SYSCLK_100:
246 return 100000000;
247 case QIXIS_SYSCLK_125:
248 return 125000000;
249 case QIXIS_SYSCLK_133:
250 return 133333333;
251 case QIXIS_SYSCLK_150:
252 return 150000000;
253 case QIXIS_SYSCLK_160:
254 return 160000000;
255 case QIXIS_SYSCLK_166:
256 return 166666666;
257 }
258
259 return 66666666;
260}
261
262unsigned long get_board_ddr_clk(void)
263{
264 u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
265
266 if (if_board_diff_clk())
267 return get_board_sys_clk();
268 switch ((ddrclk_conf & 0x30) >> 4) {
269 case QIXIS_DDRCLK_100:
270 return 100000000;
271 case QIXIS_DDRCLK_125:
272 return 125000000;
273 case QIXIS_DDRCLK_133:
274 return 133333333;
275 }
276
277 return 66666666;
278}
279
Shaohui Xiedd335672015-11-11 17:58:37 +0800280int dram_init(void)
281{
282 /*
283 * When resuming from deep sleep, the I2C channel may not be
284 * in the default channel. So, switch to the default channel
285 * before accessing DDR SPD.
Biwen Li014460b2020-02-05 22:02:16 +0800286 *
287 * PCA9547 mount on I2C1 bus
Shaohui Xiedd335672015-11-11 17:58:37 +0800288 */
Biwen Li014460b2020-02-05 22:02:16 +0800289 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
Simon Glass0e0ac202017-04-06 12:47:04 -0600290 fsl_initdram();
Rajesh Bhagat90bde112018-11-05 18:02:48 +0000291#if (!defined(CONFIG_SPL) && !defined(CONFIG_TFABOOT)) || \
292 defined(CONFIG_SPL_BUILD)
York Sun729f2d12017-03-06 09:02:34 -0800293 /* This will break-before-make MMU for DDR */
294 update_early_mmu_table();
295#endif
Shaohui Xiedd335672015-11-11 17:58:37 +0800296
297 return 0;
298}
299
300int i2c_multiplexer_select_vid_channel(u8 channel)
301{
Biwen Li014460b2020-02-05 22:02:16 +0800302 return select_i2c_ch_pca9547(channel, 0);
Shaohui Xiedd335672015-11-11 17:58:37 +0800303}
304
305void board_retimer_init(void)
306{
307 u8 reg;
Biwen Li014460b2020-02-05 22:02:16 +0800308 int bus_num = 0;
Shaohui Xiedd335672015-11-11 17:58:37 +0800309
310 /* Retimer is connected to I2C1_CH7_CH5 */
Biwen Li014460b2020-02-05 22:02:16 +0800311 select_i2c_ch_pca9547(I2C_MUX_CH7, bus_num);
Shaohui Xiedd335672015-11-11 17:58:37 +0800312 reg = I2C_MUX_CH5;
Igor Opaniukf7c91762021-02-09 13:52:45 +0200313#if CONFIG_IS_ENABLED(DM_I2C)
Biwen Li014460b2020-02-05 22:02:16 +0800314 struct udevice *dev;
315 int ret;
316
317 ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_SEC,
318 1, &dev);
319 if (ret) {
320 printf("%s: Cannot find udev for a bus %d\n", __func__,
321 bus_num);
322 return;
323 }
324 dm_i2c_write(dev, 0, &reg, 1);
325
326 /* Access to Control/Shared register */
327 ret = i2c_get_chip_for_busnum(bus_num, I2C_RETIMER_ADDR,
328 1, &dev);
329 if (ret) {
330 printf("%s: Cannot find udev for a bus %d\n", __func__,
331 bus_num);
332 return;
333 }
334
335 reg = 0x0;
336 dm_i2c_write(dev, 0xff, &reg, 1);
337
338 /* Read device revision and ID */
339 dm_i2c_read(dev, 1, &reg, 1);
340 debug("Retimer version id = 0x%x\n", reg);
341
342 /* Enable Broadcast. All writes target all channel register sets */
343 reg = 0x0c;
344 dm_i2c_write(dev, 0xff, &reg, 1);
345
346 /* Reset Channel Registers */
347 dm_i2c_read(dev, 0, &reg, 1);
348 reg |= 0x4;
349 dm_i2c_write(dev, 0, &reg, 1);
350
351 /* Enable override divider select and Enable Override Output Mux */
352 dm_i2c_read(dev, 9, &reg, 1);
353 reg |= 0x24;
354 dm_i2c_write(dev, 9, &reg, 1);
355
356 /* Select VCO Divider to full rate (000) */
357 dm_i2c_read(dev, 0x18, &reg, 1);
358 reg &= 0x8f;
359 dm_i2c_write(dev, 0x18, &reg, 1);
360
361 /* Selects active PFD MUX Input as Re-timed Data (001) */
362 dm_i2c_read(dev, 0x1e, &reg, 1);
363 reg &= 0x3f;
364 reg |= 0x20;
365 dm_i2c_write(dev, 0x1e, &reg, 1);
366
367 /* Set data rate as 10.3125 Gbps */
368 reg = 0x0;
369 dm_i2c_write(dev, 0x60, &reg, 1);
370 reg = 0xb2;
371 dm_i2c_write(dev, 0x61, &reg, 1);
372 reg = 0x90;
373 dm_i2c_write(dev, 0x62, &reg, 1);
374 reg = 0xb3;
375 dm_i2c_write(dev, 0x63, &reg, 1);
376 reg = 0xcd;
377 dm_i2c_write(dev, 0x64, &reg, 1);
378#else
Shaohui Xiedd335672015-11-11 17:58:37 +0800379 i2c_write(I2C_MUX_PCA_ADDR_SEC, 0, 1, &reg, 1);
380
381 /* Access to Control/Shared register */
382 reg = 0x0;
383 i2c_write(I2C_RETIMER_ADDR, 0xff, 1, &reg, 1);
384
385 /* Read device revision and ID */
386 i2c_read(I2C_RETIMER_ADDR, 1, 1, &reg, 1);
387 debug("Retimer version id = 0x%x\n", reg);
388
389 /* Enable Broadcast. All writes target all channel register sets */
390 reg = 0x0c;
391 i2c_write(I2C_RETIMER_ADDR, 0xff, 1, &reg, 1);
392
393 /* Reset Channel Registers */
394 i2c_read(I2C_RETIMER_ADDR, 0, 1, &reg, 1);
395 reg |= 0x4;
396 i2c_write(I2C_RETIMER_ADDR, 0, 1, &reg, 1);
397
398 /* Enable override divider select and Enable Override Output Mux */
399 i2c_read(I2C_RETIMER_ADDR, 9, 1, &reg, 1);
400 reg |= 0x24;
401 i2c_write(I2C_RETIMER_ADDR, 9, 1, &reg, 1);
402
403 /* Select VCO Divider to full rate (000) */
404 i2c_read(I2C_RETIMER_ADDR, 0x18, 1, &reg, 1);
405 reg &= 0x8f;
406 i2c_write(I2C_RETIMER_ADDR, 0x18, 1, &reg, 1);
407
408 /* Selects active PFD MUX Input as Re-timed Data (001) */
409 i2c_read(I2C_RETIMER_ADDR, 0x1e, 1, &reg, 1);
410 reg &= 0x3f;
411 reg |= 0x20;
412 i2c_write(I2C_RETIMER_ADDR, 0x1e, 1, &reg, 1);
413
414 /* Set data rate as 10.3125 Gbps */
415 reg = 0x0;
416 i2c_write(I2C_RETIMER_ADDR, 0x60, 1, &reg, 1);
417 reg = 0xb2;
418 i2c_write(I2C_RETIMER_ADDR, 0x61, 1, &reg, 1);
419 reg = 0x90;
420 i2c_write(I2C_RETIMER_ADDR, 0x62, 1, &reg, 1);
421 reg = 0xb3;
422 i2c_write(I2C_RETIMER_ADDR, 0x63, 1, &reg, 1);
423 reg = 0xcd;
424 i2c_write(I2C_RETIMER_ADDR, 0x64, 1, &reg, 1);
Biwen Li014460b2020-02-05 22:02:16 +0800425#endif
Wenbin Songbc7a4fd2016-03-09 13:38:24 +0800426
427 /* Return the default channel */
Biwen Li014460b2020-02-05 22:02:16 +0800428 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, bus_num);
Shaohui Xiedd335672015-11-11 17:58:37 +0800429}
430
431int board_early_init_f(void)
432{
Biwen Lib41f6ba2020-07-02 11:13:03 +0800433 u32 __iomem *cntcr = (u32 *)CONFIG_SYS_FSL_TIMER_ADDR;
Qianyu Gong8d3d5c42016-02-16 13:12:53 +0800434#ifdef CONFIG_HAS_FSL_XHCI_USB
435 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
436 u32 usb_pwrfault;
437#endif
Shaohui Xiedb1ab382016-01-21 17:14:53 +0800438#ifdef CONFIG_LPUART
439 u8 uart;
440#endif
Qianyu Gonga92f2132016-06-13 11:20:31 +0800441
Biwen Lib41f6ba2020-07-02 11:13:03 +0800442 /*
443 * Enable secure system counter for timer
444 */
445 out_le32(cntcr, 0x1);
446
Tom Rini714482a2021-08-18 23:12:25 -0400447#if defined(CONFIG_SYS_I2C_EARLY_INIT)
Qianyu Gonga92f2132016-06-13 11:20:31 +0800448 i2c_early_init_f();
449#endif
Shaohui Xiedd335672015-11-11 17:58:37 +0800450 fsl_lsch2_early_init_f();
Qianyu Gong8d3d5c42016-02-16 13:12:53 +0800451
452#ifdef CONFIG_HAS_FSL_XHCI_USB
453 out_be32(&scfg->rcwpmuxcr0, 0x3333);
454 out_be32(&scfg->usbdrvvbus_selcr, SCFG_USBDRVVBUS_SELCR_USB1);
455 usb_pwrfault =
Shaohui Xieb8c4fc92016-05-30 14:26:55 +0800456 (SCFG_USBPWRFAULT_DEDICATED << SCFG_USBPWRFAULT_USB3_SHIFT) |
457 (SCFG_USBPWRFAULT_DEDICATED << SCFG_USBPWRFAULT_USB2_SHIFT) |
Qianyu Gong8d3d5c42016-02-16 13:12:53 +0800458 (SCFG_USBPWRFAULT_SHARED << SCFG_USBPWRFAULT_USB1_SHIFT);
459 out_be32(&scfg->usbpwrfault_selcr, usb_pwrfault);
460#endif
461
Shaohui Xiedb1ab382016-01-21 17:14:53 +0800462#ifdef CONFIG_LPUART
463 /* We use lpuart0 as system console */
464 uart = QIXIS_READ(brdcfg[14]);
465 uart &= ~CFG_UART_MUX_MASK;
466 uart |= CFG_LPUART_EN << CFG_UART_MUX_SHIFT;
467 QIXIS_WRITE(brdcfg[14], uart);
468#endif
Shaohui Xiedd335672015-11-11 17:58:37 +0800469
470 return 0;
471}
472
473#ifdef CONFIG_FSL_DEEP_SLEEP
474/* determine if it is a warm boot */
475bool is_warm_boot(void)
476{
477#define DCFG_CCSR_CRSTSR_WDRFR (1 << 3)
478 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
479
480 if (in_be32(&gur->crstsr) & DCFG_CCSR_CRSTSR_WDRFR)
481 return 1;
482
483 return 0;
484}
485#endif
486
487int config_board_mux(int ctrl_type)
488{
489 u8 reg14;
490
491 reg14 = QIXIS_READ(brdcfg[14]);
492
493 switch (ctrl_type) {
494 case MUX_TYPE_GPIO:
495 reg14 = (reg14 & (~0x30)) | 0x20;
496 break;
497 default:
498 puts("Unsupported mux interface type\n");
499 return -1;
500 }
501
502 QIXIS_WRITE(brdcfg[14], reg14);
503
504 return 0;
505}
506
507int config_serdes_mux(void)
508{
509 return 0;
510}
511
512
513#ifdef CONFIG_MISC_INIT_R
514int misc_init_r(void)
515{
516 if (hwconfig("gpio"))
517 config_board_mux(MUX_TYPE_GPIO);
518
519 return 0;
520}
521#endif
522
523int board_init(void)
524{
Hou Zhiqiang4b23ca82016-08-02 19:03:27 +0800525#ifdef CONFIG_SYS_FSL_ERRATUM_A010315
526 erratum_a010315();
527#endif
528
Biwen Li014460b2020-02-05 22:02:16 +0800529 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0);
Shaohui Xiedd335672015-11-11 17:58:37 +0800530 board_retimer_init();
531
532#ifdef CONFIG_SYS_FSL_SERDES
533 config_serdes_mux();
534#endif
535
Hou Zhiqiang09fd9452017-04-14 14:48:21 +0800536#ifdef CONFIG_FSL_LS_PPA
537 ppa_init();
538#endif
539
Shaohui Xiedd335672015-11-11 17:58:37 +0800540 return 0;
541}
542
543#ifdef CONFIG_OF_BOARD_SETUP
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900544int ft_board_setup(void *blob, struct bd_info *bd)
Shaohui Xiedd335672015-11-11 17:58:37 +0800545{
Shaohui Xie16f15fa2016-01-04 11:03:44 +0800546 u64 base[CONFIG_NR_DRAM_BANKS];
547 u64 size[CONFIG_NR_DRAM_BANKS];
Qianyu Gongd2c492a2016-07-21 12:39:27 +0800548 u8 reg;
Shaohui Xie16f15fa2016-01-04 11:03:44 +0800549
550 /* fixup DT for the two DDR banks */
551 base[0] = gd->bd->bi_dram[0].start;
552 size[0] = gd->bd->bi_dram[0].size;
553 base[1] = gd->bd->bi_dram[1].start;
554 size[1] = gd->bd->bi_dram[1].size;
555
556 fdt_fixup_memory_banks(blob, base, size, 2);
Shaohui Xiedd335672015-11-11 17:58:37 +0800557 ft_cpu_setup(blob, bd);
558
559#ifdef CONFIG_SYS_DPAA_FMAN
Madalin Bucur70848512020-04-30 15:59:58 +0300560#ifndef CONFIG_DM_ETH
Shaohui Xiedd335672015-11-11 17:58:37 +0800561 fdt_fixup_fman_ethernet(blob);
Madalin Bucur70848512020-04-30 15:59:58 +0300562#endif
Shaohui Xiedd335672015-11-11 17:58:37 +0800563 fdt_fixup_board_enet(blob);
564#endif
Qianyu Gongd2c492a2016-07-21 12:39:27 +0800565
Laurentiu Tudor22012d52018-08-27 17:33:59 +0300566 fdt_fixup_icid(blob);
567
Qianyu Gongd2c492a2016-07-21 12:39:27 +0800568 reg = QIXIS_READ(brdcfg[0]);
569 reg = (reg & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
570
571 /* Disable IFC if QSPI is enabled */
572 if (reg == 0xF)
573 do_fixup_by_compat(blob, "fsl,ifc",
574 "status", "disabled", 8 + 1, 1);
575
Shaohui Xiedd335672015-11-11 17:58:37 +0800576 return 0;
577}
578#endif
579
580u8 flash_read8(void *addr)
581{
582 return __raw_readb(addr + 1);
583}
584
585void flash_write16(u16 val, void *addr)
586{
587 u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
588
589 __raw_writew(shftval, addr);
590}
591
592u16 flash_read16(void *addr)
593{
594 u16 val = __raw_readw(addr);
595
596 return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00);
597}
Rajesh Bhagat90bde112018-11-05 18:02:48 +0000598
Tom Rini0543c432019-11-18 20:02:08 -0500599#if defined(CONFIG_TFABOOT) && defined(CONFIG_ENV_IS_IN_SPI_FLASH)
Rajesh Bhagat90bde112018-11-05 18:02:48 +0000600void *env_sf_get_env_addr(void)
601{
602 return (void *)(CONFIG_SYS_FSL_QSPI_BASE + CONFIG_ENV_OFFSET);
603}
604#endif