summaryrefslogtreecommitdiff
path: root/common/lid_switch.c
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-07-23 11:11:25 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-07-23 22:38:06 +0000
commita834638b29823e7eeeb98a7a85675d7253f938b4 (patch)
tree57708beb6db21aadfc0d1f41f5f7eae10151f557 /common/lid_switch.c
parentbcb8e11c63679acca9b01df0c7ecd1e600cc4b88 (diff)
downloadchrome-ec-a834638b29823e7eeeb98a7a85675d7253f938b4.tar.gz
lid_switch: allow to specify several lid GPIOs
Add a X-macro CONFIG_LID_SWITCH_GPIO_LIST to be able to optionally specify more than one GPIO to check to find out whether the lid is open. By default, use GPIO_LID_OPEN as before. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=smaug BUG=chrome-os-partner:42110 TEST=on Smaug EVT2, define CONFIG_LID_SWITCH_GPIO_LIST as LID_GPIO(GPIO_LID_OPEN) LID_GPIO(GPIO_BASE_PRES_L) and play with magnets and the genuine lid, check we get the right "lid open" / "lid close" messages on the console. Change-Id: I9e7c67bb39f36f254d31d5861d535d69db754faa Reviewed-on: https://chromium-review.googlesource.com/287852 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/lid_switch.c')
-rw-r--r--common/lid_switch.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/common/lid_switch.c b/common/lid_switch.c
index 8671368631..eefd2bdfa1 100644
--- a/common/lid_switch.c
+++ b/common/lid_switch.c
@@ -20,6 +20,11 @@
#define LID_DEBOUNCE_US (30 * MSEC) /* Debounce time for lid switch */
+/* if no X-macro is defined for LID switch GPIO, use GPIO_LID_OPEN as default */
+#ifndef CONFIG_LID_SWITCH_GPIO_LIST
+#define CONFIG_LID_SWITCH_GPIO_LIST LID_GPIO(GPIO_LID_OPEN)
+#endif
+
static int debounced_lid_open; /* Debounced lid state */
static int forced_lid_open; /* Forced lid open */
@@ -30,7 +35,9 @@ static int forced_lid_open; /* Forced lid open */
*/
static int raw_lid_open(void)
{
- return (forced_lid_open || gpio_get_level(GPIO_LID_OPEN)) ? 1 : 0;
+#define LID_GPIO(gpio) || gpio_get_level(gpio)
+ return (forced_lid_open CONFIG_LID_SWITCH_GPIO_LIST) ? 1 : 0;
+#undef LID_GPIO
}
/**
@@ -79,7 +86,9 @@ static void lid_init(void)
debounced_lid_open = 1;
/* Enable interrupts, now that we've initialized */
- gpio_enable_interrupt(GPIO_LID_OPEN);
+#define LID_GPIO(gpio) gpio_enable_interrupt(gpio);
+ CONFIG_LID_SWITCH_GPIO_LIST
+#undef LID_GPIO
}
DECLARE_HOOK(HOOK_INIT, lid_init, HOOK_PRIO_INIT_LID);