sysclk: refactor speedo code

This commit is contained in:
souldbminersmwc
2026-01-10 15:52:15 -05:00
parent 27c3a2b7c9
commit b7b6153f6e
20 changed files with 171 additions and 71 deletions

View File

@@ -323,17 +323,34 @@ void Board::fuseReadSpeedos() {
svcCloseHandle(debug);
}
u16 Board::getCPUSpeedo() {
return cpuSpeedo0;
u16 Board::getSpeedo(HorizonOCSpeedo speedoType) {
switch(speedoType) {
case HorizonOCSpeedo_CPU:
return cpuSpeedo0;
case HorizonOCSpeedo_GPU:
return cpuSpeedo2;
case HorizonOCSpeedo_SOC:
return socSpeedo0;
default:
ASSERT_ENUM_VALID(HorizonOCSpeedo, speedoType);
return 0;
}
}
u16 Board::getGPUSpeedo() {
return cpuSpeedo2;
u16 Board::getIDDQ(HorizonOCSpeedo speedoType) {
switch(speedoType) {
case HorizonOCSpeedo_CPU:
return cpuIDDQ;
case HorizonOCSpeedo_GPU:
return gpuIDDQ;
case HorizonOCSpeedo_SOC:
return socIDDQ;
default:
ASSERT_ENUM_VALID(HorizonOCSpeedo, speedoType);
return 0;
}
}
u16 Board::getSOCSpeedo() {
return socSpeedo0;
}
void Board::Exit()
{
@@ -1066,3 +1083,17 @@ void Board::UpdateShadowRegs(u32 tRCD_i, u32 tRP_i, u32 tRAS_i, u32 tRRD_i, u32
WRITE_REGISTER_MC(MC_TIMING_CONTROL_0, 0x1); // update timing regs as they are shadowed
WRITE_REGISTER_EMC(EMC_TIMING_CONTROL_0, 0x1);
}
bool Board::IsDram8GB() {
SecmonArgs args = {};
args.X[0] = 0xF0000002;
args.X[1] = MC_REGISTER_BASE + MC_EMEM_CFG_0;
svcCallSecureMonitor(&args);
if(args.X[1] == (MC_REGISTER_BASE + MC_EMEM_CFG_0)) { // if param 1 is identical read failed
writeNotification("Horizon OC\nSecmon read failed!\n This may be a hardware issue!");
return false;
} else
return args.X[1] == 0x00002000 ? true : false;
}

View File

@@ -34,9 +34,8 @@ class Board
{
public:
static void fuseReadSpeedos();
static u16 getCPUSpeedo();
static u16 getGPUSpeedo();
static u16 getSOCSpeedo();
static u16 getSpeedo(HorizonOCSpeedo speedoType);
static u16 getIDDQ(HorizonOCSpeedo speedoType);
static const char* GetProfileName(SysClkProfile profile, bool pretty);
static const char* GetModuleName(SysClkModule module, bool pretty);
static const char* GetThermalSensorName(SysClkThermalSensor sensor, bool pretty);
@@ -63,6 +62,7 @@ class Board
static u8 GetFanRotationLevel();
static u8 GetDramID();
static void UpdateShadowRegs(u32 tRCD_i, u32 tRP_i, u32 tRAS_i, u32 tRRD_i, u32 tRFC_i, u32 tRTW_i, u32 tWTR_i, u32 tREFpb_i, u32 ramFreq, u32 rlAdd, u32 wlAdd, bool hpMode);
static bool IsDram8GB();
protected:
static void FetchHardwareInfos();
static PcvModule GetPcvModule(SysClkModule sysclkModule);

View File

@@ -102,12 +102,14 @@ ClockManager::ClockManager()
);
threadStart(&governorTHREAD);
this->context->speedos[HorizonOCSpeedo_CPU] = Board::getCPUSpeedo();
this->context->speedos[HorizonOCSpeedo_GPU] = Board::getGPUSpeedo();
this->context->speedos[HorizonOCSpeedo_SOC] = Board::getSOCSpeedo();
for(int i = 0; i < HorizonOCSpeedo_EnumMax; i++) {
this->context->speedos[i] = Board::getSpeedo((HorizonOCSpeedo)i);
this->context->iddq[i] = Board::getIDDQ((HorizonOCSpeedo)i);
}
this->context->dramID = Board::GetDramID();
this->context->isDram8GB = Board::IsDram8GB();
}
void ClockManager::FixCpuBug() {
@@ -666,7 +668,7 @@ bool ClockManager::RefreshContext()
// ram load do not and should not force a refresh, hasChanged untouched
for (unsigned int loadSource = 0; loadSource < SysClkPartLoad_EnumMax; loadSource++)
{
this->context->PartLoad[loadSource] = Board::GetPartLoad((SysClkPartLoad)loadSource);
this->context->partLoad[loadSource] = Board::GetPartLoad((SysClkPartLoad)loadSource);
}
for (unsigned int voltageSource = 0; voltageSource < HocClkVoltage_EnumMax; voltageSource++)
@@ -1037,7 +1039,7 @@ void ClockManager::calculateGpuVmin (void)
SysClkConfigValueList configValues;
this->config->GetConfigValues(&configValues);
int speedo = Board::getGPUSpeedo(), freq = this->config->GetConfigValue(KipConfigValue_marikoEmcMaxClock);
int speedo = Board::getSpeedo(HorizonOCSpeedo_CPU), freq = this->config->GetConfigValue(KipConfigValue_marikoEmcMaxClock);
configValues.values[KipConfigValue_marikoGpuVmin] = GetGpuVoltage(freq, speedo);
this->config->SetConfigValues(&configValues, true);
}