Skip to content

Commit 90192e2

Browse files
committed
--test-retimer: Allow testing retimer update mode
Only on systems with Intel retimer (Framework 13 with Intel CPU) This is what it's supposed to look like. Update mode for each port: false, true, false ``` > framework_tool --test-retimer Retimer Self-Test Retimers on PD Controller 0 In update mode: false Enabling update mode In update mode: true Disabling update mode In update mode: false Retimers on PD Controller 1 In update mode: false Enabling update mode In update mode: true Disabling update mode In update mode: false ``` Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 5b7ac43 commit 90192e2

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-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: 68 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,67 @@ 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!(
1650+
" In update mode: {:?}",
1651+
ec.retimer_in_fwupd_mode(i).unwrap()
1652+
);
1653+
if update_mode? {
1654+
println!(" Disabling it to start test.");
1655+
ec.retimer_enable_fwupd(i, false)?;
1656+
}
1657+
1658+
println!(" Enabling update mode");
1659+
let success = ec.retimer_enable_fwupd(i, true);
1660+
println!(
1661+
" In update mode: {:?}",
1662+
ec.retimer_in_fwupd_mode(i).unwrap()
1663+
);
1664+
1665+
println!(" Disabling update mode");
1666+
ec.retimer_enable_fwupd(i, false)?;
1667+
os_specific::sleep(100);
1668+
println!(
1669+
" In update mode: {:?}",
1670+
ec.retimer_in_fwupd_mode(i).unwrap()
1671+
);
1672+
success?;
1673+
}
1674+
Ok(())
1675+
}
1676+
16091677
fn smbios_info() {
16101678
println!("Summary");
16111679
println!(" Is Framework: {}", is_framework());

framework_lib/src/commandline/uefi.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pub fn parse(args: &[String]) -> Cli {
8484
pd_addrs: None,
8585
pd_ports: None,
8686
test: false,
87+
test_retimer: false,
8788
dry_run: false,
8889
force: false,
8990
help: false,
@@ -495,6 +496,9 @@ pub fn parse(args: &[String]) -> Cli {
495496
} else if arg == "-t" || arg == "--test" {
496497
cli.test = true;
497498
found_an_option = true;
499+
} else if arg == "-t" || arg == "--test-retimer" {
500+
cli.test_retimer = true;
501+
found_an_option = true;
498502
} else if arg == "-f" || arg == "--force" {
499503
cli.force = true;
500504
found_an_option = true;

0 commit comments

Comments
 (0)