blob: c1229c88af135f8cb465123719e07b5d4a4b353c [file] [log] [blame]
Mingkai Hu0e58b512015-10-26 19:47:50 +08001/*
2 * Copyright 2014-2015 Freescale Semiconductor, Inc.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <spl.h>
9#include <asm/io.h>
10#include <fsl_ifc.h>
11#include <fsl_csu.h>
12#include <i2c.h>
13
14DECLARE_GLOBAL_DATA_PTR;
15
16u32 spl_boot_device(void)
17{
18#ifdef CONFIG_SPL_MMC_SUPPORT
19 return BOOT_DEVICE_MMC1;
20#endif
21#ifdef CONFIG_SPL_NAND_SUPPORT
22 return BOOT_DEVICE_NAND;
23#endif
24 return 0;
25}
26
27u32 spl_boot_mode(void)
28{
29 switch (spl_boot_device()) {
30 case BOOT_DEVICE_MMC1:
31#ifdef CONFIG_SPL_FAT_SUPPORT
32 return MMCSD_MODE_FAT;
33#else
34 return MMCSD_MODE_RAW;
35#endif
36 case BOOT_DEVICE_NAND:
37 return 0;
38 default:
39 puts("spl: error: unsupported device\n");
40 hang();
41 }
42}
43
44#ifdef CONFIG_SPL_BUILD
45void board_init_f(ulong dummy)
46{
Mingkai Hu0e58b512015-10-26 19:47:50 +080047 /* Clear global data */
48 memset((void *)gd, 0, sizeof(gd_t));
York Suncbe8e1c2016-04-04 11:41:26 -070049#ifdef CONFIG_LS2080A
Mingkai Hu0e58b512015-10-26 19:47:50 +080050 arch_cpu_init();
51#endif
52#ifdef CONFIG_FSL_IFC
53 init_early_memctl_regs();
54#endif
55 board_early_init_f();
56 timer_init();
York Suncbe8e1c2016-04-04 11:41:26 -070057#ifdef CONFIG_LS2080A
Mingkai Hu0e58b512015-10-26 19:47:50 +080058 env_init();
59#endif
60 get_clocks();
61
62 preloader_console_init();
63
64#ifdef CONFIG_SPL_I2C_SUPPORT
65 i2c_init_all();
66#endif
67 dram_init();
68
69 /* Clear the BSS */
70 memset(__bss_start, 0, __bss_end - __bss_start);
71
Gong Qianyu8168a0f2015-10-26 19:47:53 +080072#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
73 enable_layerscape_ns_access();
74#endif
Mingkai Hu0e58b512015-10-26 19:47:50 +080075 board_init_r(NULL, 0);
76}
77#endif