Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input updates from Dmitry Torokhov:

- update the ili210x touchscreen driver, refreshing the code and adding
support for ILI251X line

- add support for st1633 to the st1232 touchscreen driver

- add support for sx8650 to the the sx8654 touchscreen driver

- add support for Evervision FT5726 to the edt-ft5x06 touchscreen
driver

- add support for gt5688 to the Goodix touchscreen driver

- new vibrator driver for MSM SOCs

- miscellaneous fixes for the rest of input drivers

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (53 commits)
Input: wacom_serial4 - add support for Wacom ArtPad II tablet
Input: elan_i2c - add id for touchpad found in Lenovo s21e-20
Input: raspberrypi-ts - select CONFIG_INPUT_POLLDEV
Input: msm-vibrator - use correct gpio header
Input: ti_am335x_tsc - remove set but not used variable 'tscadc_dev'
Input: i8042 - rework DT node name comparisons
Input: goodix - print values in case of inconsistencies
Input: goodix - refer to touchscreen.txt in device tree bindings
Input: goodix - support Goodix gt5688
Input: synaptics_i2c - remove redundant spinlock
Input: db9 - mark expected switch fall-through
Input: qt2160 - remove redundant spinlock
Input: st1232 - handle common DT bindings
Input: ims-pcu - switch to using brightness_set_blocking()
Input: st1232 - switch to gpiod API
Input: ili210x - fetch touchscreen geometry from DT
Input: msm-vibrator - tweak an error message
Input: tm2-touchkey - acknowledge that setting brightness is a blocking call
Input: stmfts - acknowledge that setting brightness is a blocking call
Input: ili210x - switch to using devm_device_add_group()
...

