Skip to content

Commit 0bc16b3

Browse files
committed
--version: Add better debug messages for parade_retimer
-v or -vv includes the necessary debug info. Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent f9afcfe commit 0bc16b3

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

framework_lib/src/parade_retimer.rs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ use crate::os_specific;
1010
pub fn get_version(ec: &CrosEc) -> EcResult<Option<Vec<u8>>> {
1111
let res = EcRequestGetGpuPcie {}.send_command(ec)?;
1212
let vendor: Option<GpuVendor> = FromPrimitive::from_u8(res.gpu_vendor);
13+
info!("GPU vendor: {:?}", vendor);
1314
if vendor != Some(GpuVendor::NvidiaGn22) {
14-
debug!("No compatible retimer present");
15+
info!("No compatible retimer present (vendor mismatch)");
1516
return Ok(None);
1617
};
18+
info!("NVIDIA GPU detected, checking retimer...");
1719

1820
// I2C Port on the EC
1921
let i2c_port = 5;
@@ -22,19 +24,39 @@ pub fn get_version(ec: &CrosEc) -> EcResult<Option<Vec<u8>>> {
2224
let i2c_addr = 0x10;
2325

2426
// Check safe mode
27+
info!(
28+
"Reading retimer at I2C port {} addr 0x{:02X}",
29+
i2c_port,
30+
i2c_addr >> 1
31+
);
2532
let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x00, 0x01)?;
26-
if i2c_response.data[0] == 0 {
33+
info!(
34+
"I2C response: status=0x{:02X}, data_len={}",
35+
i2c_response.i2c_status,
36+
i2c_response.data.len()
37+
);
38+
if i2c_response.i2c_status == 0x01 {
39+
// NAK
40+
warn!("Unable to communicate with dGPU Retimer. Try to force it on by plugging a cable into the dGPU");
41+
}
42+
let Some(&safe_mode) = i2c_response.data.first() else {
43+
info!("Failed to read retimer safe mode status (empty response)");
44+
return Ok(None);
45+
};
46+
info!("Retimer safe mode status: {}", safe_mode);
47+
if safe_mode == 0 {
2748
// Safe mode not enabled, enable it
2849
i2c_write(ec, i2c_port, i2c_addr >> 1, 0x00, &[0x01])?;
2950
}
3051

3152
// Wake up from low power mode
3253
for _ in 0..3 {
3354
let i2c_response = i2c_read(ec, i2c_port, (i2c_addr + 2) >> 1, 0x70, 0x01)?;
34-
if i2c_response.data[0] != 0 {
35-
i2c_write(ec, i2c_port, (i2c_addr + 2) >> 1, 0x70, &[0x00])?;
36-
os_specific::sleep(50_000);
55+
if i2c_response.data.first() == Some(&0) {
56+
continue;
3757
}
58+
i2c_write(ec, i2c_port, (i2c_addr + 2) >> 1, 0x70, &[0x00])?;
59+
os_specific::sleep(50_000);
3860
}
3961

4062
// Read version

0 commit comments

Comments
 (0)