From 01c78bf8b644598f8968e98d459b6c7839f40b71 Mon Sep 17 00:00:00 2001 From: Lightos1 <124387232+Lightos1@users.noreply.github.com> Date: Sun, 14 Jun 2026 14:39:32 +0200 Subject: [PATCH] add all low timings --- .../loader/source/oc/customize.cpp | 12 +++++-- .../loader/source/oc/customize.hpp | 10 ++++-- .../source/oc/mariko/calculate_timings.cpp | 31 ++++++++++-------- .../loader/source/oc/mtc_timing_value.hpp | 2 ++ .../loader/source/oc/pcv/pcv_mariko.cpp | 6 ---- Source/hoc-clk/common/include/hocclk/config.h | 25 +++++++++++++++ Source/hoc-clk/overlay/Makefile | 2 +- .../hoc-clk/overlay/src/ui/gui/misc_gui.cpp | 6 ++++ Source/hoc-clk/sysmodule/Makefile | 6 ++-- Source/hoc-clk/sysmodule/src/file/kip.cpp | 16 ++++++++-- Source/hoc-clk/sysmodule/src/file/kip.hpp | 32 +++++++++++++++++-- 11 files changed, 116 insertions(+), 32 deletions(-) diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp index 9a32305c..48c02288 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp @@ -36,7 +36,7 @@ volatile CustomizeTable C = { .hpMode = DISABLED, .commonEmcMemVolt = 1175000, /* LPDDR4(X) JEDEC Specification */ -.eristaEmcMaxClock = 1600000, /* Maximum HB-MGCH ram rating */ +.eristaEmcMaxClock = 1633000, /* Maximum HB-MGCH ram rating */ /* Available: 66MHz step rate, 100MHz step rate, 133MHz step rate and jedec. */ /* Jedec freqs are 1333MHz, 1600MHz, 1866MHz, 2133MHz, 2400MHz, 2666MHz, 2933MHz, 3200MHz. */ @@ -65,8 +65,14 @@ volatile CustomizeTable C = { /* Frequency where non low timings gets used. */ .timingEmcTbreak = DISABLED, -.low_t6_tRTW = 0, -.low_t7_tWTR = 0, +.low_t1_tRCD = 0, +.low_t2_tRP = 0, +.low_t3_tRAS = 0, +.low_t4_tRRD = 0, +.low_t5_tRFC = 0, +.low_t6_tRTW = 0, +.low_t7_tWTR = 0, +.low_t8_tREFI = 0, .readLatency = { /* 1333 */ 0, diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp index 94a79bf6..1db4f8aa 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp @@ -20,8 +20,8 @@ #pragma once -#define CUST_REV 4 -#define KIP_VERSION 241 +#define CUST_REV 5 +#define KIP_VERSION 242 #include "oc_common.hpp" #include "pcv/pcv_common.hpp" @@ -89,8 +89,14 @@ struct CustomizeTable { u32 t2_tRP_cap; u32 timingEmcTbreak; + u32 low_t1_tRCD; + u32 low_t2_tRP; + u32 low_t3_tRAS; + u32 low_t4_tRRD; + u32 low_t5_tRFC; u32 low_t6_tRTW; u32 low_t7_tWTR; + u32 low_t8_tREFI; u32 readLatency[4]; u32 writeLatency[4]; diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp index d03feafa..00bbe51b 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp @@ -134,27 +134,32 @@ namespace ams::ldr::hoc::pcv::mariko { /* At 1333WL, for some reason (incorrect ram timing config in mtc table?), tRP causes crashes at high reductions - 2 seems to be the most common limit. */ /* This is a lazy workaround until I find the issue... */ - u32 tRPpbIndex = C.t2_tRP; + const bool lowFreq = freq < C.timingEmcTbreak; + volatile u32 tRPpbIndex = lowFreq ? C.low_t2_tRP : C.t2_tRP; + if (WL == WL_1331) { - tRPpbIndex = MIN(C.t2_tRP_cap, C.t2_tRP); + tRPpbIndex = MIN(C.t2_tRP_cap, tRPpbIndex); } - tRCD = tRCD_values[C.t1_tRCD]; - tRPpb = tRP_values[tRPpbIndex]; - tRAS = tRAS_values[C.t3_tRAS]; - tRRD = tRRD_values[C.t4_tRRD]; - tRFCpb = tRFC_values[C.t5_tRFC]; - u32 tRTW = C.t6_tRTW; - u32 tWTR = 10 - tWTR_values[C.t7_tWTR]; + tRCD = tRCD_values[lowFreq ? C.low_t1_tRCD : C.t1_tRCD]; + tRPpb = tRP_values[tRPpbIndex]; + tRAS = tRAS_values[lowFreq ? C.low_t3_tRAS : C.t3_tRAS]; + tRRD = tRRD_values[lowFreq ? C.low_t4_tRRD : C.t4_tRRD]; + tRFCpb = tRFC_values[lowFreq ? C.low_t5_tRFC : C.t5_tRFC]; - if (freq < C.timingEmcTbreak) { - tRTW = C.low_t6_tRTW; - tWTR = 10 - tWTR_values[C.low_t7_tWTR]; - } + u32 tRTW = lowFreq ? C.low_t6_tRTW : C.t6_tRTW; + u32 tWTR = 10 - tWTR_values[lowFreq ? C.low_t7_tWTR : C.t7_tWTR]; s32 finetRTW = C.fineTune_t6_tRTW; s32 finetWTR = C.fineTune_t7_tWTR; + u32 tREFI = lowFreq ? C.low_t8_tREFI : C.t8_tREFI; + refresh_raw = 0xFFFF; + if (tREFI != 6) { + refresh_raw = CEIL(tREFpb_values[tREFI] / tCK_avg) - 0x40; + refresh_raw = MIN(refresh_raw, static_cast(0xFFFF)); + } + tRC = tRAS + tRPpb; tRFCab = tRFCpb * 2; tXSR = static_cast(tRFCab + 7.5); diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/mtc_timing_value.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/mtc_timing_value.hpp index 623c18a0..7b23d587 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/mtc_timing_value.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/mtc_timing_value.hpp @@ -130,6 +130,8 @@ namespace ams::ldr::hoc { inline u32 tFAW; inline double tRPab; + inline u32 refresh_raw; + inline u32 RL; inline u32 WL; 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 4c5280ec..e6ba8ffd 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_mariko.cpp @@ -375,12 +375,6 @@ namespace ams::ldr::hoc::pcv::mariko { WRITE_PARAM_ALL_REG(table, emc_cfg, 0xF3200000); } - u32 refresh_raw = 0xFFFF; - if (C.t8_tREFI != 6) { - refresh_raw = CEIL(tREFpb_values[C.t8_tREFI] / tCK_avg) - 0x40; - refresh_raw = MIN(refresh_raw, static_cast(0xFFFF)); - } - u32 trefbw = refresh_raw + 0x40; trefbw = MIN(trefbw, static_cast(0x3FFF)); diff --git a/Source/hoc-clk/common/include/hocclk/config.h b/Source/hoc-clk/common/include/hocclk/config.h index 624831b3..8c33c2e7 100644 --- a/Source/hoc-clk/common/include/hocclk/config.h +++ b/Source/hoc-clk/common/include/hocclk/config.h @@ -99,8 +99,14 @@ typedef enum { KipConfigValue_t8_tREFI, KipConfigValue_timingEmcTbreak, + KipConfigValue_low_t1_tRCD, + KipConfigValue_low_t2_tRP, + KipConfigValue_low_t3_tRAS, + KipConfigValue_low_t4_tRRD, + KipConfigValue_low_t5_tRFC, KipConfigValue_low_t6_tRTW, KipConfigValue_low_t7_tWTR, + KipConfigValue_low_t8_tREFI, KipConfigValue_t2_tRP_cap, @@ -362,10 +368,23 @@ static inline const char* hocclkFormatConfigValue(HocClkConfigValue val, bool pr case KipConfigValue_timingEmcTbreak: return pretty ? "Timing Emc Tbreak" : "timingEmcTbreak"; + + case KipConfigValue_low_t1_tRCD: + return pretty ? "Low T1 - tRCD" : "low_t1_tRCD"; + case KipConfigValue_low_t2_tRP: + return pretty ? "Low T2 - tRP" : "low_t2_tRP"; + case KipConfigValue_low_t3_tRAS: + return pretty ? "Low T3 - tRAS" : "low_t3_tRAS"; + case KipConfigValue_low_t4_tRRD: + return pretty ? "Low T4 - tRRD" : "low_t4_tRRD"; + case KipConfigValue_low_t5_tRFC: + return pretty ? "Low t5 - tRFC" : "low_t5_tRFC"; case KipConfigValue_low_t6_tRTW: return pretty ? "Low T6 - tRTW" : "low_t6_tRTW"; case KipConfigValue_low_t7_tWTR: return pretty ? "Low T7 - tWTR" : "low_t7_tWTR"; + case KipConfigValue_low_t8_tREFI: + return pretty ? "Low T8 - tREFI" : "low_t7_tREFI"; case KipConfigValue_t2_tRP_cap: return pretty ? "t2 - trp 1333WL Cap" : "t2_tRP_cap"; @@ -632,8 +651,14 @@ static inline uint64_t hocclkValidConfigValue(HocClkConfigValue val, uint64_t in case KipConfigValue_t7_tWTR: case KipConfigValue_t8_tREFI: case KipConfigValue_timingEmcTbreak: + case KipConfigValue_low_t1_tRCD: + case KipConfigValue_low_t2_tRP: + case KipConfigValue_low_t3_tRAS: + case KipConfigValue_low_t4_tRRD: + case KipConfigValue_low_t5_tRFC: case KipConfigValue_low_t6_tRTW: case KipConfigValue_low_t7_tWTR: + case KipConfigValue_low_t8_tREFI: case KipConfigValue_t2_tRP_cap: case KipConfigValue_read_latency_1333: case KipConfigValue_read_latency_1600: diff --git a/Source/hoc-clk/overlay/Makefile b/Source/hoc-clk/overlay/Makefile index 0e50add5..2fe755ba 100644 --- a/Source/hoc-clk/overlay/Makefile +++ b/Source/hoc-clk/overlay/Makefile @@ -39,7 +39,7 @@ include ${TOPDIR}/lib/libultrahand/ultrahand.mk # version control constants #--------------------------------------------------------------------------------- #TARGET_VERSION := $(shell git describe --dirty --always --tags) -APP_VERSION := 2.4.1 # ensure to set KIP_VERSION and CUST_REV in sysmodule Makefile when updating this +APP_VERSION := 2.4.2 # ensure to set KIP_VERSION and CUST_REV in sysmodule Makefile when updating this TARGET_VERSION := $(APP_VERSION) #--------------------------------------------------------------------------------- diff --git a/Source/hoc-clk/overlay/src/ui/gui/misc_gui.cpp b/Source/hoc-clk/overlay/src/ui/gui/misc_gui.cpp index 704401aa..3a7345df 100644 --- a/Source/hoc-clk/overlay/src/ui/gui/misc_gui.cpp +++ b/Source/hoc-clk/overlay/src/ui/gui/misc_gui.cpp @@ -1316,8 +1316,14 @@ class RamTimingsSubmenuGui : public MiscGui { addConfigButton(KipConfigValue_timingEmcTbreak, "RAM-Timing tBreak", ValueRange(0, 1, 1, "", 1), "tBreak", &thresholdsDisabled, {}, timingTbreakFreqs, false, true); + addConfigTrackbar(KipConfigValue_low_t1_tRCD, "Low t1 tRCD", ValueRange(0, 7, 1)); + addConfigTrackbar(KipConfigValue_low_t2_tRP, "Low t2 tRP", ValueRange(0, 7, 1)); + addConfigTrackbar(KipConfigValue_low_t3_tRAS, "Low t3 tRAS", ValueRange(0, 9, 1)); + addConfigTrackbar(KipConfigValue_low_t4_tRRD, "Low t4 tRRD", ValueRange(0, 6, 1)); + addConfigTrackbar(KipConfigValue_low_t5_tRFC, "Low t5 tRFC", ValueRange(0, 10, 1)); addConfigTrackbar(KipConfigValue_low_t6_tRTW, "Low t6 tRTW", ValueRange(0, 9, 1)); addConfigTrackbar(KipConfigValue_low_t7_tWTR, "Low t7 tWTR", ValueRange(0, 9, 1)); + addConfigTrackbar(KipConfigValue_low_t8_tREFI, "Low t8 tREFI", ValueRange(0, 6, 1)); { auto *spacer = new tsl::elm::CustomDrawer([](tsl::gfx::Renderer *, s32, s32, s32, s32) {}); spacer->setBoundaries(0, 0, tsl::cfg::FramebufferWidth, 8); diff --git a/Source/hoc-clk/sysmodule/Makefile b/Source/hoc-clk/sysmodule/Makefile index 7964f564..e71b2083 100644 --- a/Source/hoc-clk/sysmodule/Makefile +++ b/Source/hoc-clk/sysmodule/Makefile @@ -28,9 +28,9 @@ INCLUDES := ../common/include src/hos src/soc src/i2c src/util src/pwr src/ipc EXEFS_SRC := exefs_src LIBNAMES := minIni # major minor patch -TARGET_VERSION := 2.4.1 -KIP_VERSION := 241 -CUST_REV := 4 +TARGET_VERSION := 2.4.2 +KIP_VERSION := 242 +CUST_REV := 5 #--------------------------------------------------------------------------------- # options for code generation diff --git a/Source/hoc-clk/sysmodule/src/file/kip.cpp b/Source/hoc-clk/sysmodule/src/file/kip.cpp index 785bd2ab..de0f9443 100644 --- a/Source/hoc-clk/sysmodule/src/file/kip.cpp +++ b/Source/hoc-clk/sysmodule/src/file/kip.cpp @@ -87,8 +87,14 @@ namespace kip { CUST_WRITE_FIELD_BATCH(&table, stepMode, config::GetConfigValue(KipConfigValue_stepMode)); CUST_WRITE_FIELD_BATCH(&table, timingEmcTbreak, config::GetConfigValue(KipConfigValue_timingEmcTbreak)); + CUST_WRITE_FIELD_BATCH(&table, low_t1_tRCD, config::GetConfigValue(KipConfigValue_low_t1_tRCD)); + CUST_WRITE_FIELD_BATCH(&table, low_t2_tRP, config::GetConfigValue(KipConfigValue_low_t2_tRP)); + CUST_WRITE_FIELD_BATCH(&table, low_t3_tRAS, config::GetConfigValue(KipConfigValue_low_t3_tRAS)); + CUST_WRITE_FIELD_BATCH(&table, low_t4_tRRD, config::GetConfigValue(KipConfigValue_low_t4_tRRD)); + CUST_WRITE_FIELD_BATCH(&table, low_t5_tRFC, config::GetConfigValue(KipConfigValue_low_t5_tRFC)); CUST_WRITE_FIELD_BATCH(&table, low_t6_tRTW, config::GetConfigValue(KipConfigValue_low_t6_tRTW)); CUST_WRITE_FIELD_BATCH(&table, low_t7_tWTR, config::GetConfigValue(KipConfigValue_low_t7_tWTR)); + CUST_WRITE_FIELD_BATCH(&table, low_t8_tREFI, config::GetConfigValue(KipConfigValue_low_t8_tREFI)); CUST_WRITE_FIELD_BATCH(&table, t2_tRP_cap, config::GetConfigValue(KipConfigValue_t2_tRP_cap)); CUST_WRITE_FIELD_BATCH(&table, readLatency1333, config::GetConfigValue(KipConfigValue_read_latency_1333)); @@ -249,8 +255,14 @@ namespace kip { configValues.values[KipConfigValue_stepMode] = cust_get_step_mode(&table); configValues.values[KipConfigValue_timingEmcTbreak] = cust_get_timing_emc_tbreak(&table); - configValues.values[KipConfigValue_low_t6_tRTW] = cust_get_low_t6_tRTW(&table); - configValues.values[KipConfigValue_low_t7_tWTR] = cust_get_low_t7_tWTR(&table); + configValues.values[KipConfigValue_low_t1_tRCD] = cust_get_low_tRCD(&table); + configValues.values[KipConfigValue_low_t2_tRP] = cust_get_low_tRP(&table); + configValues.values[KipConfigValue_low_t3_tRAS] = cust_get_low_tRAS(&table); + configValues.values[KipConfigValue_low_t4_tRRD] = cust_get_low_tRRD(&table); + configValues.values[KipConfigValue_low_t5_tRFC] = cust_get_low_tRFC(&table); + configValues.values[KipConfigValue_low_t6_tRTW] = cust_get_low_tRTW(&table); + configValues.values[KipConfigValue_low_t7_tWTR] = cust_get_low_tWTR(&table); + configValues.values[KipConfigValue_low_t8_tREFI] = cust_get_low_tREFI(&table); configValues.values[KipConfigValue_t2_tRP_cap] = cust_get_tRP_cap(&table); configValues.values[KipConfigValue_read_latency_1333] = cust_get_read_latency_1333(&table); diff --git a/Source/hoc-clk/sysmodule/src/file/kip.hpp b/Source/hoc-clk/sysmodule/src/file/kip.hpp index b7302cb3..1816ff1e 100644 --- a/Source/hoc-clk/sysmodule/src/file/kip.hpp +++ b/Source/hoc-clk/sysmodule/src/file/kip.hpp @@ -57,8 +57,14 @@ namespace kip { u32 t2_tRP_cap; u32 timingEmcTbreak; + u32 low_t1_tRCD; + u32 low_t2_tRP; + u32 low_t3_tRAS; + u32 low_t4_tRRD; + u32 low_t5_tRFC; u32 low_t6_tRTW; u32 low_t7_tWTR; + u32 low_t8_tREFI; /* These latencies are arrays in loader, but it's easier to handle it this way in the configurator. */ u32 readLatency1333, readLatency1600, readLatency1866, readLatency2133; @@ -270,12 +276,24 @@ namespace kip { static inline bool cust_set_timing_emc_tbreak(const char *p, u32 v) { CUST_WRITE_FIELD(p, timingEmcTbreak, v); } + + static inline bool cust_set_low_tRCD(const char *p, u32 v) { CUST_WRITE_FIELD(p, low_t1_tRCD, v); } + static inline bool cust_set_low_tRP(const char *p, u32 v) { CUST_WRITE_FIELD(p, low_t2_tRP, v); } + static inline bool cust_set_low_tRAS(const char *p, u32 v) { CUST_WRITE_FIELD(p, low_t3_tRAS, v); } + static inline bool cust_set_low_tRRD(const char *p, u32 v) { CUST_WRITE_FIELD(p, low_t4_tRRD, v); } + static inline bool cust_set_low_tRFC(const char *p, u32 v) { CUST_WRITE_FIELD(p, low_t5_tRFC, v); } + static inline bool cust_set_low_tRTW(const char *p, u32 v) { CUST_WRITE_FIELD(p, low_t6_tRTW, v); } static inline bool cust_set_low_tWTR(const char *p, u32 v) { CUST_WRITE_FIELD(p, low_t7_tWTR, v); } + + static inline bool cust_set_low_tREFI(const char *p, u32 v) { + CUST_WRITE_FIELD(p, low_t8_tREFI, v); + } + static inline bool cust_set_tRTW_fine_tune(const char *p, u32 v) { CUST_WRITE_FIELD(p, t6_tRTW_fine_tune, v); } @@ -476,12 +494,22 @@ namespace kip { static inline u32 cust_get_timing_emc_tbreak(const CustomizeTable *t) { return CUST_GET_FIELD(t, timingEmcTbreak); } - static inline u32 cust_get_low_t6_tRTW(const CustomizeTable *t) { + + static inline u32 cust_get_low_tRCD(const CustomizeTable *t) { return CUST_GET_FIELD(t, low_t1_tRCD); } + static inline u32 cust_get_low_tRP(const CustomizeTable *t) { return CUST_GET_FIELD(t, low_t2_tRP); } + static inline u32 cust_get_low_tRAS(const CustomizeTable *t) { return CUST_GET_FIELD(t, low_t3_tRAS); } + static inline u32 cust_get_low_tRRD(const CustomizeTable *t) { return CUST_GET_FIELD(t, low_t4_tRRD); } + static inline u32 cust_get_low_tRFC(const CustomizeTable *t) { return CUST_GET_FIELD(t, low_t5_tRFC); } + + static inline u32 cust_get_low_tRTW(const CustomizeTable *t) { return CUST_GET_FIELD(t, low_t6_tRTW); } - static inline u32 cust_get_low_t7_tWTR(const CustomizeTable *t) { + static inline u32 cust_get_low_tWTR(const CustomizeTable *t) { return CUST_GET_FIELD(t, low_t7_tWTR); } + static inline u32 cust_get_low_tREFI(const CustomizeTable *t) { + return CUST_GET_FIELD(t, low_t8_tREFI); + } static inline u32 cust_get_tRTW_fine_tune(const CustomizeTable *t) { return CUST_GET_FIELD(t, t6_tRTW_fine_tune); }