From e17c68f49ee36524cfd19eb4eb52d3becac8117b Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Mon, 13 Apr 2026 22:38:34 +0800 Subject: [PATCH 1/3] EXAMPLES: Clarify --pdports output Signed-off-by: Daniel Schaefer --- EXAMPLES.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index be79a3c..3448c17 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -722,13 +722,20 @@ See [EXAMPLES_ADVANCED.md](EXAMPLES_ADVANCED.md) ## PD Ports +``` +framework_tool --pdports +``` + +Below are a few excerpts of the output. +Note that the port numbering does not match diagrams you might see elsewhere. + ### Power Adapters A 240W EPR (Framework) power adapter connected. Alongside a 65W SDR adapter - which is not active, because the EC firmware switches to the higher power adapter. ``` -USB-C Port 0 (Right Back): +USB-C Port 0: Type-C State: Source PD Contract: Yes Power Role: Sink @@ -738,7 +745,7 @@ USB-C Port 0 (Right Back): EPR: Active (Supported) CC Polarity: CC1 Active Port: Yes -USB-C Port 1 (Right Middle): +USB-C Port 1: Type-C State: Source PD Contract: Yes Power Role: Sink @@ -753,7 +760,7 @@ USB-C Port 1 (Right Middle): A 100W SDR power adapter connected: ``` -USB-C Port 0 (Right Back): +USB-C Port 0: Type-C State: Source PD Contract: Yes Power Role: Sink @@ -768,7 +775,7 @@ USB-C Port 0 (Right Back): A 65W (Framework) power adapter connected: ``` -USB-C Port 0 (Right Back): +USB-C Port 0: Type-C State: Source PD Contract: Yes Power Role: Sink @@ -785,7 +792,7 @@ USB-C Port 0 (Right Back): A USB2/3 device connected (even USB-A Expansion Card): ``` -USB-C Port 2 (Left Middle): +USB-C Port 2: Type-C State: Sink PD Contract: No Power Role: Source @@ -800,7 +807,7 @@ USB-C Port 2 (Left Middle): A Display connected through Framework DisplayPort Expansion card: ``` -USB-C Port 1 (Right Middle): +USB-C Port 1: Type-C State: Sink PD Contract: Yes Power Role: Source @@ -816,7 +823,7 @@ USB-C Port 1 (Right Middle): Nothing connected (or Type-C Expansion Card): ``` -USB-C Port 3 (Left Back): +USB-C Port 3: Type-C State: Nothing PD Contract: No Power Role: Sink From 67860c9bba3825ca38faaa19144d6b853ff44bc2 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Mon, 13 Apr 2026 22:45:36 +0800 Subject: [PATCH 2/3] --pdports: Clarify port partner type Type-C state is the state of the port partner. And hide that information if no PD contract. Signed-off-by: Daniel Schaefer --- EXAMPLES.md | 12 +++++------- framework_lib/src/power.rs | 4 +++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index 3448c17..30ee5fb 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -736,7 +736,7 @@ Alongside a 65W SDR adapter - which is not active, because the EC firmware switc ``` USB-C Port 0: - Type-C State: Source + Port Partner: Source PD Contract: Yes Power Role: Sink Data Role: Dfp @@ -746,7 +746,7 @@ USB-C Port 0: CC Polarity: CC1 Active Port: Yes USB-C Port 1: - Type-C State: Source + Port Partner: Source PD Contract: Yes Power Role: Sink Data Role: Ufp @@ -761,7 +761,7 @@ A 100W SDR power adapter connected: ``` USB-C Port 0: - Type-C State: Source + Port Partner: Source PD Contract: Yes Power Role: Sink Data Role: Ufp @@ -776,7 +776,7 @@ A 65W (Framework) power adapter connected: ``` USB-C Port 0: - Type-C State: Source + Port Partner: Source PD Contract: Yes Power Role: Sink Data Role: Dfp @@ -793,7 +793,6 @@ A USB2/3 device connected (even USB-A Expansion Card): ``` USB-C Port 2: - Type-C State: Sink PD Contract: No Power Role: Source Data Role: Dfp @@ -808,7 +807,7 @@ A Display connected through Framework DisplayPort Expansion card: ``` USB-C Port 1: - Type-C State: Sink + Port Partner: Sink PD Contract: Yes Power Role: Source Data Role: Dfp @@ -824,7 +823,6 @@ Nothing connected (or Type-C Expansion Card): ``` USB-C Port 3: - Type-C State: Nothing PD Contract: No Power Role: Sink Data Role: Ufp diff --git a/framework_lib/src/power.rs b/framework_lib/src/power.rs index fd1382f..1e61c4c 100644 --- a/framework_lib/src/power.rs +++ b/framework_lib/src/power.rs @@ -798,7 +798,9 @@ pub fn get_and_print_cypd_pd_info(ec: &CrosEc) { let current = { info.current }; let watts_mw = voltage as u32 * current as u32 / 1000; - println!(" Type-C State: {:?}", c_state); + if info.pd_state { + println!(" Port Partner: {:?}", c_state); + } println!( " PD Contract: {}", if info.pd_state != 0 { "Yes" } else { "No" } From 867e4c6107705d88be87053abfe4b7603c662d97 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Tue, 14 Apr 2026 08:09:21 +0800 Subject: [PATCH 3/3] --pdorts: Hide values depending on context - VCONN and Negotiated only makes sense if there's a connection - On top of that Port Partner role, EPR and sink active only makes sense with pd contract - Rename Active Port to Sink Active to be clearer Signed-off-by: Daniel Schaefer --- EXAMPLES.md | 48 ++++++++++++++------------ framework_lib/src/power.rs | 69 ++++++++++++++++++++------------------ 2 files changed, 62 insertions(+), 55 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index 30ee5fb..910dd74 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -736,60 +736,60 @@ Alongside a 65W SDR adapter - which is not active, because the EC firmware switc ``` USB-C Port 0: - Port Partner: Source PD Contract: Yes Power Role: Sink Data Role: Dfp VCONN: Off Negotiated: 48.000 V, 5000 mA, 240.0 W - EPR: Active (Supported) CC Polarity: CC1 - Active Port: Yes -USB-C Port 1: Port Partner: Source + EPR: Active (Supported) + Sink Active: Yes +USB-C Port 1: PD Contract: Yes Power Role: Sink Data Role: Ufp VCONN: Off Negotiated: 20.000 V, 3000 mA, 60.0 W - EPR: Inactive CC Polarity: CC1 - Active Port: No + Port Partner: Source + EPR: Inactive + Sink Active: No ``` A 100W SDR power adapter connected: ``` USB-C Port 0: - Port Partner: Source PD Contract: Yes Power Role: Sink Data Role: Ufp VCONN: Off Negotiated: 20.000 V, 5000 mA, 100.0 W - EPR: Inactive CC Polarity: CC1 - Active Port: Yes + Port Partner: Source + EPR: Inactive + Sink Active: Yes ``` A 65W (Framework) power adapter connected: ``` USB-C Port 0: - Port Partner: Source PD Contract: Yes Power Role: Sink Data Role: Dfp VCONN: On Negotiated: 20.000 V, 3250 mA, 65.0 W - EPR: Inactive CC Polarity: CC2 - Active Port: Yes + Port Partner: Source + EPR: Inactive + Sink Active: Yes ``` ### Devices -A USB2/3 device connected (even USB-A Expansion Card): +A high power USB2/3 device connected: ``` USB-C Port 2: @@ -798,24 +798,32 @@ USB-C Port 2: Data Role: Dfp VCONN: Off Negotiated: 5.000 V, 3000 mA, 15.0 W - EPR: Inactive CC Polarity: CC1 - Active Port: No +``` + +A low power USB2/3 device connected (even USB-A Expansion Card): + +``` +USB-C Port 3: + PD Contract: No + Power Role: Source + Data Role: Dfp + VCONN: Off + Negotiated: 5.000 V, 1500 mA, 7.500 W + CC Polarity: CC2 ``` A Display connected through Framework DisplayPort Expansion card: ``` USB-C Port 1: - Port Partner: Sink PD Contract: Yes Power Role: Source Data Role: Dfp VCONN: On Negotiated: 5.000 V, 410 mA, 2.50 W - EPR: Inactive CC Polarity: CC1 - Active Port: No + Port Partner: Sink DP Alt Mode: DFP_D Connected, HPD High (0x81) ``` @@ -826,8 +834,4 @@ USB-C Port 3: PD Contract: No Power Role: Sink Data Role: Ufp - VCONN: Off - Negotiated: 0.000 V, 0 mA, 0.0 W - EPR: Inactive - Active Port: No ``` diff --git a/framework_lib/src/power.rs b/framework_lib/src/power.rs index 1e61c4c..4b07208 100644 --- a/framework_lib/src/power.rs +++ b/framework_lib/src/power.rs @@ -745,7 +745,7 @@ impl From for CypdTypeCState { } } -#[derive(Debug)] +#[derive(Debug, PartialEq)] enum CypdPdPowerRole { Sink, Source, @@ -797,42 +797,27 @@ pub fn get_and_print_cypd_pd_info(ec: &CrosEc) { let voltage = { info.voltage }; let current = { info.current }; let watts_mw = voltage as u32 * current as u32 / 1000; + let has_pd_contract = info.pd_state != 0; - if info.pd_state { - println!(" Port Partner: {:?}", c_state); - } println!( " PD Contract: {}", if info.pd_state != 0 { "Yes" } else { "No" } ); println!(" Power Role: {:?}", power_role); println!(" Data Role: {:?}", data_role); - println!( - " VCONN: {}", - if info.vconn != 0 { "On" } else { "Off" } - ); - println!( - " Negotiated: {}.{:03} V, {} mA, {}.{} W", - voltage / 1000, - voltage % 1000, - current, - watts_mw / 1000, - watts_mw % 1000, - ); - println!( - " EPR: {}{}", - if info.epr_active != 0 { - "Active" - } else { - "Inactive" - }, - if info.epr_support != 0 { - " (Supported)" - } else { - "" - } - ); if connected { + println!( + " VCONN: {}", + if info.vconn != 0 { "On" } else { "Off" } + ); + println!( + " Negotiated: {}.{:03} V, {} mA, {}.{} W", + voltage / 1000, + voltage % 1000, + current, + watts_mw / 1000, + watts_mw % 1000, + ); println!( " CC Polarity: {}", match info.cc_polarity { @@ -844,10 +829,28 @@ pub fn get_and_print_cypd_pd_info(ec: &CrosEc) { } ); } - println!( - " Active Port: {}", - if info.active_port != 0 { "Yes" } else { "No" } - ); + if has_pd_contract { + println!(" Port Partner: {:?}", c_state); + println!( + " EPR: {}{}", + if info.epr_active != 0 { + "Active" + } else { + "Inactive" + }, + if info.epr_support != 0 { + " (Supported)" + } else { + "" + } + ); + if power_role == CypdPdPowerRole::Sink { + println!( + " Sink Active: {}", + if info.active_port != 0 { "Yes" } else { "No" } + ); + } + } let alt = info.pd_alt_mode_status; // Bits 0-1 indicate DP alt mode is active (bit 0 = DFP_D/TBT, // bit 1 = UFP_D). Only show when actually in DP alt mode.