aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@marvell.com>2010-02-03 15:40:59 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2010-03-07 16:17:20 -0500
commit6985403138b74ad28c8ddac8baf88869556bec9a (patch)
tree74c315ae903bd1eff89bb164eb1dac07fb315de7 /drivers/input/misc
parent2afa62ea76027b00e472ddb672191e6e15425b43 (diff)
input: Support onkey in 88pm860x
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/input/misc')
-rw-r--r--drivers/input/misc/88pm860x_onkey.c155
-rw-r--r--drivers/input/misc/Kconfig10
-rw-r--r--drivers/input/misc/Makefile1
3 files changed, 166 insertions, 0 deletions
diff --git a/drivers/input/misc/88pm860x_onkey.c b/drivers/input/misc/88pm860x_onkey.c
new file mode 100644
index 000000000000..69a48e8701b9
--- /dev/null
+++ b/drivers/input/misc/88pm860x_onkey.c
@@ -0,0 +1,155 @@
1/*
2 * 88pm860x_onkey.c - Marvell 88PM860x ONKEY driver
3 *
4 * Copyright (C) 2009-2010 Marvell International Ltd.
5 * Haojian Zhuang <haojian.zhuang@marvell.com>
6 *
7 * This file is subject to the terms and conditions of the GNU General
8 * Public License. See the file "COPYING" in the main directory of this
9 * archive for more details.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/platform_device.h>
24#include <linux/i2c.h>
25#include <linux/input.h>
26#include <linux/interrupt.h>
27#include <linux/mfd/88pm860x.h>
28
29#define PM8607_WAKEUP 0x0b
30
31#define LONG_ONKEY_EN (1 << 1)
32#define ONKEY_STATUS (1 << 0)
33
34struct pm860x_onkey_info {
35 struct input_dev *idev;
36 struct pm860x_chip *chip;
37 struct i2c_client *i2c;
38 struct device *dev;
39 int irq;
40};
41
42/* 88PM860x gives us an interrupt when ONKEY is held */
43static irqreturn_t pm860x_onkey_handler(int irq, void *data)
44{
45 struct pm860x_onkey_info *info = data;
46 int ret;
47
48 ret = pm860x_reg_read(info->i2c, PM8607_STATUS_2);
49 ret &= ONKEY_STATUS;
50 input_report_key(info->idev, KEY_POWER, ret);
51 input_sync(info->idev);
52
53 /* Enable 8-second long onkey detection */
54 pm860x_set_bits(info->i2c, PM8607_WAKEUP, 3, LONG_ONKEY_EN);
55 return IRQ_HANDLED;
56}
57
58static int __devinit pm860x_onkey_probe(struct platform_device *pdev)
59{
60 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
61 struct pm860x_onkey_info *info;
62 int irq, ret;
63
64 irq = platform_get_irq(pdev, 0);
65 if (irq < 0) {
66 dev_err(&pdev->dev, "No IRQ resource!\n");
67 return -EINVAL;
68 }
69
70 info = kzalloc(sizeof(struct pm860x_onkey_info), GFP_KERNEL);
71 if (!info)
72 return -ENOMEM;
73 info->chip = chip;
74 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
75 info->dev = &pdev->dev;
76 info->irq = irq + chip->irq_base;
77
78 info->idev = input_allocate_device();
79 if (!info->idev) {
80 dev_err(chip->dev, "Failed to allocate input dev\n");
81 ret = -ENOMEM;
82 goto out;
83 }
84
85 info->idev->name = "88pm860x_on";
86 info->idev->phys = "88pm860x_on/input0";
87 info->idev->id.bustype = BUS_I2C;
88 info->idev->dev.parent = &pdev->dev;
89 info->irq = irq;
90 info->idev->evbit[0] = BIT_MASK(EV_KEY);
91 info->idev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
92
93 ret = input_register_device(info->idev);
94 if (ret) {
95 dev_err(chip->dev, "Can't register input device: %d\n", ret);
96 goto out_reg;
97 }
98
99 ret = request_threaded_irq(info->irq, NULL, pm860x_onkey_handler,
100 IRQF_ONESHOT, "onkey", info);
101 if (ret < 0) {
102 dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
103 info->irq, ret);
104 goto out_irq;
105 }
106
107 platform_set_drvdata(pdev, info);
108 return 0;
109
110out_irq:
111 input_unregister_device(info->idev);
112 kfree(info);
113 return ret;
114
115out_reg:
116 input_free_device(info->idev);
117out:
118 kfree(info);
119 return ret;
120}
121
122static int __devexit pm860x_onkey_remove(struct platform_device *pdev)
123{
124 struct pm860x_onkey_info *info = platform_get_drvdata(pdev);
125
126 free_irq(info->irq, info);
127 input_unregister_device(info->idev);
128 kfree(info);
129 return 0;
130}
131
132static struct platform_driver pm860x_onkey_driver = {
133 .driver = {
134 .name = "88pm860x-onkey",
135 .owner = THIS_MODULE,
136 },
137 .probe = pm860x_onkey_probe,
138 .remove = __devexit_p(pm860x_onkey_remove),
139};
140
141static int __init pm860x_onkey_init(void)
142{
143 return platform_driver_register(&pm860x_onkey_driver);
144}
145module_init(pm860x_onkey_init);
146
147static void __exit pm860x_onkey_exit(void)
148{
149 platform_driver_unregister(&pm860x_onkey_driver);
150}
151module_exit(pm860x_onkey_exit);
152
153MODULE_DESCRIPTION("Marvell 88PM860x ONKEY driver");
154MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
155MODULE_LICENSE("GPL");
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 16ec5233441c..7097bfe581d7 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -12,6 +12,16 @@ menuconfig INPUT_MISC
12 12
13if INPUT_MISC 13if INPUT_MISC
14 14
15config INPUT_88PM860X_ONKEY
16 tristate "88PM860x ONKEY support"
17 depends on MFD_88PM860X
18 help
19 Support the ONKEY of Marvell 88PM860x PMICs as an input device
20 reporting power button status.
21
22 To compile this driver as a module, choose M here: the module
23 will be called 88pm860x_onkey.
24
15config INPUT_PCSPKR 25config INPUT_PCSPKR
16 tristate "PC Speaker support" 26 tristate "PC Speaker support"
17 depends on PCSPKR_PLATFORM 27 depends on PCSPKR_PLATFORM
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index a8b84854fb7b..b611615e24ad 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -4,6 +4,7 @@
4 4
5# Each configuration option enables a list of files. 5# Each configuration option enables a list of files.
6 6
7obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o
7obj-$(CONFIG_INPUT_APANEL) += apanel.o 8obj-$(CONFIG_INPUT_APANEL) += apanel.o
8obj-$(CONFIG_INPUT_ATI_REMOTE) += ati_remote.o 9obj-$(CONFIG_INPUT_ATI_REMOTE) += ati_remote.o
9obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o 10obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o