Angel Pons | a2ee761 | 2020-04-04 18:51:15 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 2 | |
| 3 | #include <cbmem.h> |
| 4 | #include <soc/addressmap.h> |
| 5 | |
Arthur Heymans | 340e4b8 | 2019-10-23 17:25:58 +0200 | [diff] [blame] | 6 | void *cbmem_top_chipset(void) |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 7 | { |
| 8 | static uintptr_t addr; |
| 9 | |
| 10 | if (addr == 0) { |
| 11 | uintptr_t begin_mib; |
| 12 | uintptr_t end_mib; |
| 13 | |
| 14 | memory_in_range_below_4gb(&begin_mib, &end_mib); |
| 15 | /* Make sure we consume everything up to 4GIB. */ |
| 16 | if (end_mib == 4096) |
| 17 | addr = ~(uint32_t)0; |
| 18 | else |
| 19 | addr = end_mib << 20; |
| 20 | } |
| 21 | |
| 22 | return (void *)addr; |
| 23 | } |