From 60853b4ee90518b4c9a0da23dc12b4f1cf19df87 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Tue, 8 Oct 2024 06:49:46 +0800 Subject: [PATCH] --thermal: Add AP throttle status Signed-off-by: Daniel Schaefer --- EXAMPLES.md | 3 +++ framework_lib/src/chromium_ec/command.rs | 2 ++ framework_lib/src/chromium_ec/commands.rs | 16 ++++++++++++++++ framework_lib/src/chromium_ec/mod.rs | 4 ++++ framework_lib/src/power.rs | 8 ++++++++ 5 files changed, 33 insertions(+) diff --git a/EXAMPLES.md b/EXAMPLES.md index 8f3819b..3a96cf2 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -488,6 +488,9 @@ sensors and number of fans, so your output may look different: F75303_DDR: 39 C APU: 62 C API Fan: 0 RPM + AP Throttle Status + Soft: false + Hard: false ``` ## Check sensors diff --git a/framework_lib/src/chromium_ec/command.rs b/framework_lib/src/chromium_ec/command.rs index 6774922..b3067fa 100644 --- a/framework_lib/src/chromium_ec/command.rs +++ b/framework_lib/src/chromium_ec/command.rs @@ -113,6 +113,8 @@ pub enum EcCommands { ProgramGpuEeprom = 0x3E1F, /// Get battery cutoff (ship mode) status GetCutoffStatus = 0x3E21, + /// This command return the AP throttle status + GetApThrottleStatus = 0x3E22, /// Get PD port state from Cypress PD controller GetPdPortState = 0x3E23, /// Read board ID of specific ADC channel diff --git a/framework_lib/src/chromium_ec/commands.rs b/framework_lib/src/chromium_ec/commands.rs index 96cab5b..e0bb0b2 100644 --- a/framework_lib/src/chromium_ec/commands.rs +++ b/framework_lib/src/chromium_ec/commands.rs @@ -1787,3 +1787,19 @@ impl EcRequest for EcRequestReadBoardId { EcCommands::ReadBoardId } } + +#[repr(C, packed)] +pub struct EcRequestGetApThrottleStatus {} + +#[repr(C, packed)] +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct EcResponseGetApThrottleStatus { + pub soft_ap_throttle: u8, + pub hard_ap_throttle: u8, +} + +impl EcRequest for EcRequestGetApThrottleStatus { + fn command_id() -> EcCommands { + EcCommands::GetApThrottleStatus + } +} diff --git a/framework_lib/src/chromium_ec/mod.rs b/framework_lib/src/chromium_ec/mod.rs index d1efd7e..fa470f9 100644 --- a/framework_lib/src/chromium_ec/mod.rs +++ b/framework_lib/src/chromium_ec/mod.rs @@ -1975,6 +1975,10 @@ impl CrosEc { } Ok(()) } + + pub fn get_ap_throttle_status(&self) -> EcResult { + EcRequestGetApThrottleStatus {}.send_command(self) + } } #[cfg_attr(not(feature = "uefi"), derive(clap::ValueEnum))] diff --git a/framework_lib/src/power.rs b/framework_lib/src/power.rs index fd2a277..3ebff27 100644 --- a/framework_lib/src/power.rs +++ b/framework_lib/src/power.rs @@ -466,6 +466,14 @@ pub fn print_thermal(ec: &CrosEc) { println!(" {name:<11} {:>4} RPM", fan); } } + + println!(" AP Throttle Status"); + if let Ok(throttle) = ec.get_ap_throttle_status() { + println!(" Soft: {:?}", throttle.soft_ap_throttle == 1); + println!(" Hard: {:?}", throttle.hard_ap_throttle == 1); + } else { + println!(" Unknown"); + } } pub fn get_fan_num(ec: &CrosEc) -> EcResult {