aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-27 12:16:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-27 12:16:53 -0400
commitc92067ae06cb71561628d9f4b24b56c1813c54e0 (patch)
tree775d6d419057de760b25dc8773cacbf65d567514
parent896a349228c494aa65279ccfc41d2395898f6f4d (diff)
parent03ae3a9caf4a59edd32b65c89c375a98ce3ea1ef (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input updates from Dmitry Torokhov: - the main change is a fix for my brain-dead patch to PS/2 button reporting for some protocols that made it in 4.17 - there is a new driver for Spreadtum vibrator that I intended to send during merge window but ended up not sending the 2nd pull request. Given that this is a brand new driver we should not see regressions here - a fixup to Elantech PS/2 driver to avoid decoding errors on Thinkpad P52 - addition of few more ACPI IDs for Silead and Elan drivers - RMI4 is switched to using IRQ domain code instead of rolling its own implementation * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: Input: psmouse - fix button reporting for basic protocols Input: xpad - fix GPD Win 2 controller name Input: elan_i2c_smbus - fix more potential stack buffer overflows Input: elan_i2c - add ELAN0618 (Lenovo v330 15IKB) ACPI ID Input: elantech - fix V4 report decoding for module with middle key Input: elantech - enable middle button of touchpads on ThinkPad P52 Input: do not assign new tracking ID when changing tool type Input: make input_report_slot_state() return boolean Input: synaptics-rmi4 - fix axis-swap behavior Input: synaptics-rmi4 - fix the error return code in rmi_probe_interrupts() Input: synaptics-rmi4 - convert irq distribution to irq_domain Input: silead - add MSSL0002 ACPI HID Input: goldfish_events - fix checkpatch warnings Input: add Spreadtrum vibrator driver
-rw-r--r--Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt23
-rw-r--r--drivers/input/input-mt.c12
-rw-r--r--drivers/input/joystick/xpad.c2
-rw-r--r--drivers/input/keyboard/goldfish_events.c9
-rw-r--r--drivers/input/misc/Kconfig10
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/sc27xx-vibra.c154
-rw-r--r--drivers/input/mouse/elan_i2c.h2
-rw-r--r--drivers/input/mouse/elan_i2c_core.c3
-rw-r--r--drivers/input/mouse/elan_i2c_smbus.c10
-rw-r--r--drivers/input/mouse/elantech.c11
-rw-r--r--drivers/input/mouse/psmouse-base.c12
-rw-r--r--drivers/input/rmi4/Kconfig1
-rw-r--r--drivers/input/rmi4/rmi_2d_sensor.c34
-rw-r--r--drivers/input/rmi4/rmi_bus.c50
-rw-r--r--drivers/input/rmi4/rmi_bus.h10
-rw-r--r--drivers/input/rmi4/rmi_driver.c52
-rw-r--r--drivers/input/rmi4/rmi_f01.c10
-rw-r--r--drivers/input/rmi4/rmi_f03.c9
-rw-r--r--drivers/input/rmi4/rmi_f11.c42
-rw-r--r--drivers/input/rmi4/rmi_f12.c8
-rw-r--r--drivers/input/rmi4/rmi_f30.c9
-rw-r--r--drivers/input/rmi4/rmi_f34.c5
-rw-r--r--drivers/input/rmi4/rmi_f54.c6
-rw-r--r--drivers/input/touchscreen/silead.c1
-rw-r--r--include/linux/input/mt.h2
-rw-r--r--include/linux/rmi.h2
27 files changed, 366 insertions, 124 deletions
diff --git a/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
new file mode 100644
index 000000000000..f2ec0d4f2dff
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
@@ -0,0 +1,23 @@
1Spreadtrum SC27xx PMIC Vibrator
2
3Required properties:
4- compatible: should be "sprd,sc2731-vibrator".
5- reg: address of vibrator control register.
6
7Example :
8
9 sc2731_pmic: pmic@0 {
10 compatible = "sprd,sc2731";
11 reg = <0>;
12 spi-max-frequency = <26000000>;
13 interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
14 interrupt-controller;
15 #interrupt-cells = <2>;
16 #address-cells = <1>;
17 #size-cells = <0>;
18
19 vibrator@eb4 {
20 compatible = "sprd,sc2731-vibrator";
21 reg = <0xeb4>;
22 };
23 };
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index cf30523c6ef6..6c7326c93721 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -131,8 +131,10 @@ EXPORT_SYMBOL(input_mt_destroy_slots);
131 * inactive, or if the tool type is changed, a new tracking id is 131 * inactive, or if the tool type is changed, a new tracking id is
132 * assigned to the slot. The tool type is only reported if the 132 * assigned to the slot. The tool type is only reported if the
133 * corresponding absbit field is set. 133 * corresponding absbit field is set.
134 *
135 * Returns true if contact is active.
134 */ 136 */
135void input_mt_report_slot_state(struct input_dev *dev, 137bool input_mt_report_slot_state(struct input_dev *dev,
136 unsigned int tool_type, bool active) 138 unsigned int tool_type, bool active)
137{ 139{
138 struct input_mt *mt = dev->mt; 140 struct input_mt *mt = dev->mt;
@@ -140,22 +142,24 @@ void input_mt_report_slot_state(struct input_dev *dev,
140 int id; 142 int id;
141 143
142 if (!mt) 144 if (!mt)
143 return; 145 return false;
144 146
145 slot = &mt->slots[mt->slot]; 147 slot = &mt->slots[mt->slot];
146 slot->frame = mt->frame; 148 slot->frame = mt->frame;
147 149
148 if (!active) { 150 if (!active) {
149 input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); 151 input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
150 return; 152 return false;
151 } 153 }
152 154
153 id = input_mt_get_value(slot, ABS_MT_TRACKING_ID); 155 id = input_mt_get_value(slot, ABS_MT_TRACKING_ID);
154 if (id < 0 || input_mt_get_value(slot, ABS_MT_TOOL_TYPE) != tool_type) 156 if (id < 0)
155 id = input_mt_new_trkid(mt); 157 id = input_mt_new_trkid(mt);
156 158
157 input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, id); 159 input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, id);
158 input_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, tool_type); 160 input_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, tool_type);
161
162 return true;
159} 163}
160EXPORT_SYMBOL(input_mt_report_slot_state); 164EXPORT_SYMBOL(input_mt_report_slot_state);
161 165
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 48e36acbeb49..cd620e009bad 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -125,7 +125,7 @@ static const struct xpad_device {
125 u8 mapping; 125 u8 mapping;
126 u8 xtype; 126 u8 xtype;
127} xpad_device[] = { 127} xpad_device[] = {
128 { 0x0079, 0x18d4, "GPD Win 2 Controller", 0, XTYPE_XBOX360 }, 128 { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 },
129 { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX }, 129 { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX },
130 { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX }, 130 { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX },
131 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, 131 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
diff --git a/drivers/input/keyboard/goldfish_events.c b/drivers/input/keyboard/goldfish_events.c
index f6e643b589b6..e8dae6195b30 100644
--- a/drivers/input/keyboard/goldfish_events.c
+++ b/drivers/input/keyboard/goldfish_events.c
@@ -45,7 +45,7 @@ struct event_dev {
45static irqreturn_t events_interrupt(int irq, void *dev_id) 45static irqreturn_t events_interrupt(int irq, void *dev_id)
46{ 46{
47 struct event_dev *edev = dev_id; 47 struct event_dev *edev = dev_id;
48 unsigned type, code, value; 48 unsigned int type, code, value;
49 49
50 type = __raw_readl(edev->addr + REG_READ); 50 type = __raw_readl(edev->addr + REG_READ);
51 code = __raw_readl(edev->addr + REG_READ); 51 code = __raw_readl(edev->addr + REG_READ);
@@ -57,7 +57,7 @@ static irqreturn_t events_interrupt(int irq, void *dev_id)
57} 57}
58 58
59static void events_import_bits(struct event_dev *edev, 59static void events_import_bits(struct event_dev *edev,
60 unsigned long bits[], unsigned type, size_t count) 60 unsigned long bits[], unsigned int type, size_t count)
61{ 61{
62 void __iomem *addr = edev->addr; 62 void __iomem *addr = edev->addr;
63 int i, j; 63 int i, j;
@@ -99,6 +99,7 @@ static void events_import_abs_params(struct event_dev *edev)
99 99
100 for (j = 0; j < ARRAY_SIZE(val); j++) { 100 for (j = 0; j < ARRAY_SIZE(val); j++) {
101 int offset = (i * ARRAY_SIZE(val) + j) * sizeof(u32); 101 int offset = (i * ARRAY_SIZE(val) + j) * sizeof(u32);
102
102 val[j] = __raw_readl(edev->addr + REG_DATA + offset); 103 val[j] = __raw_readl(edev->addr + REG_DATA + offset);
103 } 104 }
104 105
@@ -112,7 +113,7 @@ static int events_probe(struct platform_device *pdev)
112 struct input_dev *input_dev; 113 struct input_dev *input_dev;
113 struct event_dev *edev; 114 struct event_dev *edev;
114 struct resource *res; 115 struct resource *res;
115 unsigned keymapnamelen; 116 unsigned int keymapnamelen;
116 void __iomem *addr; 117 void __iomem *addr;
117 int irq; 118 int irq;
118 int i; 119 int i;
@@ -150,7 +151,7 @@ static int events_probe(struct platform_device *pdev)
150 for (i = 0; i < keymapnamelen; i++) 151 for (i = 0; i < keymapnamelen; i++)
151 edev->name[i] = __raw_readb(edev->addr + REG_DATA + i); 152 edev->name[i] = __raw_readb(edev->addr + REG_DATA + i);
152 153
153 pr_debug("events_probe() keymap=%s\n", edev->name); 154 pr_debug("%s: keymap=%s\n", __func__, edev->name);
154 155
155 input_dev->name = edev->name; 156 input_dev->name = edev->name;
156 input_dev->id.bustype = BUS_HOST; 157 input_dev->id.bustype = BUS_HOST;
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index c25606e00693..ca59a2be9bc5 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -841,4 +841,14 @@ config INPUT_RAVE_SP_PWRBUTTON
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 rave-sp-pwrbutton. 842 module will be called rave-sp-pwrbutton.
843 843
844config INPUT_SC27XX_VIBRA
845 tristate "Spreadtrum sc27xx vibrator support"
846 depends on MFD_SC27XX_PMIC || COMPILE_TEST
847 select INPUT_FF_MEMLESS
848 help
849 This option enables support for Spreadtrum sc27xx vibrator driver.
850
851 To compile this driver as a module, choose M here. The module will
852 be called sc27xx_vibra.
853
844endif 854endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 72cde28649e2..9d0f9d1ff68f 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
66obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o 66obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
67obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o 67obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o
68obj-$(CONFIG_INPUT_RK805_PWRKEY) += rk805-pwrkey.o 68obj-$(CONFIG_INPUT_RK805_PWRKEY) += rk805-pwrkey.o
69obj-$(CONFIG_INPUT_SC27XX_VIBRA) += sc27xx-vibra.o
69obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o 70obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
70obj-$(CONFIG_INPUT_SIRFSOC_ONKEY) += sirfsoc-onkey.o 71obj-$(CONFIG_INPUT_SIRFSOC_ONKEY) += sirfsoc-onkey.o
71obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o 72obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o
diff --git a/drivers/input/misc/sc27xx-vibra.c b/drivers/input/misc/sc27xx-vibra.c
new file mode 100644
index 000000000000..295251abbdac
--- /dev/null
+++ b/drivers/input/misc/sc27xx-vibra.c
@@ -0,0 +1,154 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2018 Spreadtrum Communications Inc.
4 */
5
6#include <linux/module.h>
7#include <linux/of_address.h>
8#include <linux/platform_device.h>
9#include <linux/regmap.h>
10#include <linux/input.h>
11#include <linux/workqueue.h>
12
13#define CUR_DRV_CAL_SEL GENMASK(13, 12)
14#define SLP_LDOVIBR_PD_EN BIT(9)
15#define LDO_VIBR_PD BIT(8)
16
17struct vibra_info {
18 struct input_dev *input_dev;
19 struct work_struct play_work;
20 struct regmap *regmap;
21 u32 base;
22 u32 strength;
23 bool enabled;
24};
25
26static void sc27xx_vibra_set(struct vibra_info *info, bool on)
27{
28 if (on) {
29 regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD, 0);
30 regmap_update_bits(info->regmap, info->base,
31 SLP_LDOVIBR_PD_EN, 0);
32 info->enabled = true;
33 } else {
34 regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD,
35 LDO_VIBR_PD);
36 regmap_update_bits(info->regmap, info->base,
37 SLP_LDOVIBR_PD_EN, SLP_LDOVIBR_PD_EN);
38 info->enabled = false;
39 }
40}
41
42static int sc27xx_vibra_hw_init(struct vibra_info *info)
43{
44 return regmap_update_bits(info->regmap, info->base, CUR_DRV_CAL_SEL, 0);
45}
46
47static void sc27xx_vibra_play_work(struct work_struct *work)
48{
49 struct vibra_info *info = container_of(work, struct vibra_info,
50 play_work);
51
52 if (info->strength && !info->enabled)
53 sc27xx_vibra_set(info, true);
54 else if (info->strength == 0 && info->enabled)
55 sc27xx_vibra_set(info, false);
56}
57
58static int sc27xx_vibra_play(struct input_dev *input, void *data,
59 struct ff_effect *effect)
60{
61 struct vibra_info *info = input_get_drvdata(input);
62
63 info->strength = effect->u.rumble.weak_magnitude;
64 schedule_work(&info->play_work);
65
66 return 0;
67}
68
69static void sc27xx_vibra_close(struct input_dev *input)
70{
71 struct vibra_info *info = input_get_drvdata(input);
72
73 cancel_work_sync(&info->play_work);
74 if (info->enabled)
75 sc27xx_vibra_set(info, false);
76}
77
78static int sc27xx_vibra_probe(struct platform_device *pdev)
79{
80 struct vibra_info *info;
81 int error;
82
83 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
84 if (!info)
85 return -ENOMEM;
86
87 info->regmap = dev_get_regmap(pdev->dev.parent, NULL);
88 if (!info->regmap) {
89 dev_err(&pdev->dev, "failed to get vibrator regmap.\n");
90 return -ENODEV;
91 }
92
93 error = device_property_read_u32(&pdev->dev, "reg", &info->base);
94 if (error) {
95 dev_err(&pdev->dev, "failed to get vibrator base address.\n");
96 return error;
97 }
98
99 info->input_dev = devm_input_allocate_device(&pdev->dev);
100 if (!info->input_dev) {
101 dev_err(&pdev->dev, "failed to allocate input device.\n");
102 return -ENOMEM;
103 }
104
105 info->input_dev->name = "sc27xx:vibrator";
106 info->input_dev->id.version = 0;
107 info->input_dev->close = sc27xx_vibra_close;
108
109 input_set_drvdata(info->input_dev, info);
110 input_set_capability(info->input_dev, EV_FF, FF_RUMBLE);
111 INIT_WORK(&info->play_work, sc27xx_vibra_play_work);
112 info->enabled = false;
113
114 error = sc27xx_vibra_hw_init(info);
115 if (error) {
116 dev_err(&pdev->dev, "failed to initialize the vibrator.\n");
117 return error;
118 }
119
120 error = input_ff_create_memless(info->input_dev, NULL,
121 sc27xx_vibra_play);
122 if (error) {
123 dev_err(&pdev->dev, "failed to register vibrator to FF.\n");
124 return error;
125 }
126
127 error = input_register_device(info->input_dev);
128 if (error) {
129 dev_err(&pdev->dev, "failed to register input device.\n");
130 return error;
131 }
132
133 return 0;
134}
135
136static const struct of_device_id sc27xx_vibra_of_match[] = {
137 { .compatible = "sprd,sc2731-vibrator", },
138 {}
139};
140MODULE_DEVICE_TABLE(of, sc27xx_vibra_of_match);
141
142static struct platform_driver sc27xx_vibra_driver = {
143 .driver = {
144 .name = "sc27xx-vibrator",
145 .of_match_table = sc27xx_vibra_of_match,
146 },
147 .probe = sc27xx_vibra_probe,
148};
149
150module_platform_driver(sc27xx_vibra_driver);
151
152MODULE_DESCRIPTION("Spreadtrum SC27xx Vibrator Driver");
153MODULE_LICENSE("GPL v2");
154MODULE_AUTHOR("Xiaotong Lu <xiaotong.lu@spreadtrum.com>");
diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 599544c1a91c..243e0fa6e3e3 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -27,6 +27,8 @@
27#define ETP_DISABLE_POWER 0x0001 27#define ETP_DISABLE_POWER 0x0001
28#define ETP_PRESSURE_OFFSET 25 28#define ETP_PRESSURE_OFFSET 25
29 29
30#define ETP_CALIBRATE_MAX_LEN 3
31
30/* IAP Firmware handling */ 32/* IAP Firmware handling */
31#define ETP_PRODUCT_ID_FORMAT_STRING "%d.0" 33#define ETP_PRODUCT_ID_FORMAT_STRING "%d.0"
32#define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin" 34#define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin"
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index 8ff75114e762..1f9cd7d8b7ad 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -613,7 +613,7 @@ static ssize_t calibrate_store(struct device *dev,
613 int tries = 20; 613 int tries = 20;
614 int retval; 614 int retval;
615 int error; 615 int error;
616 u8 val[3]; 616 u8 val[ETP_CALIBRATE_MAX_LEN];
617 617
618 retval = mutex_lock_interruptible(&data->sysfs_mutex); 618 retval = mutex_lock_interruptible(&data->sysfs_mutex);
619 if (retval) 619 if (retval)
@@ -1345,6 +1345,7 @@ static const struct acpi_device_id elan_acpi_id[] = {
1345 { "ELAN060C", 0 }, 1345 { "ELAN060C", 0 },
1346 { "ELAN0611", 0 }, 1346 { "ELAN0611", 0 },
1347 { "ELAN0612", 0 }, 1347 { "ELAN0612", 0 },
1348 { "ELAN0618", 0 },
1348 { "ELAN1000", 0 }, 1349 { "ELAN1000", 0 },
1349 { } 1350 { }
1350}; 1351};
diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
index cfcb32559925..c060d270bc4d 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -56,7 +56,7 @@
56static int elan_smbus_initialize(struct i2c_client *client) 56static int elan_smbus_initialize(struct i2c_client *client)
57{ 57{
58 u8 check[ETP_SMBUS_HELLOPACKET_LEN] = { 0x55, 0x55, 0x55, 0x55, 0x55 }; 58 u8 check[ETP_SMBUS_HELLOPACKET_LEN] = { 0x55, 0x55, 0x55, 0x55, 0x55 };
59 u8 values[ETP_SMBUS_HELLOPACKET_LEN] = { 0, 0, 0, 0, 0 }; 59 u8 values[I2C_SMBUS_BLOCK_MAX] = {0};
60 int len, error; 60 int len, error;
61 61
62 /* Get hello packet */ 62 /* Get hello packet */
@@ -117,12 +117,16 @@ static int elan_smbus_calibrate(struct i2c_client *client)
117static int elan_smbus_calibrate_result(struct i2c_client *client, u8 *val) 117static int elan_smbus_calibrate_result(struct i2c_client *client, u8 *val)
118{ 118{
119 int error; 119 int error;
120 u8 buf[I2C_SMBUS_BLOCK_MAX] = {0};
121
122 BUILD_BUG_ON(ETP_CALIBRATE_MAX_LEN > sizeof(buf));
120 123
121 error = i2c_smbus_read_block_data(client, 124 error = i2c_smbus_read_block_data(client,
122 ETP_SMBUS_CALIBRATE_QUERY, val); 125 ETP_SMBUS_CALIBRATE_QUERY, buf);
123 if (error < 0) 126 if (error < 0)
124 return error; 127 return error;
125 128
129 memcpy(val, buf, ETP_CALIBRATE_MAX_LEN);
126 return 0; 130 return 0;
127} 131}
128 132
@@ -472,6 +476,8 @@ static int elan_smbus_get_report(struct i2c_client *client, u8 *report)
472{ 476{
473 int len; 477 int len;
474 478
479 BUILD_BUG_ON(I2C_SMBUS_BLOCK_MAX > ETP_SMBUS_REPORT_LEN);
480
475 len = i2c_smbus_read_block_data(client, 481 len = i2c_smbus_read_block_data(client,
476 ETP_SMBUS_PACKET_QUERY, 482 ETP_SMBUS_PACKET_QUERY,
477 &report[ETP_SMBUS_REPORT_OFFSET]); 483 &report[ETP_SMBUS_REPORT_OFFSET]);
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index fb4d902c4403..dd85b16dc6f8 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -799,7 +799,7 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
799 else if (ic_version == 7 && etd->info.samples[1] == 0x2A) 799 else if (ic_version == 7 && etd->info.samples[1] == 0x2A)
800 sanity_check = ((packet[3] & 0x1c) == 0x10); 800 sanity_check = ((packet[3] & 0x1c) == 0x10);
801 else 801 else
802 sanity_check = ((packet[0] & 0x0c) == 0x04 && 802 sanity_check = ((packet[0] & 0x08) == 0x00 &&
803 (packet[3] & 0x1c) == 0x10); 803 (packet[3] & 0x1c) == 0x10);
804 804
805 if (!sanity_check) 805 if (!sanity_check)
@@ -1175,6 +1175,12 @@ static const struct dmi_system_id elantech_dmi_has_middle_button[] = {
1175 { } 1175 { }
1176}; 1176};
1177 1177
1178static const char * const middle_button_pnp_ids[] = {
1179 "LEN2131", /* ThinkPad P52 w/ NFC */
1180 "LEN2132", /* ThinkPad P52 */
1181 NULL
1182};
1183
1178/* 1184/*
1179 * Set the appropriate event bits for the input subsystem 1185 * Set the appropriate event bits for the input subsystem
1180 */ 1186 */
@@ -1194,7 +1200,8 @@ static int elantech_set_input_params(struct psmouse *psmouse)
1194 __clear_bit(EV_REL, dev->evbit); 1200 __clear_bit(EV_REL, dev->evbit);
1195 1201
1196 __set_bit(BTN_LEFT, dev->keybit); 1202 __set_bit(BTN_LEFT, dev->keybit);
1197 if (dmi_check_system(elantech_dmi_has_middle_button)) 1203 if (dmi_check_system(elantech_dmi_has_middle_button) ||
1204 psmouse_matches_pnp_id(psmouse, middle_button_pnp_ids))
1198 __set_bit(BTN_MIDDLE, dev->keybit); 1205 __set_bit(BTN_MIDDLE, dev->keybit);
1199 __set_bit(BTN_RIGHT, dev->keybit); 1206 __set_bit(BTN_RIGHT, dev->keybit);
1200 1207
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 5ff5b1952be0..d3ff1fc09af7 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -192,8 +192,8 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
192 else 192 else
193 input_report_rel(dev, REL_WHEEL, -wheel); 193 input_report_rel(dev, REL_WHEEL, -wheel);
194 194
195 input_report_key(dev, BTN_SIDE, BIT(4)); 195 input_report_key(dev, BTN_SIDE, packet[3] & BIT(4));
196 input_report_key(dev, BTN_EXTRA, BIT(5)); 196 input_report_key(dev, BTN_EXTRA, packet[3] & BIT(5));
197 break; 197 break;
198 } 198 }
199 break; 199 break;
@@ -203,13 +203,13 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
203 input_report_rel(dev, REL_WHEEL, -(s8) packet[3]); 203 input_report_rel(dev, REL_WHEEL, -(s8) packet[3]);
204 204
205 /* Extra buttons on Genius NewNet 3D */ 205 /* Extra buttons on Genius NewNet 3D */
206 input_report_key(dev, BTN_SIDE, BIT(6)); 206 input_report_key(dev, BTN_SIDE, packet[0] & BIT(6));
207 input_report_key(dev, BTN_EXTRA, BIT(7)); 207 input_report_key(dev, BTN_EXTRA, packet[0] & BIT(7));
208 break; 208 break;
209 209
210 case PSMOUSE_THINKPS: 210 case PSMOUSE_THINKPS:
211 /* Extra button on ThinkingMouse */ 211 /* Extra button on ThinkingMouse */
212 input_report_key(dev, BTN_EXTRA, BIT(3)); 212 input_report_key(dev, BTN_EXTRA, packet[0] & BIT(3));
213 213
214 /* 214 /*
215 * Without this bit of weirdness moving up gives wildly 215 * Without this bit of weirdness moving up gives wildly
@@ -223,7 +223,7 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
223 * Cortron PS2 Trackball reports SIDE button in the 223 * Cortron PS2 Trackball reports SIDE button in the
224 * 4th bit of the first byte. 224 * 4th bit of the first byte.
225 */ 225 */
226 input_report_key(dev, BTN_SIDE, BIT(3)); 226 input_report_key(dev, BTN_SIDE, packet[0] & BIT(3));
227 packet[0] |= BIT(3); 227 packet[0] |= BIT(3);
228 break; 228 break;
229 229
diff --git a/drivers/input/rmi4/Kconfig b/drivers/input/rmi4/Kconfig
index 7172b88cd064..fad2eae4a118 100644
--- a/drivers/input/rmi4/Kconfig
+++ b/drivers/input/rmi4/Kconfig
@@ -3,6 +3,7 @@
3# 3#
4config RMI4_CORE 4config RMI4_CORE
5 tristate "Synaptics RMI4 bus support" 5 tristate "Synaptics RMI4 bus support"
6 select IRQ_DOMAIN
6 help 7 help
7 Say Y here if you want to support the Synaptics RMI4 bus. This is 8 Say Y here if you want to support the Synaptics RMI4 bus. This is
8 required for all RMI4 device support. 9 required for all RMI4 device support.
diff --git a/drivers/input/rmi4/rmi_2d_sensor.c b/drivers/input/rmi4/rmi_2d_sensor.c
index 8bb866c7b985..8eeffa066022 100644
--- a/drivers/input/rmi4/rmi_2d_sensor.c
+++ b/drivers/input/rmi4/rmi_2d_sensor.c
@@ -32,15 +32,15 @@ void rmi_2d_sensor_abs_process(struct rmi_2d_sensor *sensor,
32 if (obj->type == RMI_2D_OBJECT_NONE) 32 if (obj->type == RMI_2D_OBJECT_NONE)
33 return; 33 return;
34 34
35 if (axis_align->swap_axes)
36 swap(obj->x, obj->y);
37
38 if (axis_align->flip_x) 35 if (axis_align->flip_x)
39 obj->x = sensor->max_x - obj->x; 36 obj->x = sensor->max_x - obj->x;
40 37
41 if (axis_align->flip_y) 38 if (axis_align->flip_y)
42 obj->y = sensor->max_y - obj->y; 39 obj->y = sensor->max_y - obj->y;
43 40
41 if (axis_align->swap_axes)
42 swap(obj->x, obj->y);
43
44 /* 44 /*
45 * Here checking if X offset or y offset are specified is 45 * Here checking if X offset or y offset are specified is
46 * redundant. We just add the offsets or clip the values. 46 * redundant. We just add the offsets or clip the values.
@@ -120,15 +120,15 @@ void rmi_2d_sensor_rel_report(struct rmi_2d_sensor *sensor, int x, int y)
120 x = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)x)); 120 x = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)x));
121 y = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)y)); 121 y = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)y));
122 122
123 if (axis_align->swap_axes)
124 swap(x, y);
125
126 if (axis_align->flip_x) 123 if (axis_align->flip_x)
127 x = min(RMI_2D_REL_POS_MAX, -x); 124 x = min(RMI_2D_REL_POS_MAX, -x);
128 125
129 if (axis_align->flip_y) 126 if (axis_align->flip_y)
130 y = min(RMI_2D_REL_POS_MAX, -y); 127 y = min(RMI_2D_REL_POS_MAX, -y);
131 128
129 if (axis_align->swap_axes)
130 swap(x, y);
131
132 if (x || y) { 132 if (x || y) {
133 input_report_rel(sensor->input, REL_X, x); 133 input_report_rel(sensor->input, REL_X, x);
134 input_report_rel(sensor->input, REL_Y, y); 134 input_report_rel(sensor->input, REL_Y, y);
@@ -141,17 +141,10 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
141 struct input_dev *input = sensor->input; 141 struct input_dev *input = sensor->input;
142 int res_x; 142 int res_x;
143 int res_y; 143 int res_y;
144 int max_x, max_y;
144 int input_flags = 0; 145 int input_flags = 0;
145 146
146 if (sensor->report_abs) { 147 if (sensor->report_abs) {
147 if (sensor->axis_align.swap_axes) {
148 swap(sensor->max_x, sensor->max_y);
149 swap(sensor->axis_align.clip_x_low,
150 sensor->axis_align.clip_y_low);
151 swap(sensor->axis_align.clip_x_high,
152 sensor->axis_align.clip_y_high);
153 }
154
155 sensor->min_x = sensor->axis_align.clip_x_low; 148 sensor->min_x = sensor->axis_align.clip_x_low;
156 if (sensor->axis_align.clip_x_high) 149 if (sensor->axis_align.clip_x_high)
157 sensor->max_x = min(sensor->max_x, 150 sensor->max_x = min(sensor->max_x,
@@ -163,14 +156,19 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
163 sensor->axis_align.clip_y_high); 156 sensor->axis_align.clip_y_high);
164 157
165 set_bit(EV_ABS, input->evbit); 158 set_bit(EV_ABS, input->evbit);
166 input_set_abs_params(input, ABS_MT_POSITION_X, 0, sensor->max_x, 159
167 0, 0); 160 max_x = sensor->max_x;
168 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, sensor->max_y, 161 max_y = sensor->max_y;
169 0, 0); 162 if (sensor->axis_align.swap_axes)
163 swap(max_x, max_y);
164 input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_x, 0, 0);
165 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
170 166
171 if (sensor->x_mm && sensor->y_mm) { 167 if (sensor->x_mm && sensor->y_mm) {
172 res_x = (sensor->max_x - sensor->min_x) / sensor->x_mm; 168 res_x = (sensor->max_x - sensor->min_x) / sensor->x_mm;
173 res_y = (sensor->max_y - sensor->min_y) / sensor->y_mm; 169 res_y = (sensor->max_y - sensor->min_y) / sensor->y_mm;
170 if (sensor->axis_align.swap_axes)
171 swap(res_x, res_y);
174 172
175 input_abs_set_res(input, ABS_X, res_x); 173 input_abs_set_res(input, ABS_X, res_x);
176 input_abs_set_res(input, ABS_Y, res_y); 174 input_abs_set_res(input, ABS_Y, res_y);
diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index c5fa53adba8d..bd0d5ff01b08 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -9,6 +9,8 @@
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/irq.h>
13#include <linux/irqdomain.h>
12#include <linux/list.h> 14#include <linux/list.h>
13#include <linux/pm.h> 15#include <linux/pm.h>
14#include <linux/rmi.h> 16#include <linux/rmi.h>
@@ -167,6 +169,39 @@ static inline void rmi_function_of_probe(struct rmi_function *fn)
167{} 169{}
168#endif 170#endif
169 171
172static struct irq_chip rmi_irq_chip = {
173 .name = "rmi4",
174};
175
176static int rmi_create_function_irq(struct rmi_function *fn,
177 struct rmi_function_handler *handler)
178{
179 struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev);
180 int i, error;
181
182 for (i = 0; i < fn->num_of_irqs; i++) {
183 set_bit(fn->irq_pos + i, fn->irq_mask);
184
185 fn->irq[i] = irq_create_mapping(drvdata->irqdomain,
186 fn->irq_pos + i);
187
188 irq_set_chip_data(fn->irq[i], fn);
189 irq_set_chip_and_handler(fn->irq[i], &rmi_irq_chip,
190 handle_simple_irq);
191 irq_set_nested_thread(fn->irq[i], 1);
192
193 error = devm_request_threaded_irq(&fn->dev, fn->irq[i], NULL,
194 handler->attention, IRQF_ONESHOT,
195 dev_name(&fn->dev), fn);
196 if (error) {
197 dev_err(&fn->dev, "Error %d registering IRQ\n", error);
198 return error;
199 }
200 }
201
202 return 0;
203}
204
170static int rmi_function_probe(struct device *dev) 205static int rmi_function_probe(struct device *dev)
171{ 206{
172 struct rmi_function *fn = to_rmi_function(dev); 207 struct rmi_function *fn = to_rmi_function(dev);
@@ -178,7 +213,14 @@ static int rmi_function_probe(struct device *dev)
178 213
179 if (handler->probe) { 214 if (handler->probe) {
180 error = handler->probe(fn); 215 error = handler->probe(fn);
181 return error; 216 if (error)
217 return error;
218 }
219
220 if (fn->num_of_irqs && handler->attention) {
221 error = rmi_create_function_irq(fn, handler);
222 if (error)
223 return error;
182 } 224 }
183 225
184 return 0; 226 return 0;
@@ -230,12 +272,18 @@ err_put_device:
230 272
231void rmi_unregister_function(struct rmi_function *fn) 273void rmi_unregister_function(struct rmi_function *fn)
232{ 274{
275 int i;
276
233 rmi_dbg(RMI_DEBUG_CORE, &fn->dev, "Unregistering F%02X.\n", 277 rmi_dbg(RMI_DEBUG_CORE, &fn->dev, "Unregistering F%02X.\n",
234 fn->fd.function_number); 278 fn->fd.function_number);
235 279
236 device_del(&fn->dev); 280 device_del(&fn->dev);
237 of_node_put(fn->dev.of_node); 281 of_node_put(fn->dev.of_node);
238 put_device(&fn->dev); 282 put_device(&fn->dev);
283
284 for (i = 0; i < fn->num_of_irqs; i++)
285 irq_dispose_mapping(fn->irq[i]);
286
239} 287}
240 288
241/** 289/**
diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
index b7625a9ac66a..96383eab41ba 100644
--- a/drivers/input/rmi4/rmi_bus.h
+++ b/drivers/input/rmi4/rmi_bus.h
@@ -14,6 +14,12 @@
14 14
15struct rmi_device; 15struct rmi_device;
16 16
17/*
18 * The interrupt source count in the function descriptor can represent up to
19 * 6 interrupt sources in the normal manner.
20 */
21#define RMI_FN_MAX_IRQS 6
22
17/** 23/**
18 * struct rmi_function - represents the implementation of an RMI4 24 * struct rmi_function - represents the implementation of an RMI4
19 * function for a particular device (basically, a driver for that RMI4 function) 25 * function for a particular device (basically, a driver for that RMI4 function)
@@ -26,6 +32,7 @@ struct rmi_device;
26 * @irq_pos: The position in the irq bitfield this function holds 32 * @irq_pos: The position in the irq bitfield this function holds
27 * @irq_mask: For convenience, can be used to mask IRQ bits off during ATTN 33 * @irq_mask: For convenience, can be used to mask IRQ bits off during ATTN
28 * interrupt handling. 34 * interrupt handling.
35 * @irqs: assigned virq numbers (up to num_of_irqs)
29 * 36 *
30 * @node: entry in device's list of functions 37 * @node: entry in device's list of functions
31 */ 38 */
@@ -36,6 +43,7 @@ struct rmi_function {
36 struct list_head node; 43 struct list_head node;
37 44
38 unsigned int num_of_irqs; 45 unsigned int num_of_irqs;
46 int irq[RMI_FN_MAX_IRQS];
39 unsigned int irq_pos; 47 unsigned int irq_pos;
40 unsigned long irq_mask[]; 48 unsigned long irq_mask[];
41}; 49};
@@ -76,7 +84,7 @@ struct rmi_function_handler {
76 void (*remove)(struct rmi_function *fn); 84 void (*remove)(struct rmi_function *fn);
77 int (*config)(struct rmi_function *fn); 85 int (*config)(struct rmi_function *fn);
78 int (*reset)(struct rmi_function *fn); 86 int (*reset)(struct rmi_function *fn);
79 int (*attention)(struct rmi_function *fn, unsigned long *irq_bits); 87 irqreturn_t (*attention)(int irq, void *ctx);
80 int (*suspend)(struct rmi_function *fn); 88 int (*suspend)(struct rmi_function *fn);
81 int (*resume)(struct rmi_function *fn); 89 int (*resume)(struct rmi_function *fn);
82}; 90};
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 7d29053dfb0f..fc3ab93b7aea 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -21,6 +21,7 @@
21#include <linux/pm.h> 21#include <linux/pm.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/of.h> 23#include <linux/of.h>
24#include <linux/irqdomain.h>
24#include <uapi/linux/input.h> 25#include <uapi/linux/input.h>
25#include <linux/rmi.h> 26#include <linux/rmi.h>
26#include "rmi_bus.h" 27#include "rmi_bus.h"
@@ -127,28 +128,11 @@ static int rmi_driver_process_config_requests(struct rmi_device *rmi_dev)
127 return 0; 128 return 0;
128} 129}
129 130
130static void process_one_interrupt(struct rmi_driver_data *data,
131 struct rmi_function *fn)
132{
133 struct rmi_function_handler *fh;
134
135 if (!fn || !fn->dev.driver)
136 return;
137
138 fh = to_rmi_function_handler(fn->dev.driver);
139 if (fh->attention) {
140 bitmap_and(data->fn_irq_bits, data->irq_status, fn->irq_mask,
141 data->irq_count);
142 if (!bitmap_empty(data->fn_irq_bits, data->irq_count))
143 fh->attention(fn, data->fn_irq_bits);
144 }
145}
146
147static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev) 131static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev)
148{ 132{
149 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); 133 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
150 struct device *dev = &rmi_dev->dev; 134 struct device *dev = &rmi_dev->dev;
151 struct rmi_function *entry; 135 int i;
152 int error; 136 int error;
153 137
154 if (!data) 138 if (!data)
@@ -173,16 +157,8 @@ static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev)
173 */ 157 */
174 mutex_unlock(&data->irq_mutex); 158 mutex_unlock(&data->irq_mutex);
175 159
176 /* 160 for_each_set_bit(i, data->irq_status, data->irq_count)
177 * It would be nice to be able to use irq_chip to handle these 161 handle_nested_irq(irq_find_mapping(data->irqdomain, i));
178 * nested IRQs. Unfortunately, most of the current customers for
179 * this driver are using older kernels (3.0.x) that don't support
180 * the features required for that. Once they've shifted to more
181 * recent kernels (say, 3.3 and higher), this should be switched to
182 * use irq_chip.
183 */
184 list_for_each_entry(entry, &data->function_list, node)
185 process_one_interrupt(data, entry);
186 162
187 if (data->input) 163 if (data->input)
188 input_sync(data->input); 164 input_sync(data->input);
@@ -1001,9 +977,13 @@ EXPORT_SYMBOL_GPL(rmi_driver_resume);
1001static int rmi_driver_remove(struct device *dev) 977static int rmi_driver_remove(struct device *dev)
1002{ 978{
1003 struct rmi_device *rmi_dev = to_rmi_device(dev); 979 struct rmi_device *rmi_dev = to_rmi_device(dev);
980 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
1004 981
1005 rmi_disable_irq(rmi_dev, false); 982 rmi_disable_irq(rmi_dev, false);
1006 983
984 irq_domain_remove(data->irqdomain);
985 data->irqdomain = NULL;
986
1007 rmi_f34_remove_sysfs(rmi_dev); 987 rmi_f34_remove_sysfs(rmi_dev);
1008 rmi_free_function_list(rmi_dev); 988 rmi_free_function_list(rmi_dev);
1009 989
@@ -1035,7 +1015,8 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
1035{ 1015{
1036 struct rmi_device *rmi_dev = data->rmi_dev; 1016 struct rmi_device *rmi_dev = data->rmi_dev;
1037 struct device *dev = &rmi_dev->dev; 1017 struct device *dev = &rmi_dev->dev;
1038 int irq_count; 1018 struct fwnode_handle *fwnode = rmi_dev->xport->dev->fwnode;
1019 int irq_count = 0;
1039 size_t size; 1020 size_t size;
1040 int retval; 1021 int retval;
1041 1022
@@ -1046,7 +1027,6 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
1046 * being accessed. 1027 * being accessed.
1047 */ 1028 */
1048 rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Counting IRQs.\n", __func__); 1029 rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Counting IRQs.\n", __func__);
1049 irq_count = 0;
1050 data->bootloader_mode = false; 1030 data->bootloader_mode = false;
1051 1031
1052 retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_count_irqs); 1032 retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_count_irqs);
@@ -1058,6 +1038,15 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
1058 if (data->bootloader_mode) 1038 if (data->bootloader_mode)
1059 dev_warn(dev, "Device in bootloader mode.\n"); 1039 dev_warn(dev, "Device in bootloader mode.\n");
1060 1040
1041 /* Allocate and register a linear revmap irq_domain */
1042 data->irqdomain = irq_domain_create_linear(fwnode, irq_count,
1043 &irq_domain_simple_ops,
1044 data);
1045 if (!data->irqdomain) {
1046 dev_err(&rmi_dev->dev, "Failed to create IRQ domain\n");
1047 return -ENOMEM;
1048 }
1049
1061 data->irq_count = irq_count; 1050 data->irq_count = irq_count;
1062 data->num_of_irq_regs = (data->irq_count + 7) / 8; 1051 data->num_of_irq_regs = (data->irq_count + 7) / 8;
1063 1052
@@ -1080,10 +1069,9 @@ int rmi_init_functions(struct rmi_driver_data *data)
1080{ 1069{
1081 struct rmi_device *rmi_dev = data->rmi_dev; 1070 struct rmi_device *rmi_dev = data->rmi_dev;
1082 struct device *dev = &rmi_dev->dev; 1071 struct device *dev = &rmi_dev->dev;
1083 int irq_count; 1072 int irq_count = 0;
1084 int retval; 1073 int retval;
1085 1074
1086 irq_count = 0;
1087 rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Creating functions.\n", __func__); 1075 rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Creating functions.\n", __func__);
1088 retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_create_function); 1076 retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_create_function);
1089 if (retval < 0) { 1077 if (retval < 0) {
diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
index 8a07ae147df6..4edaa14fe878 100644
--- a/drivers/input/rmi4/rmi_f01.c
+++ b/drivers/input/rmi4/rmi_f01.c
@@ -681,9 +681,9 @@ static int rmi_f01_resume(struct rmi_function *fn)
681 return 0; 681 return 0;
682} 682}
683 683
684static int rmi_f01_attention(struct rmi_function *fn, 684static irqreturn_t rmi_f01_attention(int irq, void *ctx)
685 unsigned long *irq_bits)
686{ 685{
686 struct rmi_function *fn = ctx;
687 struct rmi_device *rmi_dev = fn->rmi_dev; 687 struct rmi_device *rmi_dev = fn->rmi_dev;
688 int error; 688 int error;
689 u8 device_status; 689 u8 device_status;
@@ -692,7 +692,7 @@ static int rmi_f01_attention(struct rmi_function *fn,
692 if (error) { 692 if (error) {
693 dev_err(&fn->dev, 693 dev_err(&fn->dev,
694 "Failed to read device status: %d.\n", error); 694 "Failed to read device status: %d.\n", error);
695 return error; 695 return IRQ_RETVAL(error);
696 } 696 }
697 697
698 if (RMI_F01_STATUS_BOOTLOADER(device_status)) 698 if (RMI_F01_STATUS_BOOTLOADER(device_status))
@@ -704,11 +704,11 @@ static int rmi_f01_attention(struct rmi_function *fn,
704 error = rmi_dev->driver->reset_handler(rmi_dev); 704 error = rmi_dev->driver->reset_handler(rmi_dev);
705 if (error) { 705 if (error) {
706 dev_err(&fn->dev, "Device reset failed: %d\n", error); 706 dev_err(&fn->dev, "Device reset failed: %d\n", error);
707 return error; 707 return IRQ_RETVAL(error);
708 } 708 }
709 } 709 }
710 710
711 return 0; 711 return IRQ_HANDLED;
712} 712}
713 713
714struct rmi_function_handler rmi_f01_handler = { 714struct rmi_function_handler rmi_f01_handler = {
diff --git a/drivers/input/rmi4/rmi_f03.c b/drivers/input/rmi4/rmi_f03.c
index 88822196d6b7..aaa1edc95522 100644
--- a/drivers/input/rmi4/rmi_f03.c
+++ b/drivers/input/rmi4/rmi_f03.c
@@ -244,8 +244,9 @@ static int rmi_f03_config(struct rmi_function *fn)
244 return 0; 244 return 0;
245} 245}
246 246
247static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits) 247static irqreturn_t rmi_f03_attention(int irq, void *ctx)
248{ 248{
249 struct rmi_function *fn = ctx;
249 struct rmi_device *rmi_dev = fn->rmi_dev; 250 struct rmi_device *rmi_dev = fn->rmi_dev;
250 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); 251 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
251 struct f03_data *f03 = dev_get_drvdata(&fn->dev); 252 struct f03_data *f03 = dev_get_drvdata(&fn->dev);
@@ -262,7 +263,7 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)
262 /* First grab the data passed by the transport device */ 263 /* First grab the data passed by the transport device */
263 if (drvdata->attn_data.size < ob_len) { 264 if (drvdata->attn_data.size < ob_len) {
264 dev_warn(&fn->dev, "F03 interrupted, but data is missing!\n"); 265 dev_warn(&fn->dev, "F03 interrupted, but data is missing!\n");
265 return 0; 266 return IRQ_HANDLED;
266 } 267 }
267 268
268 memcpy(obs, drvdata->attn_data.data, ob_len); 269 memcpy(obs, drvdata->attn_data.data, ob_len);
@@ -277,7 +278,7 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)
277 "%s: Failed to read F03 output buffers: %d\n", 278 "%s: Failed to read F03 output buffers: %d\n",
278 __func__, error); 279 __func__, error);
279 serio_interrupt(f03->serio, 0, SERIO_TIMEOUT); 280 serio_interrupt(f03->serio, 0, SERIO_TIMEOUT);
280 return error; 281 return IRQ_RETVAL(error);
281 } 282 }
282 } 283 }
283 284
@@ -303,7 +304,7 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)
303 serio_interrupt(f03->serio, ob_data, serio_flags); 304 serio_interrupt(f03->serio, ob_data, serio_flags);
304 } 305 }
305 306
306 return 0; 307 return IRQ_HANDLED;
307} 308}
308 309
309static void rmi_f03_remove(struct rmi_function *fn) 310static void rmi_f03_remove(struct rmi_function *fn)
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index 12a233251793..df64d6aed4f7 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -570,9 +570,7 @@ static inline u8 rmi_f11_parse_finger_state(const u8 *f_state, u8 n_finger)
570} 570}
571 571
572static void rmi_f11_finger_handler(struct f11_data *f11, 572static void rmi_f11_finger_handler(struct f11_data *f11,
573 struct rmi_2d_sensor *sensor, 573 struct rmi_2d_sensor *sensor, int size)
574 unsigned long *irq_bits, int num_irq_regs,
575 int size)
576{ 574{
577 const u8 *f_state = f11->data.f_state; 575 const u8 *f_state = f11->data.f_state;
578 u8 finger_state; 576 u8 finger_state;
@@ -581,12 +579,7 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
581 int rel_fingers; 579 int rel_fingers;
582 int abs_size = sensor->nbr_fingers * RMI_F11_ABS_BYTES; 580 int abs_size = sensor->nbr_fingers * RMI_F11_ABS_BYTES;
583 581
584 int abs_bits = bitmap_and(f11->result_bits, irq_bits, f11->abs_mask, 582 if (sensor->report_abs) {
585 num_irq_regs * 8);
586 int rel_bits = bitmap_and(f11->result_bits, irq_bits, f11->rel_mask,
587 num_irq_regs * 8);
588
589 if (abs_bits) {
590 if (abs_size > size) 583 if (abs_size > size)
591 abs_fingers = size / RMI_F11_ABS_BYTES; 584 abs_fingers = size / RMI_F11_ABS_BYTES;
592 else 585 else
@@ -604,19 +597,7 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
604 rmi_f11_abs_pos_process(f11, sensor, &sensor->objs[i], 597 rmi_f11_abs_pos_process(f11, sensor, &sensor->objs[i],
605 finger_state, i); 598 finger_state, i);
606 } 599 }
607 }
608 600
609 if (rel_bits) {
610 if ((abs_size + sensor->nbr_fingers * RMI_F11_REL_BYTES) > size)
611 rel_fingers = (size - abs_size) / RMI_F11_REL_BYTES;
612 else
613 rel_fingers = sensor->nbr_fingers;
614
615 for (i = 0; i < rel_fingers; i++)
616 rmi_f11_rel_pos_report(f11, i);
617 }
618
619 if (abs_bits) {
620 /* 601 /*
621 * the absolute part is made in 2 parts to allow the kernel 602 * the absolute part is made in 2 parts to allow the kernel
622 * tracking to take place. 603 * tracking to take place.
@@ -638,7 +619,16 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
638 } 619 }
639 620
640 input_mt_sync_frame(sensor->input); 621 input_mt_sync_frame(sensor->input);
622 } else if (sensor->report_rel) {
623 if ((abs_size + sensor->nbr_fingers * RMI_F11_REL_BYTES) > size)
624 rel_fingers = (size - abs_size) / RMI_F11_REL_BYTES;
625 else
626 rel_fingers = sensor->nbr_fingers;
627
628 for (i = 0; i < rel_fingers; i++)
629 rmi_f11_rel_pos_report(f11, i);
641 } 630 }
631
642} 632}
643 633
644static int f11_2d_construct_data(struct f11_data *f11) 634static int f11_2d_construct_data(struct f11_data *f11)
@@ -1276,8 +1266,9 @@ static int rmi_f11_config(struct rmi_function *fn)
1276 return 0; 1266 return 0;
1277} 1267}
1278 1268
1279static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits) 1269static irqreturn_t rmi_f11_attention(int irq, void *ctx)
1280{ 1270{
1271 struct rmi_function *fn = ctx;
1281 struct rmi_device *rmi_dev = fn->rmi_dev; 1272 struct rmi_device *rmi_dev = fn->rmi_dev;
1282 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); 1273 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
1283 struct f11_data *f11 = dev_get_drvdata(&fn->dev); 1274 struct f11_data *f11 = dev_get_drvdata(&fn->dev);
@@ -1303,13 +1294,12 @@ static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits)
1303 data_base_addr, f11->sensor.data_pkt, 1294 data_base_addr, f11->sensor.data_pkt,
1304 f11->sensor.pkt_size); 1295 f11->sensor.pkt_size);
1305 if (error < 0) 1296 if (error < 0)
1306 return error; 1297 return IRQ_RETVAL(error);
1307 } 1298 }
1308 1299
1309 rmi_f11_finger_handler(f11, &f11->sensor, irq_bits, 1300 rmi_f11_finger_handler(f11, &f11->sensor, valid_bytes);
1310 drvdata->num_of_irq_regs, valid_bytes);
1311 1301
1312 return 0; 1302 return IRQ_HANDLED;
1313} 1303}
1314 1304
1315static int rmi_f11_resume(struct rmi_function *fn) 1305static int rmi_f11_resume(struct rmi_function *fn)
diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c
index a3d1aa88f2a9..5c7f48915779 100644
--- a/drivers/input/rmi4/rmi_f12.c
+++ b/drivers/input/rmi4/rmi_f12.c
@@ -197,10 +197,10 @@ static void rmi_f12_process_objects(struct f12_data *f12, u8 *data1, int size)
197 rmi_2d_sensor_abs_report(sensor, &sensor->objs[i], i); 197 rmi_2d_sensor_abs_report(sensor, &sensor->objs[i], i);
198} 198}
199 199
200static int rmi_f12_attention(struct rmi_function *fn, 200static irqreturn_t rmi_f12_attention(int irq, void *ctx)
201 unsigned long *irq_nr_regs)
202{ 201{
203 int retval; 202 int retval;
203 struct rmi_function *fn = ctx;
204 struct rmi_device *rmi_dev = fn->rmi_dev; 204 struct rmi_device *rmi_dev = fn->rmi_dev;
205 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); 205 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
206 struct f12_data *f12 = dev_get_drvdata(&fn->dev); 206 struct f12_data *f12 = dev_get_drvdata(&fn->dev);
@@ -222,7 +222,7 @@ static int rmi_f12_attention(struct rmi_function *fn,
222 if (retval < 0) { 222 if (retval < 0) {
223 dev_err(&fn->dev, "Failed to read object data. Code: %d.\n", 223 dev_err(&fn->dev, "Failed to read object data. Code: %d.\n",
224 retval); 224 retval);
225 return retval; 225 return IRQ_RETVAL(retval);
226 } 226 }
227 } 227 }
228 228
@@ -232,7 +232,7 @@ static int rmi_f12_attention(struct rmi_function *fn,
232 232
233 input_mt_sync_frame(sensor->input); 233 input_mt_sync_frame(sensor->input);
234 234
235 return 0; 235 return IRQ_HANDLED;
236} 236}
237 237
238static int rmi_f12_write_control_regs(struct rmi_function *fn) 238static int rmi_f12_write_control_regs(struct rmi_function *fn)
diff --git a/drivers/input/rmi4/rmi_f30.c b/drivers/input/rmi4/rmi_f30.c
index 82e0f0d43d55..5e3ed5ac0c3e 100644
--- a/drivers/input/rmi4/rmi_f30.c
+++ b/drivers/input/rmi4/rmi_f30.c
@@ -122,8 +122,9 @@ static void rmi_f30_report_button(struct rmi_function *fn,
122 } 122 }
123} 123}
124 124
125static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits) 125static irqreturn_t rmi_f30_attention(int irq, void *ctx)
126{ 126{
127 struct rmi_function *fn = ctx;
127 struct f30_data *f30 = dev_get_drvdata(&fn->dev); 128 struct f30_data *f30 = dev_get_drvdata(&fn->dev);
128 struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev); 129 struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev);
129 int error; 130 int error;
@@ -134,7 +135,7 @@ static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits)
134 if (drvdata->attn_data.size < f30->register_count) { 135 if (drvdata->attn_data.size < f30->register_count) {
135 dev_warn(&fn->dev, 136 dev_warn(&fn->dev,
136 "F30 interrupted, but data is missing\n"); 137 "F30 interrupted, but data is missing\n");
137 return 0; 138 return IRQ_HANDLED;
138 } 139 }
139 memcpy(f30->data_regs, drvdata->attn_data.data, 140 memcpy(f30->data_regs, drvdata->attn_data.data,
140 f30->register_count); 141 f30->register_count);
@@ -147,7 +148,7 @@ static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits)
147 dev_err(&fn->dev, 148 dev_err(&fn->dev,
148 "%s: Failed to read F30 data registers: %d\n", 149 "%s: Failed to read F30 data registers: %d\n",
149 __func__, error); 150 __func__, error);
150 return error; 151 return IRQ_RETVAL(error);
151 } 152 }
152 } 153 }
153 154
@@ -159,7 +160,7 @@ static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits)
159 rmi_f03_commit_buttons(f30->f03); 160 rmi_f03_commit_buttons(f30->f03);
160 } 161 }
161 162
162 return 0; 163 return IRQ_HANDLED;
163} 164}
164 165
165static int rmi_f30_config(struct rmi_function *fn) 166static int rmi_f30_config(struct rmi_function *fn)
diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
index f1f5ac539d5d..87a7d4ba382d 100644
--- a/drivers/input/rmi4/rmi_f34.c
+++ b/drivers/input/rmi4/rmi_f34.c
@@ -100,8 +100,9 @@ static int rmi_f34_command(struct f34_data *f34, u8 command,
100 return 0; 100 return 0;
101} 101}
102 102
103static int rmi_f34_attention(struct rmi_function *fn, unsigned long *irq_bits) 103static irqreturn_t rmi_f34_attention(int irq, void *ctx)
104{ 104{
105 struct rmi_function *fn = ctx;
105 struct f34_data *f34 = dev_get_drvdata(&fn->dev); 106 struct f34_data *f34 = dev_get_drvdata(&fn->dev);
106 int ret; 107 int ret;
107 u8 status; 108 u8 status;
@@ -126,7 +127,7 @@ static int rmi_f34_attention(struct rmi_function *fn, unsigned long *irq_bits)
126 complete(&f34->v7.cmd_done); 127 complete(&f34->v7.cmd_done);
127 } 128 }
128 129
129 return 0; 130 return IRQ_HANDLED;
130} 131}
131 132
132static int rmi_f34_write_blocks(struct f34_data *f34, const void *data, 133static int rmi_f34_write_blocks(struct f34_data *f34, const void *data,
diff --git a/drivers/input/rmi4/rmi_f54.c b/drivers/input/rmi4/rmi_f54.c
index e8a59d164019..a6f515bcab22 100644
--- a/drivers/input/rmi4/rmi_f54.c
+++ b/drivers/input/rmi4/rmi_f54.c
@@ -610,11 +610,6 @@ error:
610 mutex_unlock(&f54->data_mutex); 610 mutex_unlock(&f54->data_mutex);
611} 611}
612 612
613static int rmi_f54_attention(struct rmi_function *fn, unsigned long *irqbits)
614{
615 return 0;
616}
617
618static int rmi_f54_config(struct rmi_function *fn) 613static int rmi_f54_config(struct rmi_function *fn)
619{ 614{
620 struct rmi_driver *drv = fn->rmi_dev->driver; 615 struct rmi_driver *drv = fn->rmi_dev->driver;
@@ -756,6 +751,5 @@ struct rmi_function_handler rmi_f54_handler = {
756 .func = 0x54, 751 .func = 0x54,
757 .probe = rmi_f54_probe, 752 .probe = rmi_f54_probe,
758 .config = rmi_f54_config, 753 .config = rmi_f54_config,
759 .attention = rmi_f54_attention,
760 .remove = rmi_f54_remove, 754 .remove = rmi_f54_remove,
761}; 755};
diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
index ff7043f74a3d..d196ac3d8b8c 100644
--- a/drivers/input/touchscreen/silead.c
+++ b/drivers/input/touchscreen/silead.c
@@ -603,6 +603,7 @@ static const struct acpi_device_id silead_ts_acpi_match[] = {
603 { "GSL3692", 0 }, 603 { "GSL3692", 0 },
604 { "MSSL1680", 0 }, 604 { "MSSL1680", 0 },
605 { "MSSL0001", 0 }, 605 { "MSSL0001", 0 },
606 { "MSSL0002", 0 },
606 { } 607 { }
607}; 608};
608MODULE_DEVICE_TABLE(acpi, silead_ts_acpi_match); 609MODULE_DEVICE_TABLE(acpi, silead_ts_acpi_match);
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h
index d7188de4db96..3f4bf60b0bb5 100644
--- a/include/linux/input/mt.h
+++ b/include/linux/input/mt.h
@@ -100,7 +100,7 @@ static inline bool input_is_mt_axis(int axis)
100 return axis == ABS_MT_SLOT || input_is_mt_value(axis); 100 return axis == ABS_MT_SLOT || input_is_mt_value(axis);
101} 101}
102 102
103void input_mt_report_slot_state(struct input_dev *dev, 103bool input_mt_report_slot_state(struct input_dev *dev,
104 unsigned int tool_type, bool active); 104 unsigned int tool_type, bool active);
105 105
106void input_mt_report_finger_count(struct input_dev *dev, int count); 106void input_mt_report_finger_count(struct input_dev *dev, int count);
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
index 64125443f8a6..5ef5c7c412a7 100644
--- a/include/linux/rmi.h
+++ b/include/linux/rmi.h
@@ -354,6 +354,8 @@ struct rmi_driver_data {
354 struct mutex irq_mutex; 354 struct mutex irq_mutex;
355 struct input_dev *input; 355 struct input_dev *input;
356 356
357 struct irq_domain *irqdomain;
358
357 u8 pdt_props; 359 u8 pdt_props;
358 360
359 u8 num_rx_electrodes; 361 u8 num_rx_electrodes;