aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2013-03-17 22:40:50 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2013-03-17 22:40:50 -0400
commit688d794c4c3f8b08c814381ee2edd3ede5856056 (patch)
treeef680add71e2a9588d07d8b594edbc1b5cd127d7 /drivers/input/misc
parent16142655269aaf580488e074eabfdcf0fb4e3687 (diff)
parenta937536b868b8369b98967929045f1df54234323 (diff)
Merge tag 'v3.9-rc3' into next
Merge with mainline to bring in module_platform_driver_probe() and devm_ioremap_resource().
Diffstat (limited to 'drivers/input/misc')
-rw-r--r--drivers/input/misc/Kconfig10
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/arizona-haptics.c255
-rw-r--r--drivers/input/misc/atlas_btns.c2
-rw-r--r--drivers/input/misc/da9052_onkey.c22
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c15
-rw-r--r--drivers/input/misc/max8925_onkey.c3
7 files changed, 284 insertions, 24 deletions
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 3ec8887ce451..af80928a46b4 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -72,6 +72,16 @@ config INPUT_AD714X_SPI
72 To compile this driver as a module, choose M here: the 72 To compile this driver as a module, choose M here: the
73 module will be called ad714x-spi. 73 module will be called ad714x-spi.
74 74
75config INPUT_ARIZONA_HAPTICS
76 tristate "Arizona haptics support"
77 depends on MFD_ARIZONA && SND_SOC
78 select INPUT_FF_MEMLESS
79 help
80 Say Y to enable support for the haptics module in Arizona CODECs.
81
82 To compile this driver as a module, choose M here: the
83 module will be called arizona-haptics.
84
75config INPUT_BMA150 85config INPUT_BMA150
76 tristate "BMA150/SMB380 acceleration sensor support" 86 tristate "BMA150/SMB380 acceleration sensor support"
77 depends on I2C 87 depends on I2C
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index d6873433ba71..d7fc17f11d77 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_INPUT_ADXL34X) += adxl34x.o
14obj-$(CONFIG_INPUT_ADXL34X_I2C) += adxl34x-i2c.o 14obj-$(CONFIG_INPUT_ADXL34X_I2C) += adxl34x-i2c.o
15obj-$(CONFIG_INPUT_ADXL34X_SPI) += adxl34x-spi.o 15obj-$(CONFIG_INPUT_ADXL34X_SPI) += adxl34x-spi.o
16obj-$(CONFIG_INPUT_APANEL) += apanel.o 16obj-$(CONFIG_INPUT_APANEL) += apanel.o
17obj-$(CONFIG_INPUT_ARIZONA_HAPTICS) += arizona-haptics.o
17obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o 18obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o
18obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o 19obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
19obj-$(CONFIG_INPUT_BFIN_ROTARY) += bfin_rotary.o 20obj-$(CONFIG_INPUT_BFIN_ROTARY) += bfin_rotary.o
diff --git a/drivers/input/misc/arizona-haptics.c b/drivers/input/misc/arizona-haptics.c
new file mode 100644
index 000000000000..7a04f54ef961
--- /dev/null
+++ b/drivers/input/misc/arizona-haptics.c
@@ -0,0 +1,255 @@
1/*
2 * Arizona haptics driver
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/platform_device.h>
15#include <linux/input.h>
16#include <linux/slab.h>
17
18#include <sound/soc.h>
19#include <sound/soc-dapm.h>
20
21#include <linux/mfd/arizona/core.h>
22#include <linux/mfd/arizona/pdata.h>
23#include <linux/mfd/arizona/registers.h>
24
25struct arizona_haptics {
26 struct arizona *arizona;
27 struct input_dev *input_dev;
28 struct work_struct work;
29
30 struct mutex mutex;
31 u8 intensity;
32};
33
34static void arizona_haptics_work(struct work_struct *work)
35{
36 struct arizona_haptics *haptics = container_of(work,
37 struct arizona_haptics,
38 work);
39 struct arizona *arizona = haptics->arizona;
40 struct mutex *dapm_mutex = &arizona->dapm->card->dapm_mutex;
41 int ret;
42
43 if (!haptics->arizona->dapm) {
44 dev_err(arizona->dev, "No DAPM context\n");
45 return;
46 }
47
48 if (haptics->intensity) {
49 ret = regmap_update_bits(arizona->regmap,
50 ARIZONA_HAPTICS_PHASE_2_INTENSITY,
51 ARIZONA_PHASE2_INTENSITY_MASK,
52 haptics->intensity);
53 if (ret != 0) {
54 dev_err(arizona->dev, "Failed to set intensity: %d\n",
55 ret);
56 return;
57 }
58
59 /* This enable sequence will be a noop if already enabled */
60 ret = regmap_update_bits(arizona->regmap,
61 ARIZONA_HAPTICS_CONTROL_1,
62 ARIZONA_HAP_CTRL_MASK,
63 1 << ARIZONA_HAP_CTRL_SHIFT);
64 if (ret != 0) {
65 dev_err(arizona->dev, "Failed to start haptics: %d\n",
66 ret);
67 return;
68 }
69
70 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
71
72 ret = snd_soc_dapm_enable_pin(arizona->dapm, "HAPTICS");
73 if (ret != 0) {
74 dev_err(arizona->dev, "Failed to start HAPTICS: %d\n",
75 ret);
76 mutex_unlock(dapm_mutex);
77 return;
78 }
79
80 ret = snd_soc_dapm_sync(arizona->dapm);
81 if (ret != 0) {
82 dev_err(arizona->dev, "Failed to sync DAPM: %d\n",
83 ret);
84 mutex_unlock(dapm_mutex);
85 return;
86 }
87
88 mutex_unlock(dapm_mutex);
89
90 } else {
91 /* This disable sequence will be a noop if already enabled */
92 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
93
94 ret = snd_soc_dapm_disable_pin(arizona->dapm, "HAPTICS");
95 if (ret != 0) {
96 dev_err(arizona->dev, "Failed to disable HAPTICS: %d\n",
97 ret);
98 mutex_unlock(dapm_mutex);
99 return;
100 }
101
102 ret = snd_soc_dapm_sync(arizona->dapm);
103 if (ret != 0) {
104 dev_err(arizona->dev, "Failed to sync DAPM: %d\n",
105 ret);
106 mutex_unlock(dapm_mutex);
107 return;
108 }
109
110 mutex_unlock(dapm_mutex);
111
112 ret = regmap_update_bits(arizona->regmap,
113 ARIZONA_HAPTICS_CONTROL_1,
114 ARIZONA_HAP_CTRL_MASK,
115 1 << ARIZONA_HAP_CTRL_SHIFT);
116 if (ret != 0) {
117 dev_err(arizona->dev, "Failed to stop haptics: %d\n",
118 ret);
119 return;
120 }
121 }
122}
123
124static int arizona_haptics_play(struct input_dev *input, void *data,
125 struct ff_effect *effect)
126{
127 struct arizona_haptics *haptics = input_get_drvdata(input);
128 struct arizona *arizona = haptics->arizona;
129
130 if (!arizona->dapm) {
131 dev_err(arizona->dev, "No DAPM context\n");
132 return -EBUSY;
133 }
134
135 if (effect->u.rumble.strong_magnitude) {
136 /* Scale the magnitude into the range the device supports */
137 if (arizona->pdata.hap_act) {
138 haptics->intensity =
139 effect->u.rumble.strong_magnitude >> 9;
140 if (effect->direction < 0x8000)
141 haptics->intensity += 0x7f;
142 } else {
143 haptics->intensity =
144 effect->u.rumble.strong_magnitude >> 8;
145 }
146 } else {
147 haptics->intensity = 0;
148 }
149
150 schedule_work(&haptics->work);
151
152 return 0;
153}
154
155static void arizona_haptics_close(struct input_dev *input)
156{
157 struct arizona_haptics *haptics = input_get_drvdata(input);
158 struct mutex *dapm_mutex = &haptics->arizona->dapm->card->dapm_mutex;
159
160 cancel_work_sync(&haptics->work);
161
162 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
163
164 if (haptics->arizona->dapm)
165 snd_soc_dapm_disable_pin(haptics->arizona->dapm, "HAPTICS");
166
167 mutex_unlock(dapm_mutex);
168}
169
170static int arizona_haptics_probe(struct platform_device *pdev)
171{
172 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
173 struct arizona_haptics *haptics;
174 int ret;
175
176 haptics = devm_kzalloc(&pdev->dev, sizeof(*haptics), GFP_KERNEL);
177 if (!haptics)
178 return -ENOMEM;
179
180 haptics->arizona = arizona;
181
182 ret = regmap_update_bits(arizona->regmap, ARIZONA_HAPTICS_CONTROL_1,
183 ARIZONA_HAP_ACT, arizona->pdata.hap_act);
184 if (ret != 0) {
185 dev_err(arizona->dev, "Failed to set haptics actuator: %d\n",
186 ret);
187 return ret;
188 }
189
190 INIT_WORK(&haptics->work, arizona_haptics_work);
191
192 haptics->input_dev = input_allocate_device();
193 if (haptics->input_dev == NULL) {
194 dev_err(arizona->dev, "Failed to allocate input device\n");
195 return -ENOMEM;
196 }
197
198 input_set_drvdata(haptics->input_dev, haptics);
199
200 haptics->input_dev->name = "arizona:haptics";
201 haptics->input_dev->dev.parent = pdev->dev.parent;
202 haptics->input_dev->close = arizona_haptics_close;
203 __set_bit(FF_RUMBLE, haptics->input_dev->ffbit);
204
205 ret = input_ff_create_memless(haptics->input_dev, NULL,
206 arizona_haptics_play);
207 if (ret < 0) {
208 dev_err(arizona->dev, "input_ff_create_memless() failed: %d\n",
209 ret);
210 goto err_ialloc;
211 }
212
213 ret = input_register_device(haptics->input_dev);
214 if (ret < 0) {
215 dev_err(arizona->dev, "couldn't register input device: %d\n",
216 ret);
217 goto err_iff;
218 }
219
220 platform_set_drvdata(pdev, haptics);
221
222 return 0;
223
224err_iff:
225 if (haptics->input_dev)
226 input_ff_destroy(haptics->input_dev);
227err_ialloc:
228 input_free_device(haptics->input_dev);
229
230 return ret;
231}
232
233static int arizona_haptics_remove(struct platform_device *pdev)
234{
235 struct arizona_haptics *haptics = platform_get_drvdata(pdev);
236
237 input_unregister_device(haptics->input_dev);
238
239 return 0;
240}
241
242static struct platform_driver arizona_haptics_driver = {
243 .probe = arizona_haptics_probe,
244 .remove = arizona_haptics_remove,
245 .driver = {
246 .name = "arizona-haptics",
247 .owner = THIS_MODULE,
248 },
249};
250module_platform_driver(arizona_haptics_driver);
251
252MODULE_ALIAS("platform:arizona-haptics");
253MODULE_DESCRIPTION("Arizona haptics driver");
254MODULE_LICENSE("GPL");
255MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btns.c
index 26f13131639a..5d4402365a52 100644
--- a/drivers/input/misc/atlas_btns.c
+++ b/drivers/input/misc/atlas_btns.c
@@ -121,7 +121,7 @@ static int atlas_acpi_button_add(struct acpi_device *device)
121 return err; 121 return err;
122} 122}
123 123
124static int atlas_acpi_button_remove(struct acpi_device *device, int type) 124static int atlas_acpi_button_remove(struct acpi_device *device)
125{ 125{
126 acpi_status status; 126 acpi_status status;
127 127
diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c
index 630c1ce4980a..020569a499f2 100644
--- a/drivers/input/misc/da9052_onkey.c
+++ b/drivers/input/misc/da9052_onkey.c
@@ -24,7 +24,6 @@ struct da9052_onkey {
24 struct da9052 *da9052; 24 struct da9052 *da9052;
25 struct input_dev *input; 25 struct input_dev *input;
26 struct delayed_work work; 26 struct delayed_work work;
27 unsigned int irq;
28}; 27};
29 28
30static void da9052_onkey_query(struct da9052_onkey *onkey) 29static void da9052_onkey_query(struct da9052_onkey *onkey)
@@ -76,7 +75,6 @@ static int da9052_onkey_probe(struct platform_device *pdev)
76 struct da9052 *da9052 = dev_get_drvdata(pdev->dev.parent); 75 struct da9052 *da9052 = dev_get_drvdata(pdev->dev.parent);
77 struct da9052_onkey *onkey; 76 struct da9052_onkey *onkey;
78 struct input_dev *input_dev; 77 struct input_dev *input_dev;
79 int irq;
80 int error; 78 int error;
81 79
82 if (!da9052) { 80 if (!da9052) {
@@ -84,13 +82,6 @@ static int da9052_onkey_probe(struct platform_device *pdev)
84 return -EINVAL; 82 return -EINVAL;
85 } 83 }
86 84
87 irq = platform_get_irq_byname(pdev, "ONKEY");
88 if (irq < 0) {
89 dev_err(&pdev->dev,
90 "Failed to get an IRQ for input device, %d\n", irq);
91 return -EINVAL;
92 }
93
94 onkey = kzalloc(sizeof(*onkey), GFP_KERNEL); 85 onkey = kzalloc(sizeof(*onkey), GFP_KERNEL);
95 input_dev = input_allocate_device(); 86 input_dev = input_allocate_device();
96 if (!onkey || !input_dev) { 87 if (!onkey || !input_dev) {
@@ -101,7 +92,6 @@ static int da9052_onkey_probe(struct platform_device *pdev)
101 92
102 onkey->input = input_dev; 93 onkey->input = input_dev;
103 onkey->da9052 = da9052; 94 onkey->da9052 = da9052;
104 onkey->irq = irq;
105 INIT_DELAYED_WORK(&onkey->work, da9052_onkey_work); 95 INIT_DELAYED_WORK(&onkey->work, da9052_onkey_work);
106 96
107 input_dev->name = "da9052-onkey"; 97 input_dev->name = "da9052-onkey";
@@ -111,13 +101,11 @@ static int da9052_onkey_probe(struct platform_device *pdev)
111 input_dev->evbit[0] = BIT_MASK(EV_KEY); 101 input_dev->evbit[0] = BIT_MASK(EV_KEY);
112 __set_bit(KEY_POWER, input_dev->keybit); 102 __set_bit(KEY_POWER, input_dev->keybit);
113 103
114 error = request_threaded_irq(onkey->irq, NULL, da9052_onkey_irq, 104 error = da9052_request_irq(onkey->da9052, DA9052_IRQ_NONKEY, "ONKEY",
115 IRQF_TRIGGER_LOW | IRQF_ONESHOT, 105 da9052_onkey_irq, onkey);
116 "ONKEY", onkey);
117 if (error < 0) { 106 if (error < 0) {
118 dev_err(onkey->da9052->dev, 107 dev_err(onkey->da9052->dev,
119 "Failed to register ONKEY IRQ %d, error = %d\n", 108 "Failed to register ONKEY IRQ: %d\n", error);
120 onkey->irq, error);
121 goto err_free_mem; 109 goto err_free_mem;
122 } 110 }
123 111
@@ -132,7 +120,7 @@ static int da9052_onkey_probe(struct platform_device *pdev)
132 return 0; 120 return 0;
133 121
134err_free_irq: 122err_free_irq:
135 free_irq(onkey->irq, onkey); 123 da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
136 cancel_delayed_work_sync(&onkey->work); 124 cancel_delayed_work_sync(&onkey->work);
137err_free_mem: 125err_free_mem:
138 input_free_device(input_dev); 126 input_free_device(input_dev);
@@ -145,7 +133,7 @@ static int da9052_onkey_remove(struct platform_device *pdev)
145{ 133{
146 struct da9052_onkey *onkey = platform_get_drvdata(pdev); 134 struct da9052_onkey *onkey = platform_get_drvdata(pdev);
147 135
148 free_irq(onkey->irq, onkey); 136 da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
149 cancel_delayed_work_sync(&onkey->work); 137 cancel_delayed_work_sync(&onkey->work);
150 138
151 input_unregister_device(onkey->input); 139 input_unregister_device(onkey->input);
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index 0b4f54265f62..2e3334b8f82d 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -109,7 +109,9 @@ static int hp_sdc_rtc_do_read_bbrtc (struct rtc_time *rtctm)
109 109
110 if (hp_sdc_enqueue_transaction(&t)) return -1; 110 if (hp_sdc_enqueue_transaction(&t)) return -1;
111 111
112 down_interruptible(&tsem); /* Put ourselves to sleep for results. */ 112 /* Put ourselves to sleep for results. */
113 if (WARN_ON(down_interruptible(&tsem)))
114 return -1;
113 115
114 /* Check for nonpresence of BBRTC */ 116 /* Check for nonpresence of BBRTC */
115 if (!((tseq[83] | tseq[90] | tseq[69] | tseq[76] | 117 if (!((tseq[83] | tseq[90] | tseq[69] | tseq[76] |
@@ -176,11 +178,16 @@ static int64_t hp_sdc_rtc_read_i8042timer (uint8_t loadcmd, int numreg)
176 t.seq = tseq; 178 t.seq = tseq;
177 t.act.semaphore = &i8042tregs; 179 t.act.semaphore = &i8042tregs;
178 180
179 down_interruptible(&i8042tregs); /* Sleep if output regs in use. */ 181 /* Sleep if output regs in use. */
182 if (WARN_ON(down_interruptible(&i8042tregs)))
183 return -1;
180 184
181 if (hp_sdc_enqueue_transaction(&t)) return -1; 185 if (hp_sdc_enqueue_transaction(&t)) return -1;
182 186
183 down_interruptible(&i8042tregs); /* Sleep until results come back. */ 187 /* Sleep until results come back. */
188 if (WARN_ON(down_interruptible(&i8042tregs)))
189 return -1;
190
184 up(&i8042tregs); 191 up(&i8042tregs);
185 192
186 return (tseq[5] | 193 return (tseq[5] |
@@ -276,6 +283,7 @@ static inline int hp_sdc_rtc_read_ct(struct timeval *res) {
276} 283}
277 284
278 285
286#if 0 /* not used yet */
279/* Set the i8042 real-time clock */ 287/* Set the i8042 real-time clock */
280static int hp_sdc_rtc_set_rt (struct timeval *setto) 288static int hp_sdc_rtc_set_rt (struct timeval *setto)
281{ 289{
@@ -386,6 +394,7 @@ static int hp_sdc_rtc_set_i8042timer (struct timeval *setto, uint8_t setcmd)
386 } 394 }
387 return 0; 395 return 0;
388} 396}
397#endif
389 398
390static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf, 399static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf,
391 size_t count, loff_t *ppos) { 400 size_t count, loff_t *ppos) {
diff --git a/drivers/input/misc/max8925_onkey.c b/drivers/input/misc/max8925_onkey.c
index 369a39de4ff3..f9179b2585a9 100644
--- a/drivers/input/misc/max8925_onkey.c
+++ b/drivers/input/misc/max8925_onkey.c
@@ -100,9 +100,6 @@ static int max8925_onkey_probe(struct platform_device *pdev)
100 input->dev.parent = &pdev->dev; 100 input->dev.parent = &pdev->dev;
101 input_set_capability(input, EV_KEY, KEY_POWER); 101 input_set_capability(input, EV_KEY, KEY_POWER);
102 102
103 irq[0] += chip->irq_base;
104 irq[1] += chip->irq_base;
105
106 error = request_threaded_irq(irq[0], NULL, max8925_onkey_handler, 103 error = request_threaded_irq(irq[0], NULL, max8925_onkey_handler,
107 IRQF_ONESHOT, "onkey-down", info); 104 IRQF_ONESHOT, "onkey-down", info);
108 if (error < 0) { 105 if (error < 0) {