blob: 8196416168151b21d3f259b16d195fa1cab39661 [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
Elyes Haouas799c3212022-11-09 14:00:44 +010013uintptr_t 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)
Elyes Haouas799c3212022-11-09 14:00:44 +010023 return 0;
Furquan Shaikhcf9e0bc2016-03-28 13:29:33 -070024
Elyes Haouas799c3212022-11-09 14:00:44 +010025 return (uintptr_t)_memlayout_cbmem_top;
Vadim Bendebury15c98b02014-05-01 14:45:56 -070026}