Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 40 additions & 31 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,107 +722,116 @@ 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):
Type-C State: Source
USB-C Port 0:
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 (Right Middle):
Type-C State: Source
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 (Right Back):
Type-C State: Source
USB-C Port 0:
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 (Right Back):
Type-C State: Source
USB-C Port 0:
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 (Left Middle):
Type-C State: Sink
USB-C Port 2:
PD Contract: No
Power Role: Source
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 (Right Middle):
Type-C State: Sink
USB-C Port 1:
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)
```

Nothing connected (or Type-C Expansion Card):

```
USB-C Port 3 (Left Back):
Type-C State: Nothing
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
```
67 changes: 36 additions & 31 deletions framework_lib/src/power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ impl From<u8> for CypdTypeCState {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
enum CypdPdPowerRole {
Sink,
Source,
Expand Down Expand Up @@ -797,40 +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;

println!(" Type-C State: {:?}", 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 {
Expand All @@ -842,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.
Expand Down