blob: 551753df1b4c3142850b96a4c7abc40ad6fc71ee [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. */
Varadarajan Narayanana6935c22016-03-02 16:57:10 +05303
4#include <cbmem.h>
5#include <soc/soc_services.h>
6
Varadarajan Narayanan8ce14a72016-03-29 12:30:38 +05307static 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)
Varadarajan Narayanana6935c22016-03-02 16:57:10 +053015{
Varadarajan Narayanan8ce14a72016-03-29 12:30:38 +053016 /*
17 * In romstage, make sure that cbmem backing store is ready before
18 * returning pointer to cbmem top. Otherwise, it could lead to issues
19 * with components that utilize cbmem in romstage (e.g. vboot_locator
20 * for loading ipq blobs before DRAM is initialized).
21 */
Arthur Heymansd3c58fd2019-10-27 07:13:55 +010022 if (cbmem_backing_store_ready == 0)
Varadarajan Narayanan8ce14a72016-03-29 12:30:38 +053023 return NULL;
24
Varadarajan Narayanana6935c22016-03-02 16:57:10 +053025 return _memlayout_cbmem_top;
26}