init_helpers.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2011
  4. * Graeme Russ, <graeme.russ@gmail.com>
  5. */
  6. #include <common.h>
  7. #include <init.h>
  8. #include <asm/global_data.h>
  9. #include <linux/errno.h>
  10. #include <asm/mtrr.h>
  11. DECLARE_GLOBAL_DATA_PTR;
  12. int init_cache_f_r(void)
  13. {
  14. bool do_mtrr = CONFIG_IS_ENABLED(X86_32BIT_INIT) ||
  15. IS_ENABLED(CONFIG_FSP_VERSION2);
  16. int ret;
  17. /*
  18. * Supported configurations:
  19. *
  20. * booting from slimbootloader - MTRRs are already set up
  21. * booting with FSPv1 - MTRRs are already set up
  22. * booting with FSPv2 - MTRRs must be set here
  23. * booting from coreboot - in this case there is no SPL, so we set up
  24. * the MTRRs here
  25. * Note: if there is an SPL, then it has already set up MTRRs so we
  26. * don't need to do that here
  27. */
  28. do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) &&
  29. !IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER);
  30. if (do_mtrr) {
  31. ret = mtrr_commit(false);
  32. /*
  33. * If MTRR MSR is not implemented by the processor, just ignore
  34. * it
  35. */
  36. if (ret && ret != -ENOSYS)
  37. return ret;
  38. }
  39. /* Initialise the CPU cache(s) */
  40. return init_cache();
  41. }