Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2014-2015 Freescale Semiconductor, Inc. |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <spl.h> |
| 8 | #include <asm/io.h> |
| 9 | #include <fsl_ifc.h> |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 10 | #include <i2c.h> |
York Sun | f2aaf84 | 2017-05-15 08:52:00 -0700 | [diff] [blame] | 11 | #include <fsl_csu.h> |
| 12 | #include <asm/arch/fdt.h> |
| 13 | #include <asm/arch/ppa.h> |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
| 17 | u32 spl_boot_device(void) |
| 18 | { |
| 19 | #ifdef CONFIG_SPL_MMC_SUPPORT |
| 20 | return BOOT_DEVICE_MMC1; |
| 21 | #endif |
| 22 | #ifdef CONFIG_SPL_NAND_SUPPORT |
| 23 | return BOOT_DEVICE_NAND; |
| 24 | #endif |
| 25 | return 0; |
| 26 | } |
| 27 | |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 28 | #ifdef CONFIG_SPL_BUILD |
Ruchika Gupta | d6b8920 | 2017-04-17 18:07:17 +0530 | [diff] [blame] | 29 | |
| 30 | void spl_board_init(void) |
| 31 | { |
| 32 | #if defined(CONFIG_SECURE_BOOT) && defined(CONFIG_FSL_LSCH2) |
| 33 | /* |
| 34 | * In case of Secure Boot, the IBR configures the SMMU |
| 35 | * to allow only Secure transactions. |
| 36 | * SMMU must be reset in bypass mode. |
| 37 | * Set the ClientPD bit and Clear the USFCFG Bit |
| 38 | */ |
| 39 | u32 val; |
| 40 | val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK); |
| 41 | out_le32(SMMU_SCR0, val); |
| 42 | val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK); |
| 43 | out_le32(SMMU_NSCR0, val); |
| 44 | #endif |
York Sun | f2aaf84 | 2017-05-15 08:52:00 -0700 | [diff] [blame] | 45 | #ifdef CONFIG_LAYERSCAPE_NS_ACCESS |
| 46 | enable_layerscape_ns_access(); |
| 47 | #endif |
| 48 | #ifdef CONFIG_SPL_FSL_LS_PPA |
| 49 | ppa_init(); |
| 50 | #endif |
Ruchika Gupta | d6b8920 | 2017-04-17 18:07:17 +0530 | [diff] [blame] | 51 | } |
| 52 | |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 53 | void board_init_f(ulong dummy) |
| 54 | { |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 55 | /* Clear global data */ |
| 56 | memset((void *)gd, 0, sizeof(gd_t)); |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 57 | board_early_init_f(); |
| 58 | timer_init(); |
York Sun | 4ce6fbf | 2017-03-27 11:41:01 -0700 | [diff] [blame] | 59 | #ifdef CONFIG_ARCH_LS2080A |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 60 | env_init(); |
| 61 | #endif |
| 62 | get_clocks(); |
| 63 | |
| 64 | preloader_console_init(); |
York Sun | a34ca5f | 2017-09-28 08:42:10 -0700 | [diff] [blame] | 65 | spl_set_bd(); |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 66 | |
| 67 | #ifdef CONFIG_SPL_I2C_SUPPORT |
| 68 | i2c_init_all(); |
| 69 | #endif |
Rajesh Bhagat | f771678 | 2018-01-17 16:13:08 +0530 | [diff] [blame] | 70 | #ifdef CONFIG_VID |
| 71 | init_func_vid(); |
| 72 | #endif |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 73 | dram_init(); |
York Sun | f2aaf84 | 2017-05-15 08:52:00 -0700 | [diff] [blame] | 74 | #ifdef CONFIG_SPL_FSL_LS_PPA |
| 75 | #ifndef CONFIG_SYS_MEM_RESERVE_SECURE |
| 76 | #error Need secure RAM for PPA |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 77 | #endif |
York Sun | f2aaf84 | 2017-05-15 08:52:00 -0700 | [diff] [blame] | 78 | /* |
| 79 | * Secure memory location is determined in dram_init_banksize(). |
| 80 | * gd->ram_size is deducted by the size of secure ram. |
| 81 | */ |
| 82 | dram_init_banksize(); |
| 83 | |
| 84 | /* |
| 85 | * After dram_init_bank_size(), we know U-Boot only uses the first |
| 86 | * memory bank regardless how big the memory is. |
| 87 | */ |
| 88 | gd->ram_top = gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size; |
| 89 | |
| 90 | /* |
| 91 | * If PPA is loaded, U-Boot will resume running at EL2. |
| 92 | * Cache and MMU will be enabled. Need a place for TLB. |
| 93 | * U-Boot will be relocated to the end of available memory |
| 94 | * in first bank. At this point, we cannot know how much |
| 95 | * memory U-Boot uses. Put TLB table lower by SPL_TLB_SETBACK |
| 96 | * to avoid overlapping. As soon as the RAM version U-Boot sets |
| 97 | * up new MMU, this space is no longer needed. |
| 98 | */ |
| 99 | gd->ram_top -= SPL_TLB_SETBACK; |
| 100 | gd->arch.tlb_size = PGTABLE_SIZE; |
| 101 | gd->arch.tlb_addr = (gd->ram_top - gd->arch.tlb_size) & ~(0x10000 - 1); |
| 102 | gd->arch.tlb_allocated = gd->arch.tlb_addr; |
| 103 | #endif /* CONFIG_SPL_FSL_LS_PPA */ |
| 104 | } |
York Sun | ffea3e6 | 2017-09-28 08:42:14 -0700 | [diff] [blame] | 105 | |
| 106 | #ifdef CONFIG_SPL_OS_BOOT |
| 107 | /* |
| 108 | * Return |
| 109 | * 0 if booting into OS is selected |
| 110 | * 1 if booting into U-Boot is selected |
| 111 | */ |
| 112 | int spl_start_uboot(void) |
| 113 | { |
| 114 | env_init(); |
| 115 | if (env_get_yesno("boot_os") != 0) |
| 116 | return 0; |
| 117 | |
| 118 | return 1; |
| 119 | } |
| 120 | #endif /* CONFIG_SPL_OS_BOOT */ |
| 121 | #ifdef CONFIG_SPL_LOAD_FIT |
| 122 | int board_fit_config_name_match(const char *name) |
| 123 | { |
| 124 | /* Just empty function now - can't decide what to choose */ |
| 125 | debug("%s: %s\n", __func__, name); |
| 126 | |
| 127 | return 0; |
| 128 | } |
| 129 | #endif |
York Sun | f2aaf84 | 2017-05-15 08:52:00 -0700 | [diff] [blame] | 130 | #endif /* CONFIG_SPL_BUILD */ |