Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Graeme Russ | a875dda | 2011-12-23 16:51:29 +1100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2011 |
| 4 | * Graeme Russ, <graeme.russ@gmail.com> |
Graeme Russ | a875dda | 2011-12-23 16:51:29 +1100 | [diff] [blame] | 5 | */ |
Bin Meng | 535109a | 2015-08-13 00:29:10 -0700 | [diff] [blame] | 6 | |
Graeme Russ | a875dda | 2011-12-23 16:51:29 +1100 | [diff] [blame] | 7 | #include <common.h> |
Simon Glass | 6980b6b | 2019-11-14 12:57:45 -0700 | [diff] [blame] | 8 | #include <init.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 10 | #include <linux/errno.h> |
Simon Glass | 004ba17 | 2015-01-01 16:18:11 -0700 | [diff] [blame] | 11 | #include <asm/mtrr.h> |
Graeme Russ | a875dda | 2011-12-23 16:51:29 +1100 | [diff] [blame] | 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
Graeme Russ | 3fb4f9e | 2011-12-23 21:14:22 +1100 | [diff] [blame] | 15 | int init_cache_f_r(void) |
| 16 | { |
Simon Glass | a72a7ab | 2019-09-25 08:56:49 -0600 | [diff] [blame] | 17 | bool do_mtrr = CONFIG_IS_ENABLED(X86_32BIT_INIT) || |
Simon Glass | 37da575 | 2023-09-07 09:58:19 -0600 | [diff] [blame] | 18 | IS_ENABLED(CONFIG_FSP_VERSION2) || |
| 19 | (IS_ENABLED(CONFIG_TPL) && IS_ENABLED(CONFIG_HAVE_MRC)); |
Simon Glass | 004ba17 | 2015-01-01 16:18:11 -0700 | [diff] [blame] | 20 | int ret; |
| 21 | |
Simon Glass | 76f8bbe | 2021-06-27 17:51:03 -0600 | [diff] [blame] | 22 | /* |
| 23 | * Supported configurations: |
| 24 | * |
Bin Meng | 4a3f391 | 2023-07-31 07:56:02 -0600 | [diff] [blame] | 25 | * booting from slimbootloader - MTRRs are already set up |
Simon Glass | 76f8bbe | 2021-06-27 17:51:03 -0600 | [diff] [blame] | 26 | * booting with FSPv1 - MTRRs are already set up |
Simon Glass | 37da575 | 2023-09-07 09:58:19 -0600 | [diff] [blame] | 27 | * booting with FSPv2 or MRC - MTRRs must be set here |
Simon Glass | 76f8bbe | 2021-06-27 17:51:03 -0600 | [diff] [blame] | 28 | * booting from coreboot - in this case there is no SPL, so we set up |
| 29 | * the MTRRs here |
Simon Glass | 76f8bbe | 2021-06-27 17:51:03 -0600 | [diff] [blame] | 30 | */ |
Bin Meng | 4a3f391 | 2023-07-31 07:56:02 -0600 | [diff] [blame] | 31 | do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) && |
Simon Glass | a72a7ab | 2019-09-25 08:56:49 -0600 | [diff] [blame] | 32 | !IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER); |
| 33 | |
| 34 | if (do_mtrr) { |
| 35 | ret = mtrr_commit(false); |
| 36 | /* |
| 37 | * If MTRR MSR is not implemented by the processor, just ignore |
| 38 | * it |
| 39 | */ |
| 40 | if (ret && ret != -ENOSYS) |
| 41 | return ret; |
| 42 | } |
| 43 | |
Graeme Russ | 3fb4f9e | 2011-12-23 21:14:22 +1100 | [diff] [blame] | 44 | /* Initialise the CPU cache(s) */ |
| 45 | return init_cache(); |
| 46 | } |