Skip to content

Commit c516d4b

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

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 {
@@ -1606,6 +1613,55 @@ fn selftest(ec: &CrosEc) -> Option<()> {
16061613
Some(())
16071614
}
16081615

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

0 commit comments

Comments
 (0)