soc/amd/stoneyridge/tsc_freq: use get_pstate_core_freq
Use get_pstate_core_freq instead of open-coding the calculations in tsc_freq_mhz. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: If5d526e6b365c62a6669241f4fcdd25eca3f15fd Reviewed-on: https://review.coreboot.org/c/coreboot/+/74012 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com>
This commit is contained in:
parent
96fd62f239
commit
ad52185c2d
|
@ -1,17 +1,17 @@
|
||||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
#include <amdblocks/cpu.h>
|
||||||
#include <cpu/x86/msr.h>
|
#include <cpu/x86/msr.h>
|
||||||
#include <cpu/amd/msr.h>
|
#include <cpu/amd/msr.h>
|
||||||
#include <cpu/x86/tsc.h>
|
#include <cpu/x86/tsc.h>
|
||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <soc/pci_devs.h>
|
#include <soc/pci_devs.h>
|
||||||
|
#include <soc/msr.h>
|
||||||
#include <device/pci_ops.h>
|
#include <device/pci_ops.h>
|
||||||
|
|
||||||
unsigned long tsc_freq_mhz(void)
|
unsigned long tsc_freq_mhz(void)
|
||||||
{
|
{
|
||||||
msr_t msr;
|
union pstate_msr pstate_reg;
|
||||||
uint8_t cpufid;
|
|
||||||
uint8_t cpudid;
|
|
||||||
uint8_t boost_states;
|
uint8_t boost_states;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -23,12 +23,9 @@ unsigned long tsc_freq_mhz(void)
|
||||||
boost_states = (pci_read_config32(SOC_PM_DEV, CORE_PERF_BOOST_CTRL)
|
boost_states = (pci_read_config32(SOC_PM_DEV, CORE_PERF_BOOST_CTRL)
|
||||||
>> 2) & 0x7;
|
>> 2) & 0x7;
|
||||||
|
|
||||||
msr = rdmsr(PSTATE_MSR(boost_states));
|
pstate_reg.raw = rdmsr(PSTATE_MSR(boost_states)).raw;
|
||||||
if (!(msr.hi & 0x80000000))
|
if (!pstate_reg.pstate_en)
|
||||||
die("Unknown error: cannot determine P-state 0\n");
|
die("Unknown error: cannot determine P-state 0\n");
|
||||||
|
|
||||||
cpufid = (msr.lo & 0x3f);
|
return get_pstate_core_freq(pstate_reg);
|
||||||
cpudid = (msr.lo & 0x1c0) >> 6;
|
|
||||||
|
|
||||||
return (100 * (cpufid + 0x10)) / (0x01 << cpudid);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue