#include <linux/module.h>
#include <linux/hrtimer.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/sched.h>
#include <linux/pm.h>
#include <linux/slab.h>
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/input.h>
#include <linux/gpio_keys.h>
#include <linux/workqueue.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/spinlock.h>
#include <dt-bindings/input/gpio-keys.h>
struct gpio_button_data { … };
struct gpio_keys_drvdata { … };
static int get_n_events_by_type(int type)
{ … }
static const unsigned long *get_bm_events_by_type(struct input_dev *dev,
int type)
{ … }
static void gpio_keys_quiesce_key(void *data)
{ … }
static void gpio_keys_disable_button(struct gpio_button_data *bdata)
{ … }
static void gpio_keys_enable_button(struct gpio_button_data *bdata)
{ … }
static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata,
char *buf, unsigned int type,
bool only_disabled)
{ … }
static ssize_t gpio_keys_attr_store_helper(struct gpio_keys_drvdata *ddata,
const char *buf, unsigned int type)
{ … }
#define ATTR_SHOW_FN(name, type, only_disabled) …
ATTR_SHOW_FN(keys, EV_KEY, false);
ATTR_SHOW_FN(switches, EV_SW, false);
ATTR_SHOW_FN(disabled_keys, EV_KEY, true);
ATTR_SHOW_FN(disabled_switches, EV_SW, true);
static DEVICE_ATTR(keys, S_IRUGO, gpio_keys_show_keys, NULL);
static DEVICE_ATTR(switches, S_IRUGO, gpio_keys_show_switches, NULL);
#define ATTR_STORE_FN(name, type) …
ATTR_STORE_FN(disabled_keys, EV_KEY);
ATTR_STORE_FN(disabled_switches, EV_SW);
static DEVICE_ATTR(disabled_keys, S_IWUSR | S_IRUGO,
gpio_keys_show_disabled_keys,
gpio_keys_store_disabled_keys);
static DEVICE_ATTR(disabled_switches, S_IWUSR | S_IRUGO,
gpio_keys_show_disabled_switches,
gpio_keys_store_disabled_switches);
static struct attribute *gpio_keys_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
{ … }
static void gpio_keys_debounce_event(struct gpio_button_data *bdata)
{ … }
static void gpio_keys_gpio_work_func(struct work_struct *work)
{ … }
static enum hrtimer_restart gpio_keys_debounce_timer(struct hrtimer *t)
{ … }
static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
{ … }
static enum hrtimer_restart gpio_keys_irq_timer(struct hrtimer *t)
{ … }
static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)
{ … }
static int gpio_keys_setup_key(struct platform_device *pdev,
struct input_dev *input,
struct gpio_keys_drvdata *ddata,
const struct gpio_keys_button *button,
int idx,
struct fwnode_handle *child)
{ … }
static void gpio_keys_report_state(struct gpio_keys_drvdata *ddata)
{ … }
static int gpio_keys_open(struct input_dev *input)
{ … }
static void gpio_keys_close(struct input_dev *input)
{ … }
static struct gpio_keys_platform_data *
gpio_keys_get_devtree_pdata(struct device *dev)
{ … }
static const struct of_device_id gpio_keys_of_match[] = …;
MODULE_DEVICE_TABLE(of, gpio_keys_of_match);
static int gpio_keys_probe(struct platform_device *pdev)
{ … }
static int __maybe_unused
gpio_keys_button_enable_wakeup(struct gpio_button_data *bdata)
{ … }
static void __maybe_unused
gpio_keys_button_disable_wakeup(struct gpio_button_data *bdata)
{ … }
static int __maybe_unused
gpio_keys_enable_wakeup(struct gpio_keys_drvdata *ddata)
{ … }
static void __maybe_unused
gpio_keys_disable_wakeup(struct gpio_keys_drvdata *ddata)
{ … }
static int gpio_keys_suspend(struct device *dev)
{ … }
static int gpio_keys_resume(struct device *dev)
{ … }
static DEFINE_SIMPLE_DEV_PM_OPS(gpio_keys_pm_ops, gpio_keys_suspend, gpio_keys_resume);
static void gpio_keys_shutdown(struct platform_device *pdev)
{ … }
static struct platform_driver gpio_keys_device_driver = …;
static int __init gpio_keys_init(void)
{ … }
static void __exit gpio_keys_exit(void)
{ … }
late_initcall(gpio_keys_init);
module_exit(gpio_keys_exit);
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_ALIAS(…) …;