coreboot.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 <netdev.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. int board_eth_init(bd_t *bis)
  41. {
  42. return pci_eth_init(bis);
  43. }
  44. void board_final_cleanup(void)
  45. {
  46. /*
  47. * Un-cache the ROM so the kernel has one
  48. * more MTRR available.
  49. *
  50. * Coreboot should have assigned this to the
  51. * top available variable MTRR.
  52. */
  53. u8 top_mtrr = (native_read_msr(MTRR_CAP_MSR) & 0xff) - 1;
  54. u8 top_type = native_read_msr(MTRR_PHYS_BASE_MSR(top_mtrr)) & 0xff;
  55. /* Make sure this MTRR is the correct Write-Protected type */
  56. if (top_type == MTRR_TYPE_WRPROT) {
  57. struct mtrr_state state;
  58. mtrr_open(&state);
  59. wrmsrl(MTRR_PHYS_BASE_MSR(top_mtrr), 0);
  60. wrmsrl(MTRR_PHYS_MASK_MSR(top_mtrr), 0);
  61. mtrr_close(&state);
  62. }
  63. /* Issue SMI to Coreboot to lock down ME and registers */
  64. printf("Finalizing Coreboot\n");
  65. outb(0xcb, 0xb2);
  66. }
  67. int misc_init_r(void)
  68. {
  69. return 0;
  70. }