From 89ba7393793d8c2159ff5dc3fc1ace3a90808d79 Mon Sep 17 00:00:00 2001 From: CyrIng Date: Sat, 29 Jun 2024 21:43:32 +0200 Subject: [PATCH] [AArch64] Get the voltage core of CPUs from OPP --- aarch64/corefreqd.c | 57 ++++++++++++++++++ aarch64/corefreqk.c | 96 +++++++++++++++++++++++++++++ aarch64/corefreqk.h | 143 +++++++++++++++++++++++++++++++++++++++++++- aarch64/coretypes.h | 13 ++-- 4 files changed, 304 insertions(+), 5 deletions(-) diff --git a/aarch64/corefreqd.c b/aarch64/corefreqd.c index cad61ea2..a648f60a 100644 --- a/aarch64/corefreqd.c +++ b/aarch64/corefreqd.c @@ -158,6 +158,50 @@ static void (*ComputeVoltage_None_Matrix[4])( struct FLIP_FLOP*, [FORMULA_SCOPE_PKG ] = ComputeVoltage_None_PerPkg }; +static void ComputeVoltage_OPP( struct FLIP_FLOP *CFlip, + RO(SHM_STRUCT) *RO(Shm), + unsigned int cpu ) +{ + COMPUTE_VOLTAGE(OPP, + CFlip->Voltage.Vcore, + CFlip->Voltage.VID); + + Core_ComputeVoltageLimits(&RO(Shm)->Cpu[cpu], CFlip); +} + +#define ComputeVoltage_OPP_PerSMT ComputeVoltage_OPP + +static void ComputeVoltage_OPP_PerCore( struct FLIP_FLOP *CFlip, + RO(SHM_STRUCT) *RO(Shm), + unsigned int cpu ) +{ + if ((RO(Shm)->Cpu[cpu].Topology.ThreadID == 0) + || (RO(Shm)->Cpu[cpu].Topology.ThreadID == -1)) + { + ComputeVoltage_OPP(CFlip, RO(Shm), cpu); + } +} + +static void ComputeVoltage_OPP_PerPkg( struct FLIP_FLOP *CFlip, + RO(SHM_STRUCT) *RO(Shm), + unsigned int cpu ) +{ + if (cpu == RO(Shm)->Proc.Service.Core) + { + ComputeVoltage_OPP(CFlip, RO(Shm), cpu); + } +} + +static void (*ComputeVoltage_OPP_Matrix[4])( struct FLIP_FLOP*, + RO(SHM_STRUCT)*, + unsigned int ) = \ +{ + [FORMULA_SCOPE_NONE] = ComputeVoltage_None, + [FORMULA_SCOPE_SMT ] = ComputeVoltage_OPP_PerSMT, + [FORMULA_SCOPE_CORE] = ComputeVoltage_OPP_PerCore, + [FORMULA_SCOPE_PKG ] = ComputeVoltage_OPP_PerPkg +}; + void Core_ComputePowerLimits(CPU_STRUCT *Cpu, struct FLIP_FLOP *CFlip) { /* Per Core, computes the Min CPU Energy consumed. */ TEST_AND_SET_SENSOR( ENERGY, LOWEST, CFlip->State.Energy, @@ -245,6 +289,9 @@ static void *Core_Cycle(void *arg) } switch (KIND_OF_FORMULA(RO(Shm)->Proc.voltageFormula)) { + case VOLTAGE_KIND_OPP: + ComputeVoltageFormula = ComputeVoltage_OPP_Matrix; + break; case VOLTAGE_KIND_NONE: default: ComputeVoltageFormula = ComputeVoltage_None_Matrix; @@ -1520,6 +1567,13 @@ static void Pkg_ComputeVoltage_None(struct PKG_FLIP_FLOP *PFlip) UNUSED(PFlip); } +static void Pkg_ComputeVoltage_OPP(struct PKG_FLIP_FLOP *PFlip) +{ + COMPUTE_VOLTAGE(OPP, + PFlip->Voltage.CPU, + PFlip->Voltage.VID.CPU); +} + static void Pkg_ComputePower_None(RW(PROC) *RW(Proc), struct FLIP_FLOP *CFlop) { UNUSED(RW(Proc)); @@ -1591,6 +1645,9 @@ REASON_CODE Core_Manager(REF *Ref) } switch (KIND_OF_FORMULA(RO(Shm)->Proc.voltageFormula)) { + case VOLTAGE_KIND_OPP: + Pkg_ComputeVoltageFormula = Pkg_ComputeVoltage_OPP; + break; case VOLTAGE_KIND_NONE: default: Pkg_ComputeVoltageFormula = Pkg_ComputeVoltage_None; diff --git a/aarch64/corefreqk.c b/aarch64/corefreqk.c index dbb5ce1a..0b60532c 100644 --- a/aarch64/corefreqk.c +++ b/aarch64/corefreqk.c @@ -25,6 +25,9 @@ #ifdef CONFIG_CPU_FREQ #include #endif /* CONFIG_CPU_FREQ */ +#ifdef CONFIG_PM_OPP +#include +#endif /* CONFIG_PM_OPP */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) #include #endif /* KERNEL_VERSION(4, 11, 0) */ @@ -2021,6 +2024,62 @@ static void Query_DeviceTree(unsigned int cpu) Core->Boost[BOOST(TGT)] = cur_freq / UNIT_KHz(PRECISION); } +#ifdef CONFIG_PM_OPP +static unsigned long GetVoltage_From_OPP(unsigned int cpu, + unsigned long freq_hz) +{ + unsigned long u_volt = 0; + struct device *cpu_dev = get_cpu_device(cpu); + if (cpu_dev != NULL) { + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0) + struct dev_pm_opp *opp = dev_pm_opp_find_freq_ceil(cpu_dev, &freq_hz); + #else + struct opp *opp_find_freq_ceil(cpu_dev, &freq_hz); + #endif + if (!IS_ERR(opp)) { + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0) + u_volt = dev_pm_opp_get_voltage(opp); + dev_pm_opp_put(opp); + #else + u_volt = opp_get_voltage(opp); + #endif + } + } + return u_volt; +} + +static void Query_Voltage_From_OPP(void) +{ + unsigned int cpu; + for (cpu = 0; cpu < PUBLIC(RO(Proc))->CPU.Count; cpu++) { + enum RATIO_BOOST boost; + for (boost = BOOST(MIN); boost < BOOST(SIZE) - BOOST(18C); boost++) + { + unsigned long freq_hz = PUBLIC(RO(Proc))->Features.Factory.Clock.Hz + * PUBLIC(RO(Core, AT(cpu)))->Boost[BOOST(18C) + boost], + + u_volt = GetVoltage_From_OPP(cpu, freq_hz); + u_volt = u_volt >> 5; + + PRIVATE(OF(Core, AT(cpu)))->OPP[boost].VID = (signed int) u_volt; + } + } +} + +inline enum RATIO_BOOST Find_OPP_From_Ratio(CORE_RO *Core, unsigned int ratio) +{ + enum RATIO_BOOST boost, last = BOOST(MIN); + for (boost = BOOST(MIN); boost < BOOST(SIZE) - BOOST(18C); boost++) { + if (Core->Boost[BOOST(18C) + boost] <= ratio) { + last = boost; + continue; + } + break; + } + return last; +} +#endif /* CONFIG_PM_OPP */ + static void Compute_ACPI_CPPC_Bounds(unsigned int cpu) { CORE_RO *Core = (CORE_RO *) PUBLIC(RO(Core, AT(cpu))); @@ -3307,6 +3366,39 @@ static enum hrtimer_restart Cycle_GenericMachine(struct hrtimer *pTimer) #endif PUBLIC(RO(Core, AT(cpu)))->Boost[BOOST(TGT)] = Core->Ratio.COF.Q; + #ifdef CONFIG_PM_OPP + { + enum RATIO_BOOST index = Find_OPP_From_Ratio(Core, Core->Ratio.COF.Q); + + switch (SCOPE_OF_FORMULA(PUBLIC(RO(Proc))->voltageFormula)) { + case FORMULA_SCOPE_CORE: + if (!((Core->T.ThreadID == 0) || (Core->T.ThreadID == -1))) + { + break; + } + fallthrough; + case FORMULA_SCOPE_SMT: + Core->PowerThermal.VID = \ + PRIVATE(OF(Core, AT(Core->Bind)))->OPP[index].VID; + break; + case FORMULA_SCOPE_PKG: + if (Core->Bind == PUBLIC(RO(Proc))->Service.Core) { + Core->PowerThermal.VID = \ + PRIVATE(OF(Core, AT(Core->Bind)))->OPP[index].VID; + } + break; + case FORMULA_SCOPE_NONE: + break; + } + if (((PUBLIC(RO(Proc))->Features.Hybrid) + && (Core->Bind == PUBLIC(RO(Proc))->Service.Hybrid)) + || (Core->Bind == PUBLIC(RO(Proc))->Service.Core)) + { + PUBLIC(RO(Proc))->PowerThermal.VID.CPU = \ + PRIVATE(OF(Core, AT(Core->Bind)))->OPP[index].VID; + } + } + #endif /* CONFIG_PM_OPP */ BITSET(LOCKLESS, PUBLIC(RW(Core, AT(cpu)))->Sync.V, NTFY); return HRTIMER_RESTART; @@ -5922,6 +6014,10 @@ static int CoreFreqK_Ignition_Level_Up(INIT_ARG *pArg) Controller_Start(0); +#ifdef CONFIG_PM_OPP + Query_Voltage_From_OPP(); +#endif /* CONFIG_PM_OPP */ + #ifdef CONFIG_HOTPLUG_CPU #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) /* Always returns zero (kernel/notifier.c) */ diff --git a/aarch64/corefreqk.h b/aarch64/corefreqk.h index 77a8e236..0e1eea2b 100644 --- a/aarch64/corefreqk.h +++ b/aarch64/corefreqk.h @@ -234,8 +234,13 @@ typedef struct }; } SaveArea; #ifdef CONFIG_CPU_FREQ - struct cpufreq_policy FreqPolicy; + struct cpufreq_policy FreqPolicy; #endif /* CONFIG_CPU_FREQ */ +#ifdef CONFIG_PM_OPP + struct { + signed int VID; + } OPP[BOOST(SIZE) - BOOST(18C)]; +#endif /* CONFIG_PM_OPP */ } *Core[]; } KPRIVATE; @@ -494,7 +499,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -518,7 +527,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -542,7 +555,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -566,7 +583,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -590,7 +611,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -614,7 +639,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -638,7 +667,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -662,7 +695,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -686,7 +723,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -710,7 +751,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -734,7 +779,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -758,7 +807,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -782,7 +835,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -806,7 +863,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -830,7 +891,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -854,7 +919,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -878,7 +947,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -902,7 +975,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -926,7 +1003,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -950,7 +1031,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -974,7 +1059,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -998,7 +1087,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1022,7 +1115,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1046,7 +1143,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1070,7 +1171,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1094,7 +1199,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1118,7 +1227,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1142,7 +1255,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1166,7 +1283,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1190,7 +1311,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1214,7 +1339,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1238,7 +1367,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1262,7 +1395,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { @@ -1286,7 +1423,11 @@ static ARCH Arch[ARCHITECTURES] = { .ClockMod = NULL, .TurboClock = NULL, .thermalFormula = THERMAL_FORMULA_NONE, +#ifdef CONFIG_PM_OPP + .voltageFormula = VOLTAGE_FORMULA_OPP, +#else .voltageFormula = VOLTAGE_FORMULA_NONE, +#endif .powerFormula = POWER_FORMULA_NONE, .PCI_ids = PCI_Void_ids, .Uncore = { diff --git a/aarch64/coretypes.h b/aarch64/coretypes.h index 303fa285..8d8bfe14 100644 --- a/aarch64/coretypes.h +++ b/aarch64/coretypes.h @@ -475,15 +475,17 @@ enum THERMAL_KIND { }; enum THERMAL_FORMULAS { -THERMAL_FORMULA_NONE = (THERMAL_KIND_NONE << 8) | FORMULA_SCOPE_NONE + THERMAL_FORMULA_NONE = (THERMAL_KIND_NONE << 8) | FORMULA_SCOPE_NONE }; enum VOLTAGE_KIND { - VOLTAGE_KIND_NONE = 0b000000000000000000000000 + VOLTAGE_KIND_NONE = 0b000000000000000000000000, + VOLTAGE_KIND_OPP = 0b000000000000000000000001 }; enum VOLTAGE_FORMULAS { -VOLTAGE_FORMULA_NONE =(VOLTAGE_KIND_NONE << 8) | FORMULA_SCOPE_NONE + VOLTAGE_FORMULA_NONE = (VOLTAGE_KIND_NONE << 8) | FORMULA_SCOPE_NONE, + VOLTAGE_FORMULA_OPP = (VOLTAGE_KIND_OPP << 8) | FORMULA_SCOPE_SMT }; enum POWER_KIND { @@ -491,7 +493,7 @@ enum POWER_KIND { }; enum POWER_FORMULAS { -POWER_FORMULA_NONE =(POWER_KIND_NONE << 8) | FORMULA_SCOPE_NONE + POWER_FORMULA_NONE = (POWER_KIND_NONE << 8) | FORMULA_SCOPE_NONE }; #define SCOPE_OF_FORMULA(formula) (formula & 0b0011) @@ -559,6 +561,9 @@ POWER_FORMULA_NONE =(POWER_KIND_NONE << 8) | FORMULA_SCOPE_NONE #define COMPUTE_THERMAL(_ARCH_, Temp, Param, Sensor) \ COMPUTE_THERMAL_##_ARCH_(Temp, Param, Sensor) +#define COMPUTE_VOLTAGE_OPP(Vcore, VID) \ + (Vcore = (double) (VID << 5) / 1000000.0) + #define COMPUTE_VOLTAGE(_ARCH_, Vcore, VID) \ COMPUTE_VOLTAGE_##_ARCH_(Vcore, VID)