Arthur Heymans | e4eba13 | 2023-07-13 14:02:42 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <boot_device.h> |
| 4 | #include <endian.h> |
| 5 | #include <spi_flash.h> |
| 6 | |
| 7 | #if CONFIG_ROM_SIZE >= (16 * MiB) |
| 8 | #define ROM_SIZE (16 * MiB) |
| 9 | #else |
| 10 | #define ROM_SIZE CONFIG_ROM_SIZE |
| 11 | #endif |
| 12 | |
| 13 | /* The ROM is memory mapped just below 4GiB. Form a pointer for the base. */ |
| 14 | #define rom_base ((void *)(uintptr_t)(0x100000000ULL-ROM_SIZE)) |
| 15 | |
| 16 | static const struct mem_region_device boot_dev = |
| 17 | MEM_REGION_DEV_RO_INIT(rom_base, ROM_SIZE); |
| 18 | |
| 19 | const struct region_device *boot_device_ro(void) |
| 20 | { |
| 21 | return &boot_dev.rdev; |
| 22 | } |
| 23 | |
| 24 | uint32_t spi_flash_get_mmap_windows(struct flash_mmap_window *table) |
| 25 | { |
| 26 | table->flash_base = 0; |
| 27 | table->host_base = (uint32_t)(uintptr_t)rom_base; |
| 28 | table->size = ROM_SIZE; |
| 29 | |
| 30 | return 1; |
| 31 | } |