Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Gabe Black | 396b072 | 2013-09-26 16:22:09 -0700 | [diff] [blame] | 2 | |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 3 | #include <boot_device.h> |
Furquan Shaikh | 493937e | 2020-11-25 17:15:09 -0800 | [diff] [blame] | 4 | #include <spi_flash.h> |
Elyes Haouas | f0b28d8 | 2022-10-02 10:46:31 +0200 | [diff] [blame] | 5 | #include <stdint.h> |
Gabe Black | 396b072 | 2013-09-26 16:22:09 -0700 | [diff] [blame] | 6 | |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 7 | /* The ROM is memory mapped just below 4GiB. Form a pointer for the base. */ |
Stefan Reinauer | fb82ebe | 2015-08-04 11:14:17 -0700 | [diff] [blame] | 8 | #define rom_base ((void *)(uintptr_t)(0x100000000ULL-CONFIG_ROM_SIZE)) |
Gabe Black | 396b072 | 2013-09-26 16:22:09 -0700 | [diff] [blame] | 9 | |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 10 | static const struct mem_region_device boot_dev = |
Antonello Dettori | e5f48d2 | 2016-06-22 21:09:08 +0200 | [diff] [blame] | 11 | MEM_REGION_DEV_RO_INIT(rom_base, CONFIG_ROM_SIZE); |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 12 | |
| 13 | const struct region_device *boot_device_ro(void) |
Gabe Black | 396b072 | 2013-09-26 16:22:09 -0700 | [diff] [blame] | 14 | { |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 15 | return &boot_dev.rdev; |
Gabe Black | 396b072 | 2013-09-26 16:22:09 -0700 | [diff] [blame] | 16 | } |
Furquan Shaikh | 493937e | 2020-11-25 17:15:09 -0800 | [diff] [blame] | 17 | |
| 18 | uint32_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 | } |