| 1 |
|
| 2 |
|
| 3 |
#include <boot_device.h> |
| 4 |
#include <endian.h> |
| 5 |
#include <spi_flash.h> |
| 6 |
#include <amdblocks/spi.h> |
| 7 |
|
| 8 |
#if CONFIG_ROM_SIZE >= (16 * MiB) |
| 9 |
#define ROM_SIZE (16 * MiB) |
| 10 |
#else |
| 11 |
#define ROM_SIZE CONFIG_ROM_SIZE |
| 12 |
#endif |
| 13 |
|
| 14 |
|
| 15 |
#define rom_base ((void *)(uintptr_t)(0x100000000ULL-ROM_SIZE)) |
| 16 |
|
| 17 |
static const struct mem_region_device boot_dev = |
| 18 |
MEM_REGION_DEV_RO_INIT(rom_base, ROM_SIZE); |
| 19 |
|
| 20 |
const struct region_device *boot_device_ro(void) |
| 21 |
{ |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
if (fch_spi_rom_remapping() != 0) |
| 27 |
die("Non default SPI ROM remapping is not supported!"); |
| 28 |
|
| 29 |
return &boot_dev.rdev; |
| 30 |
} |
| 31 |
|
| 32 |
uint32_t spi_flash_get_mmap_windows(struct flash_mmap_window *table) |
| 33 |
{ |
| 34 |
table->flash_base = 0; |
| 35 |
table->host_base = (uint32_t)(uintptr_t)rom_base; |
| 36 |
table->size = ROM_SIZE; |
| 37 |
|
| 38 |
return 1; |
| 39 |
} |