@@ -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+
16091677fn smbios_info ( ) {
16101678 println ! ( "Summary" ) ;
16111679 println ! ( " Is Framework: {}" , is_framework( ) ) ;
0 commit comments