1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2011
4  * Graeme Russ, <graeme.russ@gmail.com>
5  */
6 
7 #include <common.h>
8 #include <init.h>
9 #include <asm/global_data.h>
10 #include <linux/errno.h>
11 #include <asm/mtrr.h>
12 
13 DECLARE_GLOBAL_DATA_PTR;
14 
init_cache_f_r(void)15 int init_cache_f_r(void)
16 {
17 	bool do_mtrr = CONFIG_IS_ENABLED(X86_32BIT_INIT) ||
18 		 IS_ENABLED(CONFIG_FSP_VERSION2);
19 	int ret;
20 
21 	do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) &&
22 		!IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER);
23 
24 	if (do_mtrr) {
25 		ret = mtrr_commit(false);
26 		/*
27 		 * If MTRR MSR is not implemented by the processor, just ignore
28 		 * it
29 		 */
30 		if (ret && ret != -ENOSYS)
31 			return ret;
32 	}
33 
34 	if (!ll_boot_init())
35 		return 0;
36 
37 	/* Initialise the CPU cache(s) */
38 	return init_cache();
39 }
40