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 13DECLARE_GLOBAL_DATA_PTR; 14 15int init_cache_f_r(void) 16{ 17 bool do_mtrr = CONFIG_IS_ENABLED(X86_32BIT_INIT) || 18 IS_ENABLED(CONFIG_FSP_VERSION2) || 19 (IS_ENABLED(CONFIG_TPL) && IS_ENABLED(CONFIG_HAVE_MRC)); 20 int ret; 21 22 /* 23 * Supported configurations: 24 * 25 * booting from slimbootloader - MTRRs are already set up 26 * booting with FSPv1 - MTRRs are already set up 27 * booting with FSPv2 or MRC - MTRRs must be set here 28 * booting from coreboot - in this case there is no SPL, so we set up 29 * the MTRRs here 30 */ 31 do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) && 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 44 /* Initialise the CPU cache(s) */ 45 return init_cache(); 46} 47