Recover changes
This commit is contained in:
@@ -29,6 +29,10 @@
|
||||
#include <switch.h>
|
||||
#include <pwm.h>
|
||||
#include <registers.h>
|
||||
#include <battery.h>
|
||||
#include <display_refresh_rate.h>
|
||||
#include <rgltr.h>
|
||||
#include <notification.h>
|
||||
|
||||
#include "board.hpp"
|
||||
#include "board_fuse.hpp"
|
||||
@@ -41,14 +45,15 @@ namespace board {
|
||||
SysClkSocType gSocType;
|
||||
u8 gDramID;
|
||||
HorizonOCConsoleType gConsoleType = HorizonOCConsoleType_Iowa;
|
||||
FuseSpeedoData gSpeedos;
|
||||
FuseData fuseData;
|
||||
u8 speedoBracket;
|
||||
Result nvCheck = 1;
|
||||
u23 fd = 0, fd2 = 0;
|
||||
PwmChannelSession iCon;
|
||||
|
||||
u32 fd = 0, fd2 = 0;
|
||||
|
||||
void FetchHardwareInfos() {
|
||||
FuseReadSpeedos(gSpeedos);
|
||||
FuseSetGpuBracket(gSpeedos.gpuSpeedo, speedoBracket);
|
||||
ReadFuses(fuseData);
|
||||
SetGpuBracket(fuseData.gpuSpeedo, speedoBracket);
|
||||
|
||||
u64 sku = 0, dramID = 0;
|
||||
Result rc = splInitialize();
|
||||
@@ -74,8 +79,7 @@ namespace board {
|
||||
CacheGpuVoltTable();
|
||||
}
|
||||
|
||||
gConsoleType = static_cast<HorizonOCConsoleType> sku;
|
||||
g_dramID = dramID;
|
||||
gConsoleType = static_cast<HorizonOCConsoleType>(sku);
|
||||
}
|
||||
|
||||
/* TODO: Check for config */
|
||||
@@ -90,6 +94,12 @@ namespace board {
|
||||
ASSERT_RESULT_OK(rc, "pcvInitialize");
|
||||
}
|
||||
|
||||
rc = apmExtInitialize();
|
||||
ASSERT_RESULT_OK(rc, "apmExtInitialize");
|
||||
|
||||
rc = psmInitialize();
|
||||
ASSERT_RESULT_OK(rc, "psmInitialize");
|
||||
|
||||
if(HOSSVC_HAS_TC) {
|
||||
rc = tcInitialize();
|
||||
ASSERT_RESULT_OK(rc, "tcInitialize");
|
||||
@@ -101,10 +111,16 @@ namespace board {
|
||||
rc = tmp451Initialize();
|
||||
ASSERT_RESULT_OK(rc, "tmp451Initialize");
|
||||
|
||||
nvInitialize_rc = nvInitialize();
|
||||
if (R_SUCCEEDED(nvInitialize_rc)) {
|
||||
Result nvCheck = 1;
|
||||
if (R_SUCCEEDED(nvInitialize())) {
|
||||
nvCheck = nvOpen(&fd, "/dev/nvhost-ctrl-gpu");
|
||||
nvCheck_sched = nvOpen(&fd2, "/dev/nvsched-ctrl");
|
||||
Result nvCheck_sched = nvOpen(&fd2, "/dev/nvsched-ctrl");
|
||||
/* This can be improved. */
|
||||
NvSchedSucceed(nvCheck_sched);
|
||||
|
||||
if (R_SUCCEEDED(nvCheck_sched)) {
|
||||
SchedSetFD2(fd2);
|
||||
}
|
||||
}
|
||||
|
||||
rc = rgltrInitialize();
|
||||
@@ -113,19 +129,17 @@ namespace board {
|
||||
rc = pmdmntInitialize();
|
||||
ASSERT_RESULT_OK(rc, "pmdmntInitialize");
|
||||
|
||||
StartGpuLoad(nvCheck, fd);
|
||||
|
||||
StartMiscThread(pwmCheck)
|
||||
StartLoad(nvCheck, fd);
|
||||
|
||||
batteryInfoInitialize();
|
||||
FetchHardwareInfos();
|
||||
|
||||
Result pwmCheck = 1;
|
||||
if (hosversionAtLeast(6,0,0) && R_SUCCEEDED(pwmInitialize())) {
|
||||
pwmCheck = pwmOpenSession2(&g_ICon, 0x3D000001);
|
||||
pwmCheck = pwmOpenSession2(&iCon, 0x3D000001);
|
||||
}
|
||||
|
||||
StartMiscThread(pwmCheck);
|
||||
StartMiscThread(pwmCheck, &iCon);
|
||||
|
||||
if (gConsoleType != HorizonOCConsoleType_Hoag) {
|
||||
u64 clkVirtAddr, dsiVirtAddr, outsize;
|
||||
@@ -164,7 +178,7 @@ namespace board {
|
||||
|
||||
ExitMiscThread();
|
||||
|
||||
pwmChannelSessionClose(&g_ICon);
|
||||
pwmChannelSessionClose(&iCon);
|
||||
pwmExit();
|
||||
rgltrExit();
|
||||
batteryInfoExit();
|
||||
@@ -185,7 +199,7 @@ namespace board {
|
||||
}
|
||||
|
||||
u8 GetDramID() {
|
||||
return dramID;
|
||||
return gDramID;
|
||||
}
|
||||
|
||||
bool IsDram8GB() {
|
||||
@@ -209,4 +223,16 @@ namespace board {
|
||||
}
|
||||
}
|
||||
|
||||
FuseData *GetFuseData() {
|
||||
return &fuseData;
|
||||
}
|
||||
|
||||
u8 GetGpuSpeedoBracket() {
|
||||
return speedoBracket;
|
||||
}
|
||||
|
||||
bool IsUsingRetroSuperDisplay() {
|
||||
return false; /* stub for now. */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include "board_fuse.hpp"
|
||||
#include "board_load.hpp"
|
||||
#include "board_name.hpp"
|
||||
#include "board_freq.hpp"
|
||||
#include "board_sensor.hpp"
|
||||
#include "board_volt.hpp"
|
||||
#include "board_profile.hpp"
|
||||
|
||||
#define HOSSVC_HAS_CLKRST (hosversionAtLeast(8,0,0))
|
||||
#define HOSSVC_HAS_TC (hosversionAtLeast(5,0,0))
|
||||
@@ -38,7 +46,10 @@ namespace board {
|
||||
SysClkSocType GetSocType();
|
||||
HorizonOCConsoleType GetConsoleType();
|
||||
u8 GetDramID();
|
||||
u8 GetGpuSpeedoBracket();
|
||||
bool IsDram8GB();
|
||||
void SetDisplayRefreshDockedState(bool docked);
|
||||
FuseData *GetFuseData();
|
||||
bool IsUsingRetroSuperDisplay();
|
||||
|
||||
}
|
||||
|
||||
@@ -27,20 +27,13 @@
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <nxExt.h>
|
||||
#include <display_refresh_rate.h>
|
||||
#include "board.hpp"
|
||||
#include "board_name.hpp"
|
||||
#include "../error.h"
|
||||
#include "../errors.h"
|
||||
|
||||
namespace board {
|
||||
|
||||
PcvModuleId GetPcvModuleId(SysClkModule sysclkModule) {
|
||||
PcvModuleId pcvModuleId;
|
||||
Result rc = pcvGetModuleId(&pcvModuleId, GetPcvModule(sysclkModule));
|
||||
ASSERT_RESULT_OK(rc, "pcvGetModuleId");
|
||||
|
||||
return pcvModuleId;
|
||||
}
|
||||
|
||||
PcvModule GetPcvModule(SysClkModule sysclkModule) {
|
||||
switch (sysclkModule) {
|
||||
case SysClkModule_CPU:
|
||||
@@ -53,14 +46,22 @@ namespace board {
|
||||
ASSERT_ENUM_VALID(SysClkModule, sysclkModule);
|
||||
}
|
||||
|
||||
return (PcvModule)0;
|
||||
return static_cast<PcvModule>(0);
|
||||
}
|
||||
|
||||
PcvModuleId GetPcvModuleId(SysClkModule sysclkModule) {
|
||||
PcvModuleId pcvModuleId;
|
||||
Result rc = pcvGetModuleId(&pcvModuleId, GetPcvModule(sysclkModule));
|
||||
ASSERT_RESULT_OK(rc, "pcvGetModuleId");
|
||||
|
||||
return pcvModuleId;
|
||||
}
|
||||
|
||||
void ClkrstSetHz(ClkrstSession &session, u32 hz) {
|
||||
ASSERT_RESULT_OK(clkrstSetClockRate(&session, hz), "clkrstSetClockRate");
|
||||
}
|
||||
|
||||
void PcvSetHz(PcvModuleId moduleID, u32 hz) {
|
||||
void PcvSetHz(PcvModule moduleID, u32 hz) {
|
||||
ASSERT_RESULT_OK(pcvSetClockRate(moduleID, hz), "pcvSetClockRate");
|
||||
}
|
||||
|
||||
@@ -86,7 +87,7 @@ namespace board {
|
||||
|
||||
/* Voltage bug workaround. */
|
||||
if (module == SysClkModule_CPU) {
|
||||
svcSleepThread(200'000);
|
||||
svcSleepThread(250'000);
|
||||
ClkrstSetHz(session, hz);
|
||||
}
|
||||
|
||||
@@ -95,7 +96,7 @@ namespace board {
|
||||
PcvSetHz(GetPcvModule(module), hz);
|
||||
|
||||
if (module == SysClkModule_CPU) {
|
||||
svcSleepThread(200'000);
|
||||
svcSleepThread(250'000);
|
||||
PcvSetHz(GetPcvModule(module), hz);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +115,7 @@ namespace board {
|
||||
u32 hz = 0;
|
||||
|
||||
if (module == HorizonOCModule_Display) {
|
||||
return GetDisplayRate();
|
||||
return GetDisplayRate(hz);
|
||||
}
|
||||
|
||||
if (HOSSVC_HAS_CLKRST) {
|
||||
@@ -145,7 +146,7 @@ namespace board {
|
||||
case SysClkModule_MEM:
|
||||
return t210ClkMemFreq();
|
||||
case HorizonOCModule_Display:
|
||||
return GetDisplayRate();
|
||||
return GetDisplayRate(hz);
|
||||
return hz;
|
||||
default:
|
||||
ASSERT_ENUM_VALID(SysClkModule, module);
|
||||
@@ -192,6 +193,7 @@ namespace board {
|
||||
}
|
||||
|
||||
void ResetToStock() {
|
||||
Result rc;
|
||||
if (hosversionAtLeast(9,0,0)) {
|
||||
std::uint32_t confId = 0;
|
||||
rc = apmExtGetCurrentPerformanceConfiguration(&confId);
|
||||
@@ -223,7 +225,7 @@ namespace board {
|
||||
}
|
||||
|
||||
void ResetToStockDisplay() {
|
||||
if (GetConsoleType != HorizonOCConsoleType_Hoag) {
|
||||
if (GetConsoleType() != HorizonOCConsoleType_Hoag) {
|
||||
DisplayRefresh_SetRate(60);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <nxExt.h>
|
||||
#include "../errors.h"
|
||||
|
||||
namespace board {
|
||||
|
||||
@@ -35,7 +36,7 @@ namespace board {
|
||||
|
||||
u32 GetHz(SysClkModule module);
|
||||
u32 GetRealHz(SysClkModule module);
|
||||
u32 GetFreqList(SysClkModule module, u32 *outList, u32 maxCount, u32 *outCount);
|
||||
void GetFreqList(SysClkModule module, u32 *outList, u32 maxCount, u32 *outCount);
|
||||
u32 GetHighestDockedDisplayRate();
|
||||
|
||||
void ResetToStock();
|
||||
|
||||
@@ -25,24 +25,12 @@
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include <fuse.h>
|
||||
#include "board_fuse.hpp"
|
||||
#include <cstring>
|
||||
|
||||
namespace board {
|
||||
|
||||
namespace {
|
||||
constexpr u32 FuseCpuSpeedoCalib = 0x114;
|
||||
// constexpr u32 FuseCpuSpeedo1Calib = 0x12C;
|
||||
constexpr u32 FuseGpuSpeedoCalib = 0x130;
|
||||
|
||||
constexpr u32 FuseSocSpeedoCalib = 0x134;
|
||||
// constexpr u32 FuseSocSpeedo1Calib = 0x138;
|
||||
// constexpr u32 FuseSocSpeedo2Calib = 0x13C;
|
||||
|
||||
constexpr u32 FuseCpuIddqCalib = 0x118;
|
||||
constexpr u32 FuseSocIddqCalib = 0x140;
|
||||
constexpr u32 FuseGpuIddqCalib = 0x228;
|
||||
}
|
||||
|
||||
void SetGpuBracket(u8 speedo, u8 &gpuBracket) {
|
||||
if (speedo <= 1624) {
|
||||
gpuBracket = 0;
|
||||
@@ -63,7 +51,7 @@ namespace board {
|
||||
gpuBracket = 3;
|
||||
}
|
||||
|
||||
FuseReadSpeedo(FuseSpeedoData &speedo) {
|
||||
void ReadFuses(FuseData &speedo) {
|
||||
u64 pid = 0;
|
||||
constexpr u64 UsbID = 0x0100000000000006;
|
||||
if (R_FAILED(pmdmntGetProcessId(&pid, UsbID))) {
|
||||
@@ -99,12 +87,15 @@ namespace board {
|
||||
break;
|
||||
}
|
||||
|
||||
speedo.cpuSpeedo = *reinterpret_cast<u16*>(dump + FuseCpuSpeedoCalib);
|
||||
speedo.gpuSpeedo = *reinterpret_cast<u16*>(dump + FuseGpuSpeedoCalib);
|
||||
speedo.socSpeedo = *reinterpret_cast<u16*>(dump + FuseSocSpeedoCalib);
|
||||
speedo.cpuIDDQ = *reinterpret_cast<u16*>(dump + FuseCpuIddqCalib);
|
||||
speedo.gpuIDDQ = *reinterpret_cast<u16*>(dump + FuseSocIddqCalib);
|
||||
speedo.socIDDQ = *reinterpret_cast<u16*>(dump + FUSE_GPU_IDDQ_CALIB);
|
||||
speedo.cpuSpeedo = *reinterpret_cast<u16*>(dump + FUSE_CPU_SPEEDO_0_CALIB);
|
||||
speedo.gpuSpeedo = *reinterpret_cast<u16*>(dump + FUSE_CPU_SPEEDO_2_CALIB);
|
||||
speedo.socSpeedo = *reinterpret_cast<u16*>(dump + FUSE_SOC_SPEEDO_0_CALIB);
|
||||
|
||||
speedo.cpuIDDQ = *reinterpret_cast<u16*>(dump + FUSE_CPU_IDDQ_CALIB) * 4;
|
||||
speedo.gpuIDDQ = *reinterpret_cast<u16*>(dump + FUSE_GPU_IDDQ_CALIB) * 5;
|
||||
speedo.socIDDQ = *reinterpret_cast<u16*>(dump + FUSE_SOC_IDDQ_CALIB) * 4;
|
||||
speedo.waferX = *reinterpret_cast<u16*>(dump + FUSE_OPT_X_COORDINATE);
|
||||
speedo.waferY = *reinterpret_cast<u16*>(dump + FUSE_OPT_Y_COORDINATE);
|
||||
|
||||
svcCloseHandle(debug);
|
||||
return;
|
||||
|
||||
@@ -24,11 +24,13 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
struct FuseSpeedoData {
|
||||
struct FuseData {
|
||||
u16 cpuSpeedo;
|
||||
u16 gpuSpeedo;
|
||||
u16 socSpeedo;
|
||||
@@ -36,9 +38,12 @@ namespace board {
|
||||
u16 cpuIDDQ;
|
||||
u16 gpuIDDQ;
|
||||
u16 socIDDQ;
|
||||
|
||||
u16 waferX;
|
||||
u16 waferY;
|
||||
};
|
||||
|
||||
FuseReadSpeedo(FuseSpeedoData speedo);
|
||||
FuseSetGpuBracket(u8 gpuSpeedo, u8 &gpuBracket);
|
||||
void ReadFuses(FuseData &speedo);
|
||||
void SetGpuBracket(u8 gpuSpeedo, u8 &gpuBracket);
|
||||
|
||||
}
|
||||
|
||||
@@ -30,8 +30,10 @@
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
#include <numeric>
|
||||
#include "board_misc.hpp"
|
||||
#include <minIni.h>
|
||||
#include <battery.h>
|
||||
#include "board_misc.hpp"
|
||||
#include "board.hpp"
|
||||
|
||||
namespace board {
|
||||
|
||||
@@ -42,7 +44,8 @@ namespace board {
|
||||
Thread cpuCore2Thread;
|
||||
|
||||
u32 gpuLoad;
|
||||
u32 _fd;
|
||||
u32 _fd, _fd2;
|
||||
Result nvCheckSched;
|
||||
|
||||
u64 idletick0 = 0;
|
||||
u64 idletick1 = 0;
|
||||
@@ -61,8 +64,8 @@ namespace board {
|
||||
if (R_SUCCEEDED(nvCheck)) do {
|
||||
u32 temp;
|
||||
if (R_SUCCEEDED(nvIoctl(_fd, NVGPU_GPU_IOCTL_PMU_GET_GPU_LOAD, &temp))) {
|
||||
gpu_load_array[i++ % gpu_samples_average] = temp;
|
||||
gpuLoad = std::accumulate(&gpu_load_array[0], &gpu_load_array[gpu_samples_average], 0) / gpu_samples_average;
|
||||
gpu_load_array[i++ % GpuSamples] = temp;
|
||||
gpuLoad = std::accumulate(&gpu_load_array[0], &gpu_load_array[GpuSamples], 0) / GpuSamples;
|
||||
}
|
||||
svcSleepThread(16'666'000); // wait a bit (this is the perfect amount of time to keep the reading accurate)
|
||||
} while(true);
|
||||
@@ -80,10 +83,10 @@ namespace board {
|
||||
}
|
||||
}
|
||||
|
||||
void StartLoad() {
|
||||
void StartLoad(Result nvCheck, u32 fd) {
|
||||
_fd = fd;
|
||||
threadCreate(&gpuThread, GpuLoadThread, &nvCheck, NULL, 0x1000, 0x3F, -2);
|
||||
threadStart(&gpuThread)
|
||||
threadStart(&gpuThread);
|
||||
|
||||
leventClear(&threadexit);
|
||||
threadCreate(&cpuCore0Thread, CheckCore, &idletick0, NULL, 0x1000, 0x10, 0);
|
||||
@@ -136,7 +139,7 @@ namespace board {
|
||||
constexpr u32 NVschedCtrlDisable = 0x00000602;
|
||||
}
|
||||
|
||||
void SetGpuSchedulingMode(GpuSchedulingMode mode, GpuSchedulingOverrideMethod method, Result nvCheckSched, u32 fd2) {
|
||||
void SetGpuSchedulingMode(GpuSchedulingMode mode, GpuSchedulingOverrideMethod method) {
|
||||
if (R_FAILED(nvCheckSched) && method == GpuSchedulingOverrideMethod_NvService) {
|
||||
return;
|
||||
}
|
||||
@@ -147,14 +150,14 @@ namespace board {
|
||||
case GpuSchedulingMode_DoNotOverride: break;
|
||||
case GpuSchedulingMode_Disabled:
|
||||
if (method == GpuSchedulingOverrideMethod_NvService) {
|
||||
nvIoctl(fd2, NVschedCtrlDisable, &temp);
|
||||
nvIoctl(_fd2, NVschedCtrlDisable, &temp);
|
||||
} else {
|
||||
enabled = false;
|
||||
}
|
||||
break;
|
||||
case GpuSchedulingMode_Enabled:
|
||||
if (method == GpuSchedulingOverrideMethod_NvService) {
|
||||
nvIoctl(fd2, NVschedCtrlEnable, &temp);
|
||||
nvIoctl(_fd2, NVschedCtrlEnable, &temp);
|
||||
} else {
|
||||
enabled = true;
|
||||
}
|
||||
@@ -174,4 +177,12 @@ namespace board {
|
||||
}
|
||||
}
|
||||
|
||||
void SchedSetFD2(u32 fd2) {
|
||||
_fd2 = fd2;
|
||||
}
|
||||
|
||||
void NvSchedSucceed(Result nvSched) {
|
||||
nvCheckSched = nvSched;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,12 +26,15 @@
|
||||
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
void StartLoad(Result nvCheck, u32 fd);
|
||||
void ExitLoad();
|
||||
u32 GetPartLoad();
|
||||
void SetGpuSchedulingMode(GpuSchedulingMode mode, GpuSchedulingOverrideMethod method, Result nvCheckSched, u32 fd2);
|
||||
u32 GetPartLoad(SysClkPartLoad loadSource);
|
||||
void SetGpuSchedulingMode(GpuSchedulingMode mode, GpuSchedulingOverrideMethod method);
|
||||
void SchedSetFD2(u32 fd2);
|
||||
void NvSchedSucceed(Result nvSched);
|
||||
|
||||
}
|
||||
|
||||
@@ -25,11 +25,15 @@
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include <pwm.h>
|
||||
#include <cmath>
|
||||
#include <rgltr.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
Thread miscThread;
|
||||
u8 fanLevel = 0;
|
||||
PwmChannelSession *_iCon;
|
||||
|
||||
void MiscThreadFunc(void *pwmCheckPtr) {
|
||||
Result pwmCheck = *static_cast<Result *>(pwmCheckPtr);
|
||||
@@ -38,7 +42,7 @@ namespace board {
|
||||
|
||||
while (true) {
|
||||
if (R_SUCCEEDED(pwmCheck)) {
|
||||
if (R_SUCCEEDED(pwmChannelSessionGetDutyCycle(&g_ICon, &temp))) {
|
||||
if (R_SUCCEEDED(pwmChannelSessionGetDutyCycle(_iCon, &temp))) {
|
||||
temp *= 10;
|
||||
temp = trunc(temp);
|
||||
temp /= 10;
|
||||
@@ -46,7 +50,7 @@ namespace board {
|
||||
}
|
||||
}
|
||||
|
||||
fanLevel = static_cast<u8>(Rotation_Duty);
|
||||
fanLevel = static_cast<u8>(rotationDuty);
|
||||
svcSleepThread(300'000'000);
|
||||
}
|
||||
}
|
||||
@@ -55,7 +59,8 @@ namespace board {
|
||||
return fanLevel;
|
||||
}
|
||||
|
||||
void StartMiscThread(Result pwmCheck) {
|
||||
void StartMiscThread(Result pwmCheck, PwmChannelSession *iCon) {
|
||||
_iCon = iCon;
|
||||
threadCreate(&miscThread, MiscThreadFunc, &pwmCheck, NULL, 0x1000, 0x10, 3);
|
||||
threadStart(&miscThread);
|
||||
}
|
||||
|
||||
@@ -28,10 +28,11 @@
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <pwm.h>
|
||||
|
||||
namespace board {
|
||||
|
||||
void StartMiscThread(Result pwmCheck);
|
||||
void StartMiscThread(Result pwmCheck, PwmChannelSession *iCon);
|
||||
void ExitMiscThread();
|
||||
u8 GetFanLevel();
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include "board.hpp"
|
||||
|
||||
namespace board {
|
||||
|
||||
@@ -44,4 +45,9 @@ namespace board {
|
||||
return sysclkFormatThermalSensor(sensor, pretty);
|
||||
}
|
||||
|
||||
const char *GetPowerSensorName(SysClkPowerSensor sensor, bool pretty) {
|
||||
ASSERT_ENUM_VALID(SysClkPowerSensor, sensor);
|
||||
return sysclkFormatPowerSensor(sensor, pretty);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,5 +33,6 @@ namespace board {
|
||||
const char *GetModuleName(SysClkModule module, bool pretty);
|
||||
const char *GetProfileName(SysClkProfile profile, bool pretty);
|
||||
const char *GetThermalSensorName(SysClkThermalSensor sensor, bool pretty);
|
||||
const char *GetPowerSensorName(SysClkPowerSensor sensor, bool pretty);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <switch.h>
|
||||
#include <sysclk.h>
|
||||
#include <nxExt.h>
|
||||
#include "board.hpp"
|
||||
|
||||
namespace board {
|
||||
|
||||
|
||||
@@ -24,17 +24,19 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <sysclk.h>
|
||||
#include <switch.h>
|
||||
#include <nxExt.h>
|
||||
#include <cmath.h>
|
||||
#include <cmath>
|
||||
#include <battery.h>
|
||||
#include <pwm.h>
|
||||
#include "board.hpp"
|
||||
|
||||
namespace board {
|
||||
|
||||
u32 GetTemperatureMilli(SysClkThermalSensor sensor) {
|
||||
u32 millis = 0;
|
||||
s32 millis = 0;
|
||||
BatteryChargeInfo info;
|
||||
|
||||
if (sensor == SysClkThermalSensor_SOC) {
|
||||
millis = tmp451TempSoc();
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <memmem.h>
|
||||
#include <registers.h>
|
||||
#include <cstring>
|
||||
#include <rgltr.h>
|
||||
#include <battery.h>
|
||||
#include "board.hpp"
|
||||
#include "board_freq.hpp"
|
||||
#include "board_volt.hpp"
|
||||
@@ -45,14 +47,14 @@ namespace board {
|
||||
struct EristaCpuUvEntry {
|
||||
u32 tune0;
|
||||
u32 tune1;
|
||||
} EristaCpuUvEntry;
|
||||
};
|
||||
|
||||
struct MarikoCpuUvEntry {
|
||||
u32 tune0_low;
|
||||
u32 tune0_high;
|
||||
u32 tune1_low;
|
||||
u32 tune1_high;
|
||||
} MarikoCpuUvEntry;
|
||||
};
|
||||
|
||||
EristaCpuUvEntry eristaCpuUvTable[5] = {
|
||||
{0xffff, 0x27007ff},
|
||||
@@ -95,23 +97,23 @@ namespace board {
|
||||
|
||||
void CacheDfllData() {
|
||||
u64 temp;
|
||||
rc = svcQueryMemoryMapping(&cldvfs, &temp, CLDVFS_REGION_BASE, CLDVFS_REGION_SIZE);
|
||||
Result rc = svcQueryMemoryMapping(&cldvfs, &temp, CLDVFS_REGION_BASE, CLDVFS_REGION_SIZE);
|
||||
ASSERT_RESULT_OK(rc, "svcQueryMemoryMapping (cldvfs)");
|
||||
|
||||
if (GetSocType() == SysClkSocType_Erista) {
|
||||
cachedTune.tune0Low = *static_cast<u32 *>(cldvfs + CL_DVFS_TUNE0_0);
|
||||
cachedTune.tune1Low = *static_cast<u32 *>(cldvfs + CL_DVFS_TUNE1_0);
|
||||
cachedTune.tune0Low = *reinterpret_cast<u32 *>(cldvfs + CL_DVFS_TUNE0_0);
|
||||
cachedTune.tune1Low = *reinterpret_cast<u32 *>(cldvfs + CL_DVFS_TUNE1_0);
|
||||
} else {
|
||||
SetHz(SysClkModule_CPU, 1785000000);
|
||||
cachedTune.tune0High = *static_cast<u32 *>(cldvfs + CL_DVFS_TUNE0_0);
|
||||
cachedTune.tune0High = *reinterpret_cast<u32 *>(cldvfs + CL_DVFS_TUNE0_0);
|
||||
ResetToStockCpu();
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: clean up this code. */
|
||||
void SetDfllTunings(u32 levelLow, u32 levelHigh, u32 tbreakPoint) {
|
||||
u32* tune0_ptr = static_cast<u32 *>(cldvfs + CL_DVFS_TUNE0_0);
|
||||
u32* tune1_ptr = static_cast<u32 *>(cldvfs + CL_DVFS_TUNE1_0);
|
||||
u32* tune0_ptr = reinterpret_cast<u32 *>(cldvfs + CL_DVFS_TUNE0_0);
|
||||
u32* tune1_ptr = reinterpret_cast<u32 *>(cldvfs + CL_DVFS_TUNE1_0);
|
||||
if (GetSocType() == SysClkSocType_Mariko) {
|
||||
if (GetHz(SysClkModule_CPU) < tbreakPoint && (levelLow || levelHigh)) {
|
||||
if (levelLow) {
|
||||
@@ -253,10 +255,10 @@ namespace board {
|
||||
rc = rgltrOpenSession(&session, PcvPowerDomainId_Max77621_Gpu);
|
||||
} else {
|
||||
rc = rgltrOpenSession(&session, PcvPowerDomainId_Max77812_Gpu);
|
||||
ASSERT_RESULT_OK(rc, "rgltrOpenSession")
|
||||
rgltrGetVoltage(&session, &out);
|
||||
rgltrCloseSession(&session);
|
||||
}
|
||||
ASSERT_RESULT_OK(rc, "rgltrOpenSession")
|
||||
rgltrGetVoltage(&session, &out);
|
||||
rgltrCloseSession(&session);
|
||||
break;
|
||||
case HocClkVoltage_EMCVDDQ_MarikoOnly:
|
||||
if (GetSocType() == SysClkSocType_Mariko) {
|
||||
@@ -327,9 +329,9 @@ namespace board {
|
||||
|
||||
void CacheGpuVoltTable() {
|
||||
UnkRegulator reg = {
|
||||
.voltageMinUV = 600000,
|
||||
.voltageStep = 12500,
|
||||
.voltageMax = 1400000,
|
||||
.voltageMin = 600000,
|
||||
.voltageStep = 12500,
|
||||
.voltageMax = 1400000,
|
||||
};
|
||||
|
||||
Handle handle = GetPcvHandle();
|
||||
@@ -417,7 +419,7 @@ namespace board {
|
||||
return;
|
||||
}
|
||||
|
||||
Result rc = svcWriteDebugProcessMemory(handle, table, voltData.dvfsAddress, sizeof(table));
|
||||
Result rc = svcWriteDebugProcessMemory(handle, table, voltData.voltTableAddress, sizeof(table));
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
voltData.ramVmin = vmin;
|
||||
@@ -441,7 +443,7 @@ namespace board {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < std::size(gpuDvfsArray); ++i) {
|
||||
for (u32 i = 0; i < std::size(gpuVoltArray); ++i) {
|
||||
if (freqMhz <= ramTable[bracket][i]) {
|
||||
return gpuVoltArray[i];
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace board {
|
||||
|
||||
/* TODO: Find out what component this actually targets. */
|
||||
struct UnkRegulator {
|
||||
u32 voltageMinUV;
|
||||
u32 voltageMin;
|
||||
u32 voltageStep;
|
||||
u32 voltageMax;
|
||||
};
|
||||
@@ -53,8 +53,9 @@ namespace board {
|
||||
// u64 dvco_calibration_max;
|
||||
};
|
||||
|
||||
void SetDfllTunings(u32 levelLow, u32 levelHigh, u32 tbreakPoint);
|
||||
void CacheDfllData();
|
||||
u32 CalculateTbreak();
|
||||
u32 CalculateTbreak(u32 table);
|
||||
u32 GetVoltage(HocClkVoltage voltage);
|
||||
void CacheGpuVoltTable();
|
||||
void PcvHijackGpuVolts(u32 vmin);
|
||||
|
||||
Reference in New Issue
Block a user