summaryrefslogtreecommitdiff
path: root/drivers/misc/cros_ec_sandbox.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-01-17 00:52:28 +0300
committerSimon Glass <sjg@chromium.org>2021-01-31 00:25:41 +0300
commit3a6c994f3896d66e617acdf9bb58ffc4def08b71 (patch)
treed8b222358a56ab098e8a66a3f09a5b2b0d0066ee /drivers/misc/cros_ec_sandbox.c
parent2b4b65339110e11b4a859fceeb1eec82b2ebb5f1 (diff)
downloadu-boot-3a6c994f3896d66e617acdf9bb58ffc4def08b71.tar.xz
cros_ec: Add support for switches
On x86 platforms the EC provides a way to read 'switches', which are on/off values determined by the EC. Add a new driver method for this and implement it for LPC. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/misc/cros_ec_sandbox.c')
-rw-r--r--drivers/misc/cros_ec_sandbox.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index 7213313c1a..38a2614a99 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -75,6 +75,7 @@ struct ec_keymatrix_entry {
* @keyscan: Current keyscan information (bit set for each row/column pressed)
* @recovery_req: Keyboard recovery requested
* @test_flags: Flags that control behaviour for tests
+ * @switches: Current switches value (EC_SWITCH_)
*/
struct ec_state {
u8 vbnv_context[EC_VBNV_BLOCK_SIZE_V2];
@@ -541,6 +542,14 @@ void cros_ec_check_keyboard(struct udevice *dev)
}
}
+/* Return the byte of EC switch states */
+static int cros_ec_sandbox_get_switches(struct udevice *dev)
+{
+ struct ec_state *ec = dev_get_priv(dev);
+
+ return ec->test_flags & CROSECT_LID_OPEN ? EC_SWITCH_LID_OPEN : 0;
+}
+
void sandbox_cros_ec_set_test_flags(struct udevice *dev, uint flags)
{
struct ec_state *ec = dev_get_priv(dev);
@@ -603,6 +612,7 @@ int cros_ec_probe(struct udevice *dev)
struct dm_cros_ec_ops cros_ec_ops = {
.packet = cros_ec_sandbox_packet,
+ .get_switches = cros_ec_sandbox_get_switches,
};
static const struct udevice_id cros_ec_ids[] = {