Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/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 <init.h>
9 #include <linux/errno.h>
10 #include <asm/mtrr.h>
11
12 DECLARE_GLOBAL_DATA_PTR;
13
14 int init_cache_f_r(void)
15 {
16         bool do_mtrr = CONFIG_IS_ENABLED(X86_32BIT_INIT) ||
17                  IS_ENABLED(CONFIG_FSP_VERSION2);
18         int ret;
19
20         do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) &&
21                 !IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER);
22
23         if (do_mtrr) {
24                 ret = mtrr_commit(false);
25                 /*
26                  * If MTRR MSR is not implemented by the processor, just ignore
27                  * it
28                  */
29                 if (ret && ret != -ENOSYS)
30                         return ret;
31         }
32
33         if (!ll_boot_init())
34                 return 0;
35
36         /* Initialise the CPU cache(s) */
37         return init_cache();
38 }