summaryrefslogtreecommitdiff
path: root/chip_interface/lid.h
diff options
context:
space:
mode:
Diffstat (limited to 'chip_interface/lid.h')
-rw-r--r--chip_interface/lid.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/chip_interface/lid.h b/chip_interface/lid.h
new file mode 100644
index 0000000000..cffa35c4f4
--- /dev/null
+++ b/chip_interface/lid.h
@@ -0,0 +1,38 @@
+/* lid.h - handle lid open/close
+ *
+ * (Chromium license) */
+
+#ifndef __CHIP_INTERFACE_LID_H
+#define __CHIP_INTERFACE_LID_H
+
+/* Initialize the GPIO pin */
+EcError CrLidSwitchInit(void);
+
+/* Calls GPIOPinRead() to read the GPIO state. */
+/* TODO: has the state been debounced? */
+EcError CrLidSwitchState(void);
+
+/* Register a calback function. It is called while lid state is changed.
+ */
+EcError CrLidSwitchRegister(void (*callback)(void));
+
+/* Below is the example code to register this function. */
+#if 0
+/* This callback function is implemented in Chrome OS features layer. */
+void LidSwitchChanged(void) {
+ int lid_open = CrLidSwitchState();
+ if (lid_open) {
+ if (system is in S3) {
+ // resume system
+ }
+ } else {
+ if (system is in S0) {
+ // suspend system
+ }
+ }
+}
+ ... somewhere in init code ...
+ CrLidSwitchRegister(LidSwitchChanged);
+#endif
+
+#endif /* __CHIP_INTERFACE_LID_H */