sys-clk: deprecate
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "clocks.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
uint32_t cpu_hz;
|
||||
uint32_t gpu_hz;
|
||||
uint32_t mem_hz;
|
||||
} SysClkApmConfiguration;
|
||||
|
||||
extern SysClkApmConfiguration sysclk_g_apm_configurations[];
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
#include "../config.h"
|
||||
#include "../clocks.h"
|
||||
#include "../ipc.h"
|
||||
|
||||
bool sysclkIpcRunning();
|
||||
Result sysclkIpcInitialize(void);
|
||||
void sysclkIpcExit(void);
|
||||
|
||||
Result sysclkIpcGetAPIVersion(u32* out_ver);
|
||||
Result sysclkIpcGetVersionString(char* out, size_t len);
|
||||
Result sysclkIpcGetCurrentContext(SysClkContext* out_context);
|
||||
Result sysclkIpcGetProfileCount(u64 tid, u8* out_count);
|
||||
Result sysclkIpcSetEnabled(bool enabled);
|
||||
Result sysclkIpcExitCmd();
|
||||
Result sysclkIpcSetOverride(SysClkModule module, u32 hz);
|
||||
Result sysclkIpcGetProfiles(u64 tid, SysClkTitleProfileList* out_profiles);
|
||||
Result sysclkIpcSetProfiles(u64 tid, SysClkTitleProfileList* profiles);
|
||||
Result sysclkIpcGetConfigValues(SysClkConfigValueList* out_configValues);
|
||||
Result sysclkIpcSetConfigValues(SysClkConfigValueList* configValues);
|
||||
Result sysclkIpcSetReverseNXRTMode(ReverseNXMode mode);
|
||||
Result sysclkIpcGetFrequencyTable(SysClkModule module, SysClkProfile profile, SysClkFrequencyTable* out_table);
|
||||
Result sysclkIpcGetIsMariko(bool* out_is_mariko);
|
||||
Result sysclkIpcGetBatteryChargingDisabledOverride(bool* out_is_true);
|
||||
Result sysclkIpcSetBatteryChargingDisabledOverride(bool toggle_true);
|
||||
|
||||
static inline Result sysclkIpcRemoveOverride(SysClkModule module)
|
||||
{
|
||||
return sysclkIpcSetOverride(module, 0);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __SWITCH__
|
||||
|
||||
#include <switch/types.h>
|
||||
#include <switch/result.h>
|
||||
|
||||
#else
|
||||
|
||||
#define R_FAILED(res) ((res) != 0)
|
||||
#define R_SUCCEEDED(res) ((res) == 0)
|
||||
|
||||
typedef std::uint32_t Result;
|
||||
typedef std::uint32_t u32;
|
||||
typedef std::int32_t s32;
|
||||
typedef std::uint64_t u64;
|
||||
typedef std::uint8_t u8;
|
||||
|
||||
#endif
|
||||
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SysClkProfile_Handheld = 0,
|
||||
SysClkProfile_HandheldCharging,
|
||||
SysClkProfile_HandheldChargingUSB,
|
||||
SysClkProfile_HandheldChargingOfficial,
|
||||
SysClkProfile_Docked,
|
||||
SysClkProfile_EnumMax
|
||||
} SysClkProfile;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SysClkModule_CPU = 0,
|
||||
SysClkModule_GPU,
|
||||
SysClkModule_MEM,
|
||||
SysClkModule_EnumMax
|
||||
} SysClkModule;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SysClkThermalSensor_SOC = 0,
|
||||
SysClkThermalSensor_PCB,
|
||||
SysClkThermalSensor_Skin,
|
||||
SysClkThermalSensor_EnumMax
|
||||
} SysClkThermalSensor;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t enabled;
|
||||
uint64_t applicationId;
|
||||
SysClkProfile profile;
|
||||
uint32_t freqs[SysClkModule_EnumMax];
|
||||
uint32_t overrideFreqs[SysClkModule_EnumMax];
|
||||
uint32_t temps[SysClkThermalSensor_EnumMax];
|
||||
uint32_t perfConfId;
|
||||
} SysClkContext;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ReverseNX_NotFound = 0,
|
||||
ReverseNX_SystemDefault = 0,
|
||||
ReverseNX_Handheld,
|
||||
ReverseNX_Docked,
|
||||
} ReverseNXMode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool systemCoreBoostCPU;
|
||||
bool batteryChargingDisabledOverride;
|
||||
SysClkProfile realProfile;
|
||||
} SysClkOcExtra;
|
||||
|
||||
#define FREQ_TABLE_MAX_ENTRY_COUNT 31
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t freq[FREQ_TABLE_MAX_ENTRY_COUNT];
|
||||
} SysClkFrequencyTable;
|
||||
|
||||
typedef enum {
|
||||
SysClkOcGovernorConfig_AllDisabled = 0,
|
||||
SysClkOcGovernorConfig_CPU_Shift = 0,
|
||||
SysClkOcGovernorConfig_CPUOnly = 1 << SysClkOcGovernorConfig_CPU_Shift,
|
||||
SysClkOcGovernorConfig_CPU = 1 << SysClkOcGovernorConfig_CPU_Shift,
|
||||
SysClkOcGovernorConfig_GPU_Shift = 1,
|
||||
SysClkOcGovernorConfig_GPUOnly = 1 << SysClkOcGovernorConfig_GPU_Shift,
|
||||
SysClkOcGovernorConfig_GPU = 1 << SysClkOcGovernorConfig_GPU_Shift,
|
||||
SysClkOcGovernorConfig_AllEnabled = 3,
|
||||
SysClkOcGovernorConfig_Default = 3,
|
||||
SysClkOcGovernorConfig_Mask = 3,
|
||||
} SysClkOcGovernorConfig;
|
||||
|
||||
inline bool GetGovernorEnabled(SysClkOcGovernorConfig config, SysClkModule module) {
|
||||
switch (module) {
|
||||
case SysClkModule_CPU:
|
||||
return (config >> SysClkOcGovernorConfig_CPU_Shift) & 1;
|
||||
case SysClkModule_GPU:
|
||||
return (config >> SysClkOcGovernorConfig_GPU_Shift) & 1;
|
||||
case SysClkModule_MEM:
|
||||
return false;
|
||||
default:
|
||||
return config != SysClkOcGovernorConfig_AllDisabled;
|
||||
}
|
||||
}
|
||||
|
||||
inline SysClkOcGovernorConfig ToggleGovernor(SysClkOcGovernorConfig prev, SysClkModule module, bool state) {
|
||||
uint8_t shift;
|
||||
switch (module) {
|
||||
case SysClkModule_CPU:
|
||||
shift = SysClkOcGovernorConfig_CPU_Shift;
|
||||
break;
|
||||
case SysClkModule_GPU:
|
||||
shift = SysClkOcGovernorConfig_GPU_Shift;
|
||||
break;
|
||||
case SysClkModule_MEM:
|
||||
return prev;
|
||||
default:
|
||||
return state ? SysClkOcGovernorConfig_AllEnabled : SysClkOcGovernorConfig_AllDisabled;
|
||||
}
|
||||
return (SysClkOcGovernorConfig)((prev & ~(1 << shift)) | state << shift);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union {
|
||||
uint32_t mhz[(size_t)SysClkProfile_EnumMax * (size_t)SysClkModule_EnumMax];
|
||||
uint32_t mhzMap[SysClkProfile_EnumMax][SysClkModule_EnumMax];
|
||||
};
|
||||
SysClkOcGovernorConfig governorConfig;
|
||||
} SysClkTitleProfileList;
|
||||
|
||||
#define SYSCLK_GLOBAL_PROFILE_TID 0xA111111111111111
|
||||
|
||||
extern uint32_t g_freq_table_mem_hz[];
|
||||
extern uint32_t g_freq_table_cpu_hz[];
|
||||
extern uint32_t g_freq_table_gpu_hz[];
|
||||
|
||||
#define SYSCLK_ENUM_VALID(n, v) ((v) < n##_EnumMax)
|
||||
|
||||
static inline const char* sysclkFormatModule(SysClkModule module, bool pretty)
|
||||
{
|
||||
switch(module)
|
||||
{
|
||||
case SysClkModule_CPU:
|
||||
return pretty ? "CPU" : "cpu";
|
||||
case SysClkModule_GPU:
|
||||
return pretty ? "GPU" : "gpu";
|
||||
case SysClkModule_MEM:
|
||||
return pretty ? "Memory" : "mem";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline const char* sysclkFormatThermalSensor(SysClkThermalSensor thermSensor, bool pretty)
|
||||
{
|
||||
switch(thermSensor)
|
||||
{
|
||||
case SysClkThermalSensor_SOC:
|
||||
return pretty ? "SOC" : "soc";
|
||||
case SysClkThermalSensor_PCB:
|
||||
return pretty ? "PCB" : "pcb";
|
||||
case SysClkThermalSensor_Skin:
|
||||
return pretty ? "Skin" : "skin";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline const char* sysclkFormatProfile(SysClkProfile profile, bool pretty)
|
||||
{
|
||||
switch(profile)
|
||||
{
|
||||
case SysClkProfile_Docked:
|
||||
return pretty ? "Docked" : "docked";
|
||||
case SysClkProfile_Handheld:
|
||||
return pretty ? "Handheld" : "handheld";
|
||||
case SysClkProfile_HandheldCharging:
|
||||
return pretty ? "Charging" : "handheld_charging";
|
||||
case SysClkProfile_HandheldChargingUSB:
|
||||
return pretty ? "USB Charger" : "handheld_charging_usb";
|
||||
case SysClkProfile_HandheldChargingOfficial:
|
||||
return pretty ? "Official Charger" : "handheld_charging_official";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
const uint32_t CHARGING_CURRENT_MA_LIMIT = 2000;
|
||||
|
||||
typedef enum {
|
||||
SysClkConfigValue_PollingIntervalMs = 0,
|
||||
SysClkConfigValue_TempLogIntervalMs,
|
||||
SysClkConfigValue_CsvWriteIntervalMs,
|
||||
SysClkConfigValue_AutoCPUBoost,
|
||||
SysClkConfigValue_SyncReverseNXMode,
|
||||
SysClkConfigValue_AllowUnsafeFrequencies,
|
||||
SysClkConfigValue_ChargingCurrentLimit,
|
||||
SysClkConfigValue_ChargingLimitPercentage,
|
||||
SysClkConfigValue_GovernorExperimental,
|
||||
SysClkConfigValue_GovernorHandheldOnly,
|
||||
SysClkConfigValue_EnumMax,
|
||||
} SysClkConfigValue;
|
||||
|
||||
typedef struct {
|
||||
uint64_t values[SysClkConfigValue_EnumMax];
|
||||
} SysClkConfigValueList;
|
||||
|
||||
static inline const char* sysclkFormatConfigValue(SysClkConfigValue val, bool pretty)
|
||||
{
|
||||
switch(val)
|
||||
{
|
||||
case SysClkConfigValue_PollingIntervalMs:
|
||||
return pretty ? "Polling Interval (ms)" : "poll_interval_ms";
|
||||
case SysClkConfigValue_TempLogIntervalMs:
|
||||
return pretty ? "Temperature logging interval (ms)" : "temp_log_interval_ms";
|
||||
case SysClkConfigValue_CsvWriteIntervalMs:
|
||||
return pretty ? "CSV write interval (ms)" : "csv_write_interval_ms";
|
||||
case SysClkConfigValue_AutoCPUBoost:
|
||||
return pretty ? "Auto CPU Boost" : "auto_cpu_boost";
|
||||
case SysClkConfigValue_SyncReverseNXMode:
|
||||
return pretty ? "Sync ReverseNX Mode Sync" : "sync_reversenx_mode";
|
||||
case SysClkConfigValue_AllowUnsafeFrequencies:
|
||||
return pretty ? "Allow Unsafe Frequencies" : "allow_unsafe_freq";
|
||||
case SysClkConfigValue_ChargingCurrentLimit:
|
||||
return pretty ? "Charging Current Limit (mA)" : "charging_current";
|
||||
case SysClkConfigValue_ChargingLimitPercentage:
|
||||
return pretty ? "Charging Limit (%%)" : "charging_limit_perc";
|
||||
case SysClkConfigValue_GovernorExperimental:
|
||||
return pretty ? "Frequency Governor (Experimental)" : "governor_experimental";
|
||||
case SysClkConfigValue_GovernorHandheldOnly:
|
||||
return pretty ? "Frequency Governor Handheld Only" : "governor_handheld_only";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint64_t sysclkDefaultConfigValue(SysClkConfigValue val)
|
||||
{
|
||||
switch(val)
|
||||
{
|
||||
case SysClkConfigValue_PollingIntervalMs:
|
||||
return 500ULL;
|
||||
case SysClkConfigValue_TempLogIntervalMs:
|
||||
case SysClkConfigValue_CsvWriteIntervalMs:
|
||||
case SysClkConfigValue_AllowUnsafeFrequencies:
|
||||
case SysClkConfigValue_GovernorExperimental:
|
||||
case SysClkConfigValue_GovernorHandheldOnly:
|
||||
case SysClkConfigValue_AutoCPUBoost:
|
||||
return 0ULL;
|
||||
case SysClkConfigValue_SyncReverseNXMode:
|
||||
return 1ULL;
|
||||
case SysClkConfigValue_ChargingCurrentLimit:
|
||||
return 2000ULL;
|
||||
case SysClkConfigValue_ChargingLimitPercentage:
|
||||
return 100ULL;
|
||||
default:
|
||||
return 0ULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint64_t sysclkValidConfigValue(SysClkConfigValue val, uint64_t input)
|
||||
{
|
||||
switch(val)
|
||||
{
|
||||
case SysClkConfigValue_PollingIntervalMs:
|
||||
return input > 0;
|
||||
case SysClkConfigValue_TempLogIntervalMs:
|
||||
case SysClkConfigValue_CsvWriteIntervalMs:
|
||||
return true;
|
||||
case SysClkConfigValue_AutoCPUBoost:
|
||||
case SysClkConfigValue_SyncReverseNXMode:
|
||||
case SysClkConfigValue_AllowUnsafeFrequencies:
|
||||
case SysClkConfigValue_GovernorExperimental:
|
||||
case SysClkConfigValue_GovernorHandheldOnly:
|
||||
return (input & 0x1) == input;
|
||||
case SysClkConfigValue_ChargingCurrentLimit:
|
||||
return (input >= 100 && input <= CHARGING_CURRENT_MA_LIMIT && input % 100 == 0);
|
||||
case SysClkConfigValue_ChargingLimitPercentage:
|
||||
return (input <= 100 && input >= 20);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define SYSCLK_ERROR_MODULE 388
|
||||
#define SYSCLK_ERROR(desc) ((SYSCLK_ERROR_MODULE & 0x1FF) | (SysClkError_##desc & 0x1FFF)<<9)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SysClkError_Generic = 0,
|
||||
SysClkError_ConfigNotLoaded = 1,
|
||||
SysClkError_ConfigSaveFailed = 2,
|
||||
SysClkError_InternalFrequencyTableError = 3,
|
||||
} SysClkError;
|
||||
@@ -1,57 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
// To use i2c service, sm and i2c should be intialized via smInitialize() and i2cInitialize().
|
||||
|
||||
Result I2cSet_U8(I2cDevice dev, u8 reg, u8 val);
|
||||
|
||||
Result I2cRead_OutU8(I2cDevice dev, u8 reg, u8 *out);
|
||||
Result I2cRead_OutU16(I2cDevice dev, u8 reg, u16 *out);
|
||||
|
||||
// Max17050 fuel gauge
|
||||
float I2c_Max17050_GetBatteryCurrent();
|
||||
|
||||
const u8 MAX17050_CURRENT_REG = 0x0A;
|
||||
|
||||
// Buck Converter
|
||||
typedef enum I2c_BuckConverter_Reg {
|
||||
I2c_Max77620_SD1VOLT_REG = 0x17, // Used for Erista DDR VDDQ+VDD2 / Mariko VDD2
|
||||
I2c_Max77621_VOLT_REG = 0x00,
|
||||
I2c_Max77812_CPUVOLT_REG = 0x26,
|
||||
I2c_Max77812_GPUVOLT_REG = 0x23,
|
||||
I2c_Max77812_MEMVOLT_REG = 0x25, // Master 3 (GPU 1 + 2, DRAM 3, CPU 4), used for Mariko VDDQ
|
||||
} I2c_BuckConverter_Reg;
|
||||
|
||||
typedef struct I2c_BuckConverter_Domain {
|
||||
I2cDevice device;
|
||||
I2c_BuckConverter_Reg reg;
|
||||
u8 volt_mask;
|
||||
u32 uv_step;
|
||||
u32 uv_min;
|
||||
u32 uv_max;
|
||||
u8 por_val;
|
||||
} I2c_BuckConverter_Domain;
|
||||
|
||||
const I2c_BuckConverter_Domain I2c_Erista_CPU = { I2cDevice_Max77621Cpu, I2c_Max77621_VOLT_REG, 0x7F, 6250, 606250, 1400000, };
|
||||
const I2c_BuckConverter_Domain I2c_Erista_GPU = { I2cDevice_Max77621Gpu, I2c_Max77621_VOLT_REG, 0x7F, 6250, 606250, 1400000, };
|
||||
const I2c_BuckConverter_Domain I2c_Erista_DRAM = { I2cDevice_Max77620Pmic, I2c_Max77620_SD1VOLT_REG, 0x7F, 12500, 600000, 1250000, };
|
||||
const I2c_BuckConverter_Domain I2c_Mariko_CPU = { I2cDevice_Max77812_2, I2c_Max77812_CPUVOLT_REG, 0xFF, 5000, 250000, 1525000, 0x78 };
|
||||
const I2c_BuckConverter_Domain I2c_Mariko_GPU = { I2cDevice_Max77812_2, I2c_Max77812_GPUVOLT_REG, 0xFF, 5000, 250000, 1525000, 0x78 };
|
||||
const I2c_BuckConverter_Domain I2c_Mariko_DRAM_VDDQ = { I2cDevice_Max77812_2, I2c_Max77812_MEMVOLT_REG, 0xFF, 5000, 250000, 650000, 0x78 };
|
||||
const I2c_BuckConverter_Domain I2c_Mariko_DRAM_VDD2 = { I2cDevice_Max77620Pmic, I2c_Max77620_SD1VOLT_REG, 0x7F, 12500, 600000, 1250000, };
|
||||
|
||||
u32 I2c_BuckConverter_GetMvOut(const I2c_BuckConverter_Domain* domain);
|
||||
Result I2c_BuckConverter_SetMvOut(const I2c_BuckConverter_Domain* domain, u32 mvolt);
|
||||
|
||||
// Bq24193 Battery management
|
||||
u32 I2c_Bq24193_Convert_Raw_mA(u8 raw);
|
||||
u8 I2c_Bq24193_Convert_mA_Raw(u32 ma);
|
||||
|
||||
Result I2c_Bq24193_GetFastChargeCurrentLimit(u32 *ma);
|
||||
Result I2c_Bq24193_SetFastChargeCurrentLimit(u32 ma);
|
||||
|
||||
const u32 MA_RANGE_MIN = 512;
|
||||
const u32 MA_RANGE_MAX = 4544;
|
||||
|
||||
const u8 BQ24193_CHARGE_CURRENT_CONTROL_REG = 0x2;
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* --------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
|
||||
* wrote this file. As long as you retain this notice you can do whatever you
|
||||
* want with this stuff. If you meet any of us some day, and you think this
|
||||
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "clocks.h"
|
||||
|
||||
#define SYSCLK_IPC_API_VERSION 2
|
||||
#define SYSCLK_IPC_SERVICE_NAME "sysclkOC"
|
||||
|
||||
enum SysClkIpcCmd
|
||||
{
|
||||
SysClkIpcCmd_GetApiVersion = 0,
|
||||
SysClkIpcCmd_GetVersionString = 1,
|
||||
SysClkIpcCmd_GetCurrentContext = 2,
|
||||
SysClkIpcCmd_Exit = 3,
|
||||
SysClkIpcCmd_GetProfileCount = 4,
|
||||
SysClkIpcCmd_GetProfiles = 5,
|
||||
SysClkIpcCmd_SetProfiles = 6,
|
||||
SysClkIpcCmd_SetEnabled = 7,
|
||||
SysClkIpcCmd_SetOverride = 8,
|
||||
SysClkIpcCmd_GetConfigValues = 9,
|
||||
SysClkIpcCmd_SetConfigValues = 10,
|
||||
SysClkIpcCmd_SetReverseNXRTMode = 11,
|
||||
SysClkIpcCmd_GetFrequencyTable = 12,
|
||||
SysClkIpcCmd_GetIsMariko = 13,
|
||||
SysClkIpcCmd_GetBatteryChargingDisabledOverride = 14,
|
||||
SysClkIpcCmd_SetBatteryChargingDisabledOverride = 15,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t tid;
|
||||
SysClkTitleProfileList profiles;
|
||||
} SysClkIpc_SetProfiles_Args;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SysClkModule module;
|
||||
uint32_t hz;
|
||||
} SysClkIpc_SetOverride_Args;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SysClkModule module;
|
||||
SysClkProfile profile;
|
||||
} SysClkIpc_GetFrequencyTable_Args;
|
||||
@@ -1,77 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <switch.h>
|
||||
|
||||
typedef enum {
|
||||
PsmPDC_NewPDO = 1, //Received new Power Data Object
|
||||
PsmPDC_NoPD = 2, //No Power Delivery source is detected
|
||||
PsmPDC_AcceptedRDO = 3 //Received and accepted Request Data Object
|
||||
} PsmChargeInfoPDC; //BM92T series
|
||||
|
||||
typedef enum {
|
||||
PsmPowerRole_Sink = 1,
|
||||
PsmPowerRole_Source = 2
|
||||
} PsmPowerRole;
|
||||
|
||||
const char* PsmPowerRoleToStr(PsmPowerRole role);
|
||||
|
||||
typedef enum {
|
||||
PsmInfoChargerType_None = 0,
|
||||
PsmInfoChargerType_PD = 1,
|
||||
PsmInfoChargerType_TypeC_1500mA = 2,
|
||||
PsmInfoChargerType_TypeC_3000mA = 3,
|
||||
PsmInfoChargerType_DCP = 4,
|
||||
PsmInfoChargerType_CDP = 5,
|
||||
PsmInfoChargerType_SDP = 6,
|
||||
PsmInfoChargerType_Apple_500mA = 7,
|
||||
PsmInfoChargerType_Apple_1000mA = 8,
|
||||
PsmInfoChargerType_Apple_2000mA = 9
|
||||
} PsmInfoChargerType;
|
||||
|
||||
const char* PsmInfoChargerTypeToStr(PsmInfoChargerType type);
|
||||
|
||||
typedef enum {
|
||||
PsmFlags_NoHub = BIT(0), //If hub is disconnected
|
||||
PsmFlags_Rail = BIT(8), //At least one Joy-con is charging from rail
|
||||
PsmFlags_SPDSRC = BIT(12), //OTG
|
||||
PsmFlags_ACC = BIT(16) //Accessory
|
||||
} PsmChargeInfoFlags;
|
||||
|
||||
typedef struct {
|
||||
int32_t InputCurrentLimit; //Input (Sink) current limit in mA
|
||||
int32_t VBUSCurrentLimit; //Output (Source/VBUS/OTG) current limit in mA
|
||||
int32_t ChargeCurrentLimit; //Battery charging current limit in mA (512mA when Docked, 768mA when BatteryTemperature < 17.0 C)
|
||||
int32_t ChargeVoltageLimit; //Battery charging voltage limit in mV (3952mV when BatteryTemperature >= 51.0 C)
|
||||
int32_t unk_x10; //Possibly an emum, getting the same value as PowerRole in all tested cases
|
||||
int32_t unk_x14; //Possibly flags
|
||||
PsmChargeInfoPDC PDCState; //Power Delivery Controller State
|
||||
int32_t BatteryTemperature; //Battery temperature in milli C
|
||||
int32_t RawBatteryCharge; //Raw battery charged capacity per cent-mille (i.e. 100% = 100000 pcm)
|
||||
int32_t VoltageAvg; //Voltage avg in mV (more in Notes)
|
||||
int32_t BatteryAge; //Battery age (capacity full / capacity design) per cent-mille (i.e. 100% = 100000 pcm)
|
||||
PsmPowerRole PowerRole;
|
||||
PsmInfoChargerType ChargerType;
|
||||
int32_t ChargerVoltageLimit; //Charger and external device voltage limit in mV
|
||||
int32_t ChargerCurrentLimit; //Charger and external device current limit in mA
|
||||
PsmChargeInfoFlags Flags; //Unknown flags
|
||||
} PsmChargeInfo;
|
||||
|
||||
typedef enum {
|
||||
Psm_EnableBatteryCharging = 2,
|
||||
Psm_DisableBatteryCharging = 3,
|
||||
Psm_EnableFastBatteryCharging = 10,
|
||||
Psm_DisableFastBatteryCharging = 11,
|
||||
Psm_GetBatteryChargeInfoFields = 17,
|
||||
} IPsmServerCmd;
|
||||
|
||||
bool PsmIsChargerConnected(const PsmChargeInfo* info);
|
||||
bool PsmIsCharging(const PsmChargeInfo* info);
|
||||
|
||||
typedef enum {
|
||||
PsmBatteryState_Discharging,
|
||||
PsmBatteryState_ChargingPaused,
|
||||
PsmBatteryState_FastCharging
|
||||
} PsmBatteryState;
|
||||
|
||||
PsmBatteryState PsmGetBatteryState(const PsmChargeInfo* info);
|
||||
const char* PsmGetBatteryStateIcon(const PsmChargeInfo* info);
|
||||
Reference in New Issue
Block a user