Vadim Bendebury | 15c98b0 | 2014-05-01 14:45:56 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2014 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Vadim Bendebury | 15c98b0 | 2014-05-01 14:45:56 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <cbmem.h> |
Vadim Bendebury | 59b8c38 | 2014-12-11 17:31:20 -0800 | [diff] [blame] | 17 | #include <soc/soc_services.h> |
Vadim Bendebury | 15c98b0 | 2014-05-01 14:45:56 -0700 | [diff] [blame] | 18 | |
Furquan Shaikh | cf9e0bc | 2016-03-28 13:29:33 -0700 | [diff] [blame] | 19 | static int cbmem_backing_store_ready; |
| 20 | |
| 21 | void ipq_cbmem_backing_store_ready(void) |
| 22 | { |
| 23 | cbmem_backing_store_ready = 1; |
| 24 | } |
| 25 | |
Arthur Heymans | 340e4b8 | 2019-10-23 17:25:58 +0200 | [diff] [blame^] | 26 | void *cbmem_top_chipset(void) |
Vadim Bendebury | 15c98b0 | 2014-05-01 14:45:56 -0700 | [diff] [blame] | 27 | { |
Furquan Shaikh | cf9e0bc | 2016-03-28 13:29:33 -0700 | [diff] [blame] | 28 | /* |
| 29 | * In romstage, make sure that cbmem backing store is ready before |
| 30 | * returning the pointer to cbmem top. Otherwise, it could lead to |
| 31 | * issues with components that utilize cbmem in romstage |
| 32 | * (e.g. vboot_locator for loading ipq blobs before DRAM is |
| 33 | * initialized). |
| 34 | */ |
| 35 | if (ENV_ROMSTAGE && (cbmem_backing_store_ready == 0)) |
| 36 | return NULL; |
| 37 | |
Vadim Bendebury | 59b8c38 | 2014-12-11 17:31:20 -0800 | [diff] [blame] | 38 | return _memlayout_cbmem_top; |
Vadim Bendebury | 15c98b0 | 2014-05-01 14:45:56 -0700 | [diff] [blame] | 39 | } |