Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions framework_lib/src/power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,23 @@ pub struct ApThrottleInfo {
pub hard: bool,
}

fn decode_ap_throttle(res: EcResult<EcResponseGetApThrottleStatus>) -> Option<ApThrottleInfo> {
match res {
Ok(throttle) => Some(ApThrottleInfo {
soft: throttle.soft_ap_throttle == 1,
hard: throttle.hard_ap_throttle == 1,
}),
Err(EcError::Response(EcResponseStatus::InvalidCommand)) => {
debug!("AP throttle status host command not supported by EC firmware");
None
}
Err(err) => {
warn!("Failed to read AP throttle status: {:?}", err);
None
}
}
}

/// Read temperatures, fan speeds and AP throttle status from the EC
pub fn get_thermal(ec: &CrosEc) -> EcResult<ThermalInfo> {
let temps = ec
Expand Down Expand Up @@ -641,13 +658,7 @@ pub fn get_thermal(ec: &CrosEc) -> EcResult<ThermalInfo> {
});
}

let throttle = ec
.get_ap_throttle_status()
.ok()
.map(|throttle| ApThrottleInfo {
soft: throttle.soft_ap_throttle == 1,
hard: throttle.hard_ap_throttle == 1,
});
let throttle = decode_ap_throttle(ec.get_ap_throttle_status());

Ok(ThermalInfo {
sensors,
Expand Down Expand Up @@ -690,12 +701,12 @@ pub fn print_thermal(ec: &CrosEc) {
}
}

println!(" AP Throttle Status");
if let Some(throttle) = info.throttle {
println!(" AP Throttle Status");
println!(" Soft (AMD SPPT): {:?}", throttle.soft);
println!(" Hard (PROCHOT#): {:?}", throttle.hard);
} else {
println!(" Unknown");
info!(" AP Throttle Status: Not supported");
}
}

Expand Down