aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-07 13:38:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-07 13:38:46 -0400
commit8b8a7df9a1d87ba413fce246b11f54c636bb456a (patch)
tree797265037b52117fa633b32cbe3feacb1b1b0f07 /drivers/input/misc
parentb04c99e3b845892d754ee8052d6324c39c4040de (diff)
parent07176b988ebb20f46a317a60ee1d983fe1630203 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input updates from Dmitry Torokhov: "A new driver for slidebar on Ideapad laptops and a bunch of assorted driver fixes" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (32 commits) Input: add SYN_MAX and SYN_CNT constants Input: max11801_ts - convert to devm Input: egalax-ts - fix typo and improve text Input: MAINTAINERS - change maintainer for cyttsp driver Input: cyttsp4 - kill 'defined but not used' compiler warnings Input: add driver for slidebar on Lenovo IdeaPad laptops Input: omap-keypad - set up irq type from DT Input: omap-keypad - enable wakeup capability for keypad. Input: omap-keypad - clear interrupts on open Input: omap-keypad - convert to threaded IRQ Input: omap-keypad - use bitfiled instead of hardcoded values Input: cyttsp4 - remove useless NULL test from cyttsp4_watchdog_timer() Input: wacom - fix error return code in wacom_probe() Input: as5011 - fix error return code in as5011_probe() Input: keyboard, serio - simplify use of devm_ioremap_resource Input: tegra-kbc - simplify use of devm_ioremap_resource Input: htcpen - fix incorrect placement of __initdata Input: qt1070 - add power management ops Input: wistron_btns - add MODULE_DEVICE_TABLE Input: wistron_btns - mark the Medion MD96500 keymap as tested ...
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/ideapad_slidebar.c358
-rw-r--r--drivers/input/misc/pwm-beeper.c2
-rw-r--r--drivers/input/misc/twl6040-vibra.c41
-rw-r--r--drivers/input/misc/wistron_btns.c6
6 files changed, 388 insertions, 30 deletions
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 0b541cdf9b8e..aa51baaa9b1e 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -647,4 +647,14 @@ config INPUT_SIRFSOC_ONKEY
647 647
648 If unsure, say N. 648 If unsure, say N.
649 649
650config INPUT_IDEAPAD_SLIDEBAR
651 tristate "IdeaPad Laptop Slidebar"
652 depends on INPUT
653 depends on SERIO_I8042
654 help
655 Say Y here if you have an IdeaPad laptop with a slidebar.
656
657 To compile this driver as a module, choose M here: the
658 module will be called ideapad_slidebar.
659
650endif 660endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 829de43a2427..0ebfb6dbf0f7 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -61,3 +61,4 @@ obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
61obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o 61obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o
62obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o 62obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o
63obj-$(CONFIG_INPUT_YEALINK) += yealink.o 63obj-$(CONFIG_INPUT_YEALINK) += yealink.o
64obj-$(CONFIG_INPUT_IDEAPAD_SLIDEBAR) += ideapad_slidebar.o
diff --git a/drivers/input/misc/ideapad_slidebar.c b/drivers/input/misc/ideapad_slidebar.c
new file mode 100644
index 000000000000..edfd6239f131
--- /dev/null
+++ b/drivers/input/misc/ideapad_slidebar.c
@@ -0,0 +1,358 @@
1/*
2 * Input driver for slidebars on some Lenovo IdeaPad laptops
3 *
4 * Copyright (C) 2013 Andrey Moiseev <o2g.org.ru@gmail.com>
5 *
6 * Reverse-engineered from Lenovo SlideNav software (SBarHook.dll).
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * Trademarks are the property of their respective owners.
14 */
15
16/*
17 * Currently tested and works on:
18 * Lenovo IdeaPad Y550
19 * Lenovo IdeaPad Y550P
20 *
21 * Other models can be added easily. To test,
22 * load with 'force' parameter set 'true'.
23 *
24 * LEDs blinking and input mode are managed via sysfs,
25 * (hex, unsigned byte value):
26 * /sys/devices/platform/ideapad_slidebar/slidebar_mode
27 *
28 * The value is in byte range, however, I only figured out
29 * how bits 0b10011001 work. Some other bits, probably,
30 * are meaningfull too.
31 *
32 * Possible states:
33 *
34 * STD_INT, ONMOV_INT, OFF_INT, LAST_POLL, OFF_POLL
35 *
36 * Meaning:
37 * released touched
38 * STD 'heartbeat' lights follow the finger
39 * ONMOV no lights lights follow the finger
40 * LAST at last pos lights follow the finger
41 * OFF no lights no lights
42 *
43 * INT all input events are generated, interrupts are used
44 * POLL no input events by default, to get them,
45 * send 0b10000000 (read below)
46 *
47 * Commands: write
48 *
49 * All | 0b01001 -> STD_INT
50 * possible | 0b10001 -> ONMOV_INT
51 * states | 0b01000 -> OFF_INT
52 *
53 * | 0b0 -> LAST_POLL
54 * STD_INT or ONMOV_INT |
55 * | 0b1 -> STD_INT
56 *
57 * | 0b0 -> OFF_POLL
58 * OFF_INT or OFF_POLL |
59 * | 0b1 -> OFF_INT
60 *
61 * Any state | 0b10000000 -> if the slidebar has updated data,
62 * produce one input event (last position),
63 * switch to respective POLL mode
64 * (like 0x0), if not in POLL mode yet.
65 *
66 * Get current state: read
67 *
68 * masked by 0x11 read value means:
69 *
70 * 0x00 LAST
71 * 0x01 STD
72 * 0x10 OFF
73 * 0x11 ONMOV
74 */
75
76#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
77
78#include <linux/module.h>
79#include <linux/kernel.h>
80#include <linux/dmi.h>
81#include <linux/spinlock.h>
82#include <linux/platform_device.h>
83#include <linux/input.h>
84#include <linux/io.h>
85#include <linux/ioport.h>
86#include <linux/i8042.h>
87#include <linux/serio.h>
88
89#define IDEAPAD_BASE 0xff29
90
91static bool force;
92module_param(force, bool, 0);
93MODULE_PARM_DESC(force, "Force driver load, ignore DMI data");
94
95static DEFINE_SPINLOCK(io_lock);
96
97static struct input_dev *slidebar_input_dev;
98static struct platform_device *slidebar_platform_dev;
99
100static u8 slidebar_pos_get(void)
101{
102 u8 res;
103 unsigned long flags;
104
105 spin_lock_irqsave(&io_lock, flags);
106 outb(0xf4, 0xff29);
107 outb(0xbf, 0xff2a);
108 res = inb(0xff2b);
109 spin_unlock_irqrestore(&io_lock, flags);
110
111 return res;
112}
113
114static u8 slidebar_mode_get(void)
115{
116 u8 res;
117 unsigned long flags;
118
119 spin_lock_irqsave(&io_lock, flags);
120 outb(0xf7, 0xff29);
121 outb(0x8b, 0xff2a);
122 res = inb(0xff2b);
123 spin_unlock_irqrestore(&io_lock, flags);
124
125 return res;
126}
127
128static void slidebar_mode_set(u8 mode)
129{
130 unsigned long flags;
131
132 spin_lock_irqsave(&io_lock, flags);
133 outb(0xf7, 0xff29);
134 outb(0x8b, 0xff2a);
135 outb(mode, 0xff2b);
136 spin_unlock_irqrestore(&io_lock, flags);
137}
138
139static bool slidebar_i8042_filter(unsigned char data, unsigned char str,
140 struct serio *port)
141{
142 static bool extended = false;
143
144 /* We are only interested in data coming form KBC port */
145 if (str & I8042_STR_AUXDATA)
146 return false;
147
148 /* Scancodes: e03b on move, e0bb on release. */
149 if (data == 0xe0) {
150 extended = true;
151 return true;
152 }
153
154 if (!extended)
155 return false;
156
157 extended = false;
158
159 if (likely((data & 0x7f) != 0x3b)) {
160 serio_interrupt(port, 0xe0, 0);
161 return false;
162 }
163
164 if (data & 0x80) {
165 input_report_key(slidebar_input_dev, BTN_TOUCH, 0);
166 } else {
167 input_report_key(slidebar_input_dev, BTN_TOUCH, 1);
168 input_report_abs(slidebar_input_dev, ABS_X, slidebar_pos_get());
169 }
170 input_sync(slidebar_input_dev);
171
172 return true;
173}
174
175static ssize_t show_slidebar_mode(struct device *dev,
176 struct device_attribute *attr,
177 char *buf)
178{
179 return sprintf(buf, "%x\n", slidebar_mode_get());
180}
181
182static ssize_t store_slidebar_mode(struct device *dev,
183 struct device_attribute *attr,
184 const char *buf, size_t count)
185{
186 u8 mode;
187 int error;
188
189 error = kstrtou8(buf, 0, &mode);
190 if (error)
191 return error;
192
193 slidebar_mode_set(mode);
194
195 return count;
196}
197
198static DEVICE_ATTR(slidebar_mode, S_IWUSR | S_IRUGO,
199 show_slidebar_mode, store_slidebar_mode);
200
201static struct attribute *ideapad_attrs[] = {
202 &dev_attr_slidebar_mode.attr,
203 NULL
204};
205
206static struct attribute_group ideapad_attr_group = {
207 .attrs = ideapad_attrs
208};
209
210static const struct attribute_group *ideapad_attr_groups[] = {
211 &ideapad_attr_group,
212 NULL
213};
214
215static int __init ideapad_probe(struct platform_device* pdev)
216{
217 int err;
218
219 if (!request_region(IDEAPAD_BASE, 3, "ideapad_slidebar")) {
220 dev_err(&pdev->dev, "IO ports are busy\n");
221 return -EBUSY;
222 }
223
224 slidebar_input_dev = input_allocate_device();
225 if (!slidebar_input_dev) {
226 dev_err(&pdev->dev, "Failed to allocate input device\n");
227 err = -ENOMEM;
228 goto err_release_ports;
229 }
230
231 slidebar_input_dev->name = "IdeaPad Slidebar";
232 slidebar_input_dev->id.bustype = BUS_HOST;
233 slidebar_input_dev->dev.parent = &pdev->dev;
234 input_set_capability(slidebar_input_dev, EV_KEY, BTN_TOUCH);
235 input_set_capability(slidebar_input_dev, EV_ABS, ABS_X);
236 input_set_abs_params(slidebar_input_dev, ABS_X, 0, 0xff, 0, 0);
237
238 err = i8042_install_filter(slidebar_i8042_filter);
239 if (err) {
240 dev_err(&pdev->dev,
241 "Failed to install i8042 filter: %d\n", err);
242 goto err_free_dev;
243 }
244
245 err = input_register_device(slidebar_input_dev);
246 if (err) {
247 dev_err(&pdev->dev,
248 "Failed to register input device: %d\n", err);
249 goto err_remove_filter;
250 }
251
252 return 0;
253
254err_remove_filter:
255 i8042_remove_filter(slidebar_i8042_filter);
256err_free_dev:
257 input_free_device(slidebar_input_dev);
258err_release_ports:
259 release_region(IDEAPAD_BASE, 3);
260 return err;
261}
262
263static int ideapad_remove(struct platform_device *pdev)
264{
265 i8042_remove_filter(slidebar_i8042_filter);
266 input_unregister_device(slidebar_input_dev);
267 release_region(IDEAPAD_BASE, 3);
268
269 return 0;
270}
271
272static struct platform_driver slidebar_drv = {
273 .driver = {
274 .name = "ideapad_slidebar",
275 .owner = THIS_MODULE,
276 },
277 .remove = ideapad_remove,
278};
279
280static int __init ideapad_dmi_check(const struct dmi_system_id *id)
281{
282 pr_info("Laptop model '%s'\n", id->ident);
283 return 1;
284}
285
286static const struct dmi_system_id ideapad_dmi[] __initconst = {
287 {
288 .ident = "Lenovo IdeaPad Y550",
289 .matches = {
290 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
291 DMI_MATCH(DMI_PRODUCT_NAME, "20017"),
292 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo IdeaPad Y550")
293 },
294 .callback = ideapad_dmi_check
295 },
296 {
297 .ident = "Lenovo IdeaPad Y550P",
298 .matches = {
299 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
300 DMI_MATCH(DMI_PRODUCT_NAME, "20035"),
301 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo IdeaPad Y550P")
302 },
303 .callback = ideapad_dmi_check
304 },
305 { NULL, }
306};
307MODULE_DEVICE_TABLE(dmi, ideapad_dmi);
308
309static int __init slidebar_init(void)
310{
311 int err;
312
313 if (!force && !dmi_check_system(ideapad_dmi)) {
314 pr_err("DMI does not match\n");
315 return -ENODEV;
316 }
317
318 slidebar_platform_dev = platform_device_alloc("ideapad_slidebar", -1);
319 if (!slidebar_platform_dev) {
320 pr_err("Not enough memory\n");
321 return -ENOMEM;
322 }
323
324 slidebar_platform_dev->dev.groups = ideapad_attr_groups;
325
326 err = platform_device_add(slidebar_platform_dev);
327 if (err) {
328 pr_err("Failed to register platform device\n");
329 goto err_free_dev;
330 }
331
332 err = platform_driver_probe(&slidebar_drv, ideapad_probe);
333 if (err) {
334 pr_err("Failed to register platform driver\n");
335 goto err_delete_dev;
336 }
337
338 return 0;
339
340err_delete_dev:
341 platform_device_del(slidebar_platform_dev);
342err_free_dev:
343 platform_device_put(slidebar_platform_dev);
344 return err;
345}
346
347static void __exit slidebar_exit(void)
348{
349 platform_device_unregister(slidebar_platform_dev);
350 platform_driver_unregister(&slidebar_drv);
351}
352
353module_init(slidebar_init);
354module_exit(slidebar_exit);
355
356MODULE_AUTHOR("Andrey Moiseev <o2g.org.ru@gmail.com>");
357MODULE_DESCRIPTION("Slidebar input support for some Lenovo IdeaPad laptops");
358MODULE_LICENSE("GPL");
diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
index a37f0c909aba..2ff4d1c78ab8 100644
--- a/drivers/input/misc/pwm-beeper.c
+++ b/drivers/input/misc/pwm-beeper.c
@@ -143,7 +143,7 @@ static int pwm_beeper_remove(struct platform_device *pdev)
143 return 0; 143 return 0;
144} 144}
145 145
146#ifdef CONFIG_PM 146#ifdef CONFIG_PM_SLEEP
147static int pwm_beeper_suspend(struct device *dev) 147static int pwm_beeper_suspend(struct device *dev)
148{ 148{
149 struct pwm_beeper *beeper = dev_get_drvdata(dev); 149 struct pwm_beeper *beeper = dev_get_drvdata(dev);
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
index 0c2dfc8e9691..7864b0c3ebb3 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -257,7 +257,6 @@ static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL);
257 257
258static int twl6040_vibra_probe(struct platform_device *pdev) 258static int twl6040_vibra_probe(struct platform_device *pdev)
259{ 259{
260 struct twl6040_vibra_data *pdata = pdev->dev.platform_data;
261 struct device *twl6040_core_dev = pdev->dev.parent; 260 struct device *twl6040_core_dev = pdev->dev.parent;
262 struct device_node *twl6040_core_node = NULL; 261 struct device_node *twl6040_core_node = NULL;
263 struct vibra_info *info; 262 struct vibra_info *info;
@@ -270,8 +269,8 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
270 "vibra"); 269 "vibra");
271#endif 270#endif
272 271
273 if (!pdata && !twl6040_core_node) { 272 if (!twl6040_core_node) {
274 dev_err(&pdev->dev, "platform_data not available\n"); 273 dev_err(&pdev->dev, "parent of node is missing?\n");
275 return -EINVAL; 274 return -EINVAL;
276 } 275 }
277 276
@@ -284,27 +283,17 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
284 info->dev = &pdev->dev; 283 info->dev = &pdev->dev;
285 284
286 info->twl6040 = dev_get_drvdata(pdev->dev.parent); 285 info->twl6040 = dev_get_drvdata(pdev->dev.parent);
287 if (pdata) { 286
288 info->vibldrv_res = pdata->vibldrv_res; 287 of_property_read_u32(twl6040_core_node, "ti,vibldrv-res",
289 info->vibrdrv_res = pdata->vibrdrv_res; 288 &info->vibldrv_res);
290 info->viblmotor_res = pdata->viblmotor_res; 289 of_property_read_u32(twl6040_core_node, "ti,vibrdrv-res",
291 info->vibrmotor_res = pdata->vibrmotor_res; 290 &info->vibrdrv_res);
292 vddvibl_uV = pdata->vddvibl_uV; 291 of_property_read_u32(twl6040_core_node, "ti,viblmotor-res",
293 vddvibr_uV = pdata->vddvibr_uV; 292 &info->viblmotor_res);
294 } else { 293 of_property_read_u32(twl6040_core_node, "ti,vibrmotor-res",
295 of_property_read_u32(twl6040_core_node, "ti,vibldrv-res", 294 &info->vibrmotor_res);
296 &info->vibldrv_res); 295 of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV", &vddvibl_uV);
297 of_property_read_u32(twl6040_core_node, "ti,vibrdrv-res", 296 of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV", &vddvibr_uV);
298 &info->vibrdrv_res);
299 of_property_read_u32(twl6040_core_node, "ti,viblmotor-res",
300 &info->viblmotor_res);
301 of_property_read_u32(twl6040_core_node, "ti,vibrmotor-res",
302 &info->vibrmotor_res);
303 of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV",
304 &vddvibl_uV);
305 of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV",
306 &vddvibr_uV);
307 }
308 297
309 if ((!info->vibldrv_res && !info->viblmotor_res) || 298 if ((!info->vibldrv_res && !info->viblmotor_res) ||
310 (!info->vibrdrv_res && !info->vibrmotor_res)) { 299 (!info->vibrdrv_res && !info->vibrmotor_res)) {
@@ -334,8 +323,8 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
334 * When booted with Device tree the regulators are attached to the 323 * When booted with Device tree the regulators are attached to the
335 * parent device (twl6040 MFD core) 324 * parent device (twl6040 MFD core)
336 */ 325 */
337 ret = regulator_bulk_get(pdata ? info->dev : twl6040_core_dev, 326 ret = regulator_bulk_get(twl6040_core_dev, ARRAY_SIZE(info->supplies),
338 ARRAY_SIZE(info->supplies), info->supplies); 327 info->supplies);
339 if (ret) { 328 if (ret) {
340 dev_err(info->dev, "couldn't get regulators %d\n", ret); 329 dev_err(info->dev, "couldn't get regulators %d\n", ret);
341 return ret; 330 return ret;
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 56536f4b9572..b6505454bcc4 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -46,7 +46,6 @@
46MODULE_AUTHOR("Miloslav Trmac <mitr@volny.cz>"); 46MODULE_AUTHOR("Miloslav Trmac <mitr@volny.cz>");
47MODULE_DESCRIPTION("Wistron laptop button driver"); 47MODULE_DESCRIPTION("Wistron laptop button driver");
48MODULE_LICENSE("GPL v2"); 48MODULE_LICENSE("GPL v2");
49MODULE_VERSION("0.3");
50 49
51static bool force; /* = 0; */ 50static bool force; /* = 0; */
52module_param(force, bool, 0); 51module_param(force, bool, 0);
@@ -563,7 +562,7 @@ static struct key_entry keymap_wistron_md96500[] __initdata = {
563 { KE_KEY, 0x36, {KEY_WWW} }, 562 { KE_KEY, 0x36, {KEY_WWW} },
564 { KE_WIFI, 0x30 }, 563 { KE_WIFI, 0x30 },
565 { KE_BLUETOOTH, 0x44 }, 564 { KE_BLUETOOTH, 0x44 },
566 { KE_END, FE_UNTESTED } 565 { KE_END, 0 }
567}; 566};
568 567
569static struct key_entry keymap_wistron_generic[] __initdata = { 568static struct key_entry keymap_wistron_generic[] __initdata = {
@@ -635,7 +634,7 @@ static struct key_entry keymap_prestigio[] __initdata = {
635 * a list of buttons and their key codes (reported when loading this module 634 * a list of buttons and their key codes (reported when loading this module
636 * with force=1) and the output of dmidecode to $MODULE_AUTHOR. 635 * with force=1) and the output of dmidecode to $MODULE_AUTHOR.
637 */ 636 */
638static const struct dmi_system_id __initconst dmi_ids[] = { 637static const struct dmi_system_id dmi_ids[] __initconst = {
639 { 638 {
640 /* Fujitsu-Siemens Amilo Pro V2000 */ 639 /* Fujitsu-Siemens Amilo Pro V2000 */
641 .callback = dmi_matched, 640 .callback = dmi_matched,
@@ -972,6 +971,7 @@ static const struct dmi_system_id __initconst dmi_ids[] = {
972 }, 971 },
973 { NULL, } 972 { NULL, }
974}; 973};
974MODULE_DEVICE_TABLE(dmi, dmi_ids);
975 975
976/* Copy the good keymap, as the original ones are free'd */ 976/* Copy the good keymap, as the original ones are free'd */
977static int __init copy_keymap(void) 977static int __init copy_keymap(void)