finally fix voltage bug for real

This commit is contained in:
Lightos1
2026-01-24 20:43:35 +01:00
parent af1c36d00a
commit 5012836c7e

View File

@@ -112,26 +112,32 @@ ClockManager::ClockManager()
this->context->isDram8GB = Board::IsDram8GB();
}
void ClockManager::FixCpuBug() {
static u32 cpuFreqs[] = {
1785000000,
1887000000,
1963000000,
2091000000,
2193000000,
2295000000,
2397000000,
2499000000,
2601000000,
2703000000,
1020000000
};
static u32 cpuFreqsSize = sizeof(cpuFreqs) / sizeof(u32);
for(int i = 0; i < cpuFreqsSize; i++) {
Board::SetHz(SysClkModule_CPU, cpuFreqs[i]);
svcSleepThread(2'500'000); // 2.5ms
}
u32 targetHz = 0;
u32 maxHz = 0;
u32 nearestHz = 0;
ResetToStockClocks();
targetHz = this->context->overrideFreqs[SysClkModule_CPU];
if (!targetHz) {
targetHz = this->config->GetAutoClockHz(this->context->applicationId, SysClkModule_CPU, this->context->profile, false);
if(!targetHz)
targetHz = this->config->GetAutoClockHz(GLOBAL_PROFILE_ID, SysClkModule_CPU, this->context->profile, false);
}
if (targetHz) {
maxHz = this->GetMaxAllowedHz(SysClkModule_CPU, this->context->profile);
nearestHz = this->GetNearestHz(SysClkModule_CPU, targetHz, maxHz);
while ((nearestHz = this->GetNearestHz(SysClkModule_CPU, targetHz, maxHz)) != targetHz) {
Board::SetHz(SysClkModule_CPU, 1020000000);
svcSleepThread(2'500'000);
Board::SetHz(SysClkModule_CPU, nearestHz);
this->context->freqs[SysClkModule_CPU] = nearestHz;
}
}
}
ClockManager::~ClockManager()