Commit 70656c79f3c85df77b65cda0237f5454851186ca

Authored by Vivek Gautam
Committed by Minkyu Kang
1 parent 601795462a

Exynos5: Add support for USB download boot mode

Exynos5250 supports secondary USB device boot mode. If the iROM fails
to download u-boot from the primary boot device (such as SD or eMMC),
it will try to retrieve from the secondary boot device (such as USB).

Signed-off-by: Naveen Krishna Ch <ch.naveen@samsung.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>

Showing 2 changed files with 43 additions and 2 deletions Side-by-side Diff

board/samsung/smdk5250/spl_boot.c
... ... @@ -32,8 +32,23 @@
32 32 };
33 33  
34 34 typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
  35 + typedef u32 (*usb_copy_func_t)(void);
35 36  
36 37 /*
  38 + * Set/clear program flow prediction and return the previous state.
  39 + */
  40 +static int config_branch_prediction(int set_cr_z)
  41 +{
  42 + unsigned int cr;
  43 +
  44 + /* System Control Register: 11th bit Z Branch prediction enable */
  45 + cr = get_cr();
  46 + set_cr(set_cr_z ? cr | CR_Z : cr & ~CR_Z);
  47 +
  48 + return cr & CR_Z;
  49 +}
  50 +
  51 +/*
37 52 * Copy U-boot from mmc to RAM:
38 53 * COPY_BL2_FNPTR_ADDR: Address in iRAM, which Contains
39 54 * Pointer to API (Data transfer from mmc to ram)
40 55  
41 56  
... ... @@ -41,11 +56,21 @@
41 56 void copy_uboot_to_ram(void)
42 57 {
43 58 spi_copy_func_t spi_copy;
44   - enum boot_mode bootmode;
  59 + usb_copy_func_t usb_copy;
  60 +
  61 + int is_cr_z_set;
  62 + unsigned int sec_boot_check;
  63 + enum boot_mode bootmode = BOOT_MODE_OM;
45 64 u32 (*copy_bl2)(u32, u32, u32);
46 65  
47   - bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
  66 + /* Read iRAM location to check for secondary USB boot mode */
  67 + sec_boot_check = readl(EXYNOS_IRAM_SECONDARY_BASE);
  68 + if (sec_boot_check == EXYNOS_USB_SECONDARY_BOOT)
  69 + bootmode = BOOT_MODE_USB;
48 70  
  71 + if (bootmode == BOOT_MODE_OM)
  72 + bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
  73 +
49 74 switch (bootmode) {
50 75 case BOOT_MODE_SERIAL:
51 76 spi_copy = *(spi_copy_func_t *)EXYNOS_COPY_SPI_FNPTR_ADDR;
... ... @@ -56,6 +81,17 @@
56 81 copy_bl2 = (void *) *(u32 *)COPY_BL2_FNPTR_ADDR;
57 82 copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT,
58 83 CONFIG_SYS_TEXT_BASE);
  84 + break;
  85 + case BOOT_MODE_USB:
  86 + /*
  87 + * iROM needs program flow prediction to be disabled
  88 + * before copy from USB device to RAM
  89 + */
  90 + is_cr_z_set = config_branch_prediction(0);
  91 + usb_copy = *(usb_copy_func_t *)
  92 + EXYNOS_COPY_USB_FNPTR_ADDR;
  93 + usb_copy();
  94 + config_branch_prediction(is_cr_z_set);
59 95 break;
60 96 default:
61 97 break;
include/configs/exynos5250-dt.h
... ... @@ -134,6 +134,11 @@
134 134 #define CONFIG_USB_EHCI_EXYNOS
135 135 #define CONFIG_USB_STORAGE
136 136  
  137 +/* USB boot mode */
  138 +#define EXYNOS_COPY_USB_FNPTR_ADDR 0x02020070
  139 +#define EXYNOS_USB_SECONDARY_BOOT 0xfeed0002
  140 +#define EXYNOS_IRAM_SECONDARY_BASE 0x02020018
  141 +
137 142 /* MMC SPL */
138 143 #define CONFIG_SPL
139 144 #define COPY_BL2_FNPTR_ADDR 0x02020030