blob: f89cfabdf4d743cd84373185527e84cd4c787649 [file] [log] [blame]
Angel Pons7c1d70e2020-04-04 18:51:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Vadim Bendebury15c98b02014-05-01 14:45:56 -07003
4#include <cbmem.h>
Vadim Bendebury59b8c382014-12-11 17:31:20 -08005#include <soc/soc_services.h>
Vadim Bendebury15c98b02014-05-01 14:45:56 -07006
Furquan Shaikhcf9e0bc2016-03-28 13:29:33 -07007static int cbmem_backing_store_ready;
8
9void ipq_cbmem_backing_store_ready(void)
10{
11 cbmem_backing_store_ready = 1;
12}
13
Arthur Heymans340e4b82019-10-23 17:25:58 +020014void *cbmem_top_chipset(void)
Vadim Bendebury15c98b02014-05-01 14:45:56 -070015{
Furquan Shaikhcf9e0bc2016-03-28 13:29:33 -070016 /*
17 * In romstage, make sure that cbmem backing store is ready before
18 * returning the pointer to cbmem top. Otherwise, it could lead to
19 * issues with components that utilize cbmem in romstage
20 * (e.g. vboot_locator for loading ipq blobs before DRAM is
21 * initialized).
22 */
Arthur Heymansd3c58fd2019-10-27 07:13:55 +010023 if (cbmem_backing_store_ready == 0)
Furquan Shaikhcf9e0bc2016-03-28 13:29:33 -070024 return NULL;
25
Vadim Bendebury59b8c382014-12-11 17:31:20 -080026 return _memlayout_cbmem_top;
Vadim Bendebury15c98b02014-05-01 14:45:56 -070027}