Skip to content

Don't require PD config if platform isn't detected #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2025
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
24 changes: 13 additions & 11 deletions framework_lib/src/ccgx/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ pub enum PdPort {

impl PdPort {
/// SMBUS/I2C Address
fn i2c_address(&self) -> u16 {
fn i2c_address(&self) -> EcResult<u16> {
let config = Config::get();
let platform = &(*config).as_ref().unwrap().platform;

match (platform, self) {
Ok(match (platform, self) {
(Platform::GenericFramework((left, _), _), PdPort::Left01) => *left,
(Platform::GenericFramework((_, right), _), PdPort::Right23) => *right,
// Framework AMD Platforms (CCG8)
Expand All @@ -52,10 +52,13 @@ impl PdPort {
) => 0x40,
// TODO: It only has a single PD controller
(Platform::FrameworkDesktopAmdAiMax300, _) => 0x08,
(Platform::UnknownSystem, _) => {
Err(EcError::DeviceError("Unsupported platform".to_string()))?
}
// Framework Intel Platforms (CCG5 and CCG6)
(_, PdPort::Left01) => 0x08,
(_, PdPort::Right23) => 0x40,
}
})
}

/// I2C port on the EC
Expand Down Expand Up @@ -87,10 +90,9 @@ impl PdPort {
) => 2,
// TODO: It only has a single PD controller
(Platform::FrameworkDesktopAmdAiMax300, _) => 1,
// (_, _) => Err(EcError::DeviceError(format!(
// "Unsupported platform: {:?} {:?}",
// platform, self
// )))?,
(Platform::UnknownSystem, _) => {
Err(EcError::DeviceError("Unsupported platform".to_string()))?
}
})
}
}
Expand Down Expand Up @@ -140,13 +142,13 @@ impl PdController {
fn i2c_read(&self, addr: u16, len: u16) -> EcResult<EcI2cPassthruResponse> {
trace!(
"I2C passthrough from I2C Port {} to I2C Addr {}",
self.port.i2c_port().unwrap(),
self.port.i2c_address()
self.port.i2c_port()?,
self.port.i2c_address()?
);
i2c_read(
&self.ec,
self.port.i2c_port().unwrap(),
self.port.i2c_address(),
self.port.i2c_port()?,
self.port.i2c_address()?,
addr,
len,
)
Expand Down
9 changes: 6 additions & 3 deletions framework_lib/src/smbios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum ConfigDigit0 {
pub fn is_framework() -> bool {
if matches!(
get_platform(),
Some(Platform::GenericFramework((_, _), (_, _)))
Some(Platform::GenericFramework((_, _), (_, _))) | Some(Platform::UnknownSystem)
) {
return true;
}
Expand Down Expand Up @@ -252,7 +252,10 @@ pub fn get_platform() -> Option<Platform> {
// Except if it's a GenericFramework platform
let config = Config::get();
let platform = &(*config).as_ref().unwrap().platform;
if matches!(platform, Platform::GenericFramework((_, _), (_, _))) {
if matches!(
platform,
Platform::GenericFramework((_, _), (_, _)) | Platform::UnknownSystem
) {
return Some(*platform);
}
}
Expand All @@ -270,7 +273,7 @@ pub fn get_platform() -> Option<Platform> {
"Laptop 13 (Intel Core Ultra Series 1)" => Some(Platform::IntelCoreUltra1),
"Laptop 16 (AMD Ryzen 7040 Series)" => Some(Platform::Framework16Amd7080),
"Desktop (AMD Ryzen AI Max 300 Series)" => Some(Platform::FrameworkDesktopAmdAiMax300),
_ => None,
_ => Some(Platform::UnknownSystem),
};

if let Some(platform) = platform {
Expand Down
2 changes: 2 additions & 0 deletions framework_lib/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub enum Platform {
/// Generic Framework device
/// pd_addrs, pd_ports
GenericFramework((u16, u16), (u8, u8)),
UnknownSystem,
}

#[derive(Debug, PartialEq, Clone, Copy)]
Expand All @@ -61,6 +62,7 @@ impl Platform {
Platform::Framework16Amd7080 => Some(PlatformFamily::Framework16),
Platform::FrameworkDesktopAmdAiMax300 => Some(PlatformFamily::FrameworkDesktop),
Platform::GenericFramework(..) => None,
Platform::UnknownSystem => None,
}
}
}
Expand Down