blob: 73a8680741741f501bd4ee84f9cffb98c7d7cba5 [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>
Mingkai Hu0e58b512015-10-26 19:47:50 +080011#include <i2c.h>
12
13DECLARE_GLOBAL_DATA_PTR;
14
15u32 spl_boot_device(void)
16{
17#ifdef CONFIG_SPL_MMC_SUPPORT
18 return BOOT_DEVICE_MMC1;
19#endif
20#ifdef CONFIG_SPL_NAND_SUPPORT
21 return BOOT_DEVICE_NAND;
22#endif
23 return 0;
24}
25
Marek Vasut64d64bb2016-05-14 23:42:07 +020026u32 spl_boot_mode(const u32 boot_device)
Mingkai Hu0e58b512015-10-26 19:47:50 +080027{
28 switch (spl_boot_device()) {
29 case BOOT_DEVICE_MMC1:
30#ifdef CONFIG_SPL_FAT_SUPPORT
Qianyu Gongb141ef72016-04-27 09:45:23 +080031 return MMCSD_MODE_FS;
Mingkai Hu0e58b512015-10-26 19:47:50 +080032#else
33 return MMCSD_MODE_RAW;
34#endif
35 case BOOT_DEVICE_NAND:
36 return 0;
37 default:
38 puts("spl: error: unsupported device\n");
39 hang();
40 }
41}
42
43#ifdef CONFIG_SPL_BUILD
44void board_init_f(ulong dummy)
45{
Mingkai Hu0e58b512015-10-26 19:47:50 +080046 /* Clear global data */
47 memset((void *)gd, 0, sizeof(gd_t));
Mingkai Hu0e58b512015-10-26 19:47:50 +080048 board_early_init_f();
49 timer_init();
York Suncbe8e1c2016-04-04 11:41:26 -070050#ifdef CONFIG_LS2080A
Mingkai Hu0e58b512015-10-26 19:47:50 +080051 env_init();
52#endif
53 get_clocks();
54
55 preloader_console_init();
56
57#ifdef CONFIG_SPL_I2C_SUPPORT
58 i2c_init_all();
59#endif
60 dram_init();
Mingkai Hu0e58b512015-10-26 19:47:50 +080061}
62#endif