3e3a11ac2fa93e4bd2675f2cdc012917407182b7
[platform/kernel/u-boot.git] / arch / x86 / lib / init_helpers.c
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 <linux/errno.h>
9 #include <asm/mtrr.h>
10
11 DECLARE_GLOBAL_DATA_PTR;
12
13 int init_cache_f_r(void)
14 {
15         bool do_mtrr = CONFIG_IS_ENABLED(X86_32BIT_INIT) ||
16                  IS_ENABLED(CONFIG_FSP_VERSION2);
17         int ret;
18
19         do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) &&
20                 !IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER);
21
22         if (do_mtrr) {
23                 ret = mtrr_commit(false);
24                 /*
25                  * If MTRR MSR is not implemented by the processor, just ignore
26                  * it
27                  */
28                 if (ret && ret != -ENOSYS)
29                         return ret;
30         }
31
32         /* Initialise the CPU cache(s) */
33         return init_cache();
34 }