+1207 -367
+8 -1
Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
··· 1 1 Samsung tm2-touchkey 2 2 3 3 Required properties: 4 - - compatible: must be "cypress,tm2-touchkey" 4 + - compatible: 5 + * "cypress,tm2-touchkey" - for the touchkey found on the tm2 board 6 + * "cypress,midas-touchkey" - for the touchkey found on midas boards 7 + * "cypress,aries-touchkey" - for the touchkey found on aries boards 5 8 - reg: I2C address of the chip. 6 9 - interrupts: interrupt to which the chip is connected (see interrupt 7 10 binding[0]). 8 11 - vcc-supply : internal regulator output. 1.8V 9 12 - vdd-supply : power supply for IC 3.3V 13 + 14 + Optional properties: 15 + - linux,keycodes: array of keycodes (max 4), default KEY_PHONE and KEY_BACK 10 16 11 17 [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt 12 18 ··· 27 21 interrupts = <2 IRQ_TYPE_EDGE_FALLING>; 28 22 vcc-supply=<&ldo32_reg>; 29 23 vdd-supply=<&ldo33_reg>; 24 + linux,keycodes = <KEY_PHONE KEY_BACK>; 30 25 }; 31 26 };
+25
Documentation/devicetree/bindings/input/ilitek,ili2xxx.txt
··· 1 + Ilitek ILI210x/ILI251x touchscreen controller 2 + 3 + Required properties: 4 + - compatible: 5 + ilitek,ili210x for ILI210x 6 + ilitek,ili251x for ILI251x 7 + 8 + - reg: The I2C address of the device 9 + 10 + - interrupts: The sink for the touchscreen's IRQ output 11 + See ../interrupt-controller/interrupts.txt 12 + 13 + Optional properties for main touchpad device: 14 + 15 + - reset-gpios: GPIO specifier for the touchscreen's reset pin (active low) 16 + 17 + Example: 18 + 19 + touchscreen@41 { 20 + compatible = "ilitek,ili251x"; 21 + reg = <0x41>; 22 + interrupt-parent = <&gpio4>; 23 + interrupts = <7 IRQ_TYPE_EDGE_FALLING>; 24 + reset-gpios = <&gpio5 21 GPIO_ACTIVE_LOW>; 25 + };
+36
Documentation/devicetree/bindings/input/msm-vibrator.txt
··· 1 + * Device tree bindings for the Qualcomm MSM vibrator 2 + 3 + Required properties: 4 + 5 + - compatible: Should be one of 6 + "qcom,msm8226-vibrator" 7 + "qcom,msm8974-vibrator" 8 + - reg: the base address and length of the IO memory for the registers. 9 + - pinctrl-names: set to default. 10 + - pinctrl-0: phandles pointing to pin configuration nodes. See 11 + Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt 12 + - clock-names: set to pwm 13 + - clocks: phandle of the clock. See 14 + Documentation/devicetree/bindings/clock/clock-bindings.txt 15 + - enable-gpios: GPIO that enables the vibrator. 16 + 17 + Optional properties: 18 + 19 + - vcc-supply: phandle to the regulator that provides power to the sensor. 20 + 21 + Example from a LG Nexus 5 (hammerhead) phone: 22 + 23 + vibrator@fd8c3450 { 24 + reg = <0xfd8c3450 0x400>; 25 + compatible = "qcom,msm8974-vibrator"; 26 + 27 + vcc-supply = <&pm8941_l19>; 28 + 29 + clocks = <&mmcc CAMSS_GP1_CLK>; 30 + clock-names = "pwm"; 31 + 32 + enable-gpios = <&msmgpio 60 GPIO_ACTIVE_HIGH>; 33 + 34 + pinctrl-names = "default"; 35 + pinctrl-0 = <&vibrator_pin>; 36 + };
+12 -1
Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
··· 1 1 FocalTech EDT-FT5x06 Polytouch driver 2 2 ===================================== 3 3 4 - There are 3 variants of the chip for various touch panel sizes 4 + There are 5 variants of the chip for various touch panel sizes 5 5 FT5206GE1 2.8" .. 3.8" 6 6 FT5306DE4 4.3" .. 7" 7 7 FT5406EE8 7" .. 8.9" 8 8 FT5506EEG 7" .. 8.9" 9 + FT5726NEI 5.7” .. 11.6" 9 10 10 11 The software interface is identical for all those chips, so that 11 12 currently there is no need for the driver to distinguish between the ··· 20 19 or: "edt,edt-ft5306" 21 20 or: "edt,edt-ft5406" 22 21 or: "edt,edt-ft5506" 22 + or: "evervision,ev-ft5726" 23 23 or: "focaltech,ft6236" 24 24 25 25 - reg: I2C slave address of the chip (0x38) ··· 44 42 45 43 - offset: allows setting the edge compensation in the range from 46 44 0 to 31. 45 + 46 + - offset-x: Same as offset, but applies only to the horizontal position. 47 + Range from 0 to 80, only supported by evervision,ev-ft5726 48 + devices. 49 + 50 + - offset-y: Same as offset, but applies only to the vertical position. 51 + Range from 0 to 80, only supported by evervision,ev-ft5726 52 + devices. 53 + 47 54 - touchscreen-size-x : See touchscreen.txt 48 55 - touchscreen-size-y : See touchscreen.txt 49 56 - touchscreen-fuzz-x : See touchscreen.txt
+8 -4
Documentation/devicetree/bindings/input/touchscreen/goodix.txt
··· 3 3 Required properties: 4 4 5 5 - compatible : Should be "goodix,gt1151" 6 + or "goodix,gt5688" 6 7 or "goodix,gt911" 7 8 or "goodix,gt9110" 8 9 or "goodix,gt912" ··· 19 18 - irq-gpios : GPIO pin used for IRQ. The driver uses the 20 19 interrupt gpio pin as output to reset the device. 21 20 - reset-gpios : GPIO pin used for reset 21 + - touchscreen-inverted-x 22 + - touchscreen-inverted-y 23 + - touchscreen-size-x 24 + - touchscreen-size-y 25 + - touchscreen-swapped-x-y 22 26 23 - - touchscreen-inverted-x : X axis is inverted (boolean) 24 - - touchscreen-inverted-y : Y axis is inverted (boolean) 25 - - touchscreen-swapped-x-y : X and Y axis are swapped (boolean) 26 - (swapping is done after inverting the axis) 27 + The touchscreen-* properties are documented in touchscreen.txt in this 28 + directory. 27 29 28 30 Example: 29 31
+6 -2
Documentation/devicetree/bindings/input/touchscreen/sitronix-st1232.txt
··· 1 - * Sitronix st1232 touchscreen controller 1 + * Sitronix st1232 or st1633 touchscreen controller 2 2 3 3 Required properties: 4 - - compatible: must be "sitronix,st1232" 4 + - compatible: must contain one of 5 + * "sitronix,st1232" 6 + * "sitronix,st1633" 5 7 - reg: I2C address of the chip 6 8 - interrupts: interrupt to which the chip is connected 7 9 8 10 Optional properties: 9 11 - gpios: a phandle to the reset GPIO 12 + 13 + For additional optional properties see: touchscreen.txt 10 14 11 15 Example: 12 16
+9 -1
Documentation/devicetree/bindings/input/touchscreen/sx8654.txt
··· 1 1 * Semtech SX8654 I2C Touchscreen Controller 2 2 3 3 Required properties: 4 - - compatible: must be "semtech,sx8654" 4 + - compatible: must be one of the following, depending on the model: 5 + "semtech,sx8650" 6 + "semtech,sx8654" 7 + "semtech,sx8655" 8 + "semtech,sx8656" 5 9 - reg: i2c slave address 6 10 - interrupts: touch controller interrupt 11 + 12 + Optional properties: 13 + - reset-gpios: GPIO specification for the NRST input 7 14 8 15 Example: 9 16 ··· 19 12 reg = <0x48>; 20 13 interrupt-parent = <&gpio6>; 21 14 interrupts = <3 IRQ_TYPE_EDGE_FALLING>; 15 + reset-gpios = <&gpio4 2 GPIO_ACTIVE_LOW>; 22 16 };
+1 -1
drivers/input/joystick/db9.c
··· 259 259 db9_saturn_write_sub(port, type, 3, powered, 0); 260 260 return data[0] = 0xe3; 261 261 } 262 - /* else: fall through */ 262 + /* fall through */ 263 263 default: 264 264 return data[0]; 265 265 }
+10
drivers/input/keyboard/gpio_keys.c
··· 1015 1015 1016 1016 static SIMPLE_DEV_PM_OPS(gpio_keys_pm_ops, gpio_keys_suspend, gpio_keys_resume); 1017 1017 1018 + static void gpio_keys_shutdown(struct platform_device *pdev) 1019 + { 1020 + int ret; 1021 + 1022 + ret = gpio_keys_suspend(&pdev->dev); 1023 + if (ret) 1024 + dev_err(&pdev->dev, "failed to shutdown\n"); 1025 + } 1026 + 1018 1027 static struct platform_driver gpio_keys_device_driver = { 1019 1028 .probe = gpio_keys_probe, 1029 + .shutdown = gpio_keys_shutdown, 1020 1030 .driver = { 1021 1031 .name = "gpio-keys", 1022 1032 .pm = &gpio_keys_pm_ops,
+2 -3
drivers/input/keyboard/mcs_touchkey.c
··· 113 113 return -EINVAL; 114 114 } 115 115 116 - data = kzalloc(sizeof(struct mcs_touchkey_data) + 117 - sizeof(data->keycodes[0]) * (pdata->key_maxval + 1), 118 - GFP_KERNEL); 116 + data = kzalloc(struct_size(data, keycodes, pdata->key_maxval + 1), 117 + GFP_KERNEL); 119 118 input_dev = input_allocate_device(); 120 119 if (!data || !input_dev) { 121 120 dev_err(&client->dev, "Failed to allocate memory\n");
+6 -7
drivers/input/keyboard/mtk-pmic-keys.c
··· 14 14 * 15 15 */ 16 16 17 - #include <linux/module.h> 18 - #include <linux/kernel.h> 19 17 #include <linux/input.h> 20 18 #include <linux/interrupt.h> 21 - #include <linux/platform_device.h> 22 19 #include <linux/kernel.h> 23 - #include <linux/of.h> 24 - #include <linux/of_device.h> 25 - #include <linux/regmap.h> 26 20 #include <linux/mfd/mt6323/registers.h> 27 - #include <linux/mfd/mt6397/registers.h> 28 21 #include <linux/mfd/mt6397/core.h> 22 + #include <linux/mfd/mt6397/registers.h> 23 + #include <linux/module.h> 24 + #include <linux/of_device.h> 25 + #include <linux/of.h> 26 + #include <linux/platform_device.h> 27 + #include <linux/regmap.h> 29 28 30 29 #define MTK_PMIC_PWRKEY_RST_EN_MASK 0x1 31 30 #define MTK_PMIC_PWRKEY_RST_EN_SHIFT 6
-9
drivers/input/keyboard/qt2160.c
··· 68 68 struct i2c_client *client; 69 69 struct input_dev *input; 70 70 struct delayed_work dwork; 71 - spinlock_t lock; /* Protects canceling/rescheduling of dwork */ 72 71 unsigned short keycodes[ARRAY_SIZE(qt2160_key2code)]; 73 72 u16 key_matrix; 74 73 #ifdef CONFIG_LEDS_CLASS ··· 211 212 static irqreturn_t qt2160_irq(int irq, void *_qt2160) 212 213 { 213 214 struct qt2160_data *qt2160 = _qt2160; 214 - unsigned long flags; 215 - 216 - spin_lock_irqsave(&qt2160->lock, flags); 217 215 218 216 mod_delayed_work(system_wq, &qt2160->dwork, 0); 219 - 220 - spin_unlock_irqrestore(&qt2160->lock, flags); 221 217 222 218 return IRQ_HANDLED; 223 219 } 224 220 225 221 static void qt2160_schedule_read(struct qt2160_data *qt2160) 226 222 { 227 - spin_lock_irq(&qt2160->lock); 228 223 schedule_delayed_work(&qt2160->dwork, QT2160_CYCLE_INTERVAL); 229 - spin_unlock_irq(&qt2160->lock); 230 224 } 231 225 232 226 static void qt2160_worker(struct work_struct *work) ··· 383 391 qt2160->client = client; 384 392 qt2160->input = input; 385 393 INIT_DELAYED_WORK(&qt2160->dwork, qt2160_worker); 386 - spin_lock_init(&qt2160->lock); 387 394 388 395 input->name = "AT42QT2160 Touch Sense Keyboard"; 389 396 input->id.bustype = BUS_I2C;
+1 -3
drivers/input/keyboard/tca6416-keypad.c
··· 219 219 return -EINVAL; 220 220 } 221 221 222 - chip = kzalloc(sizeof(struct tca6416_keypad_chip) + 223 - pdata->nbuttons * sizeof(struct tca6416_button), 224 - GFP_KERNEL); 222 + chip = kzalloc(struct_size(chip, buttons, pdata->nbuttons), GFP_KERNEL); 225 223 input = input_allocate_device(); 226 224 if (!chip || !input) { 227 225 error = -ENOMEM;
+101 -33
drivers/input/keyboard/tm2-touchkey.c
··· 22 22 #include <linux/leds.h> 23 23 #include <linux/module.h> 24 24 #include <linux/of.h> 25 + #include <linux/of_device.h> 25 26 #include <linux/pm.h> 26 27 #include <linux/regulator/consumer.h> 27 28 28 29 #define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey" 29 - #define TM2_TOUCHKEY_KEYCODE_REG 0x03 30 - #define TM2_TOUCHKEY_BASE_REG 0x00 30 + 31 + #define ARIES_TOUCHKEY_CMD_LED_ON 0x1 32 + #define ARIES_TOUCHKEY_CMD_LED_OFF 0x2 31 33 #define TM2_TOUCHKEY_CMD_LED_ON 0x10 32 34 #define TM2_TOUCHKEY_CMD_LED_OFF 0x20 33 35 #define TM2_TOUCHKEY_BIT_PRESS_EV BIT(3) ··· 37 35 #define TM2_TOUCHKEY_LED_VOLTAGE_MIN 2500000 38 36 #define TM2_TOUCHKEY_LED_VOLTAGE_MAX 3300000 39 37 40 - enum { 41 - TM2_TOUCHKEY_KEY_MENU = 0x1, 42 - TM2_TOUCHKEY_KEY_BACK, 38 + struct touchkey_variant { 39 + u8 keycode_reg; 40 + u8 base_reg; 41 + u8 cmd_led_on; 42 + u8 cmd_led_off; 43 + bool no_reg; 44 + bool fixed_regulator; 43 45 }; 44 46 45 47 struct tm2_touchkey_data { ··· 52 46 struct led_classdev led_dev; 53 47 struct regulator *vdd; 54 48 struct regulator_bulk_data regulators[2]; 49 + const struct touchkey_variant *variant; 50 + u32 keycodes[4]; 51 + int num_keycodes; 55 52 }; 56 53 57 - static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev, 54 + static const struct touchkey_variant tm2_touchkey_variant = { 55 + .keycode_reg = 0x03, 56 + .base_reg = 0x00, 57 + .cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON, 58 + .cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF, 59 + }; 60 + 61 + static const struct touchkey_variant midas_touchkey_variant = { 62 + .keycode_reg = 0x00, 63 + .base_reg = 0x00, 64 + .cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON, 65 + .cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF, 66 + }; 67 + 68 + static struct touchkey_variant aries_touchkey_variant = { 69 + .no_reg = true, 70 + .fixed_regulator = true, 71 + .cmd_led_on = ARIES_TOUCHKEY_CMD_LED_ON, 72 + .cmd_led_off = ARIES_TOUCHKEY_CMD_LED_OFF, 73 + }; 74 + 75 + static int tm2_touchkey_led_brightness_set(struct led_classdev *led_dev, 58 76 enum led_brightness brightness) 59 77 { 60 78 struct tm2_touchkey_data *touchkey = ··· 88 58 89 59 if (brightness == LED_OFF) { 90 60 volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN; 91 - data = TM2_TOUCHKEY_CMD_LED_OFF; 61 + data = touchkey->variant->cmd_led_off; 92 62 } else { 93 63 volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX; 94 - data = TM2_TOUCHKEY_CMD_LED_ON; 64 + data = touchkey->variant->cmd_led_on; 95 65 } 96 66 97 - regulator_set_voltage(touchkey->vdd, volt, volt); 98 - i2c_smbus_write_byte_data(touchkey->client, 99 - TM2_TOUCHKEY_BASE_REG, data); 67 + if (!touchkey->variant->fixed_regulator) 68 + regulator_set_voltage(touchkey->vdd, volt, volt); 69 + 70 + return touchkey->variant->no_reg ? 71 + i2c_smbus_write_byte(touchkey->client, data) : 72 + i2c_smbus_write_byte_data(touchkey->client, 73 + touchkey->variant->base_reg, data); 100 74 } 101 75 102 76 static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey) ··· 130 96 { 131 97 struct tm2_touchkey_data *touchkey = devid; 132 98 int data; 133 - int key; 99 + int index; 100 + int i; 134 101 135 - data = i2c_smbus_read_byte_data(touchkey->client, 136 - TM2_TOUCHKEY_KEYCODE_REG); 102 + if (touchkey->variant->no_reg) 103 + data = i2c_smbus_read_byte(touchkey->client); 104 + else 105 + data = i2c_smbus_read_byte_data(touchkey->client, 106 + touchkey->variant->keycode_reg); 137 107 if (data < 0) { 138 108 dev_err(&touchkey->client->dev, 139 109 "failed to read i2c data: %d\n", data); 140 110 goto out; 141 111 } 142 112 143 - switch (data & TM2_TOUCHKEY_BIT_KEYCODE) { 144 - case TM2_TOUCHKEY_KEY_MENU: 145 - key = KEY_PHONE; 146 - break; 147 - 148 - case TM2_TOUCHKEY_KEY_BACK: 149 - key = KEY_BACK; 150 - break; 151 - 152 - default: 113 + index = (data & TM2_TOUCHKEY_BIT_KEYCODE) - 1; 114 + if (index < 0 || index >= touchkey->num_keycodes) { 153 115 dev_warn(&touchkey->client->dev, 154 - "unhandled keycode, data %#02x\n", data); 116 + "invalid keycode index %d\n", index); 155 117 goto out; 156 118 } 157 119 158 120 if (data & TM2_TOUCHKEY_BIT_PRESS_EV) { 159 - input_report_key(touchkey->input_dev, KEY_PHONE, 0); 160 - input_report_key(touchkey->input_dev, KEY_BACK, 0); 121 + for (i = 0; i < touchkey->num_keycodes; i++) 122 + input_report_key(touchkey->input_dev, 123 + touchkey->keycodes[i], 0); 161 124 } else { 162 - input_report_key(touchkey->input_dev, key, 1); 125 + input_report_key(touchkey->input_dev, 126 + touchkey->keycodes[index], 1); 163 127 } 164 128 165 129 input_sync(touchkey->input_dev); 166 130 167 131 out: 132 + if (touchkey->variant->fixed_regulator && 133 + data & TM2_TOUCHKEY_BIT_PRESS_EV) { 134 + /* touch turns backlight on, so make sure we're in sync */ 135 + if (touchkey->led_dev.brightness == LED_OFF) 136 + tm2_touchkey_led_brightness_set(&touchkey->led_dev, 137 + LED_OFF); 138 + } 139 + 168 140 return IRQ_HANDLED; 169 141 } 170 142 171 143 static int tm2_touchkey_probe(struct i2c_client *client, 172 144 const struct i2c_device_id *id) 173 145 { 146 + struct device_node *np = client->dev.of_node; 174 147 struct tm2_touchkey_data *touchkey; 175 148 int error; 149 + int i; 176 150 177 151 if (!i2c_check_functionality(client->adapter, 178 152 I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA)) { ··· 195 153 touchkey->client = client; 196 154 i2c_set_clientdata(client, touchkey); 197 155 156 + touchkey->variant = of_device_get_match_data(&client->dev); 157 + 198 158 touchkey->regulators[0].supply = "vcc"; 199 159 touchkey->regulators[1].supply = "vdd"; 200 160 error = devm_regulator_bulk_get(&client->dev, ··· 209 165 210 166 /* Save VDD for easy access */ 211 167 touchkey->vdd = touchkey->regulators[1].consumer; 168 + 169 + touchkey->num_keycodes = of_property_read_variable_u32_array(np, 170 + "linux,keycodes", touchkey->keycodes, 0, 171 + ARRAY_SIZE(touchkey->keycodes)); 172 + if (touchkey->num_keycodes <= 0) { 173 + /* default keycodes */ 174 + touchkey->keycodes[0] = KEY_PHONE; 175 + touchkey->keycodes[1] = KEY_BACK; 176 + touchkey->num_keycodes = 2; 177 + } 212 178 213 179 error = tm2_touchkey_power_enable(touchkey); 214 180 if (error) { ··· 244 190 touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME; 245 191 touchkey->input_dev->id.bustype = BUS_I2C; 246 192 247 - input_set_capability(touchkey->input_dev, EV_KEY, KEY_PHONE); 248 - input_set_capability(touchkey->input_dev, EV_KEY, KEY_BACK); 193 + for (i = 0; i < touchkey->num_keycodes; i++) 194 + input_set_capability(touchkey->input_dev, EV_KEY, 195 + touchkey->keycodes[i]); 249 196 250 197 error = input_register_device(touchkey->input_dev); 251 198 if (error) { ··· 267 212 268 213 /* led device */ 269 214 touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME; 270 - touchkey->led_dev.brightness = LED_FULL; 215 + touchkey->led_dev.brightness = LED_ON; 271 216 touchkey->led_dev.max_brightness = LED_ON; 272 - touchkey->led_dev.brightness_set = tm2_touchkey_led_brightness_set; 217 + touchkey->led_dev.brightness_set_blocking = 218 + tm2_touchkey_led_brightness_set; 273 219 274 220 error = devm_led_classdev_register(&client->dev, &touchkey->led_dev); 275 221 if (error) { ··· 278 222 "failed to register touchkey led: %d\n", error); 279 223 return error; 280 224 } 225 + 226 + if (touchkey->variant->fixed_regulator) 227 + tm2_touchkey_led_brightness_set(&touchkey->led_dev, LED_ON); 281 228 282 229 return 0; 283 230 } ··· 321 262 MODULE_DEVICE_TABLE(i2c, tm2_touchkey_id_table); 322 263 323 264 static const struct of_device_id tm2_touchkey_of_match[] = { 324 - { .compatible = "cypress,tm2-touchkey", }, 265 + { 266 + .compatible = "cypress,tm2-touchkey", 267 + .data = &tm2_touchkey_variant, 268 + }, { 269 + .compatible = "cypress,midas-touchkey", 270 + .data = &midas_touchkey_variant, 271 + }, { 272 + .compatible = "cypress,aries-touchkey", 273 + .data = &aries_touchkey_variant, 274 + }, 325 275 { }, 326 276 }; 327 277 MODULE_DEVICE_TABLE(of, tm2_touchkey_of_match);
+10
drivers/input/misc/Kconfig
··· 117 117 To compile this driver as a module, choose M here: the 118 118 module will be called e3x0_button. 119 119 120 + config INPUT_MSM_VIBRATOR 121 + tristate "Qualcomm MSM vibrator driver" 122 + select INPUT_FF_MEMLESS 123 + help 124 + Support for the vibrator that is found on various Qualcomm MSM 125 + SOCs. 126 + 127 + To compile this driver as a module, choose M here: the module 128 + will be called msm_vibrator. 129 + 120 130 config INPUT_PCSPKR 121 131 tristate "PC Speaker support" 122 132 depends on PCSPKR_PLATFORM
+1
drivers/input/misc/Makefile
··· 48 48 obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o 49 49 obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o 50 50 obj-$(CONFIG_INPUT_MMA8450) += mma8450.o 51 + obj-$(CONFIG_INPUT_MSM_VIBRATOR) += msm-vibrator.o 51 52 obj-$(CONFIG_INPUT_PALMAS_PWRBUTTON) += palmas-pwrbutton.o 52 53 obj-$(CONFIG_INPUT_PCAP) += pcap_keys.o 53 54 obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o
+8 -19
drivers/input/misc/ims-pcu.c
··· 39 39 40 40 struct ims_pcu_backlight { 41 41 struct led_classdev cdev; 42 - struct work_struct work; 43 - enum led_brightness desired_brightness; 44 42 char name[32]; 45 43 }; 46 44 ··· 947 949 948 950 #define IMS_PCU_MAX_BRIGHTNESS 31998 949 951 950 - static void ims_pcu_backlight_work(struct work_struct *work) 952 + static int ims_pcu_backlight_set_brightness(struct led_classdev *cdev, 953 + enum led_brightness value) 951 954 { 952 955 struct ims_pcu_backlight *backlight = 953 - container_of(work, struct ims_pcu_backlight, work); 956 + container_of(cdev, struct ims_pcu_backlight, cdev); 954 957 struct ims_pcu *pcu = 955 958 container_of(backlight, struct ims_pcu, backlight); 956 - int desired_brightness = backlight->desired_brightness; 957 - __le16 br_val = cpu_to_le16(desired_brightness); 959 + __le16 br_val = cpu_to_le16(value); 958 960 int error; 959 961 960 962 mutex_lock(&pcu->cmd_mutex); ··· 964 966 if (error && error != -ENODEV) 965 967 dev_warn(pcu->dev, 966 968 "Failed to set desired brightness %u, error: %d\n", 967 - desired_brightness, error); 969 + value, error); 968 970 969 971 mutex_unlock(&pcu->cmd_mutex); 970 - } 971 972 972 - static void ims_pcu_backlight_set_brightness(struct led_classdev *cdev, 973 - enum led_brightness value) 974 - { 975 - struct ims_pcu_backlight *backlight = 976 - container_of(cdev, struct ims_pcu_backlight, cdev); 977 - 978 - backlight->desired_brightness = value; 979 - schedule_work(&backlight->work); 973 + return error; 980 974 } 981 975 982 976 static enum led_brightness ··· 1005 1015 struct ims_pcu_backlight *backlight = &pcu->backlight; 1006 1016 int error; 1007 1017 1008 - INIT_WORK(&backlight->work, ims_pcu_backlight_work); 1009 1018 snprintf(backlight->name, sizeof(backlight->name), 1010 1019 "pcu%d::kbd_backlight", pcu->device_no); 1011 1020 1012 1021 backlight->cdev.name = backlight->name; 1013 1022 backlight->cdev.max_brightness = IMS_PCU_MAX_BRIGHTNESS; 1014 1023 backlight->cdev.brightness_get = ims_pcu_backlight_get_brightness; 1015 - backlight->cdev.brightness_set = ims_pcu_backlight_set_brightness; 1024 + backlight->cdev.brightness_set_blocking = 1025 + ims_pcu_backlight_set_brightness; 1016 1026 1017 1027 error = led_classdev_register(pcu->dev, &backlight->cdev); 1018 1028 if (error) { ··· 1030 1040 struct ims_pcu_backlight *backlight = &pcu->backlight; 1031 1041 1032 1042 led_classdev_unregister(&backlight->cdev); 1033 - cancel_work_sync(&backlight->work); 1034 1043 } 1035 1044 1036 1045
+281
drivers/input/misc/msm-vibrator.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Qualcomm MSM vibrator driver 4 + * 5 + * Copyright (c) 2018 Brian Masney <masneyb@onstation.org> 6 + * 7 + * Based on qcom,pwm-vibrator.c from: 8 + * Copyright (c) 2018 Jonathan Marek <jonathan@marek.ca> 9 + * 10 + * Based on msm_pwm_vibrator.c from downstream Android sources: 11 + * Copyright (C) 2009-2014 LGE, Inc. 12 + */ 13 + 14 + #include <linux/clk.h> 15 + #include <linux/err.h> 16 + #include <linux/gpio/consumer.h> 17 + #include <linux/input.h> 18 + #include <linux/io.h> 19 + #include <linux/module.h> 20 + #include <linux/of.h> 21 + #include <linux/platform_device.h> 22 + #include <linux/regulator/consumer.h> 23 + 24 + #define REG_CMD_RCGR 0x00 25 + #define REG_CFG_RCGR 0x04 26 + #define REG_M 0x08 27 + #define REG_N 0x0C 28 + #define REG_D 0x10 29 + #define REG_CBCR 0x24 30 + #define MMSS_CC_M_DEFAULT 1 31 + 32 + struct msm_vibrator { 33 + struct input_dev *input; 34 + struct mutex mutex; 35 + struct work_struct worker; 36 + void __iomem *base; 37 + struct regulator *vcc; 38 + struct clk *clk; 39 + struct gpio_desc *enable_gpio; 40 + u16 magnitude; 41 + bool enabled; 42 + }; 43 + 44 + static void msm_vibrator_write(struct msm_vibrator *vibrator, int offset, 45 + u32 value) 46 + { 47 + writel(value, vibrator->base + offset); 48 + } 49 + 50 + static int msm_vibrator_start(struct msm_vibrator *vibrator) 51 + { 52 + int d_reg_val, ret = 0; 53 + 54 + mutex_lock(&vibrator->mutex); 55 + 56 + if (!vibrator->enabled) { 57 + ret = clk_set_rate(vibrator->clk, 24000); 58 + if (ret) { 59 + dev_err(&vibrator->input->dev, 60 + "Failed to set clock rate: %d\n", ret); 61 + goto unlock; 62 + } 63 + 64 + ret = clk_prepare_enable(vibrator->clk); 65 + if (ret) { 66 + dev_err(&vibrator->input->dev, 67 + "Failed to enable clock: %d\n", ret); 68 + goto unlock; 69 + } 70 + 71 + ret = regulator_enable(vibrator->vcc); 72 + if (ret) { 73 + dev_err(&vibrator->input->dev, 74 + "Failed to enable regulator: %d\n", ret); 75 + clk_disable(vibrator->clk); 76 + goto unlock; 77 + } 78 + 79 + gpiod_set_value_cansleep(vibrator->enable_gpio, 1); 80 + 81 + vibrator->enabled = true; 82 + } 83 + 84 + d_reg_val = 127 - ((126 * vibrator->magnitude) / 0xffff); 85 + msm_vibrator_write(vibrator, REG_CFG_RCGR, 86 + (2 << 12) | /* dual edge mode */ 87 + (0 << 8) | /* cxo */ 88 + (7 << 0)); 89 + msm_vibrator_write(vibrator, REG_M, 1); 90 + msm_vibrator_write(vibrator, REG_N, 128); 91 + msm_vibrator_write(vibrator, REG_D, d_reg_val); 92 + msm_vibrator_write(vibrator, REG_CMD_RCGR, 1); 93 + msm_vibrator_write(vibrator, REG_CBCR, 1); 94 + 95 + unlock: 96 + mutex_unlock(&vibrator->mutex); 97 + 98 + return ret; 99 + } 100 + 101 + static void msm_vibrator_stop(struct msm_vibrator *vibrator) 102 + { 103 + mutex_lock(&vibrator->mutex); 104 + 105 + if (vibrator->enabled) { 106 + gpiod_set_value_cansleep(vibrator->enable_gpio, 0); 107 + regulator_disable(vibrator->vcc); 108 + clk_disable(vibrator->clk); 109 + vibrator->enabled = false; 110 + } 111 + 112 + mutex_unlock(&vibrator->mutex); 113 + } 114 + 115 + static void msm_vibrator_worker(struct work_struct *work) 116 + { 117 + struct msm_vibrator *vibrator = container_of(work, 118 + struct msm_vibrator, 119 + worker); 120 + 121 + if (vibrator->magnitude) 122 + msm_vibrator_start(vibrator); 123 + else 124 + msm_vibrator_stop(vibrator); 125 + } 126 + 127 + static int msm_vibrator_play_effect(struct input_dev *dev, void *data, 128 + struct ff_effect *effect) 129 + { 130 + struct msm_vibrator *vibrator = input_get_drvdata(dev); 131 + 132 + mutex_lock(&vibrator->mutex); 133 + 134 + if (effect->u.rumble.strong_magnitude > 0) 135 + vibrator->magnitude = effect->u.rumble.strong_magnitude; 136 + else 137 + vibrator->magnitude = effect->u.rumble.weak_magnitude; 138 + 139 + mutex_unlock(&vibrator->mutex); 140 + 141 + schedule_work(&vibrator->worker); 142 + 143 + return 0; 144 + } 145 + 146 + static void msm_vibrator_close(struct input_dev *input) 147 + { 148 + struct msm_vibrator *vibrator = input_get_drvdata(input); 149 + 150 + cancel_work_sync(&vibrator->worker); 151 + msm_vibrator_stop(vibrator); 152 + } 153 + 154 + static int msm_vibrator_probe(struct platform_device *pdev) 155 + { 156 + struct msm_vibrator *vibrator; 157 + struct resource *res; 158 + int ret; 159 + 160 + vibrator = devm_kzalloc(&pdev->dev, sizeof(*vibrator), GFP_KERNEL); 161 + if (!vibrator) 162 + return -ENOMEM; 163 + 164 + vibrator->input = devm_input_allocate_device(&pdev->dev); 165 + if (!vibrator->input) 166 + return -ENOMEM; 167 + 168 + vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc"); 169 + if (IS_ERR(vibrator->vcc)) { 170 + if (PTR_ERR(vibrator->vcc) != -EPROBE_DEFER) 171 + dev_err(&pdev->dev, "Failed to get regulator: %ld\n", 172 + PTR_ERR(vibrator->vcc)); 173 + return PTR_ERR(vibrator->vcc); 174 + } 175 + 176 + vibrator->enable_gpio = devm_gpiod_get(&pdev->dev, "enable", 177 + GPIOD_OUT_LOW); 178 + if (IS_ERR(vibrator->enable_gpio)) { 179 + if (PTR_ERR(vibrator->enable_gpio) != -EPROBE_DEFER) 180 + dev_err(&pdev->dev, "Failed to get enable gpio: %ld\n", 181 + PTR_ERR(vibrator->enable_gpio)); 182 + return PTR_ERR(vibrator->enable_gpio); 183 + } 184 + 185 + vibrator->clk = devm_clk_get(&pdev->dev, "pwm"); 186 + if (IS_ERR(vibrator->clk)) { 187 + if (PTR_ERR(vibrator->clk) != -EPROBE_DEFER) 188 + dev_err(&pdev->dev, "Failed to lookup pwm clock: %ld\n", 189 + PTR_ERR(vibrator->clk)); 190 + return PTR_ERR(vibrator->clk); 191 + } 192 + 193 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 194 + if (!res) { 195 + dev_err(&pdev->dev, "Failed to get platform resource\n"); 196 + return -ENODEV; 197 + } 198 + 199 + vibrator->base = devm_ioremap(&pdev->dev, res->start, 200 + resource_size(res)); 201 + if (!vibrator->base) { 202 + dev_err(&pdev->dev, "Failed to iomap resource.\n"); 203 + return -ENOMEM; 204 + } 205 + 206 + vibrator->enabled = false; 207 + mutex_init(&vibrator->mutex); 208 + INIT_WORK(&vibrator->worker, msm_vibrator_worker); 209 + 210 + vibrator->input->name = "msm-vibrator"; 211 + vibrator->input->id.bustype = BUS_HOST; 212 + vibrator->input->close = msm_vibrator_close; 213 + 214 + input_set_drvdata(vibrator->input, vibrator); 215 + input_set_capability(vibrator->input, EV_FF, FF_RUMBLE); 216 + 217 + ret = input_ff_create_memless(vibrator->input, NULL, 218 + msm_vibrator_play_effect); 219 + if (ret) { 220 + dev_err(&pdev->dev, "Failed to create ff memless: %d", ret); 221 + return ret; 222 + } 223 + 224 + ret = input_register_device(vibrator->input); 225 + if (ret) { 226 + dev_err(&pdev->dev, "Failed to register input device: %d", ret); 227 + return ret; 228 + } 229 + 230 + platform_set_drvdata(pdev, vibrator); 231 + 232 + return 0; 233 + } 234 + 235 + static int __maybe_unused msm_vibrator_suspend(struct device *dev) 236 + { 237 + struct platform_device *pdev = to_platform_device(dev); 238 + struct msm_vibrator *vibrator = platform_get_drvdata(pdev); 239 + 240 + cancel_work_sync(&vibrator->worker); 241 + 242 + if (vibrator->enabled) 243 + msm_vibrator_stop(vibrator); 244 + 245 + return 0; 246 + } 247 + 248 + static int __maybe_unused msm_vibrator_resume(struct device *dev) 249 + { 250 + struct platform_device *pdev = to_platform_device(dev); 251 + struct msm_vibrator *vibrator = platform_get_drvdata(pdev); 252 + 253 + if (vibrator->enabled) 254 + msm_vibrator_start(vibrator); 255 + 256 + return 0; 257 + } 258 + 259 + static SIMPLE_DEV_PM_OPS(msm_vibrator_pm_ops, msm_vibrator_suspend, 260 + msm_vibrator_resume); 261 + 262 + static const struct of_device_id msm_vibrator_of_match[] = { 263 + { .compatible = "qcom,msm8226-vibrator" }, 264 + { .compatible = "qcom,msm8974-vibrator" }, 265 + {}, 266 + }; 267 + MODULE_DEVICE_TABLE(of, msm_vibrator_of_match); 268 + 269 + static struct platform_driver msm_vibrator_driver = { 270 + .probe = msm_vibrator_probe, 271 + .driver = { 272 + .name = "msm-vibrator", 273 + .pm = &msm_vibrator_pm_ops, 274 + .of_match_table = of_match_ptr(msm_vibrator_of_match), 275 + }, 276 + }; 277 + module_platform_driver(msm_vibrator_driver); 278 + 279 + MODULE_AUTHOR("Brian Masney <masneyb@onstation.org>"); 280 + MODULE_DESCRIPTION("Qualcomm MSM vibrator driver"); 281 + MODULE_LICENSE("GPL");
+5 -1
drivers/input/misc/soc_button_array.c
··· 185 185 info->name = "power"; 186 186 info->event_code = KEY_POWER; 187 187 info->wakeup = true; 188 + } else if (upage == 0x01 && usage == 0xca) { 189 + info->name = "rotation lock switch"; 190 + info->event_type = EV_SW; 191 + info->event_code = SW_ROTATE_LOCK; 188 192 } else if (upage == 0x07 && usage == 0xe3) { 189 193 info->name = "home"; 190 194 info->event_code = KEY_LEFTMETA; ··· 377 373 { "home", 1, EV_KEY, KEY_LEFTMETA, false, true }, 378 374 { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false }, 379 375 { "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false }, 380 - { "rotation_lock", 4, EV_SW, SW_ROTATE_LOCK, false, false }, 376 + { "rotation_lock", 4, EV_KEY, KEY_ROTATE_LOCK_TOGGLE, false, false }, 381 377 { } 382 378 }; 383 379
+1
drivers/input/mouse/elan_i2c_core.c
··· 1337 1337 { "ELAN0000", 0 }, 1338 1338 { "ELAN0100", 0 }, 1339 1339 { "ELAN0600", 0 }, 1340 + { "ELAN0601", 0 }, 1340 1341 { "ELAN0602", 0 }, 1341 1342 { "ELAN0605", 0 }, 1342 1343 { "ELAN0608", 0 },
+4 -18
drivers/input/mouse/synaptics_i2c.c
··· 219 219 struct i2c_client *client; 220 220 struct input_dev *input; 221 221 struct delayed_work dwork; 222 - spinlock_t lock; 223 222 int no_data_count; 224 223 int no_decel_param; 225 224 int reduce_report_param; ··· 368 369 return xy_delta || gesture; 369 370 } 370 371 371 - static void synaptics_i2c_reschedule_work(struct synaptics_i2c *touch, 372 - unsigned long delay) 373 - { 374 - unsigned long flags; 375 - 376 - spin_lock_irqsave(&touch->lock, flags); 377 - 378 - mod_delayed_work(system_wq, &touch->dwork, delay); 379 - 380 - spin_unlock_irqrestore(&touch->lock, flags); 381 - } 382 - 383 372 static irqreturn_t synaptics_i2c_irq(int irq, void *dev_id) 384 373 { 385 374 struct synaptics_i2c *touch = dev_id; 386 375 387 - synaptics_i2c_reschedule_work(touch, 0); 376 + mod_delayed_work(system_wq, &touch->dwork, 0); 388 377 389 378 return IRQ_HANDLED; 390 379 } ··· 448 461 * We poll the device once in THREAD_IRQ_SLEEP_SECS and 449 462 * if error is detected, we try to reset and reconfigure the touchpad. 450 463 */ 451 - synaptics_i2c_reschedule_work(touch, delay); 464 + mod_delayed_work(system_wq, &touch->dwork, delay); 452 465 } 453 466 454 467 static int synaptics_i2c_open(struct input_dev *input) ··· 461 474 return ret; 462 475 463 476 if (polling_req) 464 - synaptics_i2c_reschedule_work(touch, 477 + mod_delayed_work(system_wq, &touch->dwork, 465 478 msecs_to_jiffies(NO_DATA_SLEEP_MSECS)); 466 479 467 480 return 0; ··· 517 530 touch->scan_rate_param = scan_rate; 518 531 set_scan_rate(touch, scan_rate); 519 532 INIT_DELAYED_WORK(&touch->dwork, synaptics_i2c_work_handler); 520 - spin_lock_init(&touch->lock); 521 533 522 534 return touch; 523 535 } ··· 623 637 if (ret) 624 638 return ret; 625 639 626 - synaptics_i2c_reschedule_work(touch, 640 + mod_delayed_work(system_wq, &touch->dwork, 627 641 msecs_to_jiffies(NO_DATA_SLEEP_MSECS)); 628 642 629 643 return 0;
+10 -11
drivers/input/serio/i8042-sparcio.h
··· 53 53 54 54 static int sparc_i8042_probe(struct platform_device *op) 55 55 { 56 - struct device_node *dp = op->dev.of_node; 56 + struct device_node *dp; 57 57 58 - dp = dp->child; 59 - while (dp) { 60 - if (!strcmp(dp->name, OBP_PS2KBD_NAME1) || 61 - !strcmp(dp->name, OBP_PS2KBD_NAME2)) { 58 + for_each_child_of_node(op->dev.of_node, dp) { 59 + if (of_node_name_eq(dp, OBP_PS2KBD_NAME1) || 60 + of_node_name_eq(dp, OBP_PS2KBD_NAME2)) { 62 61 struct platform_device *kbd = of_find_device_by_node(dp); 63 62 unsigned int irq = kbd->archdata.irqs[0]; 64 63 if (irq == 0xffffffff) ··· 66 67 kbd_iobase = of_ioremap(&kbd->resource[0], 67 68 0, 8, "kbd"); 68 69 kbd_res = &kbd->resource[0]; 69 - } else if (!strcmp(dp->name, OBP_PS2MS_NAME1) || 70 - !strcmp(dp->name, OBP_PS2MS_NAME2)) { 70 + } else if (of_node_name_eq(dp, OBP_PS2MS_NAME1) || 71 + of_node_name_eq(dp, OBP_PS2MS_NAME2)) { 71 72 struct platform_device *ms = of_find_device_by_node(dp); 72 73 unsigned int irq = ms->archdata.irqs[0]; 73 74 if (irq == 0xffffffff) 74 75 irq = op->archdata.irqs[0]; 75 76 i8042_aux_irq = irq; 76 77 } 77 - 78 - dp = dp->sibling; 79 78 } 80 79 81 80 return 0; ··· 106 109 static int __init i8042_platform_init(void) 107 110 { 108 111 struct device_node *root = of_find_node_by_path("/"); 112 + const char *name = of_get_property(root, "name", NULL); 109 113 110 - if (!strcmp(root->name, "SUNW,JavaStation-1")) { 114 + if (name && !strcmp(name, "SUNW,JavaStation-1")) { 111 115 /* Hardcoded values for MrCoffee. */ 112 116 i8042_kbd_irq = i8042_aux_irq = 13 | 0x20; 113 117 kbd_iobase = ioremap(0x71300060, 8); ··· 137 139 static inline void i8042_platform_exit(void) 138 140 { 139 141 struct device_node *root = of_find_node_by_path("/"); 142 + const char *name = of_get_property(root, "name", NULL); 140 143 141 - if (strcmp(root->name, "SUNW,JavaStation-1")) 144 + if (!name || strcmp(name, "SUNW,JavaStation-1")) 142 145 platform_driver_unregister(&sparc_i8042_driver); 143 146 } 144 147
+2
drivers/input/tablet/wacom_serial4.c
··· 187 187 MODEL_DIGITIZER_II = 0x5544, /* UD */ 188 188 MODEL_GRAPHIRE = 0x4554, /* ET */ 189 189 MODEL_PENPARTNER = 0x4354, /* CT */ 190 + MODEL_ARTPAD_II = 0x4B54, /* KT */ 190 191 }; 191 192 192 193 static void wacom_handle_model_response(struct wacom *wacom) ··· 246 245 wacom->flags = F_HAS_STYLUS2 | F_HAS_SCROLLWHEEL; 247 246 break; 248 247 248 + case MODEL_ARTPAD_II: 249 249 case MODEL_DIGITIZER_II: 250 250 wacom->dev->name = "Wacom Digitizer II"; 251 251 wacom->dev->id.version = MODEL_DIGITIZER_II;
+4 -3
drivers/input/touchscreen/Kconfig
··· 699 699 config TOUCHSCREEN_RASPBERRYPI_FW 700 700 tristate "Raspberry Pi's firmware base touch screen support" 701 701 depends on RASPBERRYPI_FIRMWARE || (RASPBERRYPI_FIRMWARE=n && COMPILE_TEST) 702 + select INPUT_POLLDEV 702 703 help 703 704 Say Y here if you have the official Raspberry Pi 7 inch screen on 704 705 your system. ··· 1169 1168 module will be called sis_i2c. 1170 1169 1171 1170 config TOUCHSCREEN_ST1232 1172 - tristate "Sitronix ST1232 touchscreen controllers" 1171 + tristate "Sitronix ST1232 or ST1633 touchscreen controllers" 1173 1172 depends on I2C 1174 1173 help 1175 - Say Y here if you want to support Sitronix ST1232 1176 - touchscreen controller. 1174 + Say Y here if you want to support the Sitronix ST1232 1175 + or ST1633 touchscreen controller. 1177 1176 1178 1177 If unsure, say N. 1179 1178
+7 -4
drivers/input/touchscreen/ad7879.c
··· 246 246 static irqreturn_t ad7879_irq(int irq, void *handle) 247 247 { 248 248 struct ad7879 *ts = handle; 249 + int error; 249 250 250 - regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS, 251 - ts->conversion_data, AD7879_NR_SENSE); 252 - 253 - if (!ad7879_report(ts)) 251 + error = regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS, 252 + ts->conversion_data, AD7879_NR_SENSE); 253 + if (error) 254 + dev_err_ratelimited(ts->dev, "failed to read %#02x: %d\n", 255 + AD7879_REG_XPLUS, error); 256 + else if (!ad7879_report(ts)) 254 257 mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); 255 258 256 259 return IRQ_HANDLED;
+102 -8
drivers/input/touchscreen/edt-ft5x06.c
··· 31 31 #include <linux/interrupt.h> 32 32 #include <linux/input.h> 33 33 #include <linux/i2c.h> 34 + #include <linux/kernel.h> 34 35 #include <linux/uaccess.h> 35 36 #include <linux/delay.h> 36 37 #include <linux/debugfs.h> ··· 54 53 #define M09_REGISTER_NUM_X 0x94 55 54 #define M09_REGISTER_NUM_Y 0x95 56 55 56 + #define EV_REGISTER_THRESHOLD 0x40 57 + #define EV_REGISTER_GAIN 0x41 58 + #define EV_REGISTER_OFFSET_Y 0x45 59 + #define EV_REGISTER_OFFSET_X 0x46 60 + 57 61 #define NO_REGISTER 0xff 58 62 59 63 #define WORK_REGISTER_OPMODE 0x3c ··· 79 73 EDT_M06, 80 74 EDT_M09, 81 75 EDT_M12, 76 + EV_FT, 82 77 GENERIC_FT, 83 78 }; 84 79 ··· 88 81 int reg_report_rate; 89 82 int reg_gain; 90 83 int reg_offset; 84 + int reg_offset_x; 85 + int reg_offset_y; 91 86 int reg_num_x; 92 87 int reg_num_y; 93 88 }; ··· 115 106 int threshold; 116 107 int gain; 117 108 int offset; 109 + int offset_x; 110 + int offset_y; 118 111 int report_rate; 119 112 int max_support_points; 120 113 ··· 201 190 202 191 case EDT_M09: 203 192 case EDT_M12: 193 + case EV_FT: 204 194 case GENERIC_FT: 205 195 cmd = 0x0; 206 196 offset = 3; ··· 254 242 255 243 x = ((buf[0] << 8) | buf[1]) & 0x0fff; 256 244 y = ((buf[2] << 8) | buf[3]) & 0x0fff; 245 + /* The FT5x26 send the y coordinate first */ 246 + if (tsdata->version == EV_FT) 247 + swap(x, y); 248 + 257 249 id = (buf[2] >> 4) & 0x0f; 258 250 down = type != TOUCH_EVENT_UP; 259 251 ··· 291 275 wrbuf[3] = wrbuf[0] ^ wrbuf[1] ^ wrbuf[2]; 292 276 return edt_ft5x06_ts_readwrite(tsdata->client, 4, 293 277 wrbuf, 0, NULL); 278 + /* fallthrough */ 294 279 case EDT_M09: 295 280 case EDT_M12: 281 + case EV_FT: 296 282 case GENERIC_FT: 297 283 wrbuf[0] = addr; 298 284 wrbuf[1] = value; ··· 333 315 } 334 316 break; 335 317 318 + /* fallthrough */ 336 319 case EDT_M09: 337 320 case EDT_M12: 321 + case EV_FT: 338 322 case GENERIC_FT: 339 323 wrbuf[0] = addr; 340 324 error = edt_ft5x06_ts_readwrite(tsdata->client, 1, ··· 359 339 u8 limit_high; 360 340 u8 addr_m06; 361 341 u8 addr_m09; 342 + u8 addr_ev; 362 343 }; 363 344 364 - #define EDT_ATTR(_field, _mode, _addr_m06, _addr_m09, \ 345 + #define EDT_ATTR(_field, _mode, _addr_m06, _addr_m09, _addr_ev, \ 365 346 _limit_low, _limit_high) \ 366 347 struct edt_ft5x06_attribute edt_ft5x06_attr_##_field = { \ 367 348 .dattr = __ATTR(_field, _mode, \ ··· 371 350 .field_offset = offsetof(struct edt_ft5x06_ts_data, _field), \ 372 351 .addr_m06 = _addr_m06, \ 373 352 .addr_m09 = _addr_m09, \ 353 + .addr_ev = _addr_ev, \ 374 354 .limit_low = _limit_low, \ 375 355 .limit_high = _limit_high, \ 376 356 } ··· 406 384 case EDT_M12: 407 385 case GENERIC_FT: 408 386 addr = attr->addr_m09; 387 + break; 388 + 389 + case EV_FT: 390 + addr = attr->addr_ev; 409 391 break; 410 392 411 393 default: ··· 483 457 addr = attr->addr_m09; 484 458 break; 485 459 460 + case EV_FT: 461 + addr = attr->addr_ev; 462 + break; 463 + 486 464 default: 487 465 error = -ENODEV; 488 466 goto out; ··· 510 480 511 481 /* m06, m09: range 0-31, m12: range 0-5 */ 512 482 static EDT_ATTR(gain, S_IWUSR | S_IRUGO, WORK_REGISTER_GAIN, 513 - M09_REGISTER_GAIN, 0, 31); 483 + M09_REGISTER_GAIN, EV_REGISTER_GAIN, 0, 31); 514 484 /* m06, m09: range 0-31, m12: range 0-16 */ 515 485 static EDT_ATTR(offset, S_IWUSR | S_IRUGO, WORK_REGISTER_OFFSET, 516 - M09_REGISTER_OFFSET, 0, 31); 486 + M09_REGISTER_OFFSET, NO_REGISTER, 0, 31); 487 + /* m06, m09, m12: no supported, ev_ft: range 0-80 */ 488 + static EDT_ATTR(offset_x, S_IWUSR | S_IRUGO, NO_REGISTER, NO_REGISTER, 489 + EV_REGISTER_OFFSET_X, 0, 80); 490 + /* m06, m09, m12: no supported, ev_ft: range 0-80 */ 491 + static EDT_ATTR(offset_y, S_IWUSR | S_IRUGO, NO_REGISTER, NO_REGISTER, 492 + EV_REGISTER_OFFSET_Y, 0, 80); 517 493 /* m06: range 20 to 80, m09: range 0 to 30, m12: range 1 to 255... */ 518 494 static EDT_ATTR(threshold, S_IWUSR | S_IRUGO, WORK_REGISTER_THRESHOLD, 519 - M09_REGISTER_THRESHOLD, 0, 255); 495 + M09_REGISTER_THRESHOLD, EV_REGISTER_THRESHOLD, 0, 255); 520 496 /* m06: range 3 to 14, m12: (0x64: 100Hz) */ 521 497 static EDT_ATTR(report_rate, S_IWUSR | S_IRUGO, WORK_REGISTER_REPORT_RATE, 522 - NO_REGISTER, 0, 255); 498 + NO_REGISTER, NO_REGISTER, 0, 255); 523 499 524 500 static struct attribute *edt_ft5x06_attrs[] = { 525 501 &edt_ft5x06_attr_gain.dattr.attr, 526 502 &edt_ft5x06_attr_offset.dattr.attr, 503 + &edt_ft5x06_attr_offset_x.dattr.attr, 504 + &edt_ft5x06_attr_offset_y.dattr.attr, 527 505 &edt_ft5x06_attr_threshold.dattr.attr, 528 506 &edt_ft5x06_attr_report_rate.dattr.attr, 529 507 NULL ··· 643 605 tsdata->threshold); 644 606 edt_ft5x06_register_write(tsdata, reg_addr->reg_gain, 645 607 tsdata->gain); 646 - edt_ft5x06_register_write(tsdata, reg_addr->reg_offset, 647 - tsdata->offset); 608 + if (reg_addr->reg_offset != NO_REGISTER) 609 + edt_ft5x06_register_write(tsdata, reg_addr->reg_offset, 610 + tsdata->offset); 611 + if (reg_addr->reg_offset_x != NO_REGISTER) 612 + edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_x, 613 + tsdata->offset_x); 614 + if (reg_addr->reg_offset_y != NO_REGISTER) 615 + edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_y, 616 + tsdata->offset_y); 648 617 if (reg_addr->reg_report_rate != NO_REGISTER) 649 618 edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate, 650 619 tsdata->report_rate); ··· 912 867 case 0x5a: /* Solomon Goldentek Display */ 913 868 snprintf(model_name, EDT_NAME_LEN, "GKTW50SCED1R0"); 914 869 break; 870 + case 0x59: /* Evervision Display with FT5xx6 TS */ 871 + tsdata->version = EV_FT; 872 + error = edt_ft5x06_ts_readwrite(client, 1, "\x53", 873 + 1, rdbuf); 874 + if (error) 875 + return error; 876 + strlcpy(fw_version, rdbuf, 1); 877 + snprintf(model_name, EDT_NAME_LEN, 878 + "EVERVISION-FT5726NEi"); 879 + break; 915 880 default: 916 881 snprintf(model_name, EDT_NAME_LEN, 917 882 "generic ft5x06 (%02x)", ··· 957 902 edt_ft5x06_register_write(tsdata, reg_addr->reg_offset, val); 958 903 tsdata->offset = val; 959 904 } 905 + 906 + error = device_property_read_u32(dev, "offset-x", &val); 907 + if (!error) { 908 + edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_x, val); 909 + tsdata->offset_x = val; 910 + } 911 + 912 + error = device_property_read_u32(dev, "offset-y", &val); 913 + if (!error) { 914 + edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_y, val); 915 + tsdata->offset_y = val; 916 + } 960 917 } 961 918 962 919 static void ··· 979 912 tsdata->threshold = edt_ft5x06_register_read(tsdata, 980 913 reg_addr->reg_threshold); 981 914 tsdata->gain = edt_ft5x06_register_read(tsdata, reg_addr->reg_gain); 982 - tsdata->offset = edt_ft5x06_register_read(tsdata, reg_addr->reg_offset); 915 + if (reg_addr->reg_offset != NO_REGISTER) 916 + tsdata->offset = 917 + edt_ft5x06_register_read(tsdata, reg_addr->reg_offset); 918 + if (reg_addr->reg_offset_x != NO_REGISTER) 919 + tsdata->offset_x = edt_ft5x06_register_read(tsdata, 920 + reg_addr->reg_offset_x); 921 + if (reg_addr->reg_offset_y != NO_REGISTER) 922 + tsdata->offset_y = edt_ft5x06_register_read(tsdata, 923 + reg_addr->reg_offset_y); 983 924 if (reg_addr->reg_report_rate != NO_REGISTER) 984 925 tsdata->report_rate = edt_ft5x06_register_read(tsdata, 985 926 reg_addr->reg_report_rate); ··· 1015 940 reg_addr->reg_report_rate = WORK_REGISTER_REPORT_RATE; 1016 941 reg_addr->reg_gain = WORK_REGISTER_GAIN; 1017 942 reg_addr->reg_offset = WORK_REGISTER_OFFSET; 943 + reg_addr->reg_offset_x = NO_REGISTER; 944 + reg_addr->reg_offset_y = NO_REGISTER; 1018 945 reg_addr->reg_num_x = WORK_REGISTER_NUM_X; 1019 946 reg_addr->reg_num_y = WORK_REGISTER_NUM_Y; 1020 947 break; ··· 1027 950 reg_addr->reg_report_rate = NO_REGISTER; 1028 951 reg_addr->reg_gain = M09_REGISTER_GAIN; 1029 952 reg_addr->reg_offset = M09_REGISTER_OFFSET; 953 + reg_addr->reg_offset_x = NO_REGISTER; 954 + reg_addr->reg_offset_y = NO_REGISTER; 1030 955 reg_addr->reg_num_x = M09_REGISTER_NUM_X; 1031 956 reg_addr->reg_num_y = M09_REGISTER_NUM_Y; 957 + break; 958 + 959 + case EV_FT: 960 + reg_addr->reg_threshold = EV_REGISTER_THRESHOLD; 961 + reg_addr->reg_gain = EV_REGISTER_GAIN; 962 + reg_addr->reg_offset = NO_REGISTER; 963 + reg_addr->reg_offset_x = EV_REGISTER_OFFSET_X; 964 + reg_addr->reg_offset_y = EV_REGISTER_OFFSET_Y; 965 + reg_addr->reg_num_x = NO_REGISTER; 966 + reg_addr->reg_num_y = NO_REGISTER; 967 + reg_addr->reg_report_rate = NO_REGISTER; 1032 968 break; 1033 969 1034 970 case GENERIC_FT: ··· 1049 959 reg_addr->reg_threshold = M09_REGISTER_THRESHOLD; 1050 960 reg_addr->reg_gain = M09_REGISTER_GAIN; 1051 961 reg_addr->reg_offset = M09_REGISTER_OFFSET; 962 + reg_addr->reg_offset_x = NO_REGISTER; 963 + reg_addr->reg_offset_y = NO_REGISTER; 1052 964 break; 1053 965 } 1054 966 } ··· 1247 1155 static const struct i2c_device_id edt_ft5x06_ts_id[] = { 1248 1156 { .name = "edt-ft5x06", .driver_data = (long)&edt_ft5x06_data }, 1249 1157 { .name = "edt-ft5506", .driver_data = (long)&edt_ft5506_data }, 1158 + { .name = "ev-ft5726", .driver_data = (long)&edt_ft5506_data }, 1250 1159 /* Note no edt- prefix for compatibility with the ft6236.c driver */ 1251 1160 { .name = "ft6236", .driver_data = (long)&edt_ft6236_data }, 1252 1161 { /* sentinel */ } ··· 1260 1167 { .compatible = "edt,edt-ft5306", .data = &edt_ft5x06_data }, 1261 1168 { .compatible = "edt,edt-ft5406", .data = &edt_ft5x06_data }, 1262 1169 { .compatible = "edt,edt-ft5506", .data = &edt_ft5506_data }, 1170 + { .compatible = "evervision,ev-ft5726", .data = &edt_ft5506_data }, 1263 1171 /* Note focaltech vendor prefix for compatibility with ft6236.c */ 1264 1172 { .compatible = "focaltech,ft6236", .data = &edt_ft6236_data }, 1265 1173 { /* sentinel */ }
+5 -1
drivers/input/touchscreen/goodix.c
··· 216 216 { 217 217 switch (id) { 218 218 case 1151: 219 + case 5688: 219 220 return &gt1x_chip_data; 220 221 221 222 case 911: ··· 693 692 touchscreen_parse_properties(ts->input_dev, true, &ts->prop); 694 693 695 694 if (!ts->prop.max_x || !ts->prop.max_y || !ts->max_touch_num) { 696 - dev_err(&ts->client->dev, "Invalid config, using defaults\n"); 695 + dev_err(&ts->client->dev, 696 + "Invalid config (%d, %d, %d), using defaults\n", 697 + ts->prop.max_x, ts->prop.max_y, ts->max_touch_num); 697 698 ts->prop.max_x = GOODIX_MAX_WIDTH - 1; 698 699 ts->prop.max_y = GOODIX_MAX_HEIGHT - 1; 699 700 ts->max_touch_num = GOODIX_MAX_CONTACTS; ··· 945 942 #ifdef CONFIG_OF 946 943 static const struct of_device_id goodix_of_match[] = { 947 944 { .compatible = "goodix,gt1151" }, 945 + { .compatible = "goodix,gt5688" }, 948 946 { .compatible = "goodix,gt911" }, 949 947 { .compatible = "goodix,gt9110" }, 950 948 { .compatible = "goodix,gt912" },
+196 -129
drivers/input/touchscreen/ili210x.c
··· 4 4 #include <linux/slab.h> 5 5 #include <linux/input.h> 6 6 #include <linux/input/mt.h> 7 + #include <linux/input/touchscreen.h> 7 8 #include <linux/delay.h> 8 9 #include <linux/workqueue.h> 9 - #include <linux/input/ili210x.h> 10 + #include <linux/gpio/consumer.h> 11 + #include <linux/of_device.h> 12 + #include <asm/unaligned.h> 10 13 11 - #define MAX_TOUCHES 2 14 + #define ILI210X_TOUCHES 2 15 + #define ILI251X_TOUCHES 10 12 16 #define DEFAULT_POLL_PERIOD 20 13 17 14 18 /* Touchscreen commands */ ··· 21 17 #define REG_FIRMWARE_VERSION 0x40 22 18 #define REG_CALIBRATE 0xcc 23 19 24 - struct finger { 25 - u8 x_low; 26 - u8 x_high; 27 - u8 y_low; 28 - u8 y_high; 29 - } __packed; 30 - 31 - struct touchdata { 32 - u8 status; 33 - struct finger finger[MAX_TOUCHES]; 34 - } __packed; 35 - 36 - struct panel_info { 37 - struct finger finger_max; 38 - u8 xchannel_num; 39 - u8 ychannel_num; 40 - } __packed; 41 - 42 20 struct firmware_version { 43 21 u8 id; 44 22 u8 major; 45 23 u8 minor; 46 24 } __packed; 47 25 26 + enum ili2xxx_model { 27 + MODEL_ILI210X, 28 + MODEL_ILI251X, 29 + }; 30 + 48 31 struct ili210x { 49 32 struct i2c_client *client; 50 33 struct input_dev *input; 51 - bool (*get_pendown_state)(void); 52 34 unsigned int poll_period; 53 35 struct delayed_work dwork; 36 + struct gpio_desc *reset_gpio; 37 + struct touchscreen_properties prop; 38 + enum ili2xxx_model model; 39 + unsigned int max_touches; 54 40 }; 55 41 56 42 static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf, 57 43 size_t len) 58 44 { 45 + struct ili210x *priv = i2c_get_clientdata(client); 59 46 struct i2c_msg msg[2] = { 60 47 { 61 48 .addr = client->addr, ··· 62 67 } 63 68 }; 64 69 65 - if (i2c_transfer(client->adapter, msg, 2) != 2) { 70 + if (priv->model == MODEL_ILI251X) { 71 + if (i2c_transfer(client->adapter, msg, 1) != 1) { 72 + dev_err(&client->dev, "i2c transfer failed\n"); 73 + return -EIO; 74 + } 75 + 76 + usleep_range(5000, 5500); 77 + 78 + if (i2c_transfer(client->adapter, msg + 1, 1) != 1) { 79 + dev_err(&client->dev, "i2c transfer failed\n"); 80 + return -EIO; 81 + } 82 + } else { 83 + if (i2c_transfer(client->adapter, msg, 2) != 2) { 84 + dev_err(&client->dev, "i2c transfer failed\n"); 85 + return -EIO; 86 + } 87 + } 88 + 89 + return 0; 90 + } 91 + 92 + static int ili210x_read(struct i2c_client *client, void *buf, size_t len) 93 + { 94 + struct i2c_msg msg = { 95 + .addr = client->addr, 96 + .flags = I2C_M_RD, 97 + .len = len, 98 + .buf = buf, 99 + }; 100 + 101 + if (i2c_transfer(client->adapter, &msg, 1) != 1) { 66 102 dev_err(&client->dev, "i2c transfer failed\n"); 67 103 return -EIO; 68 104 } ··· 101 75 return 0; 102 76 } 103 77 104 - static void ili210x_report_events(struct input_dev *input, 105 - const struct touchdata *touchdata) 78 + static bool ili210x_touchdata_to_coords(struct ili210x *priv, u8 *touchdata, 79 + unsigned int finger, 80 + unsigned int *x, unsigned int *y) 106 81 { 82 + if (finger >= ILI210X_TOUCHES) 83 + return false; 84 + 85 + if (touchdata[0] & BIT(finger)) 86 + return false; 87 + 88 + *x = get_unaligned_be16(touchdata + 1 + (finger * 4) + 0); 89 + *y = get_unaligned_be16(touchdata + 1 + (finger * 4) + 2); 90 + 91 + return true; 92 + } 93 + 94 + static bool ili251x_touchdata_to_coords(struct ili210x *priv, u8 *touchdata, 95 + unsigned int finger, 96 + unsigned int *x, unsigned int *y) 97 + { 98 + if (finger >= ILI251X_TOUCHES) 99 + return false; 100 + 101 + *x = get_unaligned_be16(touchdata + 1 + (finger * 5) + 0); 102 + if (!(*x & BIT(15))) /* Touch indication */ 103 + return false; 104 + 105 + *x &= 0x3fff; 106 + *y = get_unaligned_be16(touchdata + 1 + (finger * 5) + 2); 107 + 108 + return true; 109 + } 110 + 111 + static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata) 112 + { 113 + struct input_dev *input = priv->input; 107 114 int i; 108 - bool touch; 109 - unsigned int x, y; 110 - const struct finger *finger; 115 + bool contact = false, touch = false; 116 + unsigned int x = 0, y = 0; 111 117 112 - for (i = 0; i < MAX_TOUCHES; i++) { 113 - input_mt_slot(input, i); 114 - 115 - finger = &touchdata->finger[i]; 116 - 117 - touch = touchdata->status & (1 << i); 118 - input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); 119 - if (touch) { 120 - x = finger->x_low | (finger->x_high << 8); 121 - y = finger->y_low | (finger->y_high << 8); 122 - 123 - input_report_abs(input, ABS_MT_POSITION_X, x); 124 - input_report_abs(input, ABS_MT_POSITION_Y, y); 118 + for (i = 0; i < priv->max_touches; i++) { 119 + if (priv->model == MODEL_ILI210X) { 120 + touch = ili210x_touchdata_to_coords(priv, touchdata, 121 + i, &x, &y); 122 + } else if (priv->model == MODEL_ILI251X) { 123 + touch = ili251x_touchdata_to_coords(priv, touchdata, 124 + i, &x, &y); 125 + if (touch) 126 + contact = true; 125 127 } 128 + 129 + input_mt_slot(input, i); 130 + input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); 131 + if (!touch) 132 + continue; 133 + touchscreen_report_pos(input, &priv->prop, x, y, 134 + true); 126 135 } 127 136 128 137 input_mt_report_pointer_emulation(input, false); 129 138 input_sync(input); 130 - } 131 139 132 - static bool get_pendown_state(const struct ili210x *priv) 133 - { 134 - bool state = false; 140 + if (priv->model == MODEL_ILI210X) 141 + contact = touchdata[0] & 0xf3; 135 142 136 - if (priv->get_pendown_state) 137 - state = priv->get_pendown_state(); 138 - 139 - return state; 143 + return contact; 140 144 } 141 145 142 146 static void ili210x_work(struct work_struct *work) ··· 174 118 struct ili210x *priv = container_of(work, struct ili210x, 175 119 dwork.work); 176 120 struct i2c_client *client = priv->client; 177 - struct touchdata touchdata; 178 - int error; 121 + u8 touchdata[64] = { 0 }; 122 + bool touch; 123 + int error = -EINVAL; 179 124 180 - error = ili210x_read_reg(client, REG_TOUCHDATA, 181 - &touchdata, sizeof(touchdata)); 125 + if (priv->model == MODEL_ILI210X) { 126 + error = ili210x_read_reg(client, REG_TOUCHDATA, 127 + touchdata, sizeof(touchdata)); 128 + } else if (priv->model == MODEL_ILI251X) { 129 + error = ili210x_read_reg(client, REG_TOUCHDATA, 130 + touchdata, 31); 131 + if (!error && touchdata[0] == 2) 132 + error = ili210x_read(client, &touchdata[31], 20); 133 + } 134 + 182 135 if (error) { 183 136 dev_err(&client->dev, 184 137 "Unable to get touchdata, err = %d\n", error); 185 138 return; 186 139 } 187 140 188 - ili210x_report_events(priv->input, &touchdata); 141 + touch = ili210x_report_events(priv, touchdata); 189 142 190 - if ((touchdata.status & 0xf3) || get_pendown_state(priv)) 143 + if (touch) 191 144 schedule_delayed_work(&priv->dwork, 192 145 msecs_to_jiffies(priv->poll_period)); 193 146 } ··· 245 180 .attrs = ili210x_attributes, 246 181 }; 247 182 183 + static void ili210x_power_down(void *data) 184 + { 185 + struct gpio_desc *reset_gpio = data; 186 + 187 + gpiod_set_value_cansleep(reset_gpio, 1); 188 + } 189 + 190 + static void ili210x_cancel_work(void *data) 191 + { 192 + struct ili210x *priv = data; 193 + 194 + cancel_delayed_work_sync(&priv->dwork); 195 + } 196 + 248 197 static int ili210x_i2c_probe(struct i2c_client *client, 249 198 const struct i2c_device_id *id) 250 199 { 251 200 struct device *dev = &client->dev; 252 - const struct ili210x_platform_data *pdata = dev_get_platdata(dev); 253 201 struct ili210x *priv; 202 + struct gpio_desc *reset_gpio; 254 203 struct input_dev *input; 255 - struct panel_info panel; 256 204 struct firmware_version firmware; 257 - int xmax, ymax; 205 + enum ili2xxx_model model; 258 206 int error; 259 207 260 - dev_dbg(dev, "Probing for ILI210X I2C Touschreen driver"); 208 + model = (enum ili2xxx_model)id->driver_data; 261 209 262 - if (!pdata) { 263 - dev_err(dev, "No platform data!\n"); 264 - return -EINVAL; 265 - } 210 + dev_dbg(dev, "Probing for ILI210X I2C Touschreen driver"); 266 211 267 212 if (client->irq <= 0) { 268 213 dev_err(dev, "No IRQ!\n"); 269 214 return -EINVAL; 270 215 } 216 + 217 + reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 218 + if (IS_ERR(reset_gpio)) 219 + return PTR_ERR(reset_gpio); 220 + 221 + if (reset_gpio) { 222 + error = devm_add_action_or_reset(dev, ili210x_power_down, 223 + reset_gpio); 224 + if (error) 225 + return error; 226 + 227 + usleep_range(50, 100); 228 + gpiod_set_value_cansleep(reset_gpio, 0); 229 + msleep(100); 230 + } 231 + 232 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 233 + if (!priv) 234 + return -ENOMEM; 235 + 236 + input = devm_input_allocate_device(dev); 237 + if (!input) 238 + return -ENOMEM; 239 + 240 + priv->client = client; 241 + priv->input = input; 242 + priv->poll_period = DEFAULT_POLL_PERIOD; 243 + INIT_DELAYED_WORK(&priv->dwork, ili210x_work); 244 + priv->reset_gpio = reset_gpio; 245 + priv->model = model; 246 + if (model == MODEL_ILI210X) 247 + priv->max_touches = ILI210X_TOUCHES; 248 + if (model == MODEL_ILI251X) 249 + priv->max_touches = ILI251X_TOUCHES; 250 + 251 + i2c_set_clientdata(client, priv); 271 252 272 253 /* Get firmware version */ 273 254 error = ili210x_read_reg(client, REG_FIRMWARE_VERSION, ··· 324 213 return error; 325 214 } 326 215 327 - /* get panel info */ 328 - error = ili210x_read_reg(client, REG_PANEL_INFO, &panel, sizeof(panel)); 329 - if (error) { 330 - dev_err(dev, "Failed to get panel information, err: %d\n", 331 - error); 332 - return error; 333 - } 334 - 335 - xmax = panel.finger_max.x_low | (panel.finger_max.x_high << 8); 336 - ymax = panel.finger_max.y_low | (panel.finger_max.y_high << 8); 337 - 338 - priv = kzalloc(sizeof(*priv), GFP_KERNEL); 339 - input = input_allocate_device(); 340 - if (!priv || !input) { 341 - error = -ENOMEM; 342 - goto err_free_mem; 343 - } 344 - 345 - priv->client = client; 346 - priv->input = input; 347 - priv->get_pendown_state = pdata->get_pendown_state; 348 - priv->poll_period = pdata->poll_period ? : DEFAULT_POLL_PERIOD; 349 - INIT_DELAYED_WORK(&priv->dwork, ili210x_work); 350 - 351 216 /* Setup input device */ 352 217 input->name = "ILI210x Touchscreen"; 353 218 input->id.bustype = BUS_I2C; 354 219 input->dev.parent = dev; 355 220 356 - __set_bit(EV_SYN, input->evbit); 357 - __set_bit(EV_KEY, input->evbit); 358 - __set_bit(EV_ABS, input->evbit); 359 - __set_bit(BTN_TOUCH, input->keybit); 360 - 361 - /* Single touch */ 362 - input_set_abs_params(input, ABS_X, 0, xmax, 0, 0); 363 - input_set_abs_params(input, ABS_Y, 0, ymax, 0, 0); 364 - 365 221 /* Multi touch */ 366 - input_mt_init_slots(input, MAX_TOUCHES, 0); 367 - input_set_abs_params(input, ABS_MT_POSITION_X, 0, xmax, 0, 0); 368 - input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ymax, 0, 0); 222 + input_set_abs_params(input, ABS_MT_POSITION_X, 0, 0xffff, 0, 0); 223 + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 0xffff, 0, 0); 224 + touchscreen_parse_properties(input, true, &priv->prop); 225 + input_mt_init_slots(input, priv->max_touches, INPUT_MT_DIRECT); 369 226 370 - i2c_set_clientdata(client, priv); 227 + error = devm_add_action(dev, ili210x_cancel_work, priv); 228 + if (error) 229 + return error; 371 230 372 - error = request_irq(client->irq, ili210x_irq, pdata->irq_flags, 373 - client->name, priv); 231 + error = devm_request_irq(dev, client->irq, ili210x_irq, 0, 232 + client->name, priv); 374 233 if (error) { 375 234 dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n", 376 235 error); 377 - goto err_free_mem; 236 + return error; 378 237 } 379 238 380 - error = sysfs_create_group(&dev->kobj, &ili210x_attr_group); 239 + error = devm_device_add_group(dev, &ili210x_attr_group); 381 240 if (error) { 382 241 dev_err(dev, "Unable to create sysfs attributes, err: %d\n", 383 242 error); 384 - goto err_free_irq; 243 + return error; 385 244 } 386 245 387 246 error = input_register_device(priv->input); 388 247 if (error) { 389 248 dev_err(dev, "Cannot register input device, err: %d\n", error); 390 - goto err_remove_sysfs; 249 + return error; 391 250 } 392 251 393 252 device_init_wakeup(dev, 1); ··· 365 284 dev_dbg(dev, 366 285 "ILI210x initialized (IRQ: %d), firmware version %d.%d.%d", 367 286 client->irq, firmware.id, firmware.major, firmware.minor); 368 - 369 - return 0; 370 - 371 - err_remove_sysfs: 372 - sysfs_remove_group(&dev->kobj, &ili210x_attr_group); 373 - err_free_irq: 374 - free_irq(client->irq, priv); 375 - err_free_mem: 376 - input_free_device(input); 377 - kfree(priv); 378 - return error; 379 - } 380 - 381 - static int ili210x_i2c_remove(struct i2c_client *client) 382 - { 383 - struct ili210x *priv = i2c_get_clientdata(client); 384 - 385 - sysfs_remove_group(&client->dev.kobj, &ili210x_attr_group); 386 - free_irq(priv->client->irq, priv); 387 - cancel_delayed_work_sync(&priv->dwork); 388 - input_unregister_device(priv->input); 389 - kfree(priv); 390 287 391 288 return 0; 392 289 } ··· 393 334 ili210x_i2c_suspend, ili210x_i2c_resume); 394 335 395 336 static const struct i2c_device_id ili210x_i2c_id[] = { 396 - { "ili210x", 0 }, 337 + { "ili210x", MODEL_ILI210X }, 338 + { "ili251x", MODEL_ILI251X }, 397 339 { } 398 340 }; 399 341 MODULE_DEVICE_TABLE(i2c, ili210x_i2c_id); 342 + 343 + static const struct of_device_id ili210x_dt_ids[] = { 344 + { .compatible = "ilitek,ili210x", .data = (void *)MODEL_ILI210X }, 345 + { .compatible = "ilitek,ili251x", .data = (void *)MODEL_ILI251X }, 346 + { }, 347 + }; 348 + MODULE_DEVICE_TABLE(of, ili210x_dt_ids); 400 349 401 350 static struct i2c_driver ili210x_ts_driver = { 402 351 .driver = { 403 352 .name = "ili210x_i2c", 404 353 .pm = &ili210x_i2c_pm, 354 + .of_match_table = ili210x_dt_ids, 405 355 }, 406 356 .id_table = ili210x_i2c_id, 407 357 .probe = ili210x_i2c_probe, 408 - .remove = ili210x_i2c_remove, 409 358 }; 410 359 411 360 module_i2c_driver(ili210x_ts_driver);
+104 -50
drivers/input/touchscreen/st1232.c
··· 11 11 */ 12 12 13 13 #include <linux/delay.h> 14 - #include <linux/gpio.h> 14 + #include <linux/gpio/consumer.h> 15 15 #include <linux/i2c.h> 16 16 #include <linux/input.h> 17 17 #include <linux/interrupt.h> 18 18 #include <linux/module.h> 19 19 #include <linux/of.h> 20 - #include <linux/of_gpio.h> 21 20 #include <linux/pm_qos.h> 22 21 #include <linux/slab.h> 23 22 #include <linux/types.h> 23 + #include <linux/input/touchscreen.h> 24 24 25 25 #define ST1232_TS_NAME "st1232-ts" 26 - 27 - #define MIN_X 0x00 28 - #define MIN_Y 0x00 29 - #define MAX_X 0x31f /* (800 - 1) */ 30 - #define MAX_Y 0x1df /* (480 - 1) */ 31 - #define MAX_AREA 0xff 32 - #define MAX_FINGERS 2 26 + #define ST1633_TS_NAME "st1633-ts" 33 27 34 28 struct st1232_ts_finger { 35 29 u16 x; ··· 32 38 bool is_valid; 33 39 }; 34 40 41 + struct st_chip_info { 42 + bool have_z; 43 + u16 max_x; 44 + u16 max_y; 45 + u16 max_area; 46 + u16 max_fingers; 47 + u8 start_reg; 48 + }; 49 + 35 50 struct st1232_ts_data { 36 51 struct i2c_client *client; 37 52 struct input_dev *input_dev; 38 - struct st1232_ts_finger finger[MAX_FINGERS]; 53 + struct touchscreen_properties prop; 39 54 struct dev_pm_qos_request low_latency_req; 40 - int reset_gpio; 55 + struct gpio_desc *reset_gpio; 56 + const struct st_chip_info *chip_info; 57 + int read_buf_len; 58 + u8 *read_buf; 59 + struct st1232_ts_finger *finger; 41 60 }; 42 61 43 62 static int st1232_ts_read_data(struct st1232_ts_data *ts) ··· 59 52 struct i2c_client *client = ts->client; 60 53 struct i2c_msg msg[2]; 61 54 int error; 62 - u8 start_reg; 63 - u8 buf[10]; 55 + int i, y; 56 + u8 start_reg = ts->chip_info->start_reg; 57 + u8 *buf = ts->read_buf; 64 58 65 - /* read touchscreen data from ST1232 */ 59 + /* read touchscreen data */ 66 60 msg[0].addr = client->addr; 67 61 msg[0].flags = 0; 68 62 msg[0].len = 1; 69 63 msg[0].buf = &start_reg; 70 - start_reg = 0x10; 71 64 72 65 msg[1].addr = ts->client->addr; 73 66 msg[1].flags = I2C_M_RD; 74 - msg[1].len = sizeof(buf); 67 + msg[1].len = ts->read_buf_len; 75 68 msg[1].buf = buf; 76 69 77 70 error = i2c_transfer(client->adapter, msg, 2); 78 71 if (error < 0) 79 72 return error; 80 73 81 - /* get "valid" bits */ 82 - finger[0].is_valid = buf[2] >> 7; 83 - finger[1].is_valid = buf[5] >> 7; 74 + for (i = 0, y = 0; i < ts->chip_info->max_fingers; i++, y += 3) { 75 + finger[i].is_valid = buf[i + y] >> 7; 76 + if (finger[i].is_valid) { 77 + finger[i].x = ((buf[i + y] & 0x0070) << 4) | buf[i + 1]; 78 + finger[i].y = ((buf[i + y] & 0x0007) << 8) | buf[i + 2]; 84 79 85 - /* get xy coordinate */ 86 - if (finger[0].is_valid) { 87 - finger[0].x = ((buf[2] & 0x0070) << 4) | buf[3]; 88 - finger[0].y = ((buf[2] & 0x0007) << 8) | buf[4]; 89 - finger[0].t = buf[8]; 90 - } 91 - 92 - if (finger[1].is_valid) { 93 - finger[1].x = ((buf[5] & 0x0070) << 4) | buf[6]; 94 - finger[1].y = ((buf[5] & 0x0007) << 8) | buf[7]; 95 - finger[1].t = buf[9]; 80 + /* st1232 includes a z-axis / touch strength */ 81 + if (ts->chip_info->have_z) 82 + finger[i].t = buf[i + 6]; 83 + } 96 84 } 97 85 98 86 return 0; ··· 106 104 goto end; 107 105 108 106 /* multi touch protocol */ 109 - for (i = 0; i < MAX_FINGERS; i++) { 107 + for (i = 0; i < ts->chip_info->max_fingers; i++) { 110 108 if (!finger[i].is_valid) 111 109 continue; 112 110 113 - input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, finger[i].t); 114 - input_report_abs(input_dev, ABS_MT_POSITION_X, finger[i].x); 115 - input_report_abs(input_dev, ABS_MT_POSITION_Y, finger[i].y); 111 + if (ts->chip_info->have_z) 112 + input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, 113 + finger[i].t); 114 + 115 + touchscreen_report_pos(input_dev, &ts->prop, 116 + finger[i].x, finger[i].y, true); 116 117 input_mt_sync(input_dev); 117 118 count++; 118 119 } ··· 143 138 144 139 static void st1232_ts_power(struct st1232_ts_data *ts, bool poweron) 145 140 { 146 - if (gpio_is_valid(ts->reset_gpio)) 147 - gpio_direction_output(ts->reset_gpio, poweron); 141 + if (ts->reset_gpio) 142 + gpiod_set_value_cansleep(ts->reset_gpio, !poweron); 148 143 } 144 + 145 + static const struct st_chip_info st1232_chip_info = { 146 + .have_z = true, 147 + .max_x = 0x31f, /* 800 - 1 */ 148 + .max_y = 0x1df, /* 480 -1 */ 149 + .max_area = 0xff, 150 + .max_fingers = 2, 151 + .start_reg = 0x12, 152 + }; 153 + 154 + static const struct st_chip_info st1633_chip_info = { 155 + .have_z = false, 156 + .max_x = 0x13f, /* 320 - 1 */ 157 + .max_y = 0x1df, /* 480 -1 */ 158 + .max_area = 0x00, 159 + .max_fingers = 5, 160 + .start_reg = 0x12, 161 + }; 149 162 150 163 static int st1232_ts_probe(struct i2c_client *client, 151 164 const struct i2c_device_id *id) 152 165 { 166 + const struct st_chip_info *match; 153 167 struct st1232_ts_data *ts; 168 + struct st1232_ts_finger *finger; 154 169 struct input_dev *input_dev; 155 170 int error; 171 + 172 + match = device_get_match_data(&client->dev); 173 + if (!match && id) 174 + match = (const void *)id->driver_data; 175 + if (!match) { 176 + dev_err(&client->dev, "unknown device model\n"); 177 + return -ENODEV; 178 + } 156 179 157 180 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 158 181 dev_err(&client->dev, "need I2C_FUNC_I2C\n"); ··· 196 163 if (!ts) 197 164 return -ENOMEM; 198 165 166 + ts->chip_info = match; 167 + ts->finger = devm_kcalloc(&client->dev, 168 + ts->chip_info->max_fingers, sizeof(*finger), 169 + GFP_KERNEL); 170 + if (!ts->finger) 171 + return -ENOMEM; 172 + 173 + /* allocate a buffer according to the number of registers to read */ 174 + ts->read_buf_len = ts->chip_info->max_fingers * 4; 175 + ts->read_buf = devm_kzalloc(&client->dev, ts->read_buf_len, GFP_KERNEL); 176 + if (!ts->read_buf) 177 + return -ENOMEM; 178 + 199 179 input_dev = devm_input_allocate_device(&client->dev); 200 180 if (!input_dev) 201 181 return -ENOMEM; ··· 216 170 ts->client = client; 217 171 ts->input_dev = input_dev; 218 172 219 - ts->reset_gpio = of_get_gpio(client->dev.of_node, 0); 220 - if (gpio_is_valid(ts->reset_gpio)) { 221 - error = devm_gpio_request(&client->dev, ts->reset_gpio, NULL); 222 - if (error) { 223 - dev_err(&client->dev, 224 - "Unable to request GPIO pin %d.\n", 225 - ts->reset_gpio); 226 - return error; 227 - } 173 + ts->reset_gpio = devm_gpiod_get_optional(&client->dev, NULL, 174 + GPIOD_OUT_HIGH); 175 + if (IS_ERR(ts->reset_gpio)) { 176 + error = PTR_ERR(ts->reset_gpio); 177 + dev_err(&client->dev, "Unable to request GPIO pin: %d.\n", 178 + error); 179 + return error; 228 180 } 229 181 230 182 st1232_ts_power(ts, true); ··· 236 192 __set_bit(EV_KEY, input_dev->evbit); 237 193 __set_bit(EV_ABS, input_dev->evbit); 238 194 239 - input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, MAX_AREA, 0, 0); 240 - input_set_abs_params(input_dev, ABS_MT_POSITION_X, MIN_X, MAX_X, 0, 0); 241 - input_set_abs_params(input_dev, ABS_MT_POSITION_Y, MIN_Y, MAX_Y, 0, 0); 195 + if (ts->chip_info->have_z) 196 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 197 + ts->chip_info->max_area, 0, 0); 198 + 199 + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 200 + 0, ts->chip_info->max_x, 0, 0); 201 + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 202 + 0, ts->chip_info->max_y, 0, 0); 203 + 204 + touchscreen_parse_properties(input_dev, true, &ts->prop); 242 205 243 206 error = devm_request_threaded_irq(&client->dev, client->irq, 244 207 NULL, st1232_ts_irq_handler, ··· 312 261 st1232_ts_suspend, st1232_ts_resume); 313 262 314 263 static const struct i2c_device_id st1232_ts_id[] = { 315 - { ST1232_TS_NAME, 0 }, 264 + { ST1232_TS_NAME, (unsigned long)&st1232_chip_info }, 265 + { ST1633_TS_NAME, (unsigned long)&st1633_chip_info }, 316 266 { } 317 267 }; 318 268 MODULE_DEVICE_TABLE(i2c, st1232_ts_id); 319 269 320 270 static const struct of_device_id st1232_ts_dt_ids[] = { 321 - { .compatible = "sitronix,st1232", }, 271 + { .compatible = "sitronix,st1232", .data = &st1232_chip_info }, 272 + { .compatible = "sitronix,st1633", .data = &st1633_chip_info }, 322 273 { } 323 274 }; 324 275 MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids); ··· 339 286 module_i2c_driver(st1232_ts_driver); 340 287 341 288 MODULE_AUTHOR("Tony SIM <chinyeow.sim.xt@renesas.com>"); 289 + MODULE_AUTHOR("Martin Kepplinger <martin.kepplinger@ginzinger.com>"); 342 290 MODULE_DESCRIPTION("SITRONIX ST1232 Touchscreen Controller Driver"); 343 291 MODULE_LICENSE("GPL v2");
+16 -14
drivers/input/touchscreen/stmfts.c
··· 106 106 bool running; 107 107 }; 108 108 109 - static void stmfts_brightness_set(struct led_classdev *led_cdev, 109 + static int stmfts_brightness_set(struct led_classdev *led_cdev, 110 110 enum led_brightness value) 111 111 { 112 112 struct stmfts_data *sdata = container_of(led_cdev, 113 113 struct stmfts_data, led_cdev); 114 114 int err; 115 115 116 - if (value == sdata->led_status || !sdata->ledvdd) 117 - return; 118 - 119 - if (!value) { 120 - regulator_disable(sdata->ledvdd); 121 - } else { 122 - err = regulator_enable(sdata->ledvdd); 123 - if (err) 124 - dev_warn(&sdata->client->dev, 125 - "failed to disable ledvdd regulator: %d\n", 126 - err); 116 + if (value != sdata->led_status && sdata->ledvdd) { 117 + if (!value) { 118 + regulator_disable(sdata->ledvdd); 119 + } else { 120 + err = regulator_enable(sdata->ledvdd); 121 + if (err) { 122 + dev_warn(&sdata->client->dev, 123 + "failed to disable ledvdd regulator: %d\n", 124 + err); 125 + return err; 126 + } 127 + } 128 + sdata->led_status = value; 127 129 } 128 130 129 - sdata->led_status = value; 131 + return 0; 130 132 } 131 133 132 134 static enum led_brightness stmfts_brightness_get(struct led_classdev *led_cdev) ··· 610 608 sdata->led_cdev.name = STMFTS_DEV_NAME; 611 609 sdata->led_cdev.max_brightness = LED_ON; 612 610 sdata->led_cdev.brightness = LED_OFF; 613 - sdata->led_cdev.brightness_set = stmfts_brightness_set; 611 + sdata->led_cdev.brightness_set_blocking = stmfts_brightness_set; 614 612 sdata->led_cdev.brightness_get = stmfts_brightness_get; 615 613 616 614 err = devm_led_classdev_register(&sdata->client->dev, &sdata->led_cdev);
+226 -29
drivers/input/touchscreen/sx8654.c
··· 27 27 * published by the Free Software Foundation. 28 28 */ 29 29 30 - #include <linux/input.h> 31 - #include <linux/module.h> 32 - #include <linux/of.h> 30 + #include <linux/bitops.h> 31 + #include <linux/delay.h> 32 + #include <linux/gpio/consumer.h> 33 33 #include <linux/i2c.h> 34 + #include <linux/input.h> 35 + #include <linux/input/touchscreen.h> 34 36 #include <linux/interrupt.h> 35 37 #include <linux/irq.h> 38 + #include <linux/module.h> 39 + #include <linux/of.h> 36 40 37 41 /* register addresses */ 38 42 #define I2C_REG_TOUCH0 0x00 ··· 46 42 #define I2C_REG_IRQSRC 0x23 47 43 #define I2C_REG_SOFTRESET 0x3f 48 44 45 + #define I2C_REG_SX8650_STAT 0x05 46 + #define SX8650_STAT_CONVIRQ BIT(7) 47 + 49 48 /* commands */ 50 49 #define CMD_READ_REGISTER 0x40 51 - #define CMD_MANUAL 0xc0 52 50 #define CMD_PENTRG 0xe0 53 51 54 52 /* value for I2C_REG_SOFTRESET */ 55 53 #define SOFTRESET_VALUE 0xde 56 54 57 55 /* bits for I2C_REG_IRQSRC */ 58 - #define IRQ_PENTOUCH_TOUCHCONVDONE 0x08 59 - #define IRQ_PENRELEASE 0x04 56 + #define IRQ_PENTOUCH_TOUCHCONVDONE BIT(3) 57 + #define IRQ_PENRELEASE BIT(2) 60 58 61 59 /* bits for RegTouch1 */ 62 60 #define CONDIRQ 0x20 61 + #define RPDNT_100K 0x00 63 62 #define FILT_7SA 0x03 64 63 65 64 /* bits for I2C_REG_CHANMASK */ 66 - #define CONV_X 0x80 67 - #define CONV_Y 0x40 65 + #define CONV_X BIT(7) 66 + #define CONV_Y BIT(6) 68 67 69 68 /* coordinates rate: higher nibble of CTRL0 register */ 70 69 #define RATE_MANUAL 0x00 ··· 76 69 /* power delay: lower nibble of CTRL0 register */ 77 70 #define POWDLY_1_1MS 0x0b 78 71 72 + /* for sx8650, as we have no pen release IRQ there: timeout in ns following the 73 + * last PENIRQ after which we assume the pen is lifted. 74 + */ 75 + #define SX8650_PENIRQ_TIMEOUT msecs_to_jiffies(10) 76 + 79 77 #define MAX_12BIT ((1 << 12) - 1) 78 + #define MAX_I2C_READ_LEN 10 /* see datasheet section 5.1.5 */ 79 + 80 + /* channel definition */ 81 + #define CH_X 0x00 82 + #define CH_Y 0x01 83 + 84 + struct sx865x_data { 85 + u8 cmd_manual; 86 + u8 chan_mask; 87 + bool has_irq_penrelease; 88 + bool has_reg_irqmask; 89 + irq_handler_t irqh; 90 + }; 80 91 81 92 struct sx8654 { 82 93 struct input_dev *input; 83 94 struct i2c_client *client; 95 + struct gpio_desc *gpio_reset; 96 + 97 + spinlock_t lock; /* for input reporting from irq/timer */ 98 + struct timer_list timer; 99 + 100 + struct touchscreen_properties props; 101 + 102 + const struct sx865x_data *data; 84 103 }; 104 + 105 + static inline void sx865x_penrelease(struct sx8654 *ts) 106 + { 107 + struct input_dev *input_dev = ts->input; 108 + 109 + input_report_key(input_dev, BTN_TOUCH, 0); 110 + input_sync(input_dev); 111 + } 112 + 113 + static void sx865x_penrelease_timer_handler(struct timer_list *t) 114 + { 115 + struct sx8654 *ts = from_timer(ts, t, timer); 116 + unsigned long flags; 117 + 118 + spin_lock_irqsave(&ts->lock, flags); 119 + sx865x_penrelease(ts); 120 + spin_unlock_irqrestore(&ts->lock, flags); 121 + dev_dbg(&ts->client->dev, "penrelease by timer\n"); 122 + } 123 + 124 + static irqreturn_t sx8650_irq(int irq, void *handle) 125 + { 126 + struct sx8654 *ts = handle; 127 + struct device *dev = &ts->client->dev; 128 + int len, i; 129 + unsigned long flags; 130 + u8 stat; 131 + u16 x, y; 132 + u16 ch; 133 + u16 chdata; 134 + __be16 data[MAX_I2C_READ_LEN / sizeof(__be16)]; 135 + u8 nchan = hweight32(ts->data->chan_mask); 136 + u8 readlen = nchan * sizeof(*data); 137 + 138 + stat = i2c_smbus_read_byte_data(ts->client, CMD_READ_REGISTER 139 + | I2C_REG_SX8650_STAT); 140 + 141 + if (!(stat & SX8650_STAT_CONVIRQ)) { 142 + dev_dbg(dev, "%s ignore stat [0x%02x]", __func__, stat); 143 + return IRQ_HANDLED; 144 + } 145 + 146 + len = i2c_master_recv(ts->client, (u8 *)data, readlen); 147 + if (len != readlen) { 148 + dev_dbg(dev, "ignore short recv (%d)\n", len); 149 + return IRQ_HANDLED; 150 + } 151 + 152 + spin_lock_irqsave(&ts->lock, flags); 153 + 154 + x = 0; 155 + y = 0; 156 + for (i = 0; i < nchan; i++) { 157 + chdata = be16_to_cpu(data[i]); 158 + 159 + if (unlikely(chdata == 0xFFFF)) { 160 + dev_dbg(dev, "invalid qualified data @ %d\n", i); 161 + continue; 162 + } else if (unlikely(chdata & 0x8000)) { 163 + dev_warn(dev, "hibit @ %d [0x%04x]\n", i, chdata); 164 + continue; 165 + } 166 + 167 + ch = chdata >> 12; 168 + if (ch == CH_X) 169 + x = chdata & MAX_12BIT; 170 + else if (ch == CH_Y) 171 + y = chdata & MAX_12BIT; 172 + else 173 + dev_warn(dev, "unknown channel %d [0x%04x]\n", ch, 174 + chdata); 175 + } 176 + 177 + touchscreen_report_pos(ts->input, &ts->props, x, y, false); 178 + input_report_key(ts->input, BTN_TOUCH, 1); 179 + input_sync(ts->input); 180 + dev_dbg(dev, "point(%4d,%4d)\n", x, y); 181 + 182 + mod_timer(&ts->timer, jiffies + SX8650_PENIRQ_TIMEOUT); 183 + spin_unlock_irqrestore(&ts->lock, flags); 184 + 185 + return IRQ_HANDLED; 186 + } 85 187 86 188 static irqreturn_t sx8654_irq(int irq, void *handle) 87 189 { ··· 228 112 x = ((data[0] & 0xf) << 8) | (data[1]); 229 113 y = ((data[2] & 0xf) << 8) | (data[3]); 230 114 231 - input_report_abs(sx8654->input, ABS_X, x); 232 - input_report_abs(sx8654->input, ABS_Y, y); 115 + touchscreen_report_pos(sx8654->input, &sx8654->props, x, y, 116 + false); 233 117 input_report_key(sx8654->input, BTN_TOUCH, 1); 234 118 input_sync(sx8654->input); 235 119 ··· 238 122 239 123 out: 240 124 return IRQ_HANDLED; 125 + } 126 + 127 + static int sx8654_reset(struct sx8654 *ts) 128 + { 129 + int err; 130 + 131 + if (ts->gpio_reset) { 132 + gpiod_set_value_cansleep(ts->gpio_reset, 1); 133 + udelay(2); /* Tpulse > 1µs */ 134 + gpiod_set_value_cansleep(ts->gpio_reset, 0); 135 + } else { 136 + dev_dbg(&ts->client->dev, "NRST unavailable, try softreset\n"); 137 + err = i2c_smbus_write_byte_data(ts->client, I2C_REG_SOFTRESET, 138 + SOFTRESET_VALUE); 139 + if (err) 140 + return err; 141 + } 142 + 143 + return 0; 241 144 } 242 145 243 146 static int sx8654_open(struct input_dev *dev) ··· 292 157 293 158 disable_irq(client->irq); 294 159 160 + if (!sx8654->data->has_irq_penrelease) 161 + del_timer_sync(&sx8654->timer); 162 + 295 163 /* enable manual mode mode */ 296 - error = i2c_smbus_write_byte(client, CMD_MANUAL); 164 + error = i2c_smbus_write_byte(client, sx8654->data->cmd_manual); 297 165 if (error) { 298 166 dev_err(&client->dev, "writing command CMD_MANUAL failed"); 299 167 return; 300 168 } 301 169 302 - error = i2c_smbus_write_byte_data(client, I2C_REG_TOUCH0, 0); 170 + error = i2c_smbus_write_byte_data(client, I2C_REG_TOUCH0, RATE_MANUAL); 303 171 if (error) { 304 172 dev_err(&client->dev, "writing to I2C_REG_TOUCH0 failed"); 305 173 return; ··· 324 186 if (!sx8654) 325 187 return -ENOMEM; 326 188 189 + sx8654->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset", 190 + GPIOD_OUT_HIGH); 191 + if (IS_ERR(sx8654->gpio_reset)) { 192 + error = PTR_ERR(sx8654->gpio_reset); 193 + if (error != -EPROBE_DEFER) 194 + dev_err(&client->dev, "unable to get reset-gpio: %d\n", 195 + error); 196 + return error; 197 + } 198 + dev_dbg(&client->dev, "got GPIO reset pin\n"); 199 + 200 + sx8654->data = device_get_match_data(&client->dev); 201 + if (!sx8654->data) 202 + sx8654->data = (const struct sx865x_data *)id->driver_data; 203 + if (!sx8654->data) { 204 + dev_err(&client->dev, "invalid or missing device data\n"); 205 + return -EINVAL; 206 + } 207 + 208 + if (!sx8654->data->has_irq_penrelease) { 209 + dev_dbg(&client->dev, "use timer for penrelease\n"); 210 + timer_setup(&sx8654->timer, sx865x_penrelease_timer_handler, 0); 211 + spin_lock_init(&sx8654->lock); 212 + } 213 + 327 214 input = devm_input_allocate_device(&client->dev); 328 215 if (!input) 329 216 return -ENOMEM; ··· 364 201 input_set_abs_params(input, ABS_X, 0, MAX_12BIT, 0, 0); 365 202 input_set_abs_params(input, ABS_Y, 0, MAX_12BIT, 0, 0); 366 203 204 + touchscreen_parse_properties(input, false, &sx8654->props); 205 + 367 206 sx8654->client = client; 368 207 sx8654->input = input; 369 208 370 209 input_set_drvdata(sx8654->input, sx8654); 371 210 372 - error = i2c_smbus_write_byte_data(client, I2C_REG_SOFTRESET, 373 - SOFTRESET_VALUE); 211 + error = sx8654_reset(sx8654); 374 212 if (error) { 375 - dev_err(&client->dev, "writing softreset value failed"); 213 + dev_err(&client->dev, "reset failed"); 376 214 return error; 377 215 } 378 216 379 217 error = i2c_smbus_write_byte_data(client, I2C_REG_CHANMASK, 380 - CONV_X | CONV_Y); 218 + sx8654->data->chan_mask); 381 219 if (error) { 382 220 dev_err(&client->dev, "writing to I2C_REG_CHANMASK failed"); 383 221 return error; 384 222 } 385 223 386 - error = i2c_smbus_write_byte_data(client, I2C_REG_IRQMASK, 387 - IRQ_PENTOUCH_TOUCHCONVDONE | 388 - IRQ_PENRELEASE); 389 - if (error) { 390 - dev_err(&client->dev, "writing to I2C_REG_IRQMASK failed"); 391 - return error; 224 + if (sx8654->data->has_reg_irqmask) { 225 + error = i2c_smbus_write_byte_data(client, I2C_REG_IRQMASK, 226 + IRQ_PENTOUCH_TOUCHCONVDONE | 227 + IRQ_PENRELEASE); 228 + if (error) { 229 + dev_err(&client->dev, "writing I2C_REG_IRQMASK failed"); 230 + return error; 231 + } 392 232 } 393 233 394 234 error = i2c_smbus_write_byte_data(client, I2C_REG_TOUCH1, 395 - CONDIRQ | FILT_7SA); 235 + CONDIRQ | RPDNT_100K | FILT_7SA); 396 236 if (error) { 397 237 dev_err(&client->dev, "writing to I2C_REG_TOUCH1 failed"); 398 238 return error; 399 239 } 400 240 401 241 error = devm_request_threaded_irq(&client->dev, client->irq, 402 - NULL, sx8654_irq, 403 - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 242 + NULL, sx8654->data->irqh, 243 + IRQF_ONESHOT, 404 244 client->name, sx8654); 405 245 if (error) { 406 246 dev_err(&client->dev, ··· 422 256 return 0; 423 257 } 424 258 259 + static const struct sx865x_data sx8650_data = { 260 + .cmd_manual = 0xb0, 261 + .has_irq_penrelease = false, 262 + .has_reg_irqmask = false, 263 + .chan_mask = (CONV_X | CONV_Y), 264 + .irqh = sx8650_irq, 265 + }; 266 + 267 + static const struct sx865x_data sx8654_data = { 268 + .cmd_manual = 0xc0, 269 + .has_irq_penrelease = true, 270 + .has_reg_irqmask = true, 271 + .chan_mask = (CONV_X | CONV_Y), 272 + .irqh = sx8654_irq, 273 + }; 274 + 425 275 #ifdef CONFIG_OF 426 276 static const struct of_device_id sx8654_of_match[] = { 427 - { .compatible = "semtech,sx8654", }, 428 - { }, 277 + { 278 + .compatible = "semtech,sx8650", 279 + .data = &sx8650_data, 280 + }, { 281 + .compatible = "semtech,sx8654", 282 + .data = &sx8654_data, 283 + }, { 284 + .compatible = "semtech,sx8655", 285 + .data = &sx8654_data, 286 + }, { 287 + .compatible = "semtech,sx8656", 288 + .data = &sx8654_data, 289 + }, 290 + { } 429 291 }; 430 292 MODULE_DEVICE_TABLE(of, sx8654_of_match); 431 293 #endif 432 294 433 295 static const struct i2c_device_id sx8654_id_table[] = { 434 - { "semtech_sx8654", 0 }, 435 - { }, 296 + { .name = "semtech_sx8650", .driver_data = (long)&sx8650_data }, 297 + { .name = "semtech_sx8654", .driver_data = (long)&sx8654_data }, 298 + { .name = "semtech_sx8655", .driver_data = (long)&sx8654_data }, 299 + { .name = "semtech_sx8656", .driver_data = (long)&sx8654_data }, 300 + { } 436 301 }; 437 302 MODULE_DEVICE_TABLE(i2c, sx8654_id_table); 438 303
-4
drivers/input/touchscreen/ti_am335x_tsc.c
··· 507 507 static int __maybe_unused titsc_suspend(struct device *dev) 508 508 { 509 509 struct titsc *ts_dev = dev_get_drvdata(dev); 510 - struct ti_tscadc_dev *tscadc_dev; 511 510 unsigned int idle; 512 511 513 - tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev)); 514 512 if (device_may_wakeup(dev)) { 515 513 titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK); 516 514 idle = titsc_readl(ts_dev, REG_IRQENABLE); ··· 522 524 static int __maybe_unused titsc_resume(struct device *dev) 523 525 { 524 526 struct titsc *ts_dev = dev_get_drvdata(dev); 525 - struct ti_tscadc_dev *tscadc_dev; 526 527 527 - tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev)); 528 528 if (device_may_wakeup(dev)) { 529 529 titsc_writel(ts_dev, REG_IRQWAKEUP, 530 530 0x00);
-11
include/linux/input/ili210x.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _ILI210X_H 3 - #define _ILI210X_H 4 - 5 - struct ili210x_platform_data { 6 - unsigned long irq_flags; 7 - unsigned int poll_period; 8 - bool (*get_pendown_state)(void); 9 - }; 10 - 11 - #endif