[sys-clk-OC] Disable unsafe frequencies by default; Remove emulator-mode; Move fast-charging handler to sysmodule

This commit is contained in:
KazushiM
2022-05-15 17:48:24 +08:00
parent fd77dfa6eb
commit 6f5de53382
14 changed files with 222 additions and 100 deletions

View File

@@ -32,6 +32,64 @@ class ClockManager
SysClkContext GetCurrentContext();
Config* GetConfig();
typedef enum {
PDCtrler_NewPDO = 1, //Received new Power Data Object
PDCtrler_NoPD = 2, //No Power Delivery source is detected
PDCtrler_AcceptedRDO = 3 //Received and accepted Request Data Object
} ChargeInfoPDCtrler; //BM92T series
typedef enum {
PowerRole_Sink = 1,
PowerRole_Source = 2
} ChargeInfoPowerRole;
typedef enum {
ChargerType_None = 0,
ChargerType_PD = 1,
ChargerType_TypeC_1500mA = 2,
ChargerType_TypeC_3000mA = 3,
ChargerType_DCP = 4,
ChargerType_CDP = 5,
ChargerType_SDP = 6,
ChargerType_Apple_500mA = 7,
ChargerType_Apple_1000mA = 8,
ChargerType_Apple_2000mA = 9
} ChargeInfoChargerType;
typedef enum {
Flags_NoHub = BIT(0), //If hub is disconnected
Flags_Rail = BIT(8), //At least one Joy-con is charging from rail
Flags_SPDSRC = BIT(12), //OTG
Flags_ACC = BIT(16) //Accessory
} ChargeInfoFlags;
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
ChargeInfoPDCtrler PDCtrlerState; //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)
ChargeInfoPowerRole PowerRole;
ChargeInfoChargerType ChargerType;
int32_t ChargerVoltageLimit; //Charger and external device voltage limit in mV
int32_t ChargerCurrentLimit; //Charger and external device current limit in mA
ChargeInfoFlags Flags; //Unknown flags
} ChargeInfo;
typedef enum {
EnableBatteryCharging = 2,
DisableBatteryCharging = 3,
EnableFastBatteryCharging = 10,
DisableFastBatteryCharging = 11,
GetBatteryChargeInfoFields = 17,
} IPsmServerCmd;
protected:
ClockManager();
virtual ~ClockManager();
@@ -58,4 +116,6 @@ class ClockManager
void CheckReverseNXTool();
bool CheckReverseNXRT();
void ChargingHandler();
};