Skip to content

Commit b004cbb

Browse files
committed
WIP: Retimer test
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent e507a96 commit b004cbb

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

framework_lib/src/commandline/clap_std.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ struct ClapCli {
263263
#[arg(long, short)]
264264
test: bool,
265265

266+
/// Run self-test to check if interaction with retimers is possible
267+
#[arg(long)]
268+
test_retimer: bool,
269+
266270
/// Force execution of an unsafe command - may render your hardware unbootable!
267271
#[arg(long, short)]
268272
force: bool,
@@ -455,6 +459,7 @@ pub fn parse(args: &[String]) -> Cli {
455459
pd_addrs,
456460
pd_ports,
457461
test: args.test,
462+
test_retimer: args.test_retimer,
458463
dry_run: args.dry_run,
459464
force: args.force,
460465
// TODO: Set help. Not very important because Clap handles this by itself

framework_lib/src/commandline/mod.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ pub struct Cli {
188188
pub flash_rw_ec: Option<String>,
189189
pub driver: Option<CrosEcDriverType>,
190190
pub test: bool,
191+
pub test_retimer: bool,
191192
pub dry_run: bool,
192193
pub force: bool,
193194
pub intrusion: bool,
@@ -271,6 +272,7 @@ pub fn parse(args: &[String]) -> Cli {
271272
// flash_rw_ec
272273
driver: cli.driver,
273274
test: cli.test,
275+
test_retimer: cli.test_retimer,
274276
dry_run: cli.dry_run,
275277
// force
276278
intrusion: cli.intrusion,
@@ -1174,6 +1176,11 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
11741176
println!("FAILED!!");
11751177
return 1;
11761178
}
1179+
} else if args.test_retimer {
1180+
println!("Retimer Self-Test");
1181+
if let Err(err) = selftest_retimer(&ec) {
1182+
println!(" Failed: {:?}", err);
1183+
}
11771184
} else if args.power {
11781185
return power::get_and_print_power_info(&ec);
11791186
} else if args.thermal {
@@ -1604,6 +1611,55 @@ fn selftest(ec: &CrosEc) -> Option<()> {
16041611
Some(())
16051612
}
16061613

1614+
// Platforms that have Retimers
1615+
// Retimer I2C is always connected to the CPU, except for the Framework 16 dGPU retimer.
1616+
//
1617+
// - Framework 12
1618+
// - No Retimer, only retimer for both left ports (no firmware)
1619+
// - Framework 13 Intel
1620+
// - One Intel retimer for each port (with firmware)
1621+
// - Framework 13 AMD 7040
1622+
// - Kandou Retimer on top two ports (no firmware)
1623+
// - Analogix Retimer on bottom two ports (no firmware)
1624+
// - Framework 13 AMD AI 300
1625+
// - Parade Retimer on top two ports (with firmware)
1626+
// - Analogix Retimer on bottom two ports (no firmware)
1627+
// - Framework 16 AMD 7040
1628+
// - Kandou Retimer on top two ports (no firmware)
1629+
// - Analogix Retimer on lower and middle left ports (no firmware)
1630+
// - Framework 16 AMD AI 300
1631+
// - Parade Retimer on top two ports (with firmware)
1632+
// - Framework 16 AMD dGPU
1633+
// - None
1634+
// - Framework 16 NVIDIA dGPU
1635+
// - Parade Retimer
1636+
// - Framework Desktop
1637+
// - Parade Retimer on both back ports (with firmware)
1638+
fn selftest_retimer(ec: &CrosEc) -> EcResult<()> {
1639+
// TODO: Make sure that it can work for the NVIDIA dGPU retimer and increase to 3
1640+
for i in 0..2 {
1641+
let update_mode = ec.retimer_in_fwupd_mode(i);
1642+
if update_mode == Err(EcError::Response(EcResponseStatus::InvalidParameter)) {
1643+
println!(" Retimer status not supported on this platform. Cannot test");
1644+
return Ok(());
1645+
}
1646+
println!(" Retimers on PD Controller {}", i);
1647+
println!(" In update mode: {:?}", update_mode);
1648+
if update_mode? {
1649+
println!(" Unexpected! During normal operaton it should not be in update mode! Disabling...");
1650+
ec.retimer_enable_fwupd(i, false)?;
1651+
}
1652+
println!(" Enabling update mode");
1653+
let success = ec.retimer_enable_fwupd(i, true);
1654+
println!(" Success: {:?}", success);
1655+
1656+
println!(" Disabling again");
1657+
ec.retimer_enable_fwupd(i, false)?;
1658+
success?;
1659+
}
1660+
Ok(())
1661+
}
1662+
16071663
fn smbios_info() {
16081664
println!("Summary");
16091665
println!(" Is Framework: {}", is_framework());

0 commit comments

Comments
 (0)