Skip to content

Commit 21c8956

Browse files
committed
ccgx: Implement i2c communication with CCG6 on AMD
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 1045a27 commit 21c8956

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

framework_lib/src/ccgx/device.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ pub enum PdPort {
3737
impl PdPort {
3838
/// SMBUS/I2C Address
3939
fn i2c_address(&self) -> u16 {
40-
match self {
41-
PdPort::Left01 => 0x08,
42-
PdPort::Right23 => 0x40,
40+
let config = Config::get();
41+
let platform = &(*config).as_ref().unwrap().platform;
42+
43+
match (platform, self) {
44+
(Platform::Framework13Amd | Platform::Framework16, PdPort::Left01) => 0x42,
45+
(Platform::Framework13Amd | Platform::Framework16, PdPort::Right23) => 0x40,
46+
// Intel Platforms
47+
(_, PdPort::Left01) => 0x08,
48+
(_, PdPort::Right23) => 0x40,
4349
}
4450
}
4551

@@ -54,11 +60,12 @@ impl PdPort {
5460
(Platform::IntelGen12, PdPort::Right23) => 7,
5561
(Platform::IntelGen13, PdPort::Left01) => 6,
5662
(Platform::IntelGen13, PdPort::Right23) => 7,
57-
// TODO: AMD
58-
(_, _) => Err(EcError::DeviceError(format!(
59-
"Unsupported platform: {:?} {:?}",
60-
platform, self
61-
)))?,
63+
(Platform::Framework13Amd | Platform::Framework16, PdPort::Left01) => 1,
64+
(Platform::Framework13Amd | Platform::Framework16, PdPort::Right23) => 2,
65+
// (_, _) => Err(EcError::DeviceError(format!(
66+
// "Unsupported platform: {:?} {:?}",
67+
// platform, self
68+
// )))?,
6269
})
6370
}
6471
}

0 commit comments

Comments
 (0)