From fe6e56c4fb4d5f1bb37dcc9a2ab24f1a1ba9792e Mon Sep 17 00:00:00 2001 From: Lightos1 <124387232+Lightos1@users.noreply.github.com> Date: Fri, 5 Dec 2025 19:55:25 +0100 Subject: [PATCH] Add proper low/high vMin --- .../loader/source/oc/customize.cpp | 40 +++++++++--------- .../stratosphere/loader/source/oc/pcv/pcv.hpp | 6 +-- .../loader/source/oc/pcv/pcv_mariko.cpp | 42 +++++++++---------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp index 98f25b1c..279e5223 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp @@ -45,11 +45,11 @@ volatile CustomizeTable C = { .marikoCpuMaxVolt = 1185, -.marikoEmcMaxClock = 2933000, // Hynix NME and Samsung AM-MGCJ Rating (others are 4766MT, 2133MHz) +.marikoEmcMaxClock = 2133000, // Hynix NME and Samsung AM-MGCJ Rating (others are 4766MT, 2133MHz) .marikoEmcVddqVolt = 640000, -.marikoCpuUV = 8, // No undervolt +.marikoCpuUV = 0, // No undervolt .marikoGpuUV = 3, @@ -79,7 +79,7 @@ volatile CustomizeTable C = { .marikoCpuHighVmin = 750, -.marikoCpuLowVmin = 600, +.marikoCpuLowVmin = 680, .eristaGpuVmin = 810, @@ -98,24 +98,24 @@ volatile CustomizeTable C = { // Ensure the voltages actually increase or stay the sameot .marikoGpuVoltArray = { - 800 /* 76 */, - 800 /* 153 */, - 800 /* 230 */, - 800 /* 307 */, - 800 /* 384 */, - 800 /* 460 */, - 800 /* 537 */, - 800 /* 614 */, - 800 /* 691 */, - 800 /* 768 */, - 800 /* 844 */, - 800 /* 921 */, - 800 /* 998 */, - 800 /* 1075 */, - 800 /* 1152 */, - 800 /* 1228 */, + 785 /* 76 */, + 785 /* 153 */, + 785 /* 230 */, + 785 /* 307 */, + 785 /* 384 */, + 785 /* 460 */, + 785 /* 537 */, + 785 /* 614 */, + 785 /* 691 */, + 785 /* 768 */, + 785 /* 844 */, + 785 /* 921 */, + 785 /* 998 */, + 785 /* 1075 */, + 785 /* 1152 */, + 785 /* 1228 */, 800 /* 1267 (Disabled by default) */, - 815 /* 1305 (Disabled by default) */, + 810 /* 1305 (Disabled by default) */, 960 /* 1344 (Disabled by default) */, 960 /* 1382 (Disabled by default) */, 960 /* 1420 (Disabled by default) */, diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp index 03b72611..4b1154b8 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv.hpp @@ -51,12 +51,12 @@ namespace ams::ldr::oc::pcv }; constexpr int gpuVmax = 750; - constexpr int gpuVmin = 610; - constexpr u16 CpuMinVolts[] = {800, 637, 620, 610}; + constexpr u32 CpuVminPatchValues[] = { 850, 38, 1120, 1000, 100, 1000, 0 }; + constexpr s32 CpuVminPatchOffsets[] = { -2, -1, 5, 6, 7, 8, 9 }; - constexpr u32 CpuClkOfficial = 1963'500; + constexpr u32 CpuClkOfficial = 1963'500; constexpr u32 CpuVoltOfficial = 1120; 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 b6586254..42db2cf1 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,25 @@ 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.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 - } + for (size_t i = 0; i < std::size(CpuVminPatchOffsets); ++i) { + if (*(ptr + CpuVminPatchOffsets[i]) != CpuVminPatchValues[i]) { + R_THROW(ldr::ResultInvalidCpuMinVolt()); } - R_SUCCEED(); } - R_THROW(ldr::ResultInvalidCpuMinVolt()); + + if (C.marikoCpuLowVmin) { + PATCH_OFFSET(ptr, C.marikoCpuLowVmin); + } + + if (C.marikoCpuHighVmin) { + PATCH_OFFSET((ptr - 2), C.marikoCpuHighVmin); + } + + if (C.marikoCpuMaxVolt) { + PATCH_OFFSET((ptr + 5), C.marikoCpuMaxVolt); + } + + R_SUCCEED(); } Result CpuVoltDfll(u32 *ptr) { @@ -494,7 +492,7 @@ namespace ams::ldr::oc::pcv::mariko { // WRITE_PARAM_ALL_REG(table, emc_rfcpb, GET_CYCLE(tRFCpb)); // WRITE_PARAM_ALL_REG(table, emc_r2w, tR2W); // WRITE_PARAM_ALL_REG(table, emc_w2r, tW2R); - WRITE_PARAM_ALL_REG(table, emc_r2p, (u32) 0xC); + // WRITE_PARAM_ALL_REG(table, emc_r2p, (u32) 0xC); // WRITE_PARAM_ALL_REG(table, emc_w2p, (u32) 0x2D); // // WRITE_PARAM_ALL_REG(table, emc_rext, rext); @@ -636,6 +634,8 @@ namespace ams::ldr::oc::pcv::mariko { // table->dram_timings.t_rp = tRFCpb; // table->dram_timings.t_rfc = tRFCab; // table->emc_cfg_2 = 0x11083d; + + (void) table; } void MemMtcPllmbDivisor(MarikoMtcTable *table) { @@ -846,7 +846,7 @@ namespace ams::ldr::oc::pcv::mariko { PatcherEntry patches[] = { {"CPU Freq Vdd", &CpuFreqVdd, 1, nullptr, CpuClkOSLimit}, {"CPU Freq Table", CpuFreqCvbTable, 1, nullptr, CpuCvbDefaultMaxFreq}, - {"CPU Volt Range", &CpuVoltRange, 13, nullptr, CpuVminOfficial}, + {"CPU Volt Range", &CpuVoltRange, 1, nullptr, CpuVminOfficial}, {"CPU Volt Dfll", &CpuVoltDfll, 1, nullptr, 0x0000FFCF}, {"GPU Freq Table", GpuFreqCvbTable, 1, nullptr, GpuCvbDefaultMaxFreq}, {"GPU Freq Asm", &GpuFreqMaxAsm, 2, &GpuMaxClockPatternFn},