coreboot.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. * (C) Copyright 2008
  4. * Graeme Russ, graeme.russ@gmail.com.
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <fdtdec.h>
  10. #include <asm/io.h>
  11. #include <asm/msr.h>
  12. #include <asm/mtrr.h>
  13. #include <asm/arch/sysinfo.h>
  14. #include <asm/arch/timestamp.h>
  15. DECLARE_GLOBAL_DATA_PTR;
  16. int arch_cpu_init(void)
  17. {
  18. int ret = get_coreboot_info(&lib_sysinfo);
  19. if (ret != 0) {
  20. printf("Failed to parse coreboot tables.\n");
  21. return ret;
  22. }
  23. timestamp_init();
  24. return x86_cpu_init_f();
  25. }
  26. int board_early_init_f(void)
  27. {
  28. return 0;
  29. }
  30. int print_cpuinfo(void)
  31. {
  32. return default_print_cpuinfo();
  33. }
  34. int last_stage_init(void)
  35. {
  36. if (gd->flags & GD_FLG_COLD_BOOT)
  37. timestamp_add_to_bootstage();
  38. return 0;
  39. }
  40. void board_final_cleanup(void)
  41. {
  42. /*
  43. * Un-cache the ROM so the kernel has one
  44. * more MTRR available.
  45. *
  46. * Coreboot should have assigned this to the
  47. * top available variable MTRR.
  48. */
  49. u8 top_mtrr = (native_read_msr(MTRR_CAP_MSR) & 0xff) - 1;
  50. u8 top_type = native_read_msr(MTRR_PHYS_BASE_MSR(top_mtrr)) & 0xff;
  51. /* Make sure this MTRR is the correct Write-Protected type */
  52. if (top_type == MTRR_TYPE_WRPROT) {
  53. struct mtrr_state state;
  54. mtrr_open(&state);
  55. wrmsrl(MTRR_PHYS_BASE_MSR(top_mtrr), 0);
  56. wrmsrl(MTRR_PHYS_MASK_MSR(top_mtrr), 0);
  57. mtrr_close(&state);
  58. }
  59. if (!fdtdec_get_config_bool(gd->fdt_blob, "u-boot,no-apm-finalize")) {
  60. /*
  61. * Issue SMI to coreboot to lock down ME and registers
  62. * when allowed via device tree
  63. */
  64. printf("Finalizing coreboot\n");
  65. outb(0xcb, 0xb2);
  66. }
  67. }
  68. int misc_init_r(void)
  69. {
  70. return 0;
  71. }
  72. int arch_misc_init(void)
  73. {
  74. return 0;
  75. }