Angel Pons | 7c1d70e | 2020-04-04 18:51:19 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Vadim Bendebury | 15c98b0 | 2014-05-01 14:45:56 -0700 | [diff] [blame] | 3 | |
| 4 | #include <cbmem.h> |
Vadim Bendebury | 59b8c38 | 2014-12-11 17:31:20 -0800 | [diff] [blame] | 5 | #include <soc/soc_services.h> |
Vadim Bendebury | 15c98b0 | 2014-05-01 14:45:56 -0700 | [diff] [blame] | 6 | |
Furquan Shaikh | cf9e0bc | 2016-03-28 13:29:33 -0700 | [diff] [blame] | 7 | static int cbmem_backing_store_ready; |
| 8 | |
| 9 | void ipq_cbmem_backing_store_ready(void) |
| 10 | { |
| 11 | cbmem_backing_store_ready = 1; |
| 12 | } |
| 13 | |
Arthur Heymans | 340e4b8 | 2019-10-23 17:25:58 +0200 | [diff] [blame] | 14 | void *cbmem_top_chipset(void) |
Vadim Bendebury | 15c98b0 | 2014-05-01 14:45:56 -0700 | [diff] [blame] | 15 | { |
Furquan Shaikh | cf9e0bc | 2016-03-28 13:29:33 -0700 | [diff] [blame] | 16 | /* |
| 17 | * In romstage, make sure that cbmem backing store is ready before |
| 18 | * returning the pointer to cbmem top. Otherwise, it could lead to |
| 19 | * issues with components that utilize cbmem in romstage |
| 20 | * (e.g. vboot_locator for loading ipq blobs before DRAM is |
| 21 | * initialized). |
| 22 | */ |
Arthur Heymans | d3c58fd | 2019-10-27 07:13:55 +0100 | [diff] [blame] | 23 | if (cbmem_backing_store_ready == 0) |
Furquan Shaikh | cf9e0bc | 2016-03-28 13:29:33 -0700 | [diff] [blame] | 24 | return NULL; |
| 25 | |
Vadim Bendebury | 59b8c38 | 2014-12-11 17:31:20 -0800 | [diff] [blame] | 26 | return _memlayout_cbmem_top; |
Vadim Bendebury | 15c98b0 | 2014-05-01 14:45:56 -0700 | [diff] [blame] | 27 | } |