Varadarajan Narayanan | a6935c2 | 2016-03-02 16:57:10 +0530 | [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. |
| 14 | */ |
| 15 | |
| 16 | #include <cbmem.h> |
| 17 | #include <soc/soc_services.h> |
| 18 | |
Varadarajan Narayanan | 8ce14a7 | 2016-03-29 12:30:38 +0530 | [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) |
Varadarajan Narayanan | a6935c2 | 2016-03-02 16:57:10 +0530 | [diff] [blame] | 27 | { |
Varadarajan Narayanan | 8ce14a7 | 2016-03-29 12:30:38 +0530 | [diff] [blame] | 28 | /* |
| 29 | * In romstage, make sure that cbmem backing store is ready before |
| 30 | * returning pointer to cbmem top. Otherwise, it could lead to issues |
| 31 | * with components that utilize cbmem in romstage (e.g. vboot_locator |
| 32 | * for loading ipq blobs before DRAM is initialized). |
| 33 | */ |
| 34 | if (ENV_ROMSTAGE && (cbmem_backing_store_ready == 0)) |
| 35 | return NULL; |
| 36 | |
Varadarajan Narayanan | a6935c2 | 2016-03-02 16:57:10 +0530 | [diff] [blame] | 37 | return _memlayout_cbmem_top; |
| 38 | } |