Skip to content

Commit 80d6426

Browse files
committed
--thermal: Add AP throttle status
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 30b0ffb commit 80d6426

5 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎EXAMPLES.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ sensors and number of fans, so your output may look different:
488488
F75303_DDR: 39 C
489489
APU: 62 C
490490
API Fan: 0 RPM
491+
AP Throttle Status
492+
Soft: false
493+
Hard: false
491494
```
492495

493496
## Check sensors

‎framework_lib/src/chromium_ec/command.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ pub enum EcCommands {
113113
ProgramGpuEeprom = 0x3E1F,
114114
/// Get battery cutoff (ship mode) status
115115
GetCutoffStatus = 0x3E21,
116+
/// This command return the AP throttle status
117+
GetApThrottleStatus = 0x3E22,
116118
/// Get PD port state from Cypress PD controller
117119
GetPdPortState = 0x3E23,
118120
/// Read board ID of specific ADC channel

‎framework_lib/src/chromium_ec/commands.rs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,3 +1787,19 @@ impl EcRequest<EcResponseReadBoardId> for EcRequestReadBoardId {
17871787
EcCommands::ReadBoardId
17881788
}
17891789
}
1790+
1791+
#[repr(C, packed)]
1792+
pub struct EcRequestGetApThrottleStatus {}
1793+
1794+
#[repr(C, packed)]
1795+
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
1796+
pub struct EcResponseGetApThrottleStatus {
1797+
pub soft_ap_throttle: u8,
1798+
pub hard_ap_throttle: u8,
1799+
}
1800+
1801+
impl EcRequest<EcResponseGetApThrottleStatus> for EcRequestGetApThrottleStatus {
1802+
fn command_id() -> EcCommands {
1803+
EcCommands::GetApThrottleStatus
1804+
}
1805+
}

‎framework_lib/src/chromium_ec/mod.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,10 @@ impl CrosEc {
19751975
}
19761976
Ok(())
19771977
}
1978+
1979+
pub fn get_ap_throttle_status(&self) -> EcResult<EcResponseGetApThrottleStatus> {
1980+
EcRequestGetApThrottleStatus {}.send_command(self)
1981+
}
19781982
}
19791983

19801984
#[cfg_attr(not(feature = "uefi"), derive(clap::ValueEnum))]

‎framework_lib/src/power.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,14 @@ pub fn print_thermal(ec: &CrosEc) {
466466
println!(" {name:<11} {:>4} RPM", fan);
467467
}
468468
}
469+
470+
println!(" AP Throttle Status");
471+
if let Ok(throttle) = ec.get_ap_throttle_status() {
472+
println!(" Soft: {:?}", throttle.soft_ap_throttle == 1);
473+
println!(" Hard: {:?}", throttle.hard_ap_throttle == 1);
474+
} else {
475+
println!(" Unknown");
476+
}
469477
}
470478

471479
pub fn get_fan_num(ec: &CrosEc) -> EcResult<usize> {

0 commit comments

Comments
 (0)