Skip to content

Commit 86949c2

Browse files
Alison WangYork Sun
Alison Wang
authored and
York Sun
committed
arm: ls102xa: Add SD boot support for LS1021AQDS board
This patch adds SD boot support for LS1021AQDS board. SPL framework is used. PBL initialize the internal RAM and copy SPL to it, then SPL initialize DDR using SPD and copy u-boot from SD card to DDR, finally SPL transfer control to u-boot. Signed-off-by: Alison Wang <[email protected]> Signed-off-by: Jason Jin <[email protected]> Reviewed-by: York Sun <[email protected]>
1 parent 2565d18 commit 86949c2

File tree

10 files changed

+173
-1
lines changed

10 files changed

+173
-1
lines changed

arch/arm/cpu/armv7/ls102xa/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ obj-y += fsl_epu.o
1111

1212
obj-$(CONFIG_OF_LIBFDT) += fdt.o
1313
obj-$(CONFIG_SYS_HAS_SERDES) += fsl_ls1_serdes.o ls102xa_serdes.o
14+
obj-$(CONFIG_SPL) += spl.o

arch/arm/cpu/armv7/ls102xa/spl.c

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2014 Freescale Semiconductor, Inc.
3+
*
4+
* SPDX-License-Identifier: GPL-2.0+
5+
*/
6+
7+
#include <common.h>
8+
#include <spl.h>
9+
10+
u32 spl_boot_device(void)
11+
{
12+
#ifdef CONFIG_SPL_MMC_SUPPORT
13+
return BOOT_DEVICE_MMC1;
14+
#endif
15+
return BOOT_DEVICE_NAND;
16+
}
17+
18+
u32 spl_boot_mode(void)
19+
{
20+
switch (spl_boot_device()) {
21+
case BOOT_DEVICE_MMC1:
22+
#ifdef CONFIG_SPL_FAT_SUPPORT
23+
return MMCSD_MODE_FAT;
24+
#else
25+
return MMCSD_MODE_RAW;
26+
#endif
27+
case BOOT_DEVICE_NAND:
28+
return 0;
29+
default:
30+
puts("spl: error: unsupported device\n");
31+
hang();
32+
}
33+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2014 Freescale Semiconductor, Inc.
3+
*
4+
* SPDX-License-Identifier: GPL-2.0+
5+
*/
6+
7+
#ifndef __ASM_ARCH_SPL_H__
8+
#define __ASM_ARCH_SPL_H__
9+
10+
#define BOOT_DEVICE_NONE 0
11+
#define BOOT_DEVICE_XIP 1
12+
#define BOOT_DEVICE_XIPWAIT 2
13+
#define BOOT_DEVICE_NAND 3
14+
#define BOOT_DEVICE_ONENAND 4
15+
#define BOOT_DEVICE_MMC1 5
16+
#define BOOT_DEVICE_MMC2 6
17+
#define BOOT_DEVICE_MMC2_2 7
18+
#define BOOT_DEVICE_SPI 10
19+
20+
#endif /* __ASM_ARCH_SPL_H__ */

board/freescale/ls1021aqds/MAINTAINERS

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ F: include/configs/ls1021aqds.h
66
F: configs/ls1021aqds_nor_defconfig
77
F: configs/ls1021aqds_ddr4_nor_defconfig
88
F: configs/ls1021aqds_nor_SECURE_BOOT_defconfig
9+
F: configs/ls1021aqds_sdcard_defconfig

board/freescale/ls1021aqds/ddr.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,12 @@ phys_size_t initdram(int board_type)
153153
{
154154
phys_size_t dram_size;
155155

156+
#if defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SPL)
156157
puts("Initializing DDR....using SPD\n");
157158
dram_size = fsl_ddr_sdram();
158-
159+
#else
160+
dram_size = fsl_ddr_sdram_size();
161+
#endif
159162
return dram_size;
160163
}
161164

board/freescale/ls1021aqds/ls1021aqds.c

+39
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <fsl_esdhc.h>
1616
#include <fsl_ifc.h>
1717
#include <fsl_sec.h>
18+
#include <spl.h>
1819

1920
#include "../common/qixis.h"
2021
#include "ls1021aqds_qixis.h"
@@ -34,10 +35,17 @@ enum {
3435
int checkboard(void)
3536
{
3637
char buf[64];
38+
#if !defined(CONFIG_SD_BOOT) && !defined(CONFIG_QSPI_BOOT)
3739
u8 sw;
40+
#endif
3841

3942
puts("Board: LS1021AQDS\n");
4043

44+
#ifdef CONFIG_SD_BOOT
45+
puts("SD\n");
46+
#elif CONFIG_QSPI_BOOT
47+
puts("QSPI\n");
48+
#else
4149
sw = QIXIS_READ(brdcfg[0]);
4250
sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
4351

@@ -51,6 +59,7 @@ int checkboard(void)
5159
printf("IFCCard\n");
5260
else
5361
printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
62+
#endif
5463

5564
printf("Sys ID:0x%02x, Sys Ver: 0x%02x\n",
5665
QIXIS_READ(id), QIXIS_READ(arch));
@@ -165,6 +174,36 @@ int board_early_init_f(void)
165174
return 0;
166175
}
167176

177+
#ifdef CONFIG_SPL_BUILD
178+
void board_init_f(ulong dummy)
179+
{
180+
struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
181+
182+
/* Set global data pointer */
183+
gd = &gdata;
184+
185+
/* Clear the BSS */
186+
memset(__bss_start, 0, __bss_end - __bss_start);
187+
188+
#ifdef CONFIG_FSL_IFC
189+
init_early_memctl_regs();
190+
#endif
191+
192+
get_clocks();
193+
194+
preloader_console_init();
195+
196+
#ifdef CONFIG_SPL_I2C_SUPPORT
197+
i2c_init_all();
198+
#endif
199+
out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
200+
201+
dram_init();
202+
203+
board_init_r(NULL, 0);
204+
}
205+
#endif
206+
168207
int config_board_mux(int ctrl_type)
169208
{
170209
u8 reg12;
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#PBI commands
2+
3+
09570200 ffffffff
4+
09570158 00000300
5+
8940007c 21f47300
6+
7+
#Configure Scratch register
8+
09ee0200 10000000
9+
#Configure alternate space
10+
09570158 00001000
11+
#Flush PBL data
12+
096100c0 000FFFFF
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#PBL preamble and RCW header
2+
aa55aa55 01ee0100
3+
4+
#enable IFC, disable QSPI and DSPI
5+
0608000a 00000000 00000000 00000000
6+
60000000 00407900 60040a00 21046000
7+
00000000 00000000 00000000 00038000
8+
00000000 001b7200 00000000 00000000
9+
10+
#disable IFC, enable QSPI and DSPI
11+
#0608000a 00000000 00000000 00000000
12+
#60000000 00407900 60040a00 21046000
13+
#00000000 00000000 00000000 00038000
14+
#20024800 001b7200 00000000 00000000

configs/ls1021aqds_sdcard_defconfig

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_SPL=y
2+
CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT_PBL,SPL_FSL_PBL,SD_BOOT"
3+
+S:CONFIG_ARM=y
4+
+S:CONFIG_TARGET_LS1021AQDS=y

include/configs/ls1021aqds.h

+45
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,39 @@ unsigned long get_board_ddr_clk(void);
4040
#define CONFIG_SYS_CLK_FREQ get_board_sys_clk()
4141
#define CONFIG_DDR_CLK_FREQ get_board_ddr_clk()
4242

43+
#ifdef CONFIG_RAMBOOT_PBL
44+
#define CONFIG_SYS_FSL_PBL_PBI board/freescale/ls1021aqds/ls102xa_pbi.cfg
45+
#endif
46+
47+
#ifdef CONFIG_SD_BOOT
48+
#define CONFIG_SYS_FSL_PBL_RCW board/freescale/ls1021aqds/ls102xa_rcw_sd.cfg
49+
#define CONFIG_SPL_FRAMEWORK
50+
#define CONFIG_SPL_LDSCRIPT "arch/$(ARCH)/cpu/u-boot-spl.lds"
51+
#define CONFIG_SPL_LIBCOMMON_SUPPORT
52+
#define CONFIG_SPL_LIBGENERIC_SUPPORT
53+
#define CONFIG_SPL_ENV_SUPPORT
54+
#define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
55+
#define CONFIG_SPL_I2C_SUPPORT
56+
#define CONFIG_SPL_WATCHDOG_SUPPORT
57+
#define CONFIG_SPL_SERIAL_SUPPORT
58+
#define CONFIG_SPL_DRIVERS_MISC_SUPPORT
59+
#define CONFIG_SPL_MMC_SUPPORT
60+
#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0xe8
61+
#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x400
62+
63+
#define CONFIG_SPL_TEXT_BASE 0x10000000
64+
#define CONFIG_SPL_MAX_SIZE 0x1a000
65+
#define CONFIG_SPL_STACK 0x1001d000
66+
#define CONFIG_SPL_PAD_TO 0x1c000
67+
#define CONFIG_SYS_TEXT_BASE 0x82000000
68+
69+
#define CONFIG_SYS_SPL_MALLOC_START 0x80200000
70+
#define CONFIG_SYS_SPL_MALLOC_SIZE 0x100000
71+
#define CONFIG_SPL_BSS_START_ADDR 0x80100000
72+
#define CONFIG_SPL_BSS_MAX_SIZE 0x80000
73+
#define CONFIG_SYS_MONITOR_LEN 0x80000
74+
#endif
75+
4376
#ifndef CONFIG_SYS_TEXT_BASE
4477
#define CONFIG_SYS_TEXT_BASE 0x67f80000
4578
#endif
@@ -356,6 +389,7 @@ unsigned long get_board_ddr_clk(void);
356389

357390
#define CONFIG_CMDLINE_TAG
358391
#define CONFIG_CMDLINE_EDITING
392+
359393
#define CONFIG_CMD_IMLS
360394

361395
#define CONFIG_HWCONFIG
@@ -404,17 +438,28 @@ unsigned long get_board_ddr_clk(void);
404438
#define CONFIG_SYS_INIT_SP_ADDR \
405439
(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
406440

441+
#ifdef CONFIG_SPL_BUILD
442+
#define CONFIG_SYS_MONITOR_BASE CONFIG_SPL_TEXT_BASE
443+
#else
407444
#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE /* start of monitor */
445+
#endif
408446

409447
/*
410448
* Environment
411449
*/
412450
#define CONFIG_ENV_OVERWRITE
413451

452+
#if defined(CONFIG_SD_BOOT)
453+
#define CONFIG_ENV_OFFSET 0x100000
454+
#define CONFIG_ENV_IS_IN_MMC
455+
#define CONFIG_SYS_MMC_ENV_DEV 0
456+
#define CONFIG_ENV_SIZE 0x2000
457+
#else
414458
#define CONFIG_ENV_IS_IN_FLASH
415459
#define CONFIG_ENV_ADDR (CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SECT_SIZE)
416460
#define CONFIG_ENV_SIZE 0x2000
417461
#define CONFIG_ENV_SECT_SIZE 0x20000 /* 128K (one sector) */
462+
#endif
418463

419464
#define CONFIG_OF_LIBFDT
420465
#define CONFIG_OF_BOARD_SETUP

0 commit comments

Comments
 (0)