Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier --test command #53

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions framework_lib/src/ccgx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ pub struct PdVersions {
}

/// Same as PdVersions but only the main FW
#[derive(Debug)]
pub struct MainPdVersions {
pub controller01: ControllerVersion,
pub controller23: ControllerVersion,
Expand Down
29 changes: 22 additions & 7 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use crate::chromium_ec;
use crate::chromium_ec::commands::DeckStateMode;
use crate::chromium_ec::commands::FpLedBrightnessLevel;
use crate::chromium_ec::commands::RebootEcCmd;
use crate::chromium_ec::EcResponseStatus;
use crate::chromium_ec::{print_err, EcFlashType};
use crate::chromium_ec::{EcError, EcResult};
#[cfg(feature = "linux")]
Expand Down Expand Up @@ -1049,14 +1050,16 @@ fn selftest(ec: &CrosEc) -> Option<()> {
println!(" Reading EC Build Version");
print_err(ec.version_info())?;

println!(" Reading EC Flash by EC");
print!(" Reading EC Flash by EC");
ec.flash_version()?;
println!(" - OK");

println!(" Reading EC Flash directly");
println!(" Reading EC Flash directly - See below");
ec.test_ec_flash_read().ok()?;

println!(" Getting power info from EC");
print!(" Getting power info from EC");
power::power_info(ec)?;
println!(" - OK");

println!(" Getting AC info from EC");
// All our laptops have at least 4 PD ports so far
Expand All @@ -1065,19 +1068,31 @@ fn selftest(ec: &CrosEc) -> Option<()> {
return None;
}

// Try to get PD versions through EC
power::read_pd_version(ec).ok()?;
print!("Reading PD Version from EC");
if let Err(err) = power::read_pd_version(ec) {
// TGL does not have this command, so we have to ignore it
if err != EcError::Response(EcResponseStatus::InvalidCommand) {
println!();
println!("Err: {:?}", err);
} else {
println!(" - Skipped");
}
} else {
println!(" - OK");
}

let pd_01 = PdController::new(PdPort::Left01, ec.clone());
let pd_23 = PdController::new(PdPort::Right23, ec.clone());
println!(" Getting PD01 info");
print!(" Getting PD01 info through I2C tunnel");
print_err(pd_01.get_silicon_id())?;
print_err(pd_01.get_device_info())?;
print_err(pd_01.get_fw_versions())?;
println!(" Getting PD23 info");
println!(" - OK");
print!(" Getting PD23 info through I2C tunnel");
print_err(pd_23.get_silicon_id())?;
print_err(pd_23.get_device_info())?;
print_err(pd_23.get_fw_versions())?;
println!(" - OK");

Some(())
}
Expand Down
1 change: 1 addition & 0 deletions framework_lib/src/power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ pub fn print_memmap_version_info(ec: &CrosEc) {
let _events_ver = ec.read_memory(EC_MEMMAP_EVENTS_VERSION, 2).unwrap();
}

/// Not supported on TGL EC
pub fn get_als_reading(ec: &CrosEc) -> Option<u32> {
let als = ec.read_memory(EC_MEMMAP_ALS, 0x04)?;
Some(u32::from_le_bytes([als[0], als[1], als[2], als[3]]))
Expand Down