blob: 0e9812f3c78f53ac49c169ea4d792ad1d4c11335 [file] [log] [blame]
Patrick Georgi11f00792020-03-04 15:10:45 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Gabe Black396b0722013-09-26 16:22:09 -07002
Aaron Durbinc6588c52015-05-15 13:15:34 -05003#include <boot_device.h>
Furquan Shaikh493937e2020-11-25 17:15:09 -08004#include <spi_flash.h>
Elyes Haouasf0b28d82022-10-02 10:46:31 +02005#include <stdint.h>
Gabe Black396b0722013-09-26 16:22:09 -07006
Aaron Durbinc6588c52015-05-15 13:15:34 -05007/* The ROM is memory mapped just below 4GiB. Form a pointer for the base. */
Stefan Reinauerfb82ebe2015-08-04 11:14:17 -07008#define rom_base ((void *)(uintptr_t)(0x100000000ULL-CONFIG_ROM_SIZE))
Gabe Black396b0722013-09-26 16:22:09 -07009
Aaron Durbinc6588c52015-05-15 13:15:34 -050010static const struct mem_region_device boot_dev =
Antonello Dettorie5f48d22016-06-22 21:09:08 +020011 MEM_REGION_DEV_RO_INIT(rom_base, CONFIG_ROM_SIZE);
Aaron Durbinc6588c52015-05-15 13:15:34 -050012
13const struct region_device *boot_device_ro(void)
Gabe Black396b0722013-09-26 16:22:09 -070014{
Aaron Durbinc6588c52015-05-15 13:15:34 -050015 return &boot_dev.rdev;
Gabe Black396b0722013-09-26 16:22:09 -070016}
Furquan Shaikh493937e2020-11-25 17:15:09 -080017
18uint32_t spi_flash_get_mmap_windows(struct flash_mmap_window *table)
19{
20 table->flash_base = 0;
21 table->host_base = (uint32_t)(uintptr_t)rom_base;
22 table->size = CONFIG_ROM_SIZE;
23
24 return 1;
25}