blob: a695cf827e816ce843be898123e4a8e7babad4a5 [file] [log] [blame]
Angel Pons7c1d70e2020-04-04 18:51:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Vadim Bendebury15c98b02014-05-01 14:45:56 -07002
3#include <cbmem.h>
Vadim Bendebury59b8c382014-12-11 17:31:20 -08004#include <soc/soc_services.h>
Vadim Bendebury15c98b02014-05-01 14:45:56 -07005
Furquan Shaikhcf9e0bc2016-03-28 13:29:33 -07006static int cbmem_backing_store_ready;
7
8void ipq_cbmem_backing_store_ready(void)
9{
10 cbmem_backing_store_ready = 1;
11}
12
Arthur Heymans340e4b82019-10-23 17:25:58 +020013void *cbmem_top_chipset(void)
Vadim Bendebury15c98b02014-05-01 14:45:56 -070014{
Furquan Shaikhcf9e0bc2016-03-28 13:29:33 -070015 /*
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 Heymansd3c58fd2019-10-27 07:13:55 +010022 if (cbmem_backing_store_ready == 0)
Furquan Shaikhcf9e0bc2016-03-28 13:29:33 -070023 return NULL;
24
Vadim Bendebury59b8c382014-12-11 17:31:20 -080025 return _memlayout_cbmem_top;
Vadim Bendebury15c98b02014-05-01 14:45:56 -070026}