diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2018-03-07 14:56:55 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2018-03-08 18:34:45 -0500 |
commit | 62f0f079b96d38b6c8a47a52477024b1197652f4 (patch) | |
tree | f39515d6e48653b2fe656e5f5905254a8e4954c0 /drivers/input/misc | |
parent | c6380ecd8e9bee7aba3d9a5a94b58168244c4a61 (diff) |
Input: add RAVE SP Powerbutton driver
Add driver that properly handles input event emitted by RAVE SP
devices.
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/misc')
-rw-r--r-- | drivers/input/misc/Kconfig | 9 | ||||
-rw-r--r-- | drivers/input/misc/Makefile | 1 | ||||
-rw-r--r-- | drivers/input/misc/rave-sp-pwrbutton.c | 94 |
3 files changed, 104 insertions, 0 deletions
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 62a1312a7387..6a3c753b093b 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
@@ -841,4 +841,13 @@ config INPUT_HISI_POWERKEY | |||
841 | To compile this driver as a module, choose M here: the | 841 | To compile this driver as a module, choose M here: the |
842 | module will be called hisi_powerkey. | 842 | module will be called hisi_powerkey. |
843 | 843 | ||
844 | config INPUT_RAVE_SP_PWRBUTTON | ||
845 | tristate "RAVE SP Power button Driver" | ||
846 | depends on RAVE_SP_CORE | ||
847 | help | ||
848 | Say Y here if you want to enable power key reporting from RAVE SP | ||
849 | |||
850 | To compile this driver as a module, choose M here: the | ||
851 | module will be called rave-sp-pwrbutton. | ||
852 | |||
844 | endif | 853 | endif |
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index a8f61af865aa..8cc58f362bb8 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile | |||
@@ -60,6 +60,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY) += pmic8xxx-pwrkey.o | |||
60 | obj-$(CONFIG_INPUT_POWERMATE) += powermate.o | 60 | obj-$(CONFIG_INPUT_POWERMATE) += powermate.o |
61 | obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o | 61 | obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o |
62 | obj-$(CONFIG_INPUT_PWM_VIBRA) += pwm-vibra.o | 62 | obj-$(CONFIG_INPUT_PWM_VIBRA) += pwm-vibra.o |
63 | obj-$(CONFIG_INPUT_RAVE_SP_PWRBUTTON) += rave-sp-pwrbutton.o | ||
63 | obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o | 64 | obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o |
64 | obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) += regulator-haptic.o | 65 | obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) += regulator-haptic.o |
65 | obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o | 66 | obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o |
diff --git a/drivers/input/misc/rave-sp-pwrbutton.c b/drivers/input/misc/rave-sp-pwrbutton.c new file mode 100644 index 000000000000..bcab3cdb7ebd --- /dev/null +++ b/drivers/input/misc/rave-sp-pwrbutton.c | |||
@@ -0,0 +1,94 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
2 | // | ||
3 | // Power Button driver for RAVE SP | ||
4 | // | ||
5 | // Copyright (C) 2017 Zodiac Inflight Innovations | ||
6 | // | ||
7 | // | ||
8 | |||
9 | #include <linux/input.h> | ||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/mfd/rave-sp.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | |||
15 | #define RAVE_SP_EVNT_BUTTON_PRESS (RAVE_SP_EVNT_BASE + 0x00) | ||
16 | |||
17 | struct rave_sp_power_button { | ||
18 | struct input_dev *idev; | ||
19 | struct notifier_block nb; | ||
20 | }; | ||
21 | |||
22 | static int rave_sp_power_button_event(struct notifier_block *nb, | ||
23 | unsigned long action, void *data) | ||
24 | { | ||
25 | struct rave_sp_power_button *pb = | ||
26 | container_of(nb, struct rave_sp_power_button, nb); | ||
27 | const u8 event = rave_sp_action_unpack_event(action); | ||
28 | const u8 value = rave_sp_action_unpack_value(action); | ||
29 | struct input_dev *idev = pb->idev; | ||
30 | |||
31 | if (event == RAVE_SP_EVNT_BUTTON_PRESS) { | ||
32 | input_report_key(idev, KEY_POWER, value); | ||
33 | input_sync(idev); | ||
34 | |||
35 | return NOTIFY_STOP; | ||
36 | } | ||
37 | |||
38 | return NOTIFY_DONE; | ||
39 | } | ||
40 | |||
41 | static int rave_sp_pwrbutton_probe(struct platform_device *pdev) | ||
42 | { | ||
43 | struct device *dev = &pdev->dev; | ||
44 | struct rave_sp_power_button *pb; | ||
45 | struct input_dev *idev; | ||
46 | int error; | ||
47 | |||
48 | pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL); | ||
49 | if (!pb) | ||
50 | return -ENOMEM; | ||
51 | |||
52 | idev = devm_input_allocate_device(dev); | ||
53 | if (!idev) | ||
54 | return -ENOMEM; | ||
55 | |||
56 | idev->name = pdev->name; | ||
57 | |||
58 | input_set_capability(idev, EV_KEY, KEY_POWER); | ||
59 | |||
60 | error = input_register_device(idev); | ||
61 | if (error) | ||
62 | return error; | ||
63 | |||
64 | pb->idev = idev; | ||
65 | pb->nb.notifier_call = rave_sp_power_button_event; | ||
66 | pb->nb.priority = 128; | ||
67 | |||
68 | error = devm_rave_sp_register_event_notifier(dev, &pb->nb); | ||
69 | if (error) | ||
70 | return error; | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static const struct of_device_id rave_sp_pwrbutton_of_match[] = { | ||
76 | { .compatible = "zii,rave-sp-pwrbutton" }, | ||
77 | {} | ||
78 | }; | ||
79 | |||
80 | static struct platform_driver rave_sp_pwrbutton_driver = { | ||
81 | .probe = rave_sp_pwrbutton_probe, | ||
82 | .driver = { | ||
83 | .name = KBUILD_MODNAME, | ||
84 | .of_match_table = rave_sp_pwrbutton_of_match, | ||
85 | }, | ||
86 | }; | ||
87 | module_platform_driver(rave_sp_pwrbutton_driver); | ||
88 | |||
89 | MODULE_DEVICE_TABLE(of, rave_sp_pwrbutton_of_match); | ||
90 | MODULE_LICENSE("GPL"); | ||
91 | MODULE_AUTHOR("Andrey Vostrikov <andrey.vostrikov@cogentembedded.com>"); | ||
92 | MODULE_AUTHOR("Nikita Yushchenko <nikita.yoush@cogentembedded.com>"); | ||
93 | MODULE_AUTHOR("Andrey Smirnov <andrew.smirnov@gmail.com>"); | ||
94 | MODULE_DESCRIPTION("RAVE SP Power Button driver"); | ||