blob: f61fe814e94aa474c513b17ae843a6544685879a [file] [log] [blame]
Park, Aiden6e3cc362019-08-03 08:30:12 +00001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2019 Intel Corporation <www.intel.com>
4 */
5
6#include <common.h>
Simon Glass1fa70f82019-11-14 12:57:34 -07007#include <cpu_func.h>
Simon Glass97589732020-05-10 11:40:02 -06008#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -06009#include <log.h>
Park, Aiden347f1b42019-08-03 08:30:52 +000010#include <asm/arch/slimbootloader.h>
11
12DECLARE_GLOBAL_DATA_PTR;
13
14/**
15 * This sets tsc_base and clock_rate for early_timer and tsc_timer.
16 * The performance info guid hob has all performance timestamp data, but
17 * the only tsc frequency info is used for the timer driver for now.
18 *
19 * Slim Bootloader already calibrated TSC and provides it to U-Boot.
20 * Therefore, U-Boot does not have to re-calibrate TSC.
21 * Configuring tsc_base and clock_rate here makes x86 tsc_timer driver
22 * bypass TSC calibration and use the provided TSC frequency.
23 */
24static void tsc_init(void)
25{
26 struct sbl_performance_info *data;
27 const efi_guid_t guid = SBL_PERFORMANCE_INFO_GUID;
28
29 if (!gd->arch.hob_list)
30 panic("hob list not found!");
31
32 gd->arch.tsc_base = rdtsc();
33 debug("tsc_base=0x%llx\n", gd->arch.tsc_base);
34
35 data = hob_get_guid_hob_data(gd->arch.hob_list, NULL, &guid);
36 if (!data) {
37 debug("performance info hob not found\n");
38 return;
39 }
40
41 /* frequency is in KHz, so to Hz */
42 gd->arch.clock_rate = data->frequency * 1000;
43 debug("freq=0x%lx\n", gd->arch.clock_rate);
44}
Park, Aiden6e3cc362019-08-03 08:30:12 +000045
46int arch_cpu_init(void)
47{
Park, Aiden347f1b42019-08-03 08:30:52 +000048 tsc_init();
49
Park, Aiden6e3cc362019-08-03 08:30:12 +000050 return x86_cpu_init_f();
51}
52
53int checkcpu(void)
54{
55 return 0;
56}
57
58int print_cpuinfo(void)
59{
60 return default_print_cpuinfo();
61}