Revert "runtime_probe: Wake up EC component if it's in low power mode"
This reverts commit 01d28efb89e8ef09a5fa6be3db7ac8e9bd0b83f8.
Reason for revert: This CL breaks the unit tests of Runtime Probe since the arguments of base::JSONReader::Read has changed due to libchrome uprev. See also CL:7004727.
Original change's description:
> runtime_probe: Wake up EC component if it's in low power mode
>
> If an EC component is labeled "low_power_probe_once" in the manifest,
> the first i2c command will be executed twice, with the return value of
> the first execution being ignored, to wake up the component from low
> power mode.
>
> BUG=b:436450536
> TEST=FEATURES=test emerge-${BOARD} runtime_probe
> TEST=Manually test on DUT
>
> Change-Id: I9d6c8eebb4d3b32d5ae05ff4408f84db4d586b12
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/6983322
> Tested-by: Allen Shih <allenshihmc@chromium.org>
> Commit-Queue: Allen Shih <allenshihmc@chromium.org>
> Reviewed-by: Yong Hong <yhong@chromium.org>
BUG=b:436450536
Change-Id: I4d6acefbbcdc1b77c90f2849e257aa790f949d68
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/7024923
Reviewed-by: Yong Hong <yhong@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Allen Shih <allenshihmc@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
diff --git a/runtime_probe/functions/ec_component.cc b/runtime_probe/functions/ec_component.cc
index 690e1f8..4e75f13 100644
--- a/runtime_probe/functions/ec_component.cc
+++ b/runtime_probe/functions/ec_component.cc
@@ -86,42 +86,29 @@
return string_builder.str();
}
-uint8_t GetI2cAddr(const EcComponentManifest::Component& comp,
- const EcComponentManifest::Component::I2c::Expect& expect) {
- if (expect.override_addr.has_value()) {
- return *expect.override_addr;
- }
- return comp.i2c.addr;
-}
-
} // namespace
class EcComponentFunction::CommandSequenceHistoryTracker {
public:
class I2cCommandRunRecord;
- I2cCommandRunRecord* LookupRunRecord(
- const EcComponentManifest::Component& comp,
- const EcComponentManifest::Component::I2c::Expect& expect);
+ I2cCommandRunRecord* LookupRunRecord(uint8_t port,
+ uint8_t addr7,
+ uint8_t offset,
+ const std::vector<uint8_t>& write_data,
+ uint8_t read_len);
I2cCommandRunRecord* RegisterRunRecord(
- const EcComponentManifest::Component& comp,
- const EcComponentManifest::Component::I2c::Expect& expect,
+ uint8_t port,
+ uint8_t addr7,
+ uint8_t offset,
+ const std::vector<uint8_t>& write_data,
+ uint8_t read_len,
std::unique_ptr<ec::I2cPassthruCommand> cmd,
bool is_cmd_success);
private:
struct RecordKey {
- static RecordKey Create(
- const EcComponentManifest::Component& comp,
- const EcComponentManifest::Component::I2c::Expect& expect) {
- const auto addr = GetI2cAddr(comp, expect);
- return {.port = comp.i2c.port,
- .addr7 = addr,
- .offset = expect.reg,
- .read_len = static_cast<uint8_t>(expect.bytes),
- .write_data = expect.write_data};
- }
uint8_t port;
uint8_t addr7;
uint8_t offset;
@@ -165,9 +152,16 @@
EcComponentFunction::CommandSequenceHistoryTracker::I2cCommandRunRecord*
EcComponentFunction::CommandSequenceHistoryTracker::LookupRunRecord(
- const EcComponentManifest::Component& comp,
- const EcComponentManifest::Component::I2c::Expect& expect) {
- const auto key = RecordKey::Create(comp, expect);
+ uint8_t port,
+ uint8_t addr7,
+ uint8_t offset,
+ const std::vector<uint8_t>& write_data,
+ uint8_t read_len) {
+ RecordKey key{.port = port,
+ .addr7 = addr7,
+ .offset = offset,
+ .read_len = read_len,
+ .write_data = write_data};
auto it = run_records_.find(key);
if (it == run_records_.end()) {
return nullptr;
@@ -177,11 +171,18 @@
EcComponentFunction::CommandSequenceHistoryTracker::I2cCommandRunRecord*
EcComponentFunction::CommandSequenceHistoryTracker::RegisterRunRecord(
- const EcComponentManifest::Component& comp,
- const EcComponentManifest::Component::I2c::Expect& expect,
+ uint8_t port,
+ uint8_t addr7,
+ uint8_t offset,
+ const std::vector<uint8_t>& write_data,
+ uint8_t read_len,
std::unique_ptr<ec::I2cPassthruCommand> cmd,
bool is_cmd_success) {
- const auto key = RecordKey::Create(comp, expect);
+ RecordKey key{.port = port,
+ .addr7 = addr7,
+ .offset = offset,
+ .read_len = read_len,
+ .write_data = write_data};
auto emplace_result = run_records_.insert_or_assign(
key,
std::make_unique<I2cCommandRunRecord>(std::move(cmd), is_cmd_success));
@@ -200,19 +201,6 @@
return ec::I2cPassthruCommand::Create(port, addr7, passthru_data, read_len);
}
-std::unique_ptr<ec::I2cPassthruCommand> EcComponentFunction::GetI2cReadCommand(
- const EcComponentManifest::Component& comp) const {
- // No expect value. Just verify the accessibility of the component.
- return GetI2cReadCommand(comp.i2c.port, comp.i2c.addr, 0u, {}, 1u);
-}
-
-std::unique_ptr<ec::I2cPassthruCommand> EcComponentFunction::GetI2cReadCommand(
- const EcComponentManifest::Component& comp,
- const EcComponentManifest::Component::I2c::Expect& expect) const {
- return GetI2cReadCommand(comp.i2c.port, GetI2cAddr(comp, expect), expect.reg,
- expect.write_data, expect.bytes);
-}
-
std::unique_ptr<ec::GetVersionCommand>
EcComponentFunction::GetGetVersionCommand() const {
return std::make_unique<ec::GetVersionCommand>();
@@ -239,32 +227,6 @@
}
}
-bool EcComponentFunction::WakeUpComponent(
- const EcComponentManifest::Component& comp,
- const base::ScopedFD& ec_dev_fd) const {
- auto comp_label = GenerateComponentLogLabel(comp);
- std::unique_ptr<ec::I2cPassthruCommand> wakeup_cmd;
- if (comp.i2c.expect.size() == 0) {
- wakeup_cmd = GetI2cReadCommand(comp);
- if (!wakeup_cmd) {
- LOG(ERROR) << "Failed to construct the EC i2cxfer command for "
- << "accessibility check for " << comp_label;
- return false;
- }
- } else {
- const auto& expect = comp.i2c.expect[0];
- wakeup_cmd = GetI2cReadCommand(comp, expect);
- auto i2c_cmd_label = GenerateExpectI2cCommandLogLabel(expect);
- if (!wakeup_cmd) {
- LOG(ERROR) << "Failed to construct " << i2c_cmd_label << " for "
- << comp_label;
- return false;
- }
- }
- RunI2cCommandAndCheckSuccess(ec_dev_fd, wakeup_cmd.get());
- return true;
-}
-
bool EcComponentFunction::IsValidComponent(
const EcComponentManifest::Component& comp,
const base::ScopedFD& ec_dev_fd,
@@ -273,15 +235,9 @@
auto comp_label = GenerateComponentLogLabel(comp);
VLOG(1) << "Probing " << comp_label;
- if (comp.probe_strategy == EcComponentManifest::ProbeStrategy::WAKE_UP &&
- (!use_cached_invocations || comp.i2c.expect.size() == 0)) {
- if (!WakeUpComponent(comp, ec_dev_fd)) {
- return false;
- }
- }
-
if (comp.i2c.expect.size() == 0) {
- auto cmd = GetI2cReadCommand(comp);
+ // No expect value. Just verify the accessibility of the component.
+ auto cmd = GetI2cReadCommand(comp.i2c.port, comp.i2c.addr, 0u, {}, 1u);
if (!cmd) {
LOG(ERROR) << "Failed to construct the EC i2cxfer command for "
<< "accessibility check for " << comp_label;
@@ -295,9 +251,22 @@
auto curr_tracker = tracker;
for (const auto& expect : comp.i2c.expect) {
- auto i2c_cmd_label = GenerateExpectI2cCommandLogLabel(expect);
+ auto addr = comp.i2c.addr;
+ if (expect.override_addr.has_value()) {
+ addr = *expect.override_addr;
+ }
- auto run_record = curr_tracker->LookupRunRecord(comp, expect);
+ auto cmd = GetI2cReadCommand(comp.i2c.port, addr, expect.reg,
+ expect.write_data, expect.bytes);
+ auto i2c_cmd_label = GenerateExpectI2cCommandLogLabel(expect);
+ if (!cmd) {
+ LOG(ERROR) << "Failed to construct " << i2c_cmd_label << " for "
+ << comp_label;
+ return false;
+ }
+
+ auto run_record = curr_tracker->LookupRunRecord(
+ comp.i2c.port, addr, expect.reg, expect.write_data, expect.bytes);
if (use_cached_invocations) {
if (run_record == nullptr) {
// The command hasn't been run, we should run through the whole command
@@ -308,16 +277,11 @@
}
i2c_cmd_label = "(cached) " + i2c_cmd_label;
} else {
- auto cmd = GetI2cReadCommand(comp, expect);
- if (!cmd) {
- LOG(ERROR) << "Failed to construct " << i2c_cmd_label << " for "
- << comp_label;
- return false;
- }
bool success = RunI2cCommandAndCheckSuccess(ec_dev_fd, cmd.get());
if (run_record == nullptr || run_record->is_cmd_success() != success) {
- run_record = curr_tracker->RegisterRunRecord(comp, expect,
- std::move(cmd), success);
+ run_record = curr_tracker->RegisterRunRecord(
+ comp.i2c.port, addr, expect.reg, expect.write_data, expect.bytes,
+ std::move(cmd), success);
}
}
curr_tracker = run_record->next();
diff --git a/runtime_probe/functions/ec_component.h b/runtime_probe/functions/ec_component.h
index d1d812b..a24b702 100644
--- a/runtime_probe/functions/ec_component.h
+++ b/runtime_probe/functions/ec_component.h
@@ -45,12 +45,6 @@
uint8_t read_len) const;
virtual std::unique_ptr<ec::GetVersionCommand> GetGetVersionCommand() const;
- std::unique_ptr<ec::I2cPassthruCommand> GetI2cReadCommand(
- const EcComponentManifest::Component& comp) const;
- std::unique_ptr<ec::I2cPassthruCommand> GetI2cReadCommand(
- const EcComponentManifest::Component& comp,
- const EcComponentManifest::Component::I2c::Expect& expect) const;
-
std::optional<std::string> GetCurrentECVersion(
const base::ScopedFD& ec_dev_fd) const;
@@ -59,9 +53,6 @@
CommandSequenceHistoryTracker* tracker,
bool use_cached_invocations) const;
- bool WakeUpComponent(const EcComponentManifest::Component& comp,
- const base::ScopedFD& ec_dev_fd) const;
-
template <typename ManifestReader>
DataType ProbeWithManifest(const std::optional<std::string>& manifest_path,
const std::string_view dev_path) const;
diff --git a/runtime_probe/functions/ec_component_test.cc b/runtime_probe/functions/ec_component_test.cc
index b632f13..f0e590c7 100644
--- a/runtime_probe/functions/ec_component_test.cc
+++ b/runtime_probe/functions/ec_component_test.cc
@@ -30,7 +30,6 @@
using ::testing::_;
using ::testing::ByMove;
-using ::testing::Invoke;
using ::testing::NiceMock;
using ::testing::Return;
@@ -191,7 +190,7 @@
return cmd;
};
ON_CALL(*probe_function, GetI2cReadCommand(port, addr7, _, _, _))
- .WillByDefault(Invoke(create_cmd_func));
+ .WillByDefault(testing::Invoke(create_cmd_func));
}
void ExpectI2cReadSuccess(MockEcComponentFunction* probe_function,
@@ -204,60 +203,24 @@
.WillOnce(Return(ByMove(std::move(cmd))));
}
- void ExpectI2cReadSuccessWithResult(MockEcComponentFunction* probe_function,
- uint8_t port,
- uint8_t addr7,
- uint8_t offset,
- const std::vector<uint8_t>& write_data,
- uint8_t len,
- base::span<const uint8_t> return_value,
- int* run_counter = nullptr) {
+ void SetI2cReadSuccessWithResult(MockEcComponentFunction* probe_function,
+ uint8_t port,
+ uint8_t addr7,
+ uint8_t offset,
+ const std::vector<uint8_t>& write_data,
+ uint8_t len,
+ base::span<const uint8_t> return_value) {
std::vector<uint8_t> return_value_copy(return_value.begin(),
return_value.end());
- auto create_cmd_func = [this, return_value_copy, run_counter]() {
- if (run_counter == nullptr) {
- return FakeI2cPassthruCommand::Create(
- &(this->run_command_count_), true, kEcResultSuccess,
- kEcI2cStatusSuccess, return_value_copy);
- }
- return FakeI2cPassthruCommand::Create(run_counter, true, kEcResultSuccess,
- kEcI2cStatusSuccess,
- return_value_copy);
- };
- EXPECT_CALL(*probe_function,
- GetI2cReadCommand(port, addr7, offset, write_data, len))
- .WillRepeatedly(Invoke(create_cmd_func));
- }
-
- void ExpectI2cReadWithLowPowerMode(MockEcComponentFunction* probe_function,
- uint8_t port,
- uint8_t addr7,
- uint8_t offset,
- const std::vector<uint8_t>& write_data,
- uint8_t len,
- base::span<const uint8_t> return_value,
- int* command_counter_succ,
- int* command_counter_fail) {
- std::vector<uint8_t> return_value_copy(return_value.begin(),
- return_value.end());
- auto create_cmd_func_succ = [command_counter_succ, return_value_copy]() {
+ auto create_cmd_func = [this, return_value_copy]() {
auto cmd = FakeI2cPassthruCommand::Create(
- command_counter_succ, true, kEcResultSuccess, kEcI2cStatusSuccess,
- return_value_copy);
+ &(this->run_command_count_), true, kEcResultSuccess,
+ kEcI2cStatusSuccess, return_value_copy);
return cmd;
};
- auto create_cmd_func_fail = [command_counter_fail, return_value_copy]() {
- auto cmd = FakeI2cPassthruCommand::Create(
- command_counter_fail, false, kEcResultTimeout, kEcI2cStatusSuccess,
- return_value_copy);
- return cmd;
- };
-
- EXPECT_CALL(*probe_function,
- GetI2cReadCommand(port, addr7, offset, write_data, len))
- .Times(2)
- .WillOnce(Invoke(create_cmd_func_fail))
- .WillOnce(Invoke(create_cmd_func_succ));
+ ON_CALL(*probe_function,
+ GetI2cReadCommand(port, addr7, offset, write_data, len))
+ .WillByDefault(testing::Invoke(create_cmd_func));
}
void SetI2cReadFailed(MockEcComponentFunction* probe_function,
@@ -270,7 +233,7 @@
return cmd;
};
ON_CALL(*probe_function, GetI2cReadCommand(port, addr7, _, _, _))
- .WillByDefault(Invoke(create_cmd_func));
+ .WillByDefault(testing::Invoke(create_cmd_func));
}
int run_command_count_;
@@ -308,14 +271,14 @@
auto probe_function =
CreateProbeFunction<MockEcComponentFunction>(arguments->GetDict());
- ExpectI2cReadSuccessWithResult(probe_function.get(), 1, 0x01, 0x00,
- std::vector<uint8_t>{0xaa, 0xbb}, 0, {});
- ExpectI2cReadSuccessWithResult(probe_function.get(), 1, 0x01, 0x01,
- std::vector<uint8_t>{}, 1, {0x11});
- ExpectI2cReadSuccessWithResult(probe_function.get(), 1, 0x01, 0x02,
- std::vector<uint8_t>{}, 1, {0xbb});
- ExpectI2cReadSuccessWithResult(probe_function.get(), 1, 0x01, 0xaa,
- std::vector<uint8_t>{}, 1, {0xff});
+ SetI2cReadSuccessWithResult(probe_function.get(), 1, 0x01, 0x00,
+ std::vector<uint8_t>{0xaa, 0xbb}, 0, {});
+ SetI2cReadSuccessWithResult(probe_function.get(), 1, 0x01, 0x01,
+ std::vector<uint8_t>{}, 1, {0x11});
+ SetI2cReadSuccessWithResult(probe_function.get(), 1, 0x01, 0x02,
+ std::vector<uint8_t>{}, 1, {0xbb});
+ SetI2cReadSuccessWithResult(probe_function.get(), 1, 0x01, 0xaa,
+ std::vector<uint8_t>{}, 1, {0xff});
auto actual = EvalProbeFunction(probe_function.get());
@@ -415,34 +378,6 @@
)JSON"));
}
-TEST_F(EcComponentFunctionTestNoExpect, ProbeWithLowPowerModeSucceed) {
- auto arguments = base::JSONReader::Read(R"JSON(
- {
- "type": "bc12",
- "name": "bc12_3"
- }
- )JSON");
- auto probe_function =
- CreateProbeFunction<MockEcComponentFunction>(arguments->GetDict());
-
- int command_counter_1_succ = 0;
- int command_counter_1_fail = 0;
- ExpectI2cReadWithLowPowerMode(
- probe_function.get(), 4, 0x5f, 0, std::vector<uint8_t>{}, 1, {0x00},
- &command_counter_1_succ, &command_counter_1_fail);
-
- auto actual = EvalProbeFunction(probe_function.get());
-
- ExpectUnorderedListEqual(actual, CreateProbeResultFromJson(R"JSON(
- [
- {
- "component_type": "bc12",
- "component_name": "bc12_3"
- }
- ]
- )JSON"));
-}
-
TEST_F(EcComponentFunctionTestNoExpect, ProbeWithTypeAndNameSucceed) {
auto arguments = base::JSONReader::Read(R"JSON(
{
@@ -503,14 +438,14 @@
auto probe_function =
CreateProbeFunction<MockEcComponentFunction>(arguments->GetDict());
// base_sensor_1 without a mask
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x00,
- std::vector<uint8_t>{}, 1, kMatchValueForReg0);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x01,
- std::vector<uint8_t>{}, 1, kMatchValueForReg1);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x02,
- std::vector<uint8_t>{}, 1, kMatchValueForReg2);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x2, 0x03,
- std::vector<uint8_t>{}, 1, kMatchValueForReg3);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x00,
+ std::vector<uint8_t>{}, 1, kMatchValueForReg0);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x01,
+ std::vector<uint8_t>{}, 1, kMatchValueForReg1);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x02,
+ std::vector<uint8_t>{}, 1, kMatchValueForReg2);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x2, 0x03,
+ std::vector<uint8_t>{}, 1, kMatchValueForReg3);
auto actual = EvalProbeFunction(probe_function.get());
@@ -541,13 +476,12 @@
for (const auto& match_value_for_reg4 : kMatchValuesForReg4) {
auto probe_function =
CreateProbeFunction<MockEcComponentFunction>(arguments->GetDict());
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x03,
- std::vector<uint8_t>{}, 4,
- kMatchValueForReg3);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x03,
+ std::vector<uint8_t>{}, 4, kMatchValueForReg3);
// base_sensor_3 with mask 0x00ff00ff.
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x04,
- std::vector<uint8_t>{}, 4,
- match_value_for_reg4);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x04,
+ std::vector<uint8_t>{}, 4,
+ match_value_for_reg4);
auto actual = EvalProbeFunction(probe_function.get());
@@ -577,15 +511,14 @@
auto probe_function =
CreateProbeFunction<MockEcComponentFunction>(arguments->GetDict());
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x00,
- std::vector<uint8_t>{}, 1,
- kMismatchValueForReg0);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x01,
- std::vector<uint8_t>{}, 1, kMatchValueForReg1);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x02,
- std::vector<uint8_t>{}, 1, kMatchValueForReg2);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x2, 0x03,
- std::vector<uint8_t>{}, 1, kMatchValueForReg3);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x00,
+ std::vector<uint8_t>{}, 1, kMismatchValueForReg0);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x01,
+ std::vector<uint8_t>{}, 1, kMatchValueForReg1);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x02,
+ std::vector<uint8_t>{}, 1, kMatchValueForReg2);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x2, 0x03,
+ std::vector<uint8_t>{}, 1, kMatchValueForReg3);
ExpectUnorderedListEqual(EvalProbeFunction(probe_function.get()),
CreateProbeResultFromJson("[]"));
@@ -606,15 +539,14 @@
auto probe_function =
CreateProbeFunction<MockEcComponentFunction>(arguments->GetDict());
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x00,
- std::vector<uint8_t>{}, 1, kMatchValueForReg0);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x01,
- std::vector<uint8_t>{}, 1,
- kMismatchValueForReg1);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x02,
- std::vector<uint8_t>{}, 1, kMatchValueForReg2);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x2, 0x03,
- std::vector<uint8_t>{}, 1, kMatchValueForReg3);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x00,
+ std::vector<uint8_t>{}, 1, kMatchValueForReg0);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x01,
+ std::vector<uint8_t>{}, 1, kMismatchValueForReg1);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x02,
+ std::vector<uint8_t>{}, 1, kMatchValueForReg2);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x2, 0x03,
+ std::vector<uint8_t>{}, 1, kMatchValueForReg3);
ExpectUnorderedListEqual(EvalProbeFunction(probe_function.get()),
CreateProbeResultFromJson("[]"));
@@ -635,16 +567,14 @@
auto probe_function =
CreateProbeFunction<MockEcComponentFunction>(arguments->GetDict());
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x00,
- std::vector<uint8_t>{}, 1,
- kMatchedValueForReg0);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x01,
- std::vector<uint8_t>{}, 1, kMismatchValue);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x02,
- std::vector<uint8_t>{}, 1,
- kMatchedValueForReg3);
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x2, 0x03,
- std::vector<uint8_t>{}, 1, kMatchValueForReg3);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x00,
+ std::vector<uint8_t>{}, 1, kMatchedValueForReg0);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x01,
+ std::vector<uint8_t>{}, 1, kMismatchValue);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x02,
+ std::vector<uint8_t>{}, 1, kMatchedValueForReg3);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x2, 0x03,
+ std::vector<uint8_t>{}, 1, kMatchValueForReg3);
ExpectUnorderedListEqual(EvalProbeFunction(probe_function.get()),
CreateProbeResultFromJson("[]"));
@@ -663,8 +593,8 @@
CreateProbeFunction<MockEcComponentFunction>(arguments->GetDict());
// base_sensor_2
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x02,
- std::vector<uint8_t>{}, 1, kMismatchValue);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x02,
+ std::vector<uint8_t>{}, 1, kMismatchValue);
auto actual = EvalProbeFunction(probe_function.get());
@@ -691,9 +621,9 @@
CreateProbeFunction<MockEcComponentFunction>(arguments->GetDict());
// base_sensor_2
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x03,
- std::vector<uint8_t>{0xaa, 0xbb, 0xcc}, 1,
- kUnusedI2cResponseValue);
+ SetI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x03,
+ std::vector<uint8_t>{0xaa, 0xbb, 0xcc}, 1,
+ kUnusedI2cResponseValue);
auto actual = EvalProbeFunction(probe_function.get());
@@ -707,44 +637,6 @@
)JSON"));
}
-TEST_F(EcComponentFunctionTestWithExpect, ProbeWithLowPowerModeSucceed) {
- constexpr uint8_t kMatchValueForReg0[] = {0x00};
- constexpr uint8_t kMatchValueForReg1[] = {0x01};
- auto arguments = base::JSONReader::Read(R"JSON(
- {
- "type": "base_sensor",
- "name": "base_sensor_5"
- }
- )JSON");
- auto probe_function =
- CreateProbeFunction<MockEcComponentFunction>(arguments->GetDict());
-
- int command_counter_1_succ = 0;
- int command_counter_1_fail = 0;
- ExpectI2cReadWithLowPowerMode(
- probe_function.get(), 3, 0x01, 0x00, std::vector<uint8_t>{}, 1,
- kMatchValueForReg0, &command_counter_1_succ, &command_counter_1_fail);
-
- int command_counter_2 = 0;
- ExpectI2cReadSuccessWithResult(probe_function.get(), 3, 0x01, 0x01,
- std::vector<uint8_t>{}, 1, kMatchValueForReg1,
- &command_counter_2);
-
- auto actual = EvalProbeFunction(probe_function.get());
-
- EXPECT_EQ(command_counter_1_succ, 1);
- EXPECT_EQ(command_counter_1_fail, 1);
- EXPECT_EQ(command_counter_2, 1);
- ExpectUnorderedListEqual(actual, CreateProbeResultFromJson(R"JSON(
- [
- {
- "component_type": "base_sensor",
- "component_name": "base_sensor_5"
- }
- ]
- )JSON"));
-}
-
TEST_F(EcComponentFunctionTestWithIsh, ProbeWithIshComponentsSucceed) {
auto arguments =
base::JSONReader::Read("{}", base::JSON_PARSE_CHROMIUM_EXTENSIONS);
diff --git a/runtime_probe/testdata/cme/component_manifest.basic.ish.json b/runtime_probe/testdata/cme/component_manifest.basic.ish.json
index f399d9d..aef9bf9 100644
--- a/runtime_probe/testdata/cme/component_manifest.basic.ish.json
+++ b/runtime_probe/testdata/cme/component_manifest.basic.ish.json
@@ -37,8 +37,7 @@
"bytes": 1
}
]
- },
- "probe": "low_power_probe_once"
+ }
},
{
"component_type": "base_sensor",
diff --git a/runtime_probe/testdata/cme/component_manifest.basic.json b/runtime_probe/testdata/cme/component_manifest.basic.json
index a5d46ea..c897e3e 100644
--- a/runtime_probe/testdata/cme/component_manifest.basic.json
+++ b/runtime_probe/testdata/cme/component_manifest.basic.json
@@ -37,8 +37,7 @@
"bytes": 1
}
]
- },
- "probe": "low_power_probe_once"
+ }
},
{
"component_type": "base_sensor",
diff --git a/runtime_probe/testdata/cme/component_manifest.no_expect.json b/runtime_probe/testdata/cme/component_manifest.no_expect.json
index 2c58cee..7df1f7a 100644
--- a/runtime_probe/testdata/cme/component_manifest.no_expect.json
+++ b/runtime_probe/testdata/cme/component_manifest.no_expect.json
@@ -34,18 +34,6 @@
"usbc": {
"port": 1
}
- },
- {
- "component_type": "bc12",
- "component_name": "bc12_3",
- "i2c": {
- "port": 4,
- "addr": "0x5f"
- },
- "usbc": {
- "port": 2
- },
- "probe": "low_power_probe_once"
}
]
}
diff --git a/runtime_probe/testdata/cme/component_manifest.with_expect.json b/runtime_probe/testdata/cme/component_manifest.with_expect.json
index c49fafe..5b8423e 100644
--- a/runtime_probe/testdata/cme/component_manifest.with_expect.json
+++ b/runtime_probe/testdata/cme/component_manifest.with_expect.json
@@ -82,27 +82,6 @@
}
]
}
- },
- {
- "component_type": "base_sensor",
- "component_name": "base_sensor_5",
- "i2c": {
- "port": 3,
- "addr": "0x01",
- "expect": [
- {
- "reg": "0x00",
- "mask": "0xff",
- "value": "0x00"
- },
- {
- "reg": "0x01",
- "mask": "0x0f",
- "value": "0x01"
- }
- ]
- },
- "probe": "low_power_probe_once"
}
]
}
diff --git a/runtime_probe/utils/ec_component_manifest.cc b/runtime_probe/utils/ec_component_manifest.cc
index e55ea0c..8096939d 100644
--- a/runtime_probe/utils/ec_component_manifest.cc
+++ b/runtime_probe/utils/ec_component_manifest.cc
@@ -25,7 +25,6 @@
namespace {
constexpr int kDefaultBytes = 1;
-constexpr char kLowPowerProbeOnce[] = "low_power_probe_once";
template <typename T, typename U>
bool SetValue(const U& value, T& val) {
@@ -119,9 +118,9 @@
}
bool SetBytesFromDict(const base::Value::Dict& dv,
- std::string_view key,
- std::string_view multi_byte_key,
- std::string_view override_key,
+ const std::string& key,
+ const std::string& multi_byte_key,
+ const std::string& override_key,
std::optional<std::vector<uint8_t>>& out) {
const std::string* override_value = dv.FindString(override_key);
if (override_value) {
@@ -239,13 +238,6 @@
LOG(ERROR) << "Invalid field: i2c";
return std::nullopt;
}
-
- auto probe = dv.FindString("probe");
- if (probe && *probe == kLowPowerProbeOnce) {
- ret.probe_strategy = ProbeStrategy::WAKE_UP;
- } else {
- ret.probe_strategy = ProbeStrategy::DEFAULT;
- }
return ret;
}
diff --git a/runtime_probe/utils/ec_component_manifest.h b/runtime_probe/utils/ec_component_manifest.h
index 8577841..06e911b 100644
--- a/runtime_probe/utils/ec_component_manifest.h
+++ b/runtime_probe/utils/ec_component_manifest.h
@@ -24,13 +24,6 @@
// This class handles the component manifest.
struct EcComponentManifest {
- enum class ProbeStrategy {
- DEFAULT = 0,
- // Executes the first i2c command twice, with the return value of the first
- // execution being ignored, to wake up the component from low-power mode.
- WAKE_UP = 1,
- };
-
struct Component {
struct I2c {
struct Expect {
@@ -52,7 +45,6 @@
std::string component_type;
std::string component_name;
I2c i2c;
- ProbeStrategy probe_strategy;
static std::optional<Component> Create(const base::Value::Dict&);
};
diff --git a/runtime_probe/utils/ec_component_manifest_test.cc b/runtime_probe/utils/ec_component_manifest_test.cc
index 7675de2..e21d2f1 100644
--- a/runtime_probe/utils/ec_component_manifest_test.cc
+++ b/runtime_probe/utils/ec_component_manifest_test.cc
@@ -155,7 +155,6 @@
const EcComponentManifest::Component& comp = manifest->component_list[0];
EXPECT_EQ(comp.component_type, "base_sensor");
EXPECT_EQ(comp.component_name, "base_sensor_1");
- EXPECT_EQ(comp.probe_strategy, EcComponentManifest::ProbeStrategy::WAKE_UP);
EXPECT_EQ(comp.i2c.port, 3);
EXPECT_EQ(comp.i2c.addr, 0x1);
EXPECT_EQ(comp.i2c.expect.size(), 4);
@@ -191,7 +190,6 @@
const EcComponentManifest::Component& comp = manifest->component_list[1];
EXPECT_EQ(comp.component_type, "base_sensor");
EXPECT_EQ(comp.component_name, "base_sensor_2");
- EXPECT_EQ(comp.probe_strategy, EcComponentManifest::ProbeStrategy::DEFAULT);
EXPECT_EQ(comp.i2c.port, 3);
EXPECT_EQ(comp.i2c.addr, 0x2);
EXPECT_EQ(comp.i2c.expect.size(), 0);