Debian Codegraph @

src/soc/amd/common/block/spi/mmap_boot.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
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 /* The ROM is memory mapped just below 4GiB. Form a pointer for the base. */
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 * The following code assumes that ROM2 is mapped at flash offset 0. This is the default
24 * configuration currently enforced by soft-straps.
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 }