mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-26 22:02:15 +00:00
fatal: update to use clkrst api on 8.0.0+
This commit is contained in:
parent
d44b91826d
commit
14683405be
3 changed files with 48 additions and 11 deletions
|
@ -102,9 +102,16 @@ void __appInit(void) {
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = pcvInitialize();
|
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_800) {
|
||||||
if (R_FAILED(rc)) {
|
rc = clkrstInitialize();
|
||||||
std::abort();
|
if (R_FAILED(rc)) {
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rc = pcvInitialize();
|
||||||
|
if (R_FAILED(rc)) {
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = lblInitialize();
|
rc = lblInitialize();
|
||||||
|
@ -155,7 +162,11 @@ void __appExit(void) {
|
||||||
spsmExit();
|
spsmExit();
|
||||||
psmExit();
|
psmExit();
|
||||||
lblExit();
|
lblExit();
|
||||||
pcvExit();
|
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_800) {
|
||||||
|
clkrstExit();
|
||||||
|
} else {
|
||||||
|
pcvExit();
|
||||||
|
}
|
||||||
bpcExit();
|
bpcExit();
|
||||||
i2cExit();
|
i2cExit();
|
||||||
pminfoExit();
|
pminfoExit();
|
||||||
|
|
|
@ -17,6 +17,31 @@
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#include "fatal_task_clock.hpp"
|
#include "fatal_task_clock.hpp"
|
||||||
|
|
||||||
|
Result AdjustClockTask::AdjustClockForModule(PcvModule module, u32 hz) {
|
||||||
|
Result rc;
|
||||||
|
|
||||||
|
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_800) {
|
||||||
|
/* On 8.0.0+, convert to module id + use clkrst API. */
|
||||||
|
PcvModuleId module_id;
|
||||||
|
if (R_FAILED((rc = pcvGetModuleId(&module_id, module)))) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClkrstSession session;
|
||||||
|
Result rc = clkrstOpenSession(&session, module_id, 3);
|
||||||
|
if (R_FAILED(rc)) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
ON_SCOPE_EXIT { clkrstCloseSession(&session); };
|
||||||
|
|
||||||
|
rc = clkrstSetClockRate(&session, hz);
|
||||||
|
} else {
|
||||||
|
/* On 1.0.0-7.0.1, use pcv API. */
|
||||||
|
rc = pcvSetClockRate(module, hz);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
Result AdjustClockTask::AdjustClock() {
|
Result AdjustClockTask::AdjustClock() {
|
||||||
/* Fatal sets the CPU to 1020MHz, the GPU to 307 MHz, and the EMC to 1331MHz. */
|
/* Fatal sets the CPU to 1020MHz, the GPU to 307 MHz, and the EMC to 1331MHz. */
|
||||||
|
@ -24,19 +49,19 @@ Result AdjustClockTask::AdjustClock() {
|
||||||
constexpr u32 GPU_CLOCK_307MHZ = 0x124F8000L;
|
constexpr u32 GPU_CLOCK_307MHZ = 0x124F8000L;
|
||||||
constexpr u32 EMC_CLOCK_1331MHZ = 0x4F588000L;
|
constexpr u32 EMC_CLOCK_1331MHZ = 0x4F588000L;
|
||||||
Result rc = ResultSuccess;
|
Result rc = ResultSuccess;
|
||||||
|
|
||||||
if (R_FAILED((rc = pcvSetClockRate(PcvModule_Cpu, CPU_CLOCK_1020MHZ)))) {
|
if (R_FAILED((rc = AdjustClockForModule(PcvModule_CpuBus, CPU_CLOCK_1020MHZ)))) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_FAILED((rc = pcvSetClockRate(PcvModule_Gpu, GPU_CLOCK_307MHZ)))) {
|
if (R_FAILED((rc = AdjustClockForModule(PcvModule_GPU, GPU_CLOCK_307MHZ)))) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_FAILED((rc = pcvSetClockRate(PcvModule_Emc, EMC_CLOCK_1331MHZ)))) {
|
if (R_FAILED((rc = AdjustClockForModule(PcvModule_EMC, EMC_CLOCK_1331MHZ)))) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
class AdjustClockTask : public IFatalTask {
|
class AdjustClockTask : public IFatalTask {
|
||||||
private:
|
private:
|
||||||
|
Result AdjustClockForModule(PcvModule module, u32 hz);
|
||||||
Result AdjustClock();
|
Result AdjustClock();
|
||||||
public:
|
public:
|
||||||
AdjustClockTask(FatalThrowContext *ctx, u64 title_id) : IFatalTask(ctx, title_id) { }
|
AdjustClockTask(FatalThrowContext *ctx, u64 title_id) : IFatalTask(ctx, title_id) { }
|
||||||
|
|
Loading…
Reference in a new issue