1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 3 #ifndef __DRIVERS_GENERIC_GPIO_KEYS_H__ 4 #define __DRIVERS_GENERIC_GPIO_KEYS_H__ 5 6 #include <acpi/acpi_device.h> 7 #include <stdint.h> 8 9 /* Linux input type */ 10 enum { 11 /* Switch event */ 12 EV_SW = 0x5, 13 }; 14 15 /* Switch events type (Linux code emitted for EV_SW) */ 16 enum { 17 SW_MUTE_DEVICE = 0xe, 18 SW_PEN_INSERTED = 0xf, 19 }; 20 21 /* Trigger for wakeup event action */ 22 enum { 23 EV_ACT_ANY, 24 EV_ACT_ASSERTED, 25 EV_ACT_DEASSERTED, 26 }; 27 28 enum { 29 /* 30 * GPIO key uses SCI route to wake the system from suspend state. This is typically used 31 * when the input line is dual routed i.e. one for IRQ and other for SCI or if the GPIO 32 * controller is capable of handling the filtering for IRQ and SCI separately. This 33 * requires "wake" property to be provided by the board which represents the GPE # for 34 * wake. It is exposed as _PRW in ACPI tables. 35 */ 36 WAKEUP_ROUTE_SCI, 37 /* 38 * GPIO key uses GPIO controller IRQ route for wake. This is used when IRQ and wake are 39 * routed to the same pad and the GPIO controller is not capable of handling the trigger 40 * filtering separately for IRQ and wake. Kernel driver for gpio-keys takes care of 41 * reconfiguring the IRQ trigger as both edges when used in S0 and the edge requested by 42 * BIOS (as per wakeup_event_action) when entering suspend. In this case, _PRW is not 43 * exposed for the key device. 44 */ 45 WAKEUP_ROUTE_GPIO_IRQ, 46 /* GPIO key does not support wake. */ 47 WAKEUP_ROUTE_DISABLED, 48 }; 49 50 /* Details of the child node defining key */ 51 struct key_info { 52 /* Device name of the child node - Mandatory */ 53 const char *dev_name; 54 /* Keycode emitted for this key - Mandatory */ 55 uint32_t linux_code; 56 /* 57 * Event type generated for this key 58 * See EV_* above. 59 */ 60 uint32_t linux_input_type; 61 /* Descriptive name of the key */ 62 const char *label; 63 /* Wakeup route (if any) for the key. See WAKEUP_ROUTE_* macros above. */ 64 unsigned int wakeup_route; 65 /* Wake GPE -- SCI GPE # for wake. Required for WAKEUP_ROUTE_SCI. */ 66 unsigned int wake_gpe; 67 /* Trigger for Wakeup Event Action as defined in EV_ACT_* enum */ 68 unsigned int wakeup_event_action; 69 /* Can this key be disabled? */ 70 bool can_be_disabled; 71 /* Debounce interval time in milliseconds */ 72 uint32_t debounce_interval; 73 }; 74 75 struct drivers_generic_gpio_keys_config { 76 /* Device name of the parent gpio-keys node */ 77 const char *name; 78 /* Name of the input device - Optional */ 79 const char *label; 80 /* GPIO line providing the key - Mandatory */ 81 struct acpi_gpio gpio; 82 /* Is this a polled GPIO button? - Optional */ 83 bool is_polled; 84 /* Poll interval - Mandatory only if GPIO is polled. */ 85 uint32_t poll_interval; 86 /* Details about the key - Mandatory */ 87 struct key_info key; 88 }; 89 90 #endif /* __DRIVERS_GENERIC_GPIO_KEYS_H__ */ 91