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
109 changes: 108 additions & 1 deletion EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Options:
--autofanctrl
Turn on automatic fan speed control
--pdports
Show information about USB-C PD ports
Show USB-C PD port state
--info
Show info from SMBIOS (Only on UEFI)
--pd-info
Expand Down Expand Up @@ -719,3 +719,110 @@ It's not controlled by the EC, use https://keyboard.frame.work.
Mostly for debugging firmware.

See [EXAMPLES_ADVANCED.md](EXAMPLES_ADVANCED.md)

## PD Ports

### 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
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
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
```

A 100W SDR power adapter connected:

```
USB-C Port 0 (Right Back):
Type-C State: 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
```

A 65W (Framework) power adapter connected:

```
USB-C Port 0 (Right Back):
Type-C State: 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
```

### Devices

A USB2/3 device connected (even USB-A Expansion Card):

```
USB-C Port 2 (Left Middle):
Type-C State: Sink
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 Display connected through Framework DisplayPort Expansion card:

```
USB-C Port 1 (Right Middle):
Type-C State: 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
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
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
```
2 changes: 2 additions & 0 deletions framework_lib/src/chromium_ec/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ pub enum EcCommands {
GetGpuPcie = 0x3E1E,
/// Set gpu bay serial and program structure
ProgramGpuEeprom = 0x3E1F,
/// Get PD port state from Cypress PD controller
GetPdPortState = 0x3E23,
/// Read board ID of specific ADC channel
ReadBoardId = 0x3E26,
}
Expand Down
27 changes: 27 additions & 0 deletions framework_lib/src/chromium_ec/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,33 @@ impl EcRequest<_EcResponseReadPdVersionV1> for EcRequestReadPdVersionV1 {
}
}

#[repr(C, packed)]
pub struct EcRequestGetPdPortState {
pub port: u8,
}

#[repr(C, packed)]
pub struct EcResponseGetPdPortState {
pub c_state: u8,
pub pd_state: u8,
pub power_role: u8,
pub data_role: u8,
pub vconn: u8,
pub epr_active: u8,
pub epr_support: u8,
pub cc_polarity: u8,
pub voltage: u16,
pub current: u16,
pub active_port: u8,
pub pd_alt_mode_status: u8,
}

impl EcRequest<EcResponseGetPdPortState> for EcRequestGetPdPortState {
fn command_id() -> EcCommands {
EcCommands::GetPdPortState
}
}

#[repr(C, packed)]
pub struct EcRequestPrivacySwitches {}

Expand Down
7 changes: 6 additions & 1 deletion framework_lib/src/commandline/clap_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ struct ClapCli {
#[arg(long)]
autofanctrl: Option<Option<u8>>,

/// Show information about USB-C PD ports
/// Show USB-C PD port state
#[arg(long)]
pdports: bool,

/// Show PD port info (generic Chromium EC)
#[arg(long)]
pdports_chromebook: bool,

/// Show info from SMBIOS (Only on UEFI)
#[arg(long)]
info: bool,
Expand Down Expand Up @@ -475,6 +479,7 @@ pub fn parse(args: &[String]) -> Cli {
fansetrpm,
autofanctrl: args.autofanctrl,
pdports: args.pdports,
pdports_chromebook: args.pdports_chromebook,
pd_info: args.pd_info,
pd_reset: args.pd_reset,
pd_disable: args.pd_disable,
Expand Down
7 changes: 6 additions & 1 deletion framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ pub struct Cli {
pub fansetrpm: Option<(Option<u32>, u32)>,
pub autofanctrl: Option<Option<u8>>,
pub pdports: bool,
pub pdports_chromebook: bool,
pub privacy: bool,
pub pd_info: bool,
pub pd_reset: Option<u8>,
Expand Down Expand Up @@ -260,6 +261,7 @@ pub fn parse(args: &[String]) -> Cli {
// fansetrpm
// autofanctrl
pdports: cli.pdports,
pdports_chromebook: cli.pdports_chromebook,
privacy: cli.privacy,
pd_info: cli.version,
// pd_reset
Expand Down Expand Up @@ -1549,6 +1551,8 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
} else if let Some(None) = args.autofanctrl {
print_err(ec.autofanctrl(None));
} else if args.pdports {
power::get_and_print_cypd_pd_info(&ec);
} else if args.pdports_chromebook {
power::get_and_print_pd_info(&ec);
} else if args.info {
smbios_info();
Expand Down Expand Up @@ -1840,7 +1844,8 @@ Options:
--fansetduty Set fan duty cycle (0-100%)
--fansetrpm Set fan RPM (limited by EC fan table max RPM)
--autofanctrl [<FANID>]Turn on automatic fan speed control (optionally provide fan index)
--pdports Show information about USB-C PD ports
--pdports Show USB-C PD port state
--pdports-chromebook Show PD port info (generic Chromium EC)
--info Show info from SMBIOS (Only on UEFI)
--meinfo [<DUMPFILE>] Show Intel ME information (from SMBIOS type 0xDB)
--pd-info Show details about the PD controllers
Expand Down
4 changes: 4 additions & 0 deletions framework_lib/src/commandline/uefi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub fn parse(args: &[String]) -> Cli {
fansetrpm: None,
autofanctrl: None,
pdports: false,
pdports_chromebook: false,
pd_info: false,
pd_reset: None,
pd_disable: None,
Expand Down Expand Up @@ -224,6 +225,9 @@ pub fn parse(args: &[String]) -> Cli {
} else if arg == "--pdports" {
cli.pdports = true;
found_an_option = true;
} else if arg == "--pdports-chromebook" {
cli.pdports_chromebook = true;
found_an_option = true;
} else if arg == "--allupdate" {
cli.allupdate = true;
found_an_option = true;
Expand Down
Loading
Loading