diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp b/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp index 2ba074e2..24f39eac 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/customize.cpp @@ -42,7 +42,7 @@ volatile CustomizeTable C = { /* Available: 66MHz step rate, 100MHz step rate and jedec. */ /* Jedec freqs are 1333MHz, 1600MHz, 1866MHz, 2133MHz, 2400MHz, 2666MHz, 2933MHz, 3200MHz. */ -.stepMode = StepMode_Jedec, +.stepMode = StepMode_66MHz, .marikoEmcMaxClock = 2933000, /* 1866MHz @ 1866tWRL is guaranteed to work on all Mariko units */ .marikoEmcVddqVolt = 600000, @@ -50,7 +50,7 @@ volatile CustomizeTable C = { // Primary .t1_tRCD = 0, -.t2_tRP = 0, +.t2_tRP = 4, .t3_tRAS = 0, // Secondary .t4_tRRD = 0, @@ -59,6 +59,8 @@ volatile CustomizeTable C = { .t7_tWTR = 0, .t8_tREFI = 0, +.t2_tRP_cap = 2, + .readLatency = { 2133000, 2400000, diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp index 93169bca..19d6673d 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/customize.hpp @@ -103,6 +103,8 @@ typedef struct CustomizeTable { u32 t7_tWTR; u32 t8_tREFI; + u32 t2_tRP_cap; + 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 7d58178c..2c6ee633 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/mariko/calculate_timings.cpp @@ -127,13 +127,39 @@ namespace ams::ldr::hoc::pcv::mariko { } void CalculateTimings(double tCK_avg, u32 freq) { - RL = 28; - WL = 12; + RL = RL_1331; + WL = WL_1331; HandleLatency(freq); GetRext(); + /* 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; + if (WL == WL_1331) { + tRPpbIndex = MIN(C.t2_tRP_cap, C.t2_tRP); + } + + 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 tWTR = 10 - tWTR_values[C.t7_tWTR]; + s32 finetRTW = C.fineTune_t6_tRTW; + s32 finetWTR = C.fineTune_t7_tWTR; + + Log("Freq: %u\n", freq); + Log("WL: %u\n", WL); + Log("tRP value: %u\n\n", tRPpb); + + tRC = tRAS + tRPpb; + tRFCab = tRFCpb * 2; + tXSR = static_cast(tRFCab + 7.5); + tFAW = static_cast(tRRD * 4.0); + tRPab = tRPpb + 3; + tR2P = CEIL((RL * 0.426) - 2.0); tR2W = FLOOR(FLOOR((5.0 / tCK_avg) + ((FLOOR(48.0 / WL) - 0.478) * 3.0)) / 1.501) + RL - (C.t6_tRTW * 3) + finetRTW; tRTM = FLOOR((10.0 + RL) + (3.502 / tCK_avg)) + FLOOR(7.489 / tCK_avg); 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 609901d3..1b592f0e 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/mtc_timing_value.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/mtc_timing_value.hpp @@ -111,20 +111,17 @@ namespace ams::ldr::hoc { const std::array tWTR_values = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }; const std::array tREFpb_values = { 3900, 5850, 7800, 11700, 15600, 99999 }; - const u32 tRCD = tRCD_values[C.t1_tRCD]; - const u32 tRPpb = tRP_values[C.t2_tRP]; - const u32 tRAS = tRAS_values[C.t3_tRAS]; - const double tRRD = tRRD_values[C.t4_tRRD]; - const u32 tRFCpb = tRFC_values[C.t5_tRFC]; - const u32 tWTR = 10 - tWTR_values[C.t7_tWTR]; - const s32 finetRTW = C.fineTune_t6_tRTW; - const s32 finetWTR = C.fineTune_t7_tWTR; + inline u32 tRCD; + inline u32 tRPpb; + inline u32 tRAS; + inline double tRRD; + inline u32 tRFCpb; - const u32 tRC = tRAS + tRPpb; - const u32 tRFCab = tRFCpb * 2; - const double tXSR = static_cast(tRFCab + 7.5); - const u32 tFAW = static_cast(tRRD * 4.0); - const double tRPab = tRPpb + 3; + inline u32 tRC; + inline u32 tRFCab; + inline double tXSR; + inline u32 tFAW; + inline double tRPab; inline u32 RL; inline u32 WL; diff --git a/Source/hoc-clk/common/include/hocclk/config.h b/Source/hoc-clk/common/include/hocclk/config.h index a188a9ed..0ccbf01d 100644 --- a/Source/hoc-clk/common/include/hocclk/config.h +++ b/Source/hoc-clk/common/include/hocclk/config.h @@ -94,6 +94,8 @@ typedef enum { KipConfigValue_t7_tWTR, KipConfigValue_t8_tREFI, + KipConfigValue_t2_tRP_cap, + KipConfigValue_read_latency_1333, KipConfigValue_read_latency_1600, KipConfigValue_read_latency_1866, @@ -323,6 +325,9 @@ static inline const char* hocclkFormatConfigValue(HocClkConfigValue val, bool pr case KipConfigValue_t8_tREFI: return pretty ? "t8 - tREFI" : "t8_trefi"; + case KipConfigValue_t2_tRP_cap: + return pretty ? "t2 - trp 1333WL Cap" : "t2_tRP_cap"; + case KipConfigValue_read_latency_1333: return pretty ? "1333 Read Latency" : "read_latency_1333"; case KipConfigValue_read_latency_1600: @@ -558,6 +563,7 @@ static inline uint64_t hocclkValidConfigValue(HocClkConfigValue val, uint64_t in case KipConfigValue_t6_tRTW: case KipConfigValue_t7_tWTR: case KipConfigValue_t8_tREFI: + case KipConfigValue_t2_tRP_cap: case KipConfigValue_read_latency_1333: case KipConfigValue_read_latency_1600: case KipConfigValue_read_latency_1866: 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 edec5b7b..2d7cd270 100644 --- a/Source/hoc-clk/overlay/src/ui/gui/misc_gui.cpp +++ b/Source/hoc-clk/overlay/src/ui/gui/misc_gui.cpp @@ -1032,6 +1032,7 @@ protected: }; this->listElement->addItem(new tsl::elm::CategoryHeader("Advanced")); + addConfigButton(KipConfigValue_t2_tRP_cap, "1333WL t2 RP Cap", ValueRange(0, 8, 1, "", 1), "tRP Cap", &thresholdsDisabled, {}, {}, false, true ); addConfigButton(KipConfigValue_t6_tRTW_fine_tune, "t6 tRTW Fine Tune", ValueRange(0, 4, 1, "", 0), "tRTW Fine Tune", &thresholdsDisabled, {}, t6_tRTW_fine_tune, false, true); addConfigButton(KipConfigValue_t7_tWTR_fine_tune, "t7 tWTR Fine Tune", ValueRange(0, 6, 1, "", 0), "tWTR Fine Tune", &thresholdsDisabled, {}, t7_tWTR_fine_tune, false, true); } diff --git a/Source/hoc-clk/sysmodule/src/kip.cpp b/Source/hoc-clk/sysmodule/src/kip.cpp index c11c06c6..6f670241 100644 --- a/Source/hoc-clk/sysmodule/src/kip.cpp +++ b/Source/hoc-clk/sysmodule/src/kip.cpp @@ -71,6 +71,7 @@ namespace kip { CUST_WRITE_FIELD_BATCH(&table, t7_tWTR, config::GetConfigValue(KipConfigValue_t7_tWTR)); CUST_WRITE_FIELD_BATCH(&table, t8_tREFI, config::GetConfigValue(KipConfigValue_t8_tREFI)); CUST_WRITE_FIELD_BATCH(&table, stepMode, config::GetConfigValue(KipConfigValue_stepMode)); + 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)); CUST_WRITE_FIELD_BATCH(&table, readLatency1600, config::GetConfigValue(KipConfigValue_read_latency_1600)); @@ -201,6 +202,8 @@ namespace kip { configValues.values[KipConfigValue_t8_tREFI] = cust_get_tREFI(&table); configValues.values[KipConfigValue_stepMode] = cust_get_step_mode(&table); + configValues.values[KipConfigValue_t2_tRP_cap] = cust_get_tRP_cap(&table); + configValues.values[KipConfigValue_read_latency_1333] = cust_get_read_latency_1333(&table); configValues.values[KipConfigValue_read_latency_1600] = cust_get_read_latency_1600(&table); configValues.values[KipConfigValue_read_latency_1866] = cust_get_read_latency_1866(&table); diff --git a/Source/hoc-clk/sysmodule/src/kip.hpp b/Source/hoc-clk/sysmodule/src/kip.hpp index 8cb27f17..460775a1 100644 --- a/Source/hoc-clk/sysmodule/src/kip.hpp +++ b/Source/hoc-clk/sysmodule/src/kip.hpp @@ -54,6 +54,8 @@ namespace kip { u32 t7_tWTR; u32 t8_tREFI; + u32 t2_tRP_cap; + /* These latencies are arrays in loader, but it's easier to handle it this way in the configurator. */ u32 readLatency1333, readLatency1600, readLatency1866, readLatency2133; u32 writeLatency1333, writeLatency1600, writeLatency1866, writeLatency2133; @@ -219,6 +221,7 @@ namespace kip { static inline bool cust_set_tRTW(const char* p, u32 v) { CUST_WRITE_FIELD(p, t6_tRTW, v); } static inline bool cust_set_tWTR(const char* p, u32 v) { CUST_WRITE_FIELD(p, t7_tWTR, v); } static inline bool cust_set_tREFI(const char* p, u32 v) { CUST_WRITE_FIELD(p, t8_tREFI, v); } + static inline bool cust_set_tRP_cap(const char* p, u32 v) { CUST_WRITE_FIELD(p, t2_tRP_cap, v); } static inline bool cust_set_tRTW_fine_tune(const char* p, u32 v) { CUST_WRITE_FIELD(p, t6_tRTW_fine_tune, v); } static inline bool cust_set_tWTR_fine_tune(const char* p, u32 v) { CUST_WRITE_FIELD(p, t7_tWTR_fine_tune, v); } @@ -302,6 +305,7 @@ namespace kip { static inline u32 cust_get_tRTW(const CustomizeTable* t) { return CUST_GET_FIELD(t, t6_tRTW); } static inline u32 cust_get_tWTR(const CustomizeTable* t) { return CUST_GET_FIELD(t, t7_tWTR); } static inline u32 cust_get_tREFI(const CustomizeTable* t) { return CUST_GET_FIELD(t, t8_tREFI); } + static inline u32 cust_get_tRP_cap(const CustomizeTable* t) { return CUST_GET_FIELD(t, t2_tRP_cap); } static inline u32 cust_get_tRTW_fine_tune(const CustomizeTable* t) { return CUST_GET_FIELD(t, t6_tRTW_fine_tune); } static inline u32 cust_get_tWTR_fine_tune(const CustomizeTable* t) { return CUST_GET_FIELD(t, t7_tWTR_fine_tune); }