]> Git Repo - J-u-boot.git/blob - arch/x86/cpu/coreboot/coreboot.c
Merge patch series "'eeprom' command improvements"
[J-u-boot.git] / arch / x86 / cpu / coreboot / coreboot.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2011 The Chromium OS Authors.
4  * (C) Copyright 2008
5  * Graeme Russ, [email protected].
6  */
7
8 #include <cpu_func.h>
9 #include <event.h>
10 #include <fdtdec.h>
11 #include <init.h>
12 #include <usb.h>
13 #include <asm/global_data.h>
14 #include <asm/io.h>
15 #include <asm/msr.h>
16 #include <asm/mtrr.h>
17 #include <asm/cb_sysinfo.h>
18 #include <asm/arch/timestamp.h>
19 #include <dm/ofnode.h>
20
21 int arch_cpu_init(void)
22 {
23         int ret;
24
25         ret = IS_ENABLED(CONFIG_X86_RUN_64BIT) ? x86_cpu_reinit_f() :
26                 x86_cpu_init_f();
27         if (ret)
28                 return ret;
29
30         ret = get_coreboot_info(&lib_sysinfo);
31         if (ret != 0) {
32                 printf("Failed to parse coreboot tables.\n");
33                 return ret;
34         }
35
36         timestamp_init();
37
38         return 0;
39 }
40
41 int checkcpu(void)
42 {
43         return 0;
44 }
45
46 int print_cpuinfo(void)
47 {
48         return default_print_cpuinfo();
49 }
50
51 static void board_final_init(void)
52 {
53         /*
54          * Un-cache the ROM so the kernel has one
55          * more MTRR available.
56          *
57          * Coreboot should have assigned this to the
58          * top available variable MTRR.
59          */
60         u8 top_mtrr = (native_read_msr(MTRR_CAP_MSR) & 0xff) - 1;
61         u8 top_type = native_read_msr(MTRR_PHYS_BASE_MSR(top_mtrr)) & 0xff;
62
63         /* Make sure this MTRR is the correct Write-Protected type */
64         if (top_type == MTRR_TYPE_WRPROT) {
65                 struct mtrr_state state;
66
67                 mtrr_open(&state, true);
68                 wrmsrl(MTRR_PHYS_BASE_MSR(top_mtrr), 0);
69                 wrmsrl(MTRR_PHYS_MASK_MSR(top_mtrr), 0);
70                 mtrr_close(&state, true);
71         }
72
73         if (!ofnode_conf_read_bool("u-boot,no-apm-finalize")) {
74                 /*
75                  * Issue SMI to coreboot to lock down ME and registers
76                  * when allowed via device tree
77                  */
78                 printf("Finalizing coreboot\n");
79                 outb(0xcb, 0xb2);
80         }
81 }
82
83 static int last_stage_init(void)
84 {
85         if (IS_ENABLED(CONFIG_SPL_BUILD))
86                 return 0;
87
88         board_final_init();
89
90         return 0;
91 }
92 EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
This page took 0.047151 seconds and 4 git commands to generate.