2 * Copyright (C) 2012 Samsung Electronics
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <asm/arch-exynos/dmc.h>
27 #include <asm/arch/clock.h>
28 #include <asm/arch/clk.h>
30 #include "clock_init.h"
32 /* Index into irom ptr table */
41 /* IROM Function Pointers Table */
42 u32 irom_ptr_table[] = {
43 [MMC_INDEX] = 0x02020030, /* iROM Function Pointer-SDMMC boot */
44 [EMMC44_INDEX] = 0x02020044, /* iROM Function Pointer-EMMC4.4 boot*/
45 [EMMC44_END_INDEX] = 0x02020048,/* iROM Function Pointer
46 -EMMC4.4 end boot operation */
47 [SPI_INDEX] = 0x02020058, /* iROM Function Pointer-SPI boot */
48 [USB_INDEX] = 0x02020070, /* iROM Function Pointer-USB boot*/
53 BOOT_MODE_SERIAL = 20,
54 BOOT_MODE_EMMC = 8, /* EMMC4.4 */
55 /* Boot based on Operating Mode pin settings */
57 BOOT_MODE_USB, /* Boot using USB download */
60 void *get_irom_func(int index)
62 return (void *)*(u32 *)irom_ptr_table[index];
66 * Set/clear program flow prediction and return the previous state.
68 static int config_branch_prediction(int set_cr_z)
72 /* System Control Register: 11th bit Z Branch prediction enable */
74 set_cr(set_cr_z ? cr | CR_Z : cr & ~CR_Z);
80 * Copy U-boot from mmc to RAM:
81 * COPY_BL2_FNPTR_ADDR: Address in iRAM, which Contains
82 * Pointer to API (Data transfer from mmc to ram)
84 void copy_uboot_to_ram(void)
87 unsigned int sec_boot_check;
88 enum boot_mode bootmode = BOOT_MODE_OM;
90 u32 (*spi_copy)(u32 offset, u32 nblock, u32 dst);
91 u32 (*copy_bl2)(u32 offset, u32 nblock, u32 dst);
92 u32 (*copy_bl2_from_emmc)(u32 nblock, u32 dst);
93 void (*end_bootop_from_emmc)(void);
94 u32 (*usb_copy)(void);
96 /* Read iRAM location to check for secondary USB boot mode */
97 sec_boot_check = readl(EXYNOS_IRAM_SECONDARY_BASE);
98 if (sec_boot_check == EXYNOS_USB_SECONDARY_BOOT)
99 bootmode = BOOT_MODE_USB;
101 if (bootmode == BOOT_MODE_OM)
102 bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
105 case BOOT_MODE_SERIAL:
106 spi_copy = get_irom_func(SPI_INDEX);
107 spi_copy(SPI_FLASH_UBOOT_POS, CONFIG_BL2_SIZE,
108 CONFIG_SYS_TEXT_BASE);
111 copy_bl2 = get_irom_func(MMC_INDEX);
112 copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT,
113 CONFIG_SYS_TEXT_BASE);
116 /* Set the FSYS1 clock divisor value for EMMC boot */
117 emmc_boot_clk_div_set();
119 copy_bl2_from_emmc = get_irom_func(EMMC44_INDEX);
120 end_bootop_from_emmc = get_irom_func(EMMC44_END_INDEX);
122 copy_bl2_from_emmc(BL2_SIZE_BLOC_COUNT, CONFIG_SYS_TEXT_BASE);
123 end_bootop_from_emmc();
127 * iROM needs program flow prediction to be disabled
128 * before copy from USB device to RAM
130 is_cr_z_set = config_branch_prediction(0);
131 usb_copy = get_irom_func(USB_INDEX);
133 config_branch_prediction(is_cr_z_set);
140 void board_init_f(unsigned long bootflag)
142 __attribute__((noreturn)) void (*uboot)(void);
145 /* Jump to U-Boot image */
146 uboot = (void *)CONFIG_SYS_TEXT_BASE;
148 /* Never returns Here */
152 void board_init_r(gd_t *id, ulong dest_addr)
154 /* Function attribute is no-return */
155 /* This Function never executes */
159 void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3) {}