This reverts commit b54252ccac, reversing
changes made to 96ff480607.
This commit is contained in:
souldbminersmwc
2025-11-12 18:41:37 -05:00
parent b54252ccac
commit d4fad33020
14 changed files with 2455 additions and 164 deletions

View File

@@ -235,23 +235,32 @@ void ClockManager::Tick()
std::uint32_t maxHz = 0;
std::uint32_t nearestHz = 0;
std::uint32_t mode = 0;
if(this->config->GetConfigValue(HocClkConfigValue_EMCVdd2VoltageUV) < 1400000) { // Safety Check
set_sd1_voltage((u32)this->config->GetConfigValue(HocClkConfigValue_EMCVdd2VoltageUV));
}
AppletOperationMode opMode = appletGetOperationMode();
Result rc = apmExtGetCurrentPerformanceConfiguration(&mode);
ASSERT_RESULT_OK(rc, "apmExtGetCurrentPerformanceConfiguration");
if(this->config->GetConfigValue(HocClkConfigValue_HandheldTDP) && opMode == AppletOperationMode_Handheld) {
if(Board::GetSocType() == SysClkSocType_MarikoLite) {
if(Board::GetPowerMw(SysClkPowerSensor_Now) < -(int)this->config->GetConfigValue(HocClkConfigValue_LiteTDPLimit)) {
if(Board::GetPowerMw(SysClkPowerSensor_Avg) < -(int)this->config->GetConfigValue(HocClkConfigValue_LiteTDPLimit)) {
ResetToStockClocks();
return;
}
} else {
if(Board::GetPowerMw(SysClkPowerSensor_Now) < -(int)this->config->GetConfigValue(HocClkConfigValue_HandheldTDPLimit)) {
if(Board::GetPowerMw(SysClkPowerSensor_Avg) < -(int)this->config->GetConfigValue(HocClkConfigValue_HandheldTDPLimit)) {
ResetToStockClocks();
return;
}
}
} else if(opMode == AppletOperationMode_Console && this->config->GetConfigValue(HocClkConfigValue_EnforceBoardLimit)) {
if(Board::GetPowerMw(SysClkPowerSensor_Avg) < 0) {
ResetToStockClocks();
return;
}
}
if(apmExtIsBoostMode(mode) && !this->config->GetConfigValue(HocClkConfigValue_OverwriteBoostMode)) {
@@ -442,4 +451,52 @@ bool ClockManager::RefreshContext()
void ClockManager::SetRNXRTMode(ReverseNXMode mode)
{
this->rnxSync->SetRTMode(mode);
}
void ClockManager::set_sd1_voltage(uint32_t voltage_uv)
{
// SD1 parameters
const u32 uv_step = 12500;
const u32 uv_min = 600000;
const u32 uv_max = 1237500;
const u8 volt_addr = 0x17; // MAX77620_REG_SD1
const u8 volt_mask = 0x7F; // MAX77620_SD1_VOLT_MASK
// Validate input voltage
if (voltage_uv < uv_min || voltage_uv > uv_max)
return;
// Calculate voltage multiplier
u32 mult = (voltage_uv + uv_step - 1 - uv_min) / uv_step;
mult = mult & volt_mask;
// Open I2C session to MAX77620 PMIC
I2cSession session;
Result res = i2cOpenSession(&session, I2cDevice_Max77620Pmic);
if (R_FAILED(res)) {
return;
}
// Read current register value
u8 current_val = 0;
res = i2csessionSendAuto(&session, &volt_addr, 1, I2cTransactionOption_Start);
if (R_FAILED(res)) {
i2csessionClose(&session);
return;
}
res = i2csessionReceiveAuto(&session, &current_val, 1, I2cTransactionOption_Stop);
if (R_FAILED(res)) {
i2csessionClose(&session);
return;
}
// Mask in the new voltage bits, preserving other bits
u8 new_val = (current_val & ~volt_mask) | mult;
// Write back register with START and STOP conditions
u8 write_buf[2] = {volt_addr, new_val};
res = i2csessionSendAuto(&session, write_buf, sizeof(write_buf), I2cTransactionOption_All);
i2csessionClose(&session);
}