Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
| 16 | u32 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 | |
| 27 | u32 spl_boot_mode(void) |
| 28 | { |
| 29 | switch (spl_boot_device()) { |
| 30 | case BOOT_DEVICE_MMC1: |
| 31 | #ifdef CONFIG_SPL_FAT_SUPPORT |
Qianyu Gong | b141ef7 | 2016-04-27 09:45:23 +0800 | [diff] [blame^] | 32 | return MMCSD_MODE_FS; |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 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 |
| 45 | void board_init_f(ulong dummy) |
| 46 | { |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 47 | /* Clear global data */ |
| 48 | memset((void *)gd, 0, sizeof(gd_t)); |
York Sun | cbe8e1c | 2016-04-04 11:41:26 -0700 | [diff] [blame] | 49 | #ifdef CONFIG_LS2080A |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 50 | arch_cpu_init(); |
| 51 | #endif |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 52 | board_early_init_f(); |
| 53 | timer_init(); |
York Sun | cbe8e1c | 2016-04-04 11:41:26 -0700 | [diff] [blame] | 54 | #ifdef CONFIG_LS2080A |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 55 | env_init(); |
| 56 | #endif |
| 57 | get_clocks(); |
| 58 | |
| 59 | preloader_console_init(); |
| 60 | |
| 61 | #ifdef CONFIG_SPL_I2C_SUPPORT |
| 62 | i2c_init_all(); |
| 63 | #endif |
| 64 | dram_init(); |
| 65 | |
| 66 | /* Clear the BSS */ |
| 67 | memset(__bss_start, 0, __bss_end - __bss_start); |
| 68 | |
Gong Qianyu | 8168a0f | 2015-10-26 19:47:53 +0800 | [diff] [blame] | 69 | #ifdef CONFIG_LAYERSCAPE_NS_ACCESS |
| 70 | enable_layerscape_ns_access(); |
| 71 | #endif |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 72 | board_init_r(NULL, 0); |
| 73 | } |
| 74 | #endif |