Skip to content

Commit 4d341f4

Browse files
committed
chromium: Add s0ixcounter EC command
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 58cb353 commit 4d341f4

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

framework_lib/src/chromium_ec/command.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub enum EcCommands {
4444
ChargeState = 0x00A0,
4545
ChargeCurrentLimit = 0x00A1,
4646
HibernationDelay = 0x00A8,
47+
S0ixCounter = 0x00AB,
4748
/// List the features supported by the firmware
4849
GetFeatures = 0x000D,
4950
/// Force reboot, causes host reboot as well

framework_lib/src/chromium_ec/commands.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,25 @@ impl EcRequest<EcResponseHibernationDelay> for EcRequesetHibernationDelay {
641641
}
642642
}
643643

644+
#[repr(C, packed)]
645+
pub struct EcRequestS0ixCounter {
646+
/// If 0x01 then reset the counter, otherwise get it
647+
pub flags: u32,
648+
}
649+
650+
#[repr(C, packed)]
651+
pub struct EcResponseS0ixCounter {
652+
pub s0ix_counter: u32,
653+
}
654+
655+
pub const EC_S0IX_COUNTER_RESET: u32 = 0x01;
656+
657+
impl EcRequest<EcResponseS0ixCounter> for EcRequestS0ixCounter {
658+
fn command_id() -> EcCommands {
659+
EcCommands::S0ixCounter
660+
}
661+
}
662+
644663
/// Supported features
645664
#[derive(Debug, FromPrimitive)]
646665
pub enum EcFeatureCode {

framework_lib/src/chromium_ec/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,19 @@ impl CrosEc {
14981498
Ok(res.hibernation_delay)
14991499
}
15001500

1501+
pub fn reset_s0ix_counter(&self) -> EcResult<()> {
1502+
EcRequestS0ixCounter {
1503+
flags: EC_S0IX_COUNTER_RESET,
1504+
}
1505+
.send_command(self)?;
1506+
Ok(())
1507+
}
1508+
1509+
pub fn get_s0ix_counter(&self) -> EcResult<u32> {
1510+
let res = EcRequestS0ixCounter { flags: 0 }.send_command(self)?;
1511+
Ok(res.s0ix_counter)
1512+
}
1513+
15011514
/// Check features supported by the firmware
15021515
pub fn get_features(&self) -> EcResult<()> {
15031516
let data = EcRequestGetFeatures {}.send_command(self)?;

0 commit comments

Comments
 (0)