blob: 6dc92a0c110edbd175556b7cf49de67be184e222 [file] [log] [blame]
Vadim Bendebury15c98b02014-05-01 14:45:56 -07001/*
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.
Vadim Bendebury15c98b02014-05-01 14:45:56 -070014 */
15
16#include <cbmem.h>
Vadim Bendebury59b8c382014-12-11 17:31:20 -080017#include <soc/soc_services.h>
Vadim Bendebury15c98b02014-05-01 14:45:56 -070018
Furquan Shaikhcf9e0bc2016-03-28 13:29:33 -070019static int cbmem_backing_store_ready;
20
21void ipq_cbmem_backing_store_ready(void)
22{
23 cbmem_backing_store_ready = 1;
24}
25
Arthur Heymans340e4b82019-10-23 17:25:58 +020026void *cbmem_top_chipset(void)
Vadim Bendebury15c98b02014-05-01 14:45:56 -070027{
Furquan Shaikhcf9e0bc2016-03-28 13:29:33 -070028 /*
29 * In romstage, make sure that cbmem backing store is ready before
30 * returning the pointer to cbmem top. Otherwise, it could lead to
31 * issues with components that utilize cbmem in romstage
32 * (e.g. vboot_locator for loading ipq blobs before DRAM is
33 * initialized).
34 */
35 if (ENV_ROMSTAGE && (cbmem_backing_store_ready == 0))
36 return NULL;
37
Vadim Bendebury59b8c382014-12-11 17:31:20 -080038 return _memlayout_cbmem_top;
Vadim Bendebury15c98b02014-05-01 14:45:56 -070039}