From d16b1ab8da696cb78396525b8dcd82ac23eb0d05 Mon Sep 17 00:00:00 2001 From: souldbminersmwc Date: Tue, 2 Dec 2025 19:11:24 -0500 Subject: [PATCH] pcv_mariko: fix cpu vmin/vmax --- .../stratosphere/loader/source/oc/pcv/pcv.hpp | 2 ++ .../loader/source/oc/pcv/pcv_mariko.cpp | 34 ++++++++----------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp index 33f8d72d..a0e859fb 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp @@ -96,6 +96,8 @@ namespace ams::ldr::oc::pcv constexpr u32 GpuClkPllLimit = 1300'000'000; + constexpr u32 CpuVminOfficial = 620; + /* GPU Max Clock asm Pattern: * * MOV W11, #0x1000 MOV (wide immediate) 0x1000 0xB (11) diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp index e5f5dc0d..43afb68f 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp @@ -55,27 +55,20 @@ namespace ams::ldr::oc::pcv::mariko { } Result CpuVoltRange(u32 *ptr) { - u32 min_volt_got = *(ptr - 1); - for (const auto &mv : CpuMinVolts) { - if (min_volt_got != mv) - continue; + if(!C.marikoCpuHighVmin && !C.marikoCpuLowVmin) + R_SKIP(); + PATCH_OFFSET((ptr - 5), C.marikoCpuHighVmin); // hf vmin + PATCH_OFFSET((ptr - 1), C.marikoCpuLowVmin); // lf vmin + R_SUCCEED(); + } - if (!C.marikoCpuMaxVolt) - R_SKIP(); + Result CpuVmax(u32 *ptr) { + if (!C.marikoCpuMaxVolt) + R_SKIP(); - PATCH_OFFSET(ptr, C.marikoCpuMaxVolt); - // Patch vmin for slt - if (C.marikoCpuUV) { - if (*(ptr - 5) == 620) { - PATCH_OFFSET((ptr - 5), C.marikoCpuLowVmin); // hf vmin - } - if (*(ptr - 1) == 620) { - PATCH_OFFSET((ptr - 1), C.marikoCpuHighVmin); // lf vmin - } - } - R_SUCCEED(); - } - R_THROW(ldr::ResultInvalidCpuMinVolt()); + PATCH_OFFSET(ptr, C.marikoCpuMaxVolt); + + R_SUCCEED(); } Result CpuVoltDfll(u32 *ptr) { @@ -874,7 +867,8 @@ namespace ams::ldr::oc::pcv::mariko { PatcherEntry patches[] = { {"CPU Freq Vdd", &CpuFreqVdd, 1, nullptr, CpuClkOSLimit}, {"CPU Freq Table", CpuFreqCvbTable, 1, nullptr, CpuCvbDefaultMaxFreq}, - {"CPU Volt Limit", &CpuVoltRange, 13, nullptr, CpuVoltOfficial}, + {"CPU Volt Range", &CpuVoltRange, 1, nullptr, CpuVminOfficial}, + {"CPU Volt Limit", &CpuVmax, 13, nullptr, CpuVoltOfficial}, {"CPU Volt Dfll", &CpuVoltDfll, 1, nullptr, 0x0000FFCF}, {"GPU Freq Table", GpuFreqCvbTable, 1, nullptr, GpuCvbDefaultMaxFreq}, {"GPU Freq Asm", &GpuFreqMaxAsm, 2, &GpuMaxClockPatternFn},