| 1 |
|
| 2 |
|
| 3 |
#include <boot_device.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <soc/alternate_cbfs.h> |
| 6 |
#include <soc/power.h> |
| 7 |
#include <soc/spi.h> |
| 8 |
#include <symbols.h> |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
static int usb_cbfs_open(void) |
| 28 |
{ |
| 29 |
if (!ENV_ROMSTAGE_OR_BEFORE) |
| 30 |
return 0; |
| 31 |
|
| 32 |
static int first_run = 1; |
| 33 |
int (*irom_load_usb)(void) = *irom_load_image_from_usb_ptr; |
| 34 |
|
| 35 |
if (!first_run) |
| 36 |
return 0; |
| 37 |
|
| 38 |
if (!irom_load_usb()) { |
| 39 |
printk(BIOS_EMERG, "Unable to load CBFS image via USB!\n"); |
| 40 |
return -1; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
printk(BIOS_DEBUG, "USB A-A transfer successful, CBFS image should now" |
| 50 |
" be at %p\n", _cbfs_cache); |
| 51 |
first_run = 0; |
| 52 |
return 0; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
static int sdmmc_cbfs_open(void) |
| 64 |
{ |
| 65 |
if (!ENV_ROMSTAGE_OR_BEFORE) |
| 66 |
return 0; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
const u32 count = REGION_SIZE(cbfs_cache) / 512; |
| 77 |
static int first_run = 1; |
| 78 |
int (*irom_load_sdmmc)(u32 start, u32 count, void *dst) = |
| 79 |
*irom_sdmmc_read_blocks_ptr; |
| 80 |
|
| 81 |
if (!first_run) |
| 82 |
return 0; |
| 83 |
|
| 84 |
if (!irom_load_sdmmc(1, count, _cbfs_cache)) { |
| 85 |
printk(BIOS_EMERG, "Unable to load CBFS image from SDMMC!\n"); |
| 86 |
return -1; |
| 87 |
} |
| 88 |
|
| 89 |
printk(BIOS_DEBUG, "SDMMC read successful, CBFS image should now be" |
| 90 |
" at %p\n", _cbfs_cache); |
| 91 |
first_run = 0; |
| 92 |
return 0; |
| 93 |
} |
| 94 |
|
| 95 |
static const struct mem_region_device alternate_rdev = |
| 96 |
MEM_REGION_DEV_RO_INIT(_cbfs_cache, REGION_SIZE(cbfs_cache)); |
| 97 |
|
| 98 |
const struct region_device *boot_device_ro(void) |
| 99 |
{ |
| 100 |
if (*iram_secondary_base == SECONDARY_BASE_BOOT_USB) |
| 101 |
return &alternate_rdev.rdev; |
| 102 |
|
| 103 |
switch (exynos_power->om_stat & OM_STAT_MASK) { |
| 104 |
case OM_STAT_SDMMC: |
| 105 |
return &alternate_rdev.rdev; |
| 106 |
case OM_STAT_SPI: |
| 107 |
return exynos_spi_boot_device(); |
| 108 |
default: |
| 109 |
printk(BIOS_EMERG, "Exynos OM_STAT value 0x%x not supported!\n", |
| 110 |
exynos_power->om_stat); |
| 111 |
return NULL; |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
void boot_device_init(void) |
| 116 |
{ |
| 117 |
if (*iram_secondary_base == SECONDARY_BASE_BOOT_USB) { |
| 118 |
printk(BIOS_DEBUG, "Using Exynos alternate boot mode USB A-A\n"); |
| 119 |
usb_cbfs_open(); |
| 120 |
return; |
| 121 |
} |
| 122 |
|
| 123 |
switch (exynos_power->om_stat & OM_STAT_MASK) { |
| 124 |
case OM_STAT_SDMMC: |
| 125 |
printk(BIOS_DEBUG, "Using Exynos alternate boot mode SDMMC\n"); |
| 126 |
sdmmc_cbfs_open(); |
| 127 |
break; |
| 128 |
case OM_STAT_SPI: |
| 129 |
exynos_init_spi_boot_device(); |
| 130 |
break; |
| 131 |
default: |
| 132 |
printk(BIOS_EMERG, "Exynos OM_STAT value 0x%x not supported!\n", |
| 133 |
exynos_power->om_stat); |
| 134 |
} |
| 135 |
} |