Merge upstream Horizon-OC main (749fd385)
Some checks failed
Build Horizon OC Zeus / build (push) Failing after 6s
Some checks failed
Build Horizon OC Zeus / build (push) Failing after 6s
Includes 2.3.1 changes: kip migration, erista GPU workaround, safety fixes, and Mariko GPU boot voltage patch. Resolve dist binary conflicts with upstream build artifacts.
This commit is contained in:
@@ -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.3.1
|
||||
KIP_VERSION := 231
|
||||
CUST_REV := 3
|
||||
TARGET_VERSION := 2.4.0
|
||||
KIP_VERSION := 240
|
||||
CUST_REV := 4
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "../tsensor/aotag.hpp"
|
||||
#include "../hos/integrations.hpp"
|
||||
#include "../file/file_utils.hpp"
|
||||
#include "../hos/rgltr.h"
|
||||
namespace board {
|
||||
|
||||
u64 clkVirtAddr, dsiVirtAddr, apbVirtAddr, fuseVirtAddr;
|
||||
@@ -137,6 +138,9 @@ namespace board {
|
||||
rc = pmdmntInitialize();
|
||||
ASSERT_RESULT_OK(rc, "pmdmntInitialize");
|
||||
|
||||
rc = rgltrInitialize();
|
||||
ASSERT_RESULT_OK(rc, "rgltrInitialize");
|
||||
|
||||
rc = QueryMemoryMapping(&clkVirtAddr, 0x60006000, 0x1000);
|
||||
ASSERT_RESULT_OK(rc, "QueryMemoryMapping (clk)");
|
||||
|
||||
@@ -201,7 +205,7 @@ namespace board {
|
||||
|
||||
apmExtExit();
|
||||
psmExit();
|
||||
|
||||
rgltrExit();
|
||||
if (HOSSVC_HAS_TC) {
|
||||
tcExit();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "../soc/pllmb.hpp"
|
||||
#include "../file/config.hpp"
|
||||
#include "../soc/gm20b.hpp"
|
||||
#include "../file/config.hpp"
|
||||
namespace board {
|
||||
#define MIDDLE_FREQ_TABLE_START_POINT 1228800000
|
||||
static u32 currentInjectedHz = 0;
|
||||
@@ -75,6 +76,14 @@ namespace board {
|
||||
ASSERT_RESULT_OK(pcvSetClockRate(moduleID, hz), "pcvSetClockRate");
|
||||
}
|
||||
|
||||
void HandleCpuUv()
|
||||
{
|
||||
if (board::GetSocType() == HocClkSocType_Erista)
|
||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000); // Erista tbreak is always 1581MHz
|
||||
else
|
||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
||||
}
|
||||
|
||||
void SetHz(HocClkModule module, u32 hz) {
|
||||
Result rc = 0;
|
||||
bool usesGovenor = module > HocClkModule_MEM;
|
||||
@@ -116,7 +125,9 @@ namespace board {
|
||||
PcvSetHz(GetPcvModule(module), pcvHz);
|
||||
}
|
||||
}
|
||||
|
||||
if(config::GetConfigValue(HocClkConfigValue_LiveCpuUv) && module == HocClkModule_CPU) {
|
||||
HandleCpuUv();
|
||||
}
|
||||
if (useGm20b) {
|
||||
gm20b::setClock(hz / 1000);
|
||||
currentInjectedHz = hz;
|
||||
|
||||
@@ -44,7 +44,8 @@ namespace board {
|
||||
u32 GetRealHz(HocClkModule module);
|
||||
void GetFreqList(HocClkModule module, u32 *outList, u32 maxCount, u32 *outCount);
|
||||
u32 GetHighestDockedDisplayRate();
|
||||
|
||||
void HandleCpuUv();
|
||||
|
||||
void ResetToStock();
|
||||
void ResetToStockDisplay();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "board_volt.hpp"
|
||||
#include "../file/file_utils.hpp"
|
||||
#include "../i2c/i2cDrv.h"
|
||||
#include "../hos/rgltr.h"
|
||||
namespace board {
|
||||
|
||||
GpuVoltData voltData = {};
|
||||
@@ -49,7 +50,8 @@ namespace board {
|
||||
u32 tune1_high;
|
||||
};
|
||||
|
||||
EristaCpuUvEntry eristaCpuUvTable[5] = {
|
||||
EristaCpuUvEntry eristaCpuUvTable[6] = {
|
||||
{0xFFEAD0FF, 0x0},
|
||||
{0xffff, 0x27007ff},
|
||||
{0xefff, 0x27407ff},
|
||||
{0xdfff, 0x27807ff},
|
||||
@@ -134,19 +136,16 @@ namespace board {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (GetHz(HocClkModule_CPU) < tbreakPoint || (!levelLow)) { // account for tbreak
|
||||
*tune0_ptr = cachedTune.tune0Low; // I think each erista has a different tune0/tune1?
|
||||
*tune1_ptr = cachedTune.tune1Low;
|
||||
return;
|
||||
} else {
|
||||
if (levelLow) {
|
||||
*tune0_ptr = eristaCpuUvTable[levelLow-1].tune0;
|
||||
*tune1_ptr = eristaCpuUvTable[levelLow-1].tune1;
|
||||
} else {
|
||||
*tune0_ptr = 0x0;
|
||||
*tune1_ptr = 0x0;
|
||||
}
|
||||
}
|
||||
// if (GetHz(HocClkModule_CPU) < tbreakPoint || (!levelLow)) { // account for tbreak
|
||||
// *tune0_ptr = cachedTune.tune0Low; // I think each erista has a different tune0/tune1?
|
||||
// *tune1_ptr = cachedTune.tune1Low;
|
||||
// return;
|
||||
// } else {
|
||||
// if (levelLow) {
|
||||
*tune0_ptr = eristaCpuUvTable[levelLow].tune0;
|
||||
*tune1_ptr = eristaCpuUvTable[levelLow].tune1;
|
||||
// } else {
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,10 +212,13 @@ namespace board {
|
||||
PcvPowerDomainId_Max77812_Dram = 0x3A000005, // vddq
|
||||
} PowerDomainId;
|
||||
*/
|
||||
/*
|
||||
Note: I think Nintendo's I2C driver (or my driver, but it looks correct to me)
|
||||
*/
|
||||
u32 GetVoltage(HocClkVoltage voltage) {
|
||||
u32 out = 0;
|
||||
BatteryChargeInfo info;
|
||||
|
||||
RgltrSession s;
|
||||
switch (voltage) {
|
||||
case HocClkVoltage_SOC:
|
||||
out = I2c_BuckConverter_GetUvOut(&I2c_SOC);
|
||||
@@ -228,14 +230,18 @@ namespace board {
|
||||
if(GetSocType() == HocClkSocType_Mariko) {
|
||||
out = I2c_BuckConverter_GetUvOut(&I2c_Mariko_CPU);
|
||||
} else {
|
||||
out = I2c_BuckConverter_GetUvOut(&I2c_Erista_CPU);
|
||||
rgltrOpenSession(&s, PcvPowerDomainId_Max77621_Cpu);
|
||||
rgltrGetVoltage(&s, &out);
|
||||
rgltrCloseSession(&s);
|
||||
}
|
||||
break;
|
||||
case HocClkVoltage_GPU:
|
||||
if(GetSocType() == HocClkSocType_Mariko) {
|
||||
out = I2c_BuckConverter_GetUvOut(&I2c_Mariko_GPU);
|
||||
} else {
|
||||
out = I2c_BuckConverter_GetUvOut(&I2c_Erista_GPU);
|
||||
rgltrOpenSession(&s, PcvPowerDomainId_Max77621_Gpu);
|
||||
rgltrGetVoltage(&s, &out);
|
||||
rgltrCloseSession(&s);
|
||||
}
|
||||
break;
|
||||
case HocClkVoltage_EMCVDDQ:
|
||||
@@ -453,5 +459,4 @@ namespace board {
|
||||
|
||||
return baseVolt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,6 @@
|
||||
namespace kip {
|
||||
|
||||
bool kipAvailable = false;
|
||||
|
||||
void SetKipData()
|
||||
{
|
||||
// TODO: figure out if this REALLY causes issues (i doubt it)
|
||||
@@ -76,7 +75,7 @@ namespace kip {
|
||||
CUST_WRITE_FIELD_BATCH(&table, eristaEmcMaxClock2, config::GetConfigValue(KipConfigValue_eristaEmcMaxClock2));
|
||||
CUST_WRITE_FIELD_BATCH(&table, marikoEmcMaxClock, config::GetConfigValue(KipConfigValue_marikoEmcMaxClock));
|
||||
CUST_WRITE_FIELD_BATCH(&table, marikoEmcVddqVolt, config::GetConfigValue(KipConfigValue_marikoEmcVddqVolt));
|
||||
CUST_WRITE_FIELD_BATCH(&table, emcDvbShift, config::GetConfigValue(KipConfigValue_emcDvbShift) > 8 && config::GetConfigValue(KipConfigValue_emcDvbShift) <= 16 ? 8 : config::GetConfigValue(KipConfigValue_emcDvbShift)); // 2.2.0 -> 2.3.0 compat
|
||||
CUST_WRITE_FIELD_BATCH(&table, emcDvbShift, config::GetConfigValue(KipConfigValue_emcDvbShift));
|
||||
CUST_WRITE_FIELD_BATCH(&table, marikoSocVmax, config::GetConfigValue(KipConfigValue_marikoSocVmax));
|
||||
|
||||
CUST_WRITE_FIELD_BATCH(&table, t1_tRCD, config::GetConfigValue(KipConfigValue_t1_tRCD));
|
||||
@@ -127,6 +126,7 @@ namespace kip {
|
||||
|
||||
CUST_WRITE_FIELD_BATCH(&table, marikoGpuUV, config::GetConfigValue(KipConfigValue_marikoGpuUV));
|
||||
CUST_WRITE_FIELD_BATCH(&table, marikoGpuVmin, config::GetConfigValue(KipConfigValue_marikoGpuVmin));
|
||||
CUST_WRITE_FIELD_BATCH(&table, marikoGpuBootVolt, config::GetConfigValue(KipConfigValue_marikoGpuBootVolt));
|
||||
CUST_WRITE_FIELD_BATCH(&table, marikoGpuVmax, config::GetConfigValue(KipConfigValue_marikoGpuVmax));
|
||||
|
||||
CUST_WRITE_FIELD_BATCH(&table, commonGpuVoltOffset, config::GetConfigValue(KipConfigValue_commonGpuVoltOffset));
|
||||
@@ -196,6 +196,7 @@ namespace kip {
|
||||
// }
|
||||
|
||||
if ((u64)crc32::checksum_file("sdmc:/atmosphere/kips/hoc.kip") != config::GetConfigValue(KipCrc32) && !config::GetConfigValue(HocClkConfigValue_IsFirstLoad)) {
|
||||
MigrateKipData(cust_get_cust_rev(&table), cust_get_kip_version(&table));
|
||||
SetKipData();
|
||||
notification::writeNotification("Horizon OC\nKIP wurde aktualisiert\nBitte Konsole neu starten");
|
||||
return;
|
||||
@@ -225,6 +226,7 @@ namespace kip {
|
||||
|
||||
clockManager::gContext.kipVersion = kipVersion;
|
||||
configValues.values[KipConfigValue_custRev] = cust_get_cust_rev(&table);
|
||||
configValues.values[KipConfigValue_KipVersion] = cust_get_kip_version(&table); // Run this after the check so we can do migration process
|
||||
configValues.values[KipConfigValue_hpMode] = cust_get_hp_mode(&table);
|
||||
|
||||
configValues.values[KipConfigValue_commonEmcMemVolt] = cust_get_common_emc_volt(&table);
|
||||
@@ -233,7 +235,7 @@ namespace kip {
|
||||
configValues.values[KipConfigValue_eristaEmcMaxClock2] = cust_get_erista_emc_max2(&table);
|
||||
configValues.values[KipConfigValue_marikoEmcMaxClock] = cust_get_mariko_emc_max(&table);
|
||||
configValues.values[KipConfigValue_marikoEmcVddqVolt] = cust_get_mariko_emc_vddq(&table);
|
||||
configValues.values[KipConfigValue_emcDvbShift] = cust_get_emc_dvb_shift(&table) > 8 && cust_get_emc_dvb_shift(&table) <= 16 ? 8 : cust_get_emc_dvb_shift(&table); // 2.2.0 -> 2.3.0 compat
|
||||
configValues.values[KipConfigValue_emcDvbShift] = cust_get_emc_dvb_shift(&table);
|
||||
configValues.values[KipConfigValue_marikoSocVmax] = cust_get_marikoSocVmax(&table);
|
||||
|
||||
configValues.values[KipConfigValue_t1_tRCD] = cust_get_tRCD(&table);
|
||||
@@ -283,6 +285,7 @@ namespace kip {
|
||||
configValues.values[KipConfigValue_eristaGpuVmin] = cust_get_erista_gpu_vmin(&table);
|
||||
configValues.values[KipConfigValue_marikoGpuUV] = cust_get_mariko_gpu_uv(&table);
|
||||
configValues.values[KipConfigValue_marikoGpuVmin] = cust_get_mariko_gpu_vmin(&table);
|
||||
configValues.values[KipConfigValue_marikoGpuBootVolt] = cust_get_mariko_gpu_boot_volt(&table);
|
||||
configValues.values[KipConfigValue_marikoGpuVmax] = cust_get_mariko_gpu_vmax(&table);
|
||||
configValues.values[KipConfigValue_commonGpuVoltOffset] = cust_get_common_gpu_offset(&table);
|
||||
configValues.values[KipConfigValue_gpuSpeedo] = board::GetFuseData()->gpuSpeedo; // cust_get_gpu_speedo(&table);
|
||||
@@ -313,5 +316,17 @@ namespace kip {
|
||||
notification::writeNotification("Horizon OC\nKonfigurationspuffer stimmt nicht überein");
|
||||
}
|
||||
}
|
||||
|
||||
void MigrateKipData(u32 custRev, u32 version) {
|
||||
HocClkConfigValueList configValues;
|
||||
config::GetConfigValues(&configValues);
|
||||
u32 previousVersion = configValues.values[KipConfigValue_KipVersion];
|
||||
if(previousVersion < 240 && version >= 240) {
|
||||
// <2.4.0 -> 2.4.0 migration: add marikoGpuBootVolt with default value of 800mV
|
||||
configValues.values[KipConfigValue_marikoGpuBootVolt] = 800;
|
||||
}
|
||||
config::SetConfigValues(&configValues, true);
|
||||
// This function cannot do anything at the moment. The capabilities will be expanded in the next release
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#include <notification.h>
|
||||
#include <crc32.h>
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
namespace kip {
|
||||
extern bool kipAvailable;
|
||||
|
||||
@@ -90,6 +88,7 @@ namespace kip {
|
||||
|
||||
u32 marikoGpuUV;
|
||||
u32 marikoGpuVmin;
|
||||
u32 marikoGpuBootVolt;
|
||||
u32 marikoGpuVmax;
|
||||
|
||||
u32 commonGpuVoltOffset;
|
||||
@@ -105,8 +104,6 @@ namespace kip {
|
||||
u32 reserved[60];
|
||||
} CustomizeTable;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#define CUST_MAGIC "CUST"
|
||||
#define CUST_MAGIC_LEN 4
|
||||
|
||||
@@ -264,6 +261,7 @@ namespace kip {
|
||||
static inline bool cust_set_erista_gpu_vmin(const char* p, u32 v) { CUST_WRITE_FIELD(p, eristaGpuVmin, v); }
|
||||
static inline bool cust_set_mariko_gpu_uv(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoGpuUV, v); }
|
||||
static inline bool cust_set_mariko_gpu_vmin(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoGpuVmin, v); }
|
||||
static inline bool cust_set_mariko_gpu_boot_volt(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoGpuBootVolt, v); }
|
||||
static inline bool cust_set_mariko_gpu_vmax(const char* p, u32 v) { CUST_WRITE_FIELD(p, marikoGpuVmax, v); }
|
||||
static inline bool cust_set_common_gpu_offset(const char* p, u32 v) { CUST_WRITE_FIELD(p, commonGpuVoltOffset, v); }
|
||||
static inline bool cust_set_gpu_speedo(const char* p, u32 v) { CUST_WRITE_FIELD(p, gpuSpeedo, v); }
|
||||
@@ -354,6 +352,7 @@ namespace kip {
|
||||
static inline u32 cust_get_erista_gpu_vmin(const CustomizeTable* t) { return CUST_GET_FIELD(t, eristaGpuVmin); }
|
||||
static inline u32 cust_get_mariko_gpu_uv(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoGpuUV); }
|
||||
static inline u32 cust_get_mariko_gpu_vmin(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoGpuVmin); }
|
||||
static inline u32 cust_get_mariko_gpu_boot_volt(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoGpuBootVolt); }
|
||||
static inline u32 cust_get_mariko_gpu_vmax(const CustomizeTable* t) { return CUST_GET_FIELD(t, marikoGpuVmax); }
|
||||
static inline u32 cust_get_common_gpu_offset(const CustomizeTable* t) { return CUST_GET_FIELD(t, commonGpuVoltOffset); }
|
||||
static inline u32 cust_get_gpu_speedo(const CustomizeTable* t) { return CUST_GET_FIELD(t, gpuSpeedo); }
|
||||
@@ -500,7 +499,7 @@ namespace kip {
|
||||
DECL_MARIKO_GPU_VOLT_GET(1459200, 21)
|
||||
DECL_MARIKO_GPU_VOLT_GET(1497600, 22)
|
||||
DECL_MARIKO_GPU_VOLT_GET(1536000, 23)
|
||||
|
||||
void MigrateKipData(u32 custRev, u32 version);
|
||||
void SetKipData();
|
||||
void GetKipData();
|
||||
}
|
||||
38
Source/hoc-clk/sysmodule/src/hos/rgltr.h
Normal file
38
Source/hoc-clk/sysmodule/src/hos/rgltr.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) ppkantorski (bord2death)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include "pcv_types.h"
|
||||
|
||||
typedef struct {
|
||||
Service s;
|
||||
} RgltrSession;
|
||||
|
||||
Result rgltrInitialize(void);
|
||||
|
||||
void rgltrExit(void);
|
||||
|
||||
Service* rgltrGetServiceSession(void);
|
||||
|
||||
Result rgltrOpenSession(RgltrSession* session_out, PowerDomainId module_id);
|
||||
void rgltrCloseSession(RgltrSession* session);
|
||||
Result rgltrGetVoltage(RgltrSession* session, u32 *out_volt);
|
||||
Result rgltrGetPowerModuleNumLimit(u32 *out);
|
||||
Result rgltrGetVoltageEnabled(RgltrSession* session, u32 *out);
|
||||
Result rgltrRequestVoltage(RgltrSession* session, u32 microvolt);
|
||||
Result rgltrCancelVoltageRequest(RgltrSession* session);
|
||||
66
Source/hoc-clk/sysmodule/src/hos/rgltr_services.cpp
Normal file
66
Source/hoc-clk/sysmodule/src/hos/rgltr_services.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) ppkantorski (bord2death)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include "rgltr.h"
|
||||
#include "rgltr_services.h" // for extern Service g_rgltrSrv, etc.
|
||||
|
||||
// Global service handle
|
||||
Service g_rgltrSrv;
|
||||
|
||||
Result rgltrInitialize(void) {
|
||||
if (hosversionBefore(8, 0, 0)) {
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
}
|
||||
return smGetService(&g_rgltrSrv, "rgltr");
|
||||
}
|
||||
|
||||
void rgltrExit(void) {
|
||||
serviceClose(&g_rgltrSrv);
|
||||
}
|
||||
|
||||
Result rgltrOpenSession(RgltrSession* session_out, PowerDomainId module_id) {
|
||||
const u32 in = (u32)module_id;
|
||||
return serviceDispatchIn(
|
||||
&g_rgltrSrv,
|
||||
0,
|
||||
in,
|
||||
.out_num_objects = 1,
|
||||
.out_objects = &session_out->s
|
||||
);
|
||||
}
|
||||
|
||||
Result rgltrGetVoltage(RgltrSession* session, u32* out_volt) {
|
||||
u32 temp = 0;
|
||||
Result rc = serviceDispatchOut(&session->s, 4, temp);
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
*out_volt = temp;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result rgltrRequestVoltage(RgltrSession* session, u32 microvolt) {
|
||||
return serviceDispatchIn(&session->s, 5, microvolt);
|
||||
}
|
||||
|
||||
Result rgltrCancelVoltageRequest(RgltrSession* session) {
|
||||
return serviceDispatch(&session->s, 6);
|
||||
}
|
||||
|
||||
void rgltrCloseSession(RgltrSession* session) {
|
||||
serviceClose(&session->s);
|
||||
}
|
||||
32
Source/hoc-clk/sysmodule/src/hos/rgltr_services.h
Normal file
32
Source/hoc-clk/sysmodule/src/hos/rgltr_services.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) ppkantorski (bord2death)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <switch.h> // for Service, Result, hosversionBefore(), smGetService(), serviceClose(), etc.
|
||||
#include "rgltr.h" // for RgltrSession, PowerDomainId, etc.
|
||||
|
||||
extern Service g_rgltrSrv;
|
||||
|
||||
Result rgltrInitialize(void);
|
||||
void rgltrExit(void);
|
||||
|
||||
Result rgltrOpenSession(RgltrSession* session_out, PowerDomainId module_id);
|
||||
|
||||
Result rgltrGetVoltage(RgltrSession* session, u32* out_volt);
|
||||
|
||||
void rgltrCloseSession(RgltrSession* session);
|
||||
@@ -185,7 +185,23 @@ namespace clockManager {
|
||||
if (module == HocClkModule_GPU && board::GetSocType() == HocClkSocType_Mariko) {
|
||||
constexpr u32 kStep = 38400000;
|
||||
constexpr u32 kPcvStep = 76800000;
|
||||
constexpr u32 kMax = 1228800000;
|
||||
|
||||
u32 kMax = 0;
|
||||
for (u32 i = 0; i < count; i++) {
|
||||
for (u32 j = 0; j < count; j++) {
|
||||
if (freqs[j] == freqs[i] + kStep) {
|
||||
kMax = freqs[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kMax == 0) {
|
||||
for (u32 i = 0; i < count; i++) {
|
||||
if (freqs[i] > kMax)
|
||||
kMax = freqs[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (u32 f = kPcvStep; f <= kMax && gFreqTable[module].count < HOCCLK_FREQ_LIST_MAX; f += kStep) {
|
||||
if (f % kPcvStep != 0) {
|
||||
@@ -221,6 +237,52 @@ namespace clockManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Workaround for PCV bug involving 38.4mhz step rate on erista
|
||||
if (module == HocClkModule_GPU && board::GetSocType() == HocClkSocType_Erista) {
|
||||
static const struct {
|
||||
u32 hz;
|
||||
HocClkConfigValue kval;
|
||||
} eristaGpuVoltMap[] = {
|
||||
{ 76800000, KipConfigValue_g_volt_e_76800 },
|
||||
{ 115200000, KipConfigValue_g_volt_e_115200 },
|
||||
{ 153600000, KipConfigValue_g_volt_e_153600 },
|
||||
{ 192000000, KipConfigValue_g_volt_e_192000 },
|
||||
{ 230400000, KipConfigValue_g_volt_e_230400 },
|
||||
{ 268800000, KipConfigValue_g_volt_e_268800 },
|
||||
{ 307200000, KipConfigValue_g_volt_e_307200 },
|
||||
{ 345600000, KipConfigValue_g_volt_e_345600 },
|
||||
{ 384000000, KipConfigValue_g_volt_e_384000 },
|
||||
{ 422400000, KipConfigValue_g_volt_e_422400 },
|
||||
{ 460800000, KipConfigValue_g_volt_e_460800 },
|
||||
{ 499200000, KipConfigValue_g_volt_e_499200 },
|
||||
{ 537600000, KipConfigValue_g_volt_e_537600 },
|
||||
{ 576000000, KipConfigValue_g_volt_e_576000 },
|
||||
{ 614400000, KipConfigValue_g_volt_e_614400 },
|
||||
{ 652800000, KipConfigValue_g_volt_e_652800 },
|
||||
{ 691200000, KipConfigValue_g_volt_e_691200 },
|
||||
{ 729600000, KipConfigValue_g_volt_e_729600 },
|
||||
{ 768000000, KipConfigValue_g_volt_e_768000 },
|
||||
{ 806400000, KipConfigValue_g_volt_e_806400 },
|
||||
{ 844800000, KipConfigValue_g_volt_e_844800 },
|
||||
{ 883200000, KipConfigValue_g_volt_e_883200 },
|
||||
{ 921600000, KipConfigValue_g_volt_e_921600 },
|
||||
{ 960000000, KipConfigValue_g_volt_e_960000 },
|
||||
{ 998400000, KipConfigValue_g_volt_e_998400 },
|
||||
{1036800000, KipConfigValue_g_volt_e_1036800 },
|
||||
{1075200000, KipConfigValue_g_volt_e_1075200 },
|
||||
};
|
||||
bool skip = false;
|
||||
for (auto& entry : eristaGpuVoltMap) {
|
||||
if (entry.hz == freqs[i]) {
|
||||
if (config::GetConfigValue(entry.kval) == 2000) {
|
||||
skip = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (skip) continue;
|
||||
}
|
||||
|
||||
*hz = freqs[i];
|
||||
fileUtils::LogLine("[mgr] %02u - %u - %u.%u MHz", gFreqTable[module].count, *hz, *hz / 1000000, *hz / 100000 - *hz / 1000000 * 10);
|
||||
|
||||
@@ -231,26 +293,27 @@ namespace clockManager {
|
||||
fileUtils::LogLine("[mgr] count = %u", gFreqTable[module].count);
|
||||
}
|
||||
|
||||
void HandleSafetyFeatures()
|
||||
bool HandleSafetyFeatures()
|
||||
{
|
||||
if (config::GetConfigValue(HocClkConfigValue_HandheldTDP) && (gContext.profile != HocClkProfile_Docked)) {
|
||||
if (board::GetConsoleType() == HocClkConsoleType_Hoag) {
|
||||
if (board::GetPowerMw(HocClkPowerSensor_Avg) < -(int)config::GetConfigValue(HocClkConfigValue_LiteTDPLimit)) {
|
||||
ResetToStockClocks();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (board::GetPowerMw(HocClkPowerSensor_Avg) < -(int)config::GetConfigValue(HocClkConfigValue_HandheldTDPLimit)) {
|
||||
ResetToStockClocks();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (((tmp451TempSoc() / 1000) > (int)config::GetConfigValue(HocClkConfigValue_ThermalThrottleThreshold)) && config::GetConfigValue(HocClkConfigValue_ThermalThrottle)) {
|
||||
ResetToStockClocks();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void HandleMiscFeatures()
|
||||
{
|
||||
@@ -267,6 +330,9 @@ namespace clockManager {
|
||||
|
||||
if(board::GetConsoleType() == HocClkConsoleType_Aula)
|
||||
AulaDisplay::SetDisplayColorMode((AulaColorMode)config::GetConfigValue(HocClkConfigValue_AulaDisplayColorPreset));
|
||||
if(config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
||||
board::HandleCpuUv();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,13 +365,6 @@ namespace clockManager {
|
||||
}
|
||||
}
|
||||
|
||||
void HandleCpuUv()
|
||||
{
|
||||
if (board::GetSocType() == HocClkSocType_Erista)
|
||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_eristaCpuUV), 0, 1581000000); // Erista tbreak is always 1581MHz
|
||||
else
|
||||
board::SetDfllTunings(config::GetConfigValue(KipConfigValue_marikoCpuUVLow), config::GetConfigValue(KipConfigValue_marikoCpuUVHigh), board::CalculateTbreak(config::GetConfigValue(KipConfigValue_tableConf)));
|
||||
}
|
||||
|
||||
void DVFSReset()
|
||||
{
|
||||
@@ -452,10 +511,6 @@ namespace clockManager {
|
||||
gContext.stable.freqs[module] = nearestHz;
|
||||
}
|
||||
|
||||
if (module == HocClkModule_CPU && config::GetConfigValue(HocClkConfigValue_LiveCpuUv)) {
|
||||
HandleCpuUv();
|
||||
}
|
||||
|
||||
if (module == HocClkModule_MEM && board::GetSocType() == HocClkSocType_Mariko && targetHz < oldHz && config::GetConfigValue(HocClkConfigValue_DVFSMode) == DVFSMode_Hijack) {
|
||||
ApplyGpuDvfs(targetHz);
|
||||
}
|
||||
@@ -711,11 +766,11 @@ namespace clockManager {
|
||||
|
||||
bool isBoost = apmExtIsBoostMode(mode);
|
||||
|
||||
HandleSafetyFeatures();
|
||||
bool shouldSkipClockSet = HandleSafetyFeatures();
|
||||
HandleMiscFeatures();
|
||||
|
||||
// GPU clock should always be the same unless PCV has overwriten our change, so reset it
|
||||
if (RefreshContext() || config::Refresh() || board::GetRealHz(HocClkModule_GPU) != gContext.freqs[HocClkModule_GPU]) {
|
||||
if ((RefreshContext() || config::Refresh() || (board::GetRealHz(HocClkModule_GPU) != gContext.freqs[HocClkModule_GPU])) && !shouldSkipClockSet) {
|
||||
SetClocks(isBoost);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user