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