aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/generic/gpio_keys/chip.h
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2018-01-11 19:28:37 -0800
committerFurquan Shaikh <furquan@google.com>2018-01-31 03:04:36 +0000
commit3c8e00e4cc46a25aaead85481ec745ebac95ed30 (patch)
tree3c19ce3e179527d3977b785cfaa2e3e53f5150af /src/drivers/generic/gpio_keys/chip.h
parentc32e6cb34a76fed21dc8e6841fe4a4ee1ebd6803 (diff)
drivers/gpio_keys: Add driver for handling gpio-keys
This change adds the required device node in SSDT for defining gpio-keys/gpio-keys-polled. Currently, it supports only one gpio-key per device node. BUG=b:71329519 TEST=Verified by adding details to devicetree that device node is added to SSDT: Device (PENH) { Name (_HID, "PRP0001") // _HID: Hardware ID Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings { GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionInputOnly, "\\_SB.PCI0.GPIO", 0x00, ResourceConsumer, , ) { // Pin list 0x002B } }) Name (_DSD, Package (0x04) // _DSD: Device-Specific Data { ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */, Package (0x01) { Package (0x02) { "compatible", "gpio-keys" } }, ToUUID ("dbb8e3e6-5886-4ba6-8795-1319f52a966b"), Package (0x01) { Package (0x02) { "button-0", "EJCT" } } }) Name (EJCT, Package (0x02) { ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */, Package (0x04) { Package (0x02) { "linux,code", 0x0F }, Package (0x02) { "linux,input-type", 0x05 }, Package (0x02) { "label", "pen_eject" }, Package (0x02) { "gpios", Package (0x04) { \_SB.PCI0.I2C0.PENH, Zero, Zero, One } } } }) } Change-Id: I6f11397b17d9de1c87d56f6a61669ef4052ec27b Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/23236 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers/generic/gpio_keys/chip.h')
-rw-r--r--src/drivers/generic/gpio_keys/chip.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/drivers/generic/gpio_keys/chip.h b/src/drivers/generic/gpio_keys/chip.h
new file mode 100644
index 0000000000..bdeb0afeb7
--- /dev/null
+++ b/src/drivers/generic/gpio_keys/chip.h
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __DRIVERS_GENERIC_GPIO_KEYS_H__
+#define __DRIVERS_GENERIC_GPIO_KEYS_H__
+
+#include <arch/acpi_device.h>
+#include <stdint.h>
+
+/* Linux input type */
+enum {
+ /* Switch event */
+ EV_SW = 0x5,
+};
+
+/* Switch events type (Linux code emitted for EV_SW) */
+enum {
+ SW_PEN_INSERTED = 0xf,
+};
+
+/* Details of the child node defining key */
+struct key_info {
+ /* Device name of the child node - Mandatory */
+ const char *dev_name;
+ /* Keycode emitted for this key - Mandatory */
+ uint32_t linux_code;
+ /*
+ * Event type generated for this key
+ * See EV_* above.
+ */
+ uint32_t linux_input_type;
+ /* Descriptive name of the key */
+ const char *label;
+ /* Can this key wake-up the system? */
+ bool is_wakeup_source;
+ /* Can this key be disabled? */
+ bool can_be_disabled;
+ /* Debounce interval time in milliseconds */
+ uint32_t debounce_interval;
+};
+
+struct drivers_generic_gpio_keys_config {
+ /* Device name of the parent gpio-keys node */
+ const char *name;
+ /* GPIO line providing the key - Mandatory */
+ struct acpi_gpio gpio;
+ /* Is this a polled GPIO button? - Optional */
+ bool is_polled;
+ /* Poll inverval - Mandatory only if GPIO is polled. */
+ uint32_t poll_interval;
+ /* Details about the key - Mandatory */
+ struct key_info key;
+};
+
+#endif /* __DRIVERS_GENERIC_GPIO_KEYS_H__ */