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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull input updates from Dmitry Torokhov:

- three new touchscreen drivers: EETI EXC3000, HiDeep, and Samsung
S6SY761

- the timer API conversion (setup_timer() -> timer_setup())

- a few drivers swiytched to using managed API for creating custom
device attributes

- other assorted fixed and cleanups.

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (50 commits)
Input: gamecon - mark expected switch fall-throughs
Input: sidewinder - mark expected switch fall-throughs
Input: spaceball - mark expected switch fall-throughs
Input: uinput - unlock on allocation failure in ioctl
Input: add support for the Samsung S6SY761 touchscreen
Input: add support for HiDeep touchscreen
Input: st1232 - remove obsolete platform device support
Input: convert autorepeat timer to use timer_setup()
media: ttpci: remove autorepeat handling and use timer_setup
Input: cyttsp4 - avoid overflows when calculating memory sizes
Input: mxs-lradc - remove redundant assignment to pointer input
Input: add I2C attached EETI EXC3000 multi touch driver
Input: goodix - support gt1151 touchpanel
Input: ps2-gpio - actually abort probe when connected to sleeping GPIOs
Input: hil_mlc - convert to using timer_setup()
Input: hp_sdc - convert to using timer_setup()
Input: touchsceen - convert timers to use timer_setup()
Input: keyboard - convert timers to use timer_setup()
Input: uinput - fold header into the driver proper
Input: uinput - remove uinput_allocate_device()
...

+2797 -752
+32
Documentation/devicetree/bindings/input/gpio-mouse.txt
··· 1 + Device-Tree bindings for GPIO attached mice 2 + 3 + This simply uses standard GPIO handles to define a simple mouse connected 4 + to 5-7 GPIO lines. 5 + 6 + Required properties: 7 + - compatible: must be "gpio-mouse" 8 + - scan-interval-ms: The scanning interval in milliseconds 9 + - up-gpios: GPIO line phandle to the line indicating "up" 10 + - down-gpios: GPIO line phandle to the line indicating "down" 11 + - left-gpios: GPIO line phandle to the line indicating "left" 12 + - right-gpios: GPIO line phandle to the line indicating "right" 13 + 14 + Optional properties: 15 + - button-left-gpios: GPIO line handle to the left mouse button 16 + - button-middle-gpios: GPIO line handle to the middle mouse button 17 + - button-right-gpios: GPIO line handle to the right mouse button 18 + Example: 19 + 20 + #include <dt-bindings/gpio/gpio.h> 21 + 22 + gpio-mouse { 23 + compatible = "gpio-mouse"; 24 + scan-interval-ms = <50>; 25 + up-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>; 26 + down-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>; 27 + left-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; 28 + right-gpios = <&gpio0 3 GPIO_ACTIVE_LOW>; 29 + button-left-gpios = <&gpio0 4 GPIO_ACTIVE_LOW>; 30 + button-middle-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>; 31 + button-right-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; 32 + };
+27
Documentation/devicetree/bindings/input/touchscreen/exc3000.txt
··· 1 + * EETI EXC3000 Multiple Touch Controller 2 + 3 + Required properties: 4 + - compatible: must be "eeti,exc3000" 5 + - reg: i2c slave address 6 + - interrupt-parent: the phandle for the interrupt controller 7 + - interrupts: touch controller interrupt 8 + - touchscreen-size-x: See touchscreen.txt 9 + - touchscreen-size-y: See touchscreen.txt 10 + 11 + Optional properties: 12 + - touchscreen-inverted-x: See touchscreen.txt 13 + - touchscreen-inverted-y: See touchscreen.txt 14 + - touchscreen-swapped-x-y: See touchscreen.txt 15 + 16 + Example: 17 + 18 + touchscreen@2a { 19 + compatible = "eeti,exc3000"; 20 + reg = <0x2a>; 21 + interrupt-parent = <&gpio1>; 22 + interrupts = <9 IRQ_TYPE_LEVEL_LOW>; 23 + touchscreen-size-x = <4096>; 24 + touchscreen-size-y = <4096>; 25 + touchscreen-inverted-x; 26 + touchscreen-swapped-x-y; 27 + };
+2 -1
Documentation/devicetree/bindings/input/touchscreen/goodix.txt
··· 2 2 3 3 Required properties: 4 4 5 - - compatible : Should be "goodix,gt911" 5 + - compatible : Should be "goodix,gt1151" 6 + or "goodix,gt911" 6 7 or "goodix,gt9110" 7 8 or "goodix,gt912" 8 9 or "goodix,gt927"
+42
Documentation/devicetree/bindings/input/touchscreen/hideep.txt
··· 1 + * HiDeep Finger and Stylus touchscreen controller 2 + 3 + Required properties: 4 + - compatible : must be "hideep,hideep-ts" 5 + - reg : I2C slave address, (e.g. 0x6C). 6 + - interrupt-parent : Interrupt controller to which the chip is connected. 7 + - interrupts : Interrupt to which the chip is connected. 8 + 9 + Optional properties: 10 + - vdd-supply : It is the controller supply for controlling 11 + main voltage(3.3V) through the regulator. 12 + - vid-supply : It is the controller supply for controlling 13 + IO voltage(1.8V) through the regulator. 14 + - reset-gpios : Define for reset gpio pin. 15 + It is to use for reset IC. 16 + - touchscreen-size-x : X axis size of touchscreen 17 + - touchscreen-size-y : Y axis size of touchscreen 18 + - linux,keycodes : Specifies an array of numeric keycode values to 19 + be used for reporting button presses. The array can 20 + contain up to 3 entries. 21 + 22 + Example: 23 + 24 + #include "dt-bindings/input/input.h" 25 + 26 + i2c@00000000 { 27 + 28 + /* ... */ 29 + 30 + touchscreen@6c { 31 + compatible = "hideep,hideep-ts"; 32 + reg = <0x6c>; 33 + interrupt-parent = <&gpx1>; 34 + interrupts = <2 IRQ_TYPE_LEVEL_LOW>; 35 + vdd-supply = <&ldo15_reg>"; 36 + vid-supply = <&ldo18_reg>; 37 + reset-gpios = <&gpx1 5 0>; 38 + touchscreen-size-x = <1080>; 39 + touchscreen-size-y = <1920>; 40 + linux,keycodes = <KEY_HOME>, <KEY_MENU>, <KEY_BACK>; 41 + }; 42 + };
+34
Documentation/devicetree/bindings/input/touchscreen/samsung,s6sy761.txt
··· 1 + * Samsung S6SY761 touchscreen controller 2 + 3 + Required properties: 4 + - compatible : must be "samsung,s6sy761" 5 + - reg : I2C slave address, (e.g. 0x48) 6 + - interrupt-parent : the phandle to the interrupt controller which provides 7 + the interrupt 8 + - interrupts : interrupt specification 9 + - avdd-supply : analogic power supply 10 + - vdd-supply : power supply 11 + 12 + Optional properties: 13 + - touchscreen-size-x : see touchscreen.txt. This property is embedded in the 14 + device. If defined it forces a different x resolution. 15 + - touchscreen-size-y : see touchscreen.txt. This property is embedded in the 16 + device. If defined it forces a different y resolution. 17 + 18 + Example: 19 + 20 + i2c@00000000 { 21 + 22 + /* ... */ 23 + 24 + touchscreen@48 { 25 + compatible = "samsung,s6sy761"; 26 + reg = <0x48>; 27 + interrupt-parent = <&gpa1>; 28 + interrupts = <1 IRQ_TYPE_NONE>; 29 + avdd-supply = <&ldo30_reg>; 30 + vdd-supply = <&ldo31_reg>; 31 + touchscreen-size-x = <4096>; 32 + touchscreen-size-y = <4096>; 33 + }; 34 + };
+1
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 137 137 hannstar HannStar Display Corporation 138 138 haoyu Haoyu Microelectronic Co. Ltd. 139 139 hardkernel Hardkernel Co., Ltd 140 + hideep HiDeep Inc. 140 141 himax Himax Technologies, Inc. 141 142 hisilicon Hisilicon Limited. 142 143 hit Hitachi Ltd.
+4 -4
drivers/input/ff-memless.c
··· 412 412 ml_schedule_timer(ml); 413 413 } 414 414 415 - static void ml_effect_timer(unsigned long timer_data) 415 + static void ml_effect_timer(struct timer_list *t) 416 416 { 417 - struct input_dev *dev = (struct input_dev *)timer_data; 418 - struct ml_device *ml = dev->ff->private; 417 + struct ml_device *ml = from_timer(ml, t, timer); 418 + struct input_dev *dev = ml->dev; 419 419 unsigned long flags; 420 420 421 421 pr_debug("timer: updating effects\n"); ··· 526 526 ml->private = data; 527 527 ml->play_effect = play_effect; 528 528 ml->gain = 0xffff; 529 - setup_timer(&ml->timer, ml_effect_timer, (unsigned long)dev); 529 + timer_setup(&ml->timer, ml_effect_timer, 0); 530 530 531 531 set_bit(FF_GAIN, dev->ffbit); 532 532
+5 -6
drivers/input/input.c
··· 76 76 { 77 77 if (test_bit(EV_REP, dev->evbit) && 78 78 dev->rep[REP_PERIOD] && dev->rep[REP_DELAY] && 79 - dev->timer.data) { 79 + dev->timer.function) { 80 80 dev->repeat_key = code; 81 81 mod_timer(&dev->timer, 82 82 jiffies + msecs_to_jiffies(dev->rep[REP_DELAY])); ··· 179 179 * dev->event_lock here to avoid racing with input_event 180 180 * which may cause keys get "stuck". 181 181 */ 182 - static void input_repeat_key(unsigned long data) 182 + static void input_repeat_key(struct timer_list *t) 183 183 { 184 - struct input_dev *dev = (void *) data; 184 + struct input_dev *dev = from_timer(dev, t, timer); 185 185 unsigned long flags; 186 186 187 187 spin_lock_irqsave(&dev->event_lock, flags); ··· 1784 1784 device_initialize(&dev->dev); 1785 1785 mutex_init(&dev->mutex); 1786 1786 spin_lock_init(&dev->event_lock); 1787 - init_timer(&dev->timer); 1787 + timer_setup(&dev->timer, NULL, 0); 1788 1788 INIT_LIST_HEAD(&dev->h_list); 1789 1789 INIT_LIST_HEAD(&dev->node); 1790 1790 ··· 2047 2047 */ 2048 2048 void input_enable_softrepeat(struct input_dev *dev, int delay, int period) 2049 2049 { 2050 - dev->timer.data = (unsigned long) dev; 2051 - dev->timer.function = input_repeat_key; 2050 + dev->timer.function = (TIMER_FUNC_TYPE)input_repeat_key; 2052 2051 dev->rep[REP_DELAY] = delay; 2053 2052 dev->rep[REP_PERIOD] = period; 2054 2053 }
+3
drivers/input/joystick/gamecon.c
··· 654 654 655 655 input_report_key(dev, BTN_THUMBL, ~data[0] & 0x04); 656 656 input_report_key(dev, BTN_THUMBR, ~data[0] & 0x02); 657 + /* fall through */ 657 658 658 659 case GC_PSX_NEGCON: 659 660 case GC_PSX_ANALOG: ··· 888 887 case GC_SNES: 889 888 for (i = 4; i < 8; i++) 890 889 __set_bit(gc_snes_btn[i], input_dev->keybit); 890 + /* fall through */ 891 891 case GC_NES: 892 892 for (i = 0; i < 4; i++) 893 893 __set_bit(gc_snes_btn[i], input_dev->keybit); ··· 896 894 897 895 case GC_MULTI2: 898 896 __set_bit(BTN_THUMB, input_dev->keybit); 897 + /* fall through */ 899 898 case GC_MULTI: 900 899 __set_bit(BTN_TRIGGER, input_dev->keybit); 901 900 break;
+5 -5
drivers/input/joystick/sidewinder.c
··· 672 672 673 673 switch (i * m) { 674 674 case 60: 675 - sw->number++; 675 + sw->number++; /* fall through */ 676 676 case 45: /* Ambiguous packet length */ 677 677 if (j <= 40) { /* ID length less or eq 40 -> FSP */ 678 678 case 43: 679 679 sw->type = SW_ID_FSP; 680 680 break; 681 681 } 682 - sw->number++; 682 + sw->number++; /* fall through */ 683 683 case 30: 684 - sw->number++; 684 + sw->number++; /* fall through */ 685 685 case 15: 686 686 sw->type = SW_ID_GP; 687 687 break; ··· 697 697 sw->type = SW_ID_PP; 698 698 break; 699 699 case 66: 700 - sw->bits = 3; 700 + sw->bits = 3; /* fall through */ 701 701 case 198: 702 - sw->length = 22; 702 + sw->length = 22; /* fall through */ 703 703 case 64: 704 704 sw->type = SW_ID_3DP; 705 705 if (j == 160)
+4
drivers/input/joystick/spaceball.c
··· 162 162 break; 163 163 } 164 164 spaceball->escape = 0; 165 + /* fall through */ 165 166 case 'M': 166 167 case 'Q': 167 168 case 'S': ··· 170 169 spaceball->escape = 0; 171 170 data &= 0x1f; 172 171 } 172 + /* fall through */ 173 173 default: 174 174 if (spaceball->escape) 175 175 spaceball->escape = 0; ··· 236 234 input_dev->keybit[BIT_WORD(BTN_A)] |= BIT_MASK(BTN_A) | 237 235 BIT_MASK(BTN_B) | BIT_MASK(BTN_C) | 238 236 BIT_MASK(BTN_MODE); 237 + /* fall through */ 239 238 default: 240 239 input_dev->keybit[BIT_WORD(BTN_0)] |= BIT_MASK(BTN_2) | 241 240 BIT_MASK(BTN_3) | BIT_MASK(BTN_4) | 242 241 BIT_MASK(BTN_5) | BIT_MASK(BTN_6) | 243 242 BIT_MASK(BTN_7) | BIT_MASK(BTN_8); 243 + /* fall through */ 244 244 case SPACEBALL_3003C: 245 245 input_dev->keybit[BIT_WORD(BTN_0)] |= BIT_MASK(BTN_1) | 246 246 BIT_MASK(BTN_8);
+3 -4
drivers/input/keyboard/bf54x-keys.c
··· 127 127 bfin_write_KPAD_ROWCOL(0xFFFF); 128 128 } 129 129 130 - static void bfin_kpad_timer(unsigned long data) 130 + static void bfin_kpad_timer(struct timer_list *t) 131 131 { 132 - struct platform_device *pdev = (struct platform_device *) data; 133 - struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); 132 + struct bf54x_kpad *bf54x_kpad = from_timer(bf54x_kpad, t, timer); 134 133 135 134 if (bfin_kpad_get_keypressed(bf54x_kpad)) { 136 135 /* Try again later */ ··· 297 298 298 299 /* Init Keypad Key Up/Release test timer */ 299 300 300 - setup_timer(&bf54x_kpad->timer, bfin_kpad_timer, (unsigned long) pdev); 301 + timer_setup(&bf54x_kpad->timer, bfin_kpad_timer, 0); 301 302 302 303 bfin_write_KPAD_PRESCALE(bfin_kpad_get_prescale(TIME_SCALE)); 303 304
+3 -4
drivers/input/keyboard/gpio_keys.c
··· 419 419 return IRQ_HANDLED; 420 420 } 421 421 422 - static void gpio_keys_irq_timer(unsigned long _data) 422 + static void gpio_keys_irq_timer(struct timer_list *t) 423 423 { 424 - struct gpio_button_data *bdata = (struct gpio_button_data *)_data; 424 + struct gpio_button_data *bdata = from_timer(bdata, t, release_timer); 425 425 struct input_dev *input = bdata->input; 426 426 unsigned long flags; 427 427 ··· 582 582 } 583 583 584 584 bdata->release_delay = button->debounce_interval; 585 - setup_timer(&bdata->release_timer, 586 - gpio_keys_irq_timer, (unsigned long)bdata); 585 + timer_setup(&bdata->release_timer, gpio_keys_irq_timer, 0); 587 586 588 587 isr = gpio_keys_irq_isr; 589 588 irqflags = 0;
+4 -4
drivers/input/keyboard/imx_keypad.c
··· 184 184 /* 185 185 * imx_keypad_check_for_events is the timer handler. 186 186 */ 187 - static void imx_keypad_check_for_events(unsigned long data) 187 + static void imx_keypad_check_for_events(struct timer_list *t) 188 188 { 189 - struct imx_keypad *keypad = (struct imx_keypad *) data; 189 + struct imx_keypad *keypad = from_timer(keypad, t, check_matrix_timer); 190 190 unsigned short matrix_volatile_state[MAX_MATRIX_KEY_COLS]; 191 191 unsigned short reg_val; 192 192 bool state_changed, is_zero_matrix; ··· 456 456 keypad->irq = irq; 457 457 keypad->stable_count = 0; 458 458 459 - setup_timer(&keypad->check_matrix_timer, 460 - imx_keypad_check_for_events, (unsigned long) keypad); 459 + timer_setup(&keypad->check_matrix_timer, 460 + imx_keypad_check_for_events, 0); 461 461 462 462 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 463 463 keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res);
+3 -4
drivers/input/keyboard/locomokbd.c
··· 210 210 /* 211 211 * LoCoMo timer checking for released keys 212 212 */ 213 - static void locomokbd_timer_callback(unsigned long data) 213 + static void locomokbd_timer_callback(struct timer_list *t) 214 214 { 215 - struct locomokbd *locomokbd = (struct locomokbd *) data; 215 + struct locomokbd *locomokbd = from_timer(locomokbd, t, timer); 216 216 217 217 locomokbd_scankeyboard(locomokbd); 218 218 } ··· 264 264 265 265 spin_lock_init(&locomokbd->lock); 266 266 267 - setup_timer(&locomokbd->timer, locomokbd_timer_callback, 268 - (unsigned long)locomokbd); 267 + timer_setup(&locomokbd->timer, locomokbd_timer_callback, 0); 269 268 270 269 locomokbd->suspend_jiffies = jiffies; 271 270
+3 -3
drivers/input/keyboard/omap-keypad.c
··· 41 41 #undef NEW_BOARD_LEARNING_MODE 42 42 43 43 static void omap_kp_tasklet(unsigned long); 44 - static void omap_kp_timer(unsigned long); 44 + static void omap_kp_timer(struct timer_list *); 45 45 46 46 static unsigned char keypad_state[8]; 47 47 static DEFINE_MUTEX(kp_enable_mutex); ··· 74 74 return IRQ_HANDLED; 75 75 } 76 76 77 - static void omap_kp_timer(unsigned long data) 77 + static void omap_kp_timer(struct timer_list *unused) 78 78 { 79 79 tasklet_schedule(&kp_tasklet); 80 80 } ··· 233 233 col_idx = 0; 234 234 row_idx = 0; 235 235 236 - setup_timer(&omap_kp->timer, omap_kp_timer, (unsigned long)omap_kp); 236 + timer_setup(&omap_kp->timer, omap_kp_timer, 0); 237 237 238 238 /* get the irq and init timer*/ 239 239 kp_tasklet.data = (unsigned long) omap_kp;
+3 -4
drivers/input/keyboard/snvs_pwrkey.c
··· 45 45 struct input_dev *input; 46 46 }; 47 47 48 - static void imx_imx_snvs_check_for_events(unsigned long data) 48 + static void imx_imx_snvs_check_for_events(struct timer_list *t) 49 49 { 50 - struct pwrkey_drv_data *pdata = (struct pwrkey_drv_data *) data; 50 + struct pwrkey_drv_data *pdata = from_timer(pdata, t, check_timer); 51 51 struct input_dev *input = pdata->input; 52 52 u32 state; 53 53 ··· 134 134 /* clear the unexpected interrupt before driver ready */ 135 135 regmap_write(pdata->snvs, SNVS_LPSR_REG, SNVS_LPSR_SPO); 136 136 137 - setup_timer(&pdata->check_timer, 138 - imx_imx_snvs_check_for_events, (unsigned long) pdata); 137 + timer_setup(&pdata->check_timer, imx_imx_snvs_check_for_events, 0); 139 138 140 139 input = devm_input_allocate_device(&pdev->dev); 141 140 if (!input) {
+3 -3
drivers/input/keyboard/tegra-kbc.c
··· 251 251 writel(val, kbc->mmio + KBC_CONTROL_0); 252 252 } 253 253 254 - static void tegra_kbc_keypress_timer(unsigned long data) 254 + static void tegra_kbc_keypress_timer(struct timer_list *t) 255 255 { 256 - struct tegra_kbc *kbc = (struct tegra_kbc *)data; 256 + struct tegra_kbc *kbc = from_timer(kbc, t, timer); 257 257 unsigned long flags; 258 258 u32 val; 259 259 unsigned int i; ··· 655 655 return -ENOMEM; 656 656 } 657 657 658 - setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc); 658 + timer_setup(&kbc->timer, tegra_kbc_keypress_timer, 0); 659 659 660 660 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 661 661 kbc->mmio = devm_ioremap_resource(&pdev->dev, res);
+1 -1
drivers/input/misc/adxl34x.c
··· 796 796 797 797 if (pdata->watermark) { 798 798 ac->int_mask |= WATERMARK; 799 - if (!FIFO_MODE(pdata->fifo_mode)) 799 + if (FIFO_MODE(pdata->fifo_mode) == FIFO_BYPASS) 800 800 ac->pdata.fifo_mode |= FIFO_STREAM; 801 801 } else { 802 802 ac->int_mask |= DATA_READY;
+194 -159
drivers/input/misc/uinput.c
··· 31 31 * 0.1 20/06/2002 32 32 * - first public version 33 33 */ 34 + #include <uapi/linux/uinput.h> 34 35 #include <linux/poll.h> 35 36 #include <linux/sched.h> 36 37 #include <linux/slab.h> ··· 39 38 #include <linux/init.h> 40 39 #include <linux/fs.h> 41 40 #include <linux/miscdevice.h> 42 - #include <linux/uinput.h> 43 41 #include <linux/input/mt.h> 44 42 #include "../input-compat.h" 43 + 44 + #define UINPUT_NAME "uinput" 45 + #define UINPUT_BUFFER_SIZE 16 46 + #define UINPUT_NUM_REQUESTS 16 47 + 48 + enum uinput_state { UIST_NEW_DEVICE, UIST_SETUP_COMPLETE, UIST_CREATED }; 49 + 50 + struct uinput_request { 51 + unsigned int id; 52 + unsigned int code; /* UI_FF_UPLOAD, UI_FF_ERASE */ 53 + 54 + int retval; 55 + struct completion done; 56 + 57 + union { 58 + unsigned int effect_id; 59 + struct { 60 + struct ff_effect *effect; 61 + struct ff_effect *old; 62 + } upload; 63 + } u; 64 + }; 65 + 66 + struct uinput_device { 67 + struct input_dev *dev; 68 + struct mutex mutex; 69 + enum uinput_state state; 70 + wait_queue_head_t waitq; 71 + unsigned char ready; 72 + unsigned char head; 73 + unsigned char tail; 74 + struct input_event buff[UINPUT_BUFFER_SIZE]; 75 + unsigned int ff_effects_max; 76 + 77 + struct uinput_request *requests[UINPUT_NUM_REQUESTS]; 78 + wait_queue_head_t requests_waitq; 79 + spinlock_t requests_lock; 80 + }; 45 81 46 82 static int uinput_dev_event(struct input_dev *dev, 47 83 unsigned int type, unsigned int code, int value) ··· 187 149 if (retval) 188 150 goto out; 189 151 190 - wait_for_completion(&request->done); 152 + if (!wait_for_completion_timeout(&request->done, 30 * HZ)) { 153 + retval = -ETIMEDOUT; 154 + goto out; 155 + } 156 + 191 157 retval = request->retval; 192 158 193 159 out: ··· 362 320 dev->flush = uinput_dev_flush; 363 321 } 364 322 323 + dev->event = uinput_dev_event; 324 + 325 + input_set_drvdata(udev->dev, udev); 326 + 365 327 error = input_register_device(udev->dev); 366 328 if (error) 367 329 goto fail2; ··· 448 402 return 0; 449 403 } 450 404 451 - static int uinput_allocate_device(struct uinput_device *udev) 452 - { 453 - udev->dev = input_allocate_device(); 454 - if (!udev->dev) 455 - return -ENOMEM; 456 - 457 - udev->dev->event = uinput_dev_event; 458 - input_set_drvdata(udev->dev, udev); 459 - 460 - return 0; 461 - } 462 - 463 405 static int uinput_dev_setup(struct uinput_device *udev, 464 406 struct uinput_setup __user *arg) 465 407 { ··· 523 489 return -EINVAL; 524 490 525 491 if (!udev->dev) { 526 - retval = uinput_allocate_device(udev); 527 - if (retval) 528 - return retval; 492 + udev->dev = input_allocate_device(); 493 + if (!udev->dev) 494 + return -ENOMEM; 529 495 } 530 496 531 497 dev = udev->dev; ··· 856 822 return retval; 857 823 858 824 if (!udev->dev) { 859 - retval = uinput_allocate_device(udev); 860 - if (retval) 825 + udev->dev = input_allocate_device(); 826 + if (!udev->dev) { 827 + retval = -ENOMEM; 861 828 goto out; 829 + } 862 830 } 863 831 864 832 switch (cmd) { 865 - case UI_GET_VERSION: 866 - if (put_user(UINPUT_VERSION, 867 - (unsigned int __user *)p)) 868 - retval = -EFAULT; 833 + case UI_GET_VERSION: 834 + if (put_user(UINPUT_VERSION, (unsigned int __user *)p)) 835 + retval = -EFAULT; 836 + goto out; 837 + 838 + case UI_DEV_CREATE: 839 + retval = uinput_create_device(udev); 840 + goto out; 841 + 842 + case UI_DEV_DESTROY: 843 + uinput_destroy_device(udev); 844 + goto out; 845 + 846 + case UI_DEV_SETUP: 847 + retval = uinput_dev_setup(udev, p); 848 + goto out; 849 + 850 + /* UI_ABS_SETUP is handled in the variable size ioctls */ 851 + 852 + case UI_SET_EVBIT: 853 + retval = uinput_set_bit(arg, evbit, EV_MAX); 854 + goto out; 855 + 856 + case UI_SET_KEYBIT: 857 + retval = uinput_set_bit(arg, keybit, KEY_MAX); 858 + goto out; 859 + 860 + case UI_SET_RELBIT: 861 + retval = uinput_set_bit(arg, relbit, REL_MAX); 862 + goto out; 863 + 864 + case UI_SET_ABSBIT: 865 + retval = uinput_set_bit(arg, absbit, ABS_MAX); 866 + goto out; 867 + 868 + case UI_SET_MSCBIT: 869 + retval = uinput_set_bit(arg, mscbit, MSC_MAX); 870 + goto out; 871 + 872 + case UI_SET_LEDBIT: 873 + retval = uinput_set_bit(arg, ledbit, LED_MAX); 874 + goto out; 875 + 876 + case UI_SET_SNDBIT: 877 + retval = uinput_set_bit(arg, sndbit, SND_MAX); 878 + goto out; 879 + 880 + case UI_SET_FFBIT: 881 + retval = uinput_set_bit(arg, ffbit, FF_MAX); 882 + goto out; 883 + 884 + case UI_SET_SWBIT: 885 + retval = uinput_set_bit(arg, swbit, SW_MAX); 886 + goto out; 887 + 888 + case UI_SET_PROPBIT: 889 + retval = uinput_set_bit(arg, propbit, INPUT_PROP_MAX); 890 + goto out; 891 + 892 + case UI_SET_PHYS: 893 + if (udev->state == UIST_CREATED) { 894 + retval = -EINVAL; 895 + goto out; 896 + } 897 + 898 + phys = strndup_user(p, 1024); 899 + if (IS_ERR(phys)) { 900 + retval = PTR_ERR(phys); 901 + goto out; 902 + } 903 + 904 + kfree(udev->dev->phys); 905 + udev->dev->phys = phys; 906 + goto out; 907 + 908 + case UI_BEGIN_FF_UPLOAD: 909 + retval = uinput_ff_upload_from_user(p, &ff_up); 910 + if (retval) 869 911 goto out; 870 912 871 - case UI_DEV_CREATE: 872 - retval = uinput_create_device(udev); 913 + req = uinput_request_find(udev, ff_up.request_id); 914 + if (!req || req->code != UI_FF_UPLOAD || 915 + !req->u.upload.effect) { 916 + retval = -EINVAL; 917 + goto out; 918 + } 919 + 920 + ff_up.retval = 0; 921 + ff_up.effect = *req->u.upload.effect; 922 + if (req->u.upload.old) 923 + ff_up.old = *req->u.upload.old; 924 + else 925 + memset(&ff_up.old, 0, sizeof(struct ff_effect)); 926 + 927 + retval = uinput_ff_upload_to_user(p, &ff_up); 928 + goto out; 929 + 930 + case UI_BEGIN_FF_ERASE: 931 + if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { 932 + retval = -EFAULT; 933 + goto out; 934 + } 935 + 936 + req = uinput_request_find(udev, ff_erase.request_id); 937 + if (!req || req->code != UI_FF_ERASE) { 938 + retval = -EINVAL; 939 + goto out; 940 + } 941 + 942 + ff_erase.retval = 0; 943 + ff_erase.effect_id = req->u.effect_id; 944 + if (copy_to_user(p, &ff_erase, sizeof(ff_erase))) { 945 + retval = -EFAULT; 946 + goto out; 947 + } 948 + 949 + goto out; 950 + 951 + case UI_END_FF_UPLOAD: 952 + retval = uinput_ff_upload_from_user(p, &ff_up); 953 + if (retval) 873 954 goto out; 874 955 875 - case UI_DEV_DESTROY: 876 - uinput_destroy_device(udev); 956 + req = uinput_request_find(udev, ff_up.request_id); 957 + if (!req || req->code != UI_FF_UPLOAD || 958 + !req->u.upload.effect) { 959 + retval = -EINVAL; 877 960 goto out; 961 + } 878 962 879 - case UI_DEV_SETUP: 880 - retval = uinput_dev_setup(udev, p); 963 + req->retval = ff_up.retval; 964 + complete(&req->done); 965 + goto out; 966 + 967 + case UI_END_FF_ERASE: 968 + if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { 969 + retval = -EFAULT; 881 970 goto out; 971 + } 882 972 883 - /* UI_ABS_SETUP is handled in the variable size ioctls */ 884 - 885 - case UI_SET_EVBIT: 886 - retval = uinput_set_bit(arg, evbit, EV_MAX); 973 + req = uinput_request_find(udev, ff_erase.request_id); 974 + if (!req || req->code != UI_FF_ERASE) { 975 + retval = -EINVAL; 887 976 goto out; 977 + } 888 978 889 - case UI_SET_KEYBIT: 890 - retval = uinput_set_bit(arg, keybit, KEY_MAX); 891 - goto out; 892 - 893 - case UI_SET_RELBIT: 894 - retval = uinput_set_bit(arg, relbit, REL_MAX); 895 - goto out; 896 - 897 - case UI_SET_ABSBIT: 898 - retval = uinput_set_bit(arg, absbit, ABS_MAX); 899 - goto out; 900 - 901 - case UI_SET_MSCBIT: 902 - retval = uinput_set_bit(arg, mscbit, MSC_MAX); 903 - goto out; 904 - 905 - case UI_SET_LEDBIT: 906 - retval = uinput_set_bit(arg, ledbit, LED_MAX); 907 - goto out; 908 - 909 - case UI_SET_SNDBIT: 910 - retval = uinput_set_bit(arg, sndbit, SND_MAX); 911 - goto out; 912 - 913 - case UI_SET_FFBIT: 914 - retval = uinput_set_bit(arg, ffbit, FF_MAX); 915 - goto out; 916 - 917 - case UI_SET_SWBIT: 918 - retval = uinput_set_bit(arg, swbit, SW_MAX); 919 - goto out; 920 - 921 - case UI_SET_PROPBIT: 922 - retval = uinput_set_bit(arg, propbit, INPUT_PROP_MAX); 923 - goto out; 924 - 925 - case UI_SET_PHYS: 926 - if (udev->state == UIST_CREATED) { 927 - retval = -EINVAL; 928 - goto out; 929 - } 930 - 931 - phys = strndup_user(p, 1024); 932 - if (IS_ERR(phys)) { 933 - retval = PTR_ERR(phys); 934 - goto out; 935 - } 936 - 937 - kfree(udev->dev->phys); 938 - udev->dev->phys = phys; 939 - goto out; 940 - 941 - case UI_BEGIN_FF_UPLOAD: 942 - retval = uinput_ff_upload_from_user(p, &ff_up); 943 - if (retval) 944 - goto out; 945 - 946 - req = uinput_request_find(udev, ff_up.request_id); 947 - if (!req || req->code != UI_FF_UPLOAD || 948 - !req->u.upload.effect) { 949 - retval = -EINVAL; 950 - goto out; 951 - } 952 - 953 - ff_up.retval = 0; 954 - ff_up.effect = *req->u.upload.effect; 955 - if (req->u.upload.old) 956 - ff_up.old = *req->u.upload.old; 957 - else 958 - memset(&ff_up.old, 0, sizeof(struct ff_effect)); 959 - 960 - retval = uinput_ff_upload_to_user(p, &ff_up); 961 - goto out; 962 - 963 - case UI_BEGIN_FF_ERASE: 964 - if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { 965 - retval = -EFAULT; 966 - goto out; 967 - } 968 - 969 - req = uinput_request_find(udev, ff_erase.request_id); 970 - if (!req || req->code != UI_FF_ERASE) { 971 - retval = -EINVAL; 972 - goto out; 973 - } 974 - 975 - ff_erase.retval = 0; 976 - ff_erase.effect_id = req->u.effect_id; 977 - if (copy_to_user(p, &ff_erase, sizeof(ff_erase))) { 978 - retval = -EFAULT; 979 - goto out; 980 - } 981 - 982 - goto out; 983 - 984 - case UI_END_FF_UPLOAD: 985 - retval = uinput_ff_upload_from_user(p, &ff_up); 986 - if (retval) 987 - goto out; 988 - 989 - req = uinput_request_find(udev, ff_up.request_id); 990 - if (!req || req->code != UI_FF_UPLOAD || 991 - !req->u.upload.effect) { 992 - retval = -EINVAL; 993 - goto out; 994 - } 995 - 996 - req->retval = ff_up.retval; 997 - complete(&req->done); 998 - goto out; 999 - 1000 - case UI_END_FF_ERASE: 1001 - if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { 1002 - retval = -EFAULT; 1003 - goto out; 1004 - } 1005 - 1006 - req = uinput_request_find(udev, ff_erase.request_id); 1007 - if (!req || req->code != UI_FF_ERASE) { 1008 - retval = -EINVAL; 1009 - goto out; 1010 - } 1011 - 1012 - req->retval = ff_erase.retval; 1013 - complete(&req->done); 1014 - goto out; 979 + req->retval = ff_erase.retval; 980 + complete(&req->done); 981 + goto out; 1015 982 } 1016 983 1017 984 size = _IOC_SIZE(cmd);
+4 -4
drivers/input/mouse/alps.c
··· 1587 1587 return PSMOUSE_GOOD_DATA; 1588 1588 } 1589 1589 1590 - static void alps_flush_packet(unsigned long data) 1590 + static void alps_flush_packet(struct timer_list *t) 1591 1591 { 1592 - struct psmouse *psmouse = (struct psmouse *)data; 1593 - struct alps_data *priv = psmouse->private; 1592 + struct alps_data *priv = from_timer(priv, t, timer); 1593 + struct psmouse *psmouse = priv->psmouse; 1594 1594 1595 1595 serio_pause_rx(psmouse->ps2dev.serio); 1596 1596 ··· 2702 2702 { 2703 2703 psmouse->private = priv; 2704 2704 2705 - setup_timer(&priv->timer, alps_flush_packet, (unsigned long)psmouse); 2705 + timer_setup(&priv->timer, alps_flush_packet, 0); 2706 2706 2707 2707 priv->proto_version = protocol->version; 2708 2708 priv->byte0 = protocol->byte0;
+6 -4
drivers/input/mouse/byd.c
··· 227 227 228 228 struct byd_data { 229 229 struct timer_list timer; 230 + struct psmouse *psmouse; 230 231 s32 abs_x; 231 232 s32 abs_y; 232 233 typeof(jiffies) last_touch_time; ··· 252 251 input_sync(dev); 253 252 } 254 253 255 - static void byd_clear_touch(unsigned long data) 254 + static void byd_clear_touch(struct timer_list *t) 256 255 { 257 - struct psmouse *psmouse = (struct psmouse *)data; 258 - struct byd_data *priv = psmouse->private; 256 + struct byd_data *priv = from_timer(priv, t, timer); 257 + struct psmouse *psmouse = priv->psmouse; 259 258 260 259 serio_pause_rx(psmouse->ps2dev.serio); 261 260 priv->touch = false; ··· 479 478 if (!priv) 480 479 return -ENOMEM; 481 480 482 - setup_timer(&priv->timer, byd_clear_touch, (unsigned long) psmouse); 481 + priv->psmouse = psmouse; 482 + timer_setup(&priv->timer, byd_clear_touch, 0); 483 483 484 484 psmouse->private = priv; 485 485 psmouse->disconnect = byd_disconnect;
+7 -4
drivers/input/mouse/elan_i2c_core.c
··· 26 26 #include <linux/init.h> 27 27 #include <linux/input/mt.h> 28 28 #include <linux/interrupt.h> 29 + #include <linux/irq.h> 29 30 #include <linux/module.h> 30 31 #include <linux/slab.h> 31 32 #include <linux/kernel.h> ··· 1142 1141 return error; 1143 1142 1144 1143 /* 1145 - * Systems using device tree should set up interrupt via DTS, 1146 - * the rest will use the default falling edge interrupts. 1144 + * Platform code (ACPI, DTS) should normally set up interrupt 1145 + * for us, but in case it did not let's fall back to using falling 1146 + * edge to be compatible with older Chromebooks. 1147 1147 */ 1148 - irqflags = dev->of_node ? 0 : IRQF_TRIGGER_FALLING; 1148 + irqflags = irq_get_trigger_type(client->irq); 1149 + if (!irqflags) 1150 + irqflags = IRQF_TRIGGER_FALLING; 1149 1151 1150 1152 error = devm_request_threaded_irq(dev, client->irq, NULL, elan_isr, 1151 1153 irqflags | IRQF_ONESHOT, ··· 1259 1255 { "ELAN0602", 0 }, 1260 1256 { "ELAN0605", 0 }, 1261 1257 { "ELAN0608", 0 }, 1262 - { "ELAN0605", 0 }, 1263 1258 { "ELAN0609", 0 }, 1264 1259 { "ELAN060B", 0 }, 1265 1260 { "ELAN060C", 0 },
+98 -102
drivers/input/mouse/gpio_mouse.c
··· 2 2 * Driver for simulating a mouse on GPIO lines. 3 3 * 4 4 * Copyright (C) 2007 Atmel Corporation 5 + * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org> 5 6 * 6 7 * This program is free software; you can redistribute it and/or modify 7 8 * it under the terms of the GNU General Public License version 2 as ··· 12 11 #include <linux/module.h> 13 12 #include <linux/platform_device.h> 14 13 #include <linux/input-polldev.h> 15 - #include <linux/gpio.h> 16 - #include <linux/gpio_mouse.h> 14 + #include <linux/gpio/consumer.h> 15 + #include <linux/property.h> 16 + #include <linux/of.h> 17 17 18 + /** 19 + * struct gpio_mouse 20 + * @scan_ms: the scan interval in milliseconds. 21 + * @up: GPIO line for up value. 22 + * @down: GPIO line for down value. 23 + * @left: GPIO line for left value. 24 + * @right: GPIO line for right value. 25 + * @bleft: GPIO line for left button. 26 + * @bmiddle: GPIO line for middle button. 27 + * @bright: GPIO line for right button. 28 + * 29 + * This struct must be added to the platform_device in the board code. 30 + * It is used by the gpio_mouse driver to setup GPIO lines and to 31 + * calculate mouse movement. 32 + */ 33 + struct gpio_mouse { 34 + u32 scan_ms; 35 + struct gpio_desc *up; 36 + struct gpio_desc *down; 37 + struct gpio_desc *left; 38 + struct gpio_desc *right; 39 + struct gpio_desc *bleft; 40 + struct gpio_desc *bmiddle; 41 + struct gpio_desc *bright; 42 + }; 18 43 19 44 /* 20 45 * Timer function which is run every scan_ms ms when the device is opened. ··· 48 21 */ 49 22 static void gpio_mouse_scan(struct input_polled_dev *dev) 50 23 { 51 - struct gpio_mouse_platform_data *gpio = dev->private; 24 + struct gpio_mouse *gpio = dev->private; 52 25 struct input_dev *input = dev->input; 53 26 int x, y; 54 27 55 - if (gpio->bleft >= 0) 28 + if (gpio->bleft) 56 29 input_report_key(input, BTN_LEFT, 57 - gpio_get_value(gpio->bleft) ^ gpio->polarity); 58 - if (gpio->bmiddle >= 0) 30 + gpiod_get_value(gpio->bleft)); 31 + if (gpio->bmiddle) 59 32 input_report_key(input, BTN_MIDDLE, 60 - gpio_get_value(gpio->bmiddle) ^ gpio->polarity); 61 - if (gpio->bright >= 0) 33 + gpiod_get_value(gpio->bmiddle)); 34 + if (gpio->bright) 62 35 input_report_key(input, BTN_RIGHT, 63 - gpio_get_value(gpio->bright) ^ gpio->polarity); 36 + gpiod_get_value(gpio->bright)); 64 37 65 - x = (gpio_get_value(gpio->right) ^ gpio->polarity) 66 - - (gpio_get_value(gpio->left) ^ gpio->polarity); 67 - y = (gpio_get_value(gpio->down) ^ gpio->polarity) 68 - - (gpio_get_value(gpio->up) ^ gpio->polarity); 38 + x = gpiod_get_value(gpio->right) - gpiod_get_value(gpio->left); 39 + y = gpiod_get_value(gpio->down) - gpiod_get_value(gpio->up); 69 40 70 41 input_report_rel(input, REL_X, x); 71 42 input_report_rel(input, REL_Y, y); ··· 72 47 73 48 static int gpio_mouse_probe(struct platform_device *pdev) 74 49 { 75 - struct gpio_mouse_platform_data *pdata = dev_get_platdata(&pdev->dev); 50 + struct device *dev = &pdev->dev; 51 + struct gpio_mouse *gmouse; 76 52 struct input_polled_dev *input_poll; 77 53 struct input_dev *input; 78 - int pin, i; 79 - int error; 54 + int ret; 80 55 81 - if (!pdata) { 82 - dev_err(&pdev->dev, "no platform data\n"); 83 - error = -ENXIO; 84 - goto out; 56 + gmouse = devm_kzalloc(dev, sizeof(*gmouse), GFP_KERNEL); 57 + if (!gmouse) 58 + return -ENOMEM; 59 + 60 + /* Assign some default scanning time */ 61 + ret = device_property_read_u32(dev, "scan-interval-ms", 62 + &gmouse->scan_ms); 63 + if (ret || gmouse->scan_ms == 0) { 64 + dev_warn(dev, "invalid scan time, set to 50 ms\n"); 65 + gmouse->scan_ms = 50; 85 66 } 86 67 87 - if (pdata->scan_ms < 0) { 88 - dev_err(&pdev->dev, "invalid scan time\n"); 89 - error = -EINVAL; 90 - goto out; 91 - } 68 + gmouse->up = devm_gpiod_get(dev, "up", GPIOD_IN); 69 + if (IS_ERR(gmouse->up)) 70 + return PTR_ERR(gmouse->up); 71 + gmouse->down = devm_gpiod_get(dev, "down", GPIOD_IN); 72 + if (IS_ERR(gmouse->down)) 73 + return PTR_ERR(gmouse->down); 74 + gmouse->left = devm_gpiod_get(dev, "left", GPIOD_IN); 75 + if (IS_ERR(gmouse->left)) 76 + return PTR_ERR(gmouse->left); 77 + gmouse->right = devm_gpiod_get(dev, "right", GPIOD_IN); 78 + if (IS_ERR(gmouse->right)) 79 + return PTR_ERR(gmouse->right); 92 80 93 - for (i = 0; i < GPIO_MOUSE_PIN_MAX; i++) { 94 - pin = pdata->pins[i]; 81 + gmouse->bleft = devm_gpiod_get_optional(dev, "button-left", GPIOD_IN); 82 + if (IS_ERR(gmouse->bleft)) 83 + return PTR_ERR(gmouse->bleft); 84 + gmouse->bmiddle = devm_gpiod_get_optional(dev, "button-middle", 85 + GPIOD_IN); 86 + if (IS_ERR(gmouse->bmiddle)) 87 + return PTR_ERR(gmouse->bmiddle); 88 + gmouse->bright = devm_gpiod_get_optional(dev, "button-right", 89 + GPIOD_IN); 90 + if (IS_ERR(gmouse->bright)) 91 + return PTR_ERR(gmouse->bright); 95 92 96 - if (pin < 0) { 97 - 98 - if (i <= GPIO_MOUSE_PIN_RIGHT) { 99 - /* Mouse direction is required. */ 100 - dev_err(&pdev->dev, 101 - "missing GPIO for directions\n"); 102 - error = -EINVAL; 103 - goto out_free_gpios; 104 - } 105 - 106 - if (i == GPIO_MOUSE_PIN_BLEFT) 107 - dev_dbg(&pdev->dev, "no left button defined\n"); 108 - 109 - } else { 110 - error = gpio_request(pin, "gpio_mouse"); 111 - if (error) { 112 - dev_err(&pdev->dev, "fail %d pin (%d idx)\n", 113 - pin, i); 114 - goto out_free_gpios; 115 - } 116 - 117 - gpio_direction_input(pin); 118 - } 119 - } 120 - 121 - input_poll = input_allocate_polled_device(); 93 + input_poll = devm_input_allocate_polled_device(dev); 122 94 if (!input_poll) { 123 - dev_err(&pdev->dev, "not enough memory for input device\n"); 124 - error = -ENOMEM; 125 - goto out_free_gpios; 95 + dev_err(dev, "not enough memory for input device\n"); 96 + return -ENOMEM; 126 97 } 127 98 128 99 platform_set_drvdata(pdev, input_poll); 129 100 130 101 /* set input-polldev handlers */ 131 - input_poll->private = pdata; 102 + input_poll->private = gmouse; 132 103 input_poll->poll = gpio_mouse_scan; 133 - input_poll->poll_interval = pdata->scan_ms; 104 + input_poll->poll_interval = gmouse->scan_ms; 134 105 135 106 input = input_poll->input; 136 107 input->name = pdev->name; ··· 135 114 136 115 input_set_capability(input, EV_REL, REL_X); 137 116 input_set_capability(input, EV_REL, REL_Y); 138 - if (pdata->bleft >= 0) 117 + if (gmouse->bleft) 139 118 input_set_capability(input, EV_KEY, BTN_LEFT); 140 - if (pdata->bmiddle >= 0) 119 + if (gmouse->bmiddle) 141 120 input_set_capability(input, EV_KEY, BTN_MIDDLE); 142 - if (pdata->bright >= 0) 121 + if (gmouse->bright) 143 122 input_set_capability(input, EV_KEY, BTN_RIGHT); 144 123 145 - error = input_register_polled_device(input_poll); 146 - if (error) { 147 - dev_err(&pdev->dev, "could not register input device\n"); 148 - goto out_free_polldev; 124 + ret = input_register_polled_device(input_poll); 125 + if (ret) { 126 + dev_err(dev, "could not register input device\n"); 127 + return ret; 149 128 } 150 129 151 - dev_dbg(&pdev->dev, "%d ms scan time, buttons: %s%s%s\n", 152 - pdata->scan_ms, 153 - pdata->bleft < 0 ? "" : "left ", 154 - pdata->bmiddle < 0 ? "" : "middle ", 155 - pdata->bright < 0 ? "" : "right"); 156 - 157 - return 0; 158 - 159 - out_free_polldev: 160 - input_free_polled_device(input_poll); 161 - 162 - out_free_gpios: 163 - while (--i >= 0) { 164 - pin = pdata->pins[i]; 165 - if (pin) 166 - gpio_free(pin); 167 - } 168 - out: 169 - return error; 170 - } 171 - 172 - static int gpio_mouse_remove(struct platform_device *pdev) 173 - { 174 - struct input_polled_dev *input = platform_get_drvdata(pdev); 175 - struct gpio_mouse_platform_data *pdata = input->private; 176 - int pin, i; 177 - 178 - input_unregister_polled_device(input); 179 - input_free_polled_device(input); 180 - 181 - for (i = 0; i < GPIO_MOUSE_PIN_MAX; i++) { 182 - pin = pdata->pins[i]; 183 - if (pin >= 0) 184 - gpio_free(pin); 185 - } 130 + dev_dbg(dev, "%d ms scan time, buttons: %s%s%s\n", 131 + gmouse->scan_ms, 132 + gmouse->bleft ? "" : "left ", 133 + gmouse->bmiddle ? "" : "middle ", 134 + gmouse->bright ? "" : "right"); 186 135 187 136 return 0; 188 137 } 138 + 139 + static const struct of_device_id gpio_mouse_of_match[] = { 140 + { .compatible = "gpio-mouse", }, 141 + { }, 142 + }; 143 + MODULE_DEVICE_TABLE(of, gpio_mouse_of_match); 189 144 190 145 static struct platform_driver gpio_mouse_device_driver = { 191 146 .probe = gpio_mouse_probe, 192 - .remove = gpio_mouse_remove, 193 147 .driver = { 194 148 .name = "gpio_mouse", 149 + .of_match_table = gpio_mouse_of_match, 195 150 } 196 151 }; 197 152 module_platform_driver(gpio_mouse_device_driver); ··· 176 179 MODULE_DESCRIPTION("GPIO mouse driver"); 177 180 MODULE_LICENSE("GPL"); 178 181 MODULE_ALIAS("platform:gpio_mouse"); /* work with hotplug and coldplug */ 179 -
+1 -1
drivers/input/rmi4/rmi_f54.c
··· 73 73 F54_MAX_REPORT_TYPE, 74 74 }; 75 75 76 - const char *rmi_f54_report_type_names[] = { 76 + static const char * const rmi_f54_report_type_names[] = { 77 77 [F54_REPORT_NONE] = "Unknown", 78 78 [F54_8BIT_IMAGE] = "Normalized 8-Bit Image", 79 79 [F54_16BIT_IMAGE] = "Normalized 16-Bit Image",
+2 -2
drivers/input/serio/hil_mlc.c
··· 784 784 785 785 /************************* Keepalive timer task *********************/ 786 786 787 - static void hil_mlcs_timer(unsigned long data) 787 + static void hil_mlcs_timer(struct timer_list *unused) 788 788 { 789 789 hil_mlcs_probe = 1; 790 790 tasklet_schedule(&hil_mlcs_tasklet); ··· 998 998 999 999 static int __init hil_mlc_init(void) 1000 1000 { 1001 - setup_timer(&hil_mlcs_kicker, &hil_mlcs_timer, 0); 1001 + timer_setup(&hil_mlcs_kicker, &hil_mlcs_timer, 0); 1002 1002 mod_timer(&hil_mlcs_kicker, jiffies + HZ); 1003 1003 1004 1004 tasklet_enable(&hil_mlcs_tasklet);
+2 -3
drivers/input/serio/hp_sdc.c
··· 794 794 795 795 /************************* Keepalive timer task *********************/ 796 796 797 - static void hp_sdc_kicker(unsigned long data) 797 + static void hp_sdc_kicker(struct timer_list *unused) 798 798 { 799 799 tasklet_schedule(&hp_sdc.task); 800 800 /* Re-insert the periodic task. */ ··· 909 909 down(&s_sync); /* Wait for t_sync to complete */ 910 910 911 911 /* Create the keepalive task */ 912 - init_timer(&hp_sdc.kicker); 912 + timer_setup(&hp_sdc.kicker, hp_sdc_kicker, 0); 913 913 hp_sdc.kicker.expires = jiffies + HZ; 914 - hp_sdc.kicker.function = &hp_sdc_kicker; 915 914 add_timer(&hp_sdc.kicker); 916 915 917 916 hp_sdc.dev_err = 0;
+1
drivers/input/serio/ps2-gpio.c
··· 366 366 gpiod_cansleep(drvdata->gpio_clk)) { 367 367 dev_err(dev, "GPIO data or clk are connected via slow bus\n"); 368 368 error = -EINVAL; 369 + goto err_free_serio; 369 370 } 370 371 371 372 drvdata->irq = platform_get_irq(pdev, 0);
+41 -28
drivers/input/serio/sa1111ps2.c
··· 47 47 struct serio *io; 48 48 struct sa1111_dev *dev; 49 49 void __iomem *base; 50 + int rx_irq; 51 + int tx_irq; 50 52 unsigned int open; 51 53 spinlock_t lock; 52 54 unsigned int head; ··· 66 64 struct ps2if *ps2if = dev_id; 67 65 unsigned int scancode, flag, status; 68 66 69 - status = sa1111_readl(ps2if->base + PS2STAT); 67 + status = readl_relaxed(ps2if->base + PS2STAT); 70 68 while (status & PS2STAT_RXF) { 71 69 if (status & PS2STAT_STP) 72 - sa1111_writel(PS2STAT_STP, ps2if->base + PS2STAT); 70 + writel_relaxed(PS2STAT_STP, ps2if->base + PS2STAT); 73 71 74 72 flag = (status & PS2STAT_STP ? SERIO_FRAME : 0) | 75 73 (status & PS2STAT_RXP ? 0 : SERIO_PARITY); 76 74 77 - scancode = sa1111_readl(ps2if->base + PS2DATA) & 0xff; 75 + scancode = readl_relaxed(ps2if->base + PS2DATA) & 0xff; 78 76 79 77 if (hweight8(scancode) & 1) 80 78 flag ^= SERIO_PARITY; 81 79 82 80 serio_interrupt(ps2if->io, scancode, flag); 83 81 84 - status = sa1111_readl(ps2if->base + PS2STAT); 82 + status = readl_relaxed(ps2if->base + PS2STAT); 85 83 } 86 84 87 85 return IRQ_HANDLED; ··· 96 94 unsigned int status; 97 95 98 96 spin_lock(&ps2if->lock); 99 - status = sa1111_readl(ps2if->base + PS2STAT); 97 + status = readl_relaxed(ps2if->base + PS2STAT); 100 98 if (ps2if->head == ps2if->tail) { 101 99 disable_irq_nosync(irq); 102 100 /* done */ 103 101 } else if (status & PS2STAT_TXE) { 104 - sa1111_writel(ps2if->buf[ps2if->tail], ps2if->base + PS2DATA); 102 + writel_relaxed(ps2if->buf[ps2if->tail], ps2if->base + PS2DATA); 105 103 ps2if->tail = (ps2if->tail + 1) & (sizeof(ps2if->buf) - 1); 106 104 } 107 105 spin_unlock(&ps2if->lock); ··· 124 122 /* 125 123 * If the TX register is empty, we can go straight out. 126 124 */ 127 - if (sa1111_readl(ps2if->base + PS2STAT) & PS2STAT_TXE) { 128 - sa1111_writel(val, ps2if->base + PS2DATA); 125 + if (readl_relaxed(ps2if->base + PS2STAT) & PS2STAT_TXE) { 126 + writel_relaxed(val, ps2if->base + PS2DATA); 129 127 } else { 130 128 if (ps2if->head == ps2if->tail) 131 - enable_irq(ps2if->dev->irq[1]); 129 + enable_irq(ps2if->tx_irq); 132 130 head = (ps2if->head + 1) & (sizeof(ps2if->buf) - 1); 133 131 if (head != ps2if->tail) { 134 132 ps2if->buf[ps2if->head] = val; ··· 149 147 if (ret) 150 148 return ret; 151 149 152 - ret = request_irq(ps2if->dev->irq[0], ps2_rxint, 0, 150 + ret = request_irq(ps2if->rx_irq, ps2_rxint, 0, 153 151 SA1111_DRIVER_NAME(ps2if->dev), ps2if); 154 152 if (ret) { 155 153 printk(KERN_ERR "sa1111ps2: could not allocate IRQ%d: %d\n", 156 - ps2if->dev->irq[0], ret); 154 + ps2if->rx_irq, ret); 157 155 sa1111_disable_device(ps2if->dev); 158 156 return ret; 159 157 } 160 158 161 - ret = request_irq(ps2if->dev->irq[1], ps2_txint, 0, 159 + ret = request_irq(ps2if->tx_irq, ps2_txint, 0, 162 160 SA1111_DRIVER_NAME(ps2if->dev), ps2if); 163 161 if (ret) { 164 162 printk(KERN_ERR "sa1111ps2: could not allocate IRQ%d: %d\n", 165 - ps2if->dev->irq[1], ret); 166 - free_irq(ps2if->dev->irq[0], ps2if); 163 + ps2if->tx_irq, ret); 164 + free_irq(ps2if->rx_irq, ps2if); 167 165 sa1111_disable_device(ps2if->dev); 168 166 return ret; 169 167 } 170 168 171 169 ps2if->open = 1; 172 170 173 - enable_irq_wake(ps2if->dev->irq[0]); 171 + enable_irq_wake(ps2if->rx_irq); 174 172 175 - sa1111_writel(PS2CR_ENA, ps2if->base + PS2CR); 173 + writel_relaxed(PS2CR_ENA, ps2if->base + PS2CR); 176 174 return 0; 177 175 } 178 176 ··· 180 178 { 181 179 struct ps2if *ps2if = io->port_data; 182 180 183 - sa1111_writel(0, ps2if->base + PS2CR); 181 + writel_relaxed(0, ps2if->base + PS2CR); 184 182 185 - disable_irq_wake(ps2if->dev->irq[0]); 183 + disable_irq_wake(ps2if->rx_irq); 186 184 187 185 ps2if->open = 0; 188 186 189 - free_irq(ps2if->dev->irq[1], ps2if); 190 - free_irq(ps2if->dev->irq[0], ps2if); 187 + free_irq(ps2if->tx_irq, ps2if); 188 + free_irq(ps2if->rx_irq, ps2if); 191 189 192 190 sa1111_disable_device(ps2if->dev); 193 191 } ··· 200 198 int maxread = 100; 201 199 202 200 while (maxread--) { 203 - if ((sa1111_readl(ps2if->base + PS2DATA) & 0xff) == 0xff) 201 + if ((readl_relaxed(ps2if->base + PS2DATA) & 0xff) == 0xff) 204 202 break; 205 203 } 206 204 } ··· 210 208 { 211 209 unsigned int val; 212 210 213 - sa1111_writel(PS2CR_ENA | mask, ps2if->base + PS2CR); 211 + writel_relaxed(PS2CR_ENA | mask, ps2if->base + PS2CR); 214 212 215 - udelay(2); 213 + udelay(10); 216 214 217 - val = sa1111_readl(ps2if->base + PS2STAT); 215 + val = readl_relaxed(ps2if->base + PS2STAT); 218 216 return val & (PS2STAT_KBC | PS2STAT_KBD); 219 217 } 220 218 ··· 245 243 ret = -ENODEV; 246 244 } 247 245 248 - sa1111_writel(0, ps2if->base + PS2CR); 246 + writel_relaxed(0, ps2if->base + PS2CR); 249 247 250 248 return ret; 251 249 } ··· 266 264 goto free; 267 265 } 268 266 269 - 270 267 serio->id.type = SERIO_8042; 271 268 serio->write = ps2_write; 272 269 serio->open = ps2_open; ··· 279 278 sa1111_set_drvdata(dev, ps2if); 280 279 281 280 spin_lock_init(&ps2if->lock); 281 + 282 + ps2if->rx_irq = sa1111_get_irq(dev, 0); 283 + if (ps2if->rx_irq <= 0) { 284 + ret = ps2if->rx_irq ? : -ENXIO; 285 + goto free; 286 + } 287 + 288 + ps2if->tx_irq = sa1111_get_irq(dev, 1); 289 + if (ps2if->tx_irq <= 0) { 290 + ret = ps2if->tx_irq ? : -ENXIO; 291 + goto free; 292 + } 282 293 283 294 /* 284 295 * Request the physical region for this PS2 port. ··· 310 297 sa1111_enable_device(ps2if->dev); 311 298 312 299 /* Incoming clock is 8MHz */ 313 - sa1111_writel(0, ps2if->base + PS2CLKDIV); 314 - sa1111_writel(127, ps2if->base + PS2PRECNT); 300 + writel_relaxed(0, ps2if->base + PS2CLKDIV); 301 + writel_relaxed(127, ps2if->base + PS2PRECNT); 315 302 316 303 /* 317 304 * Flush any pending input.
+33 -1
drivers/input/touchscreen/Kconfig
··· 316 316 To compile this driver as a module, choose M here: the 317 317 module will be called egalax_ts_serial. 318 318 319 + config TOUCHSCREEN_EXC3000 320 + tristate "EETI EXC3000 multi-touch panel support" 321 + depends on I2C 322 + help 323 + Say Y here to enable support for I2C connected EETI 324 + EXC3000 multi-touch panels. 325 + 326 + To compile this driver as a module, choose M here: the 327 + module will be called exc3000. 328 + 319 329 config TOUCHSCREEN_FUJITSU 320 330 tristate "Fujitsu serial touchscreen" 321 331 select SERIO ··· 353 343 354 344 To compile this driver as a module, choose M here: the 355 345 module will be called goodix. 346 + 347 + config TOUCHSCREEN_HIDEEP 348 + tristate "HiDeep Touch IC" 349 + depends on I2C 350 + help 351 + Say Y here if you have a touchscreen using HiDeep. 352 + 353 + If unsure, say N. 354 + 355 + To compile this driver as a moudle, choose M here : the 356 + module will be called hideep_ts. 356 357 357 358 config TOUCHSCREEN_ILI210X 358 359 tristate "Ilitek ILI210X based touchscreen" ··· 403 382 404 383 To compile this driver as a module, choose M here: the 405 384 module will be called s3c2410_ts. 385 + 386 + config TOUCHSCREEN_S6SY761 387 + tristate "Samsung S6SY761 Touchscreen driver" 388 + depends on I2C 389 + help 390 + Say Y if you have the Samsung S6SY761 driver 391 + 392 + If unsure, say N 393 + 394 + To compile this driver as module, choose M here: the 395 + module will be called s6sy761. 406 396 407 397 config TOUCHSCREEN_GUNZE 408 398 tristate "Gunze AHL-51S touchscreen" ··· 981 949 982 950 config TOUCHSCREEN_USB_EASYTOUCH 983 951 default y 984 - bool "EasyTouch USB Touch controller device support" if EMBEDDED 952 + bool "EasyTouch USB Touch controller device support" if EXPERT 985 953 depends on TOUCHSCREEN_USB_COMPOSITE 986 954 help 987 955 Say Y here if you have an EasyTouch USB Touch controller.
+3
drivers/input/touchscreen/Makefile
··· 38 38 obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o 39 39 obj-$(CONFIG_TOUCHSCREEN_EGALAX) += egalax_ts.o 40 40 obj-$(CONFIG_TOUCHSCREEN_EGALAX_SERIAL) += egalax_ts_serial.o 41 + obj-$(CONFIG_TOUCHSCREEN_EXC3000) += exc3000.o 41 42 obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o 42 43 obj-$(CONFIG_TOUCHSCREEN_GOODIX) += goodix.o 44 + obj-$(CONFIG_TOUCHSCREEN_HIDEEP) += hideep.o 43 45 obj-$(CONFIG_TOUCHSCREEN_ILI210X) += ili210x.o 44 46 obj-$(CONFIG_TOUCHSCREEN_IMX6UL_TSC) += imx6ul_tsc.o 45 47 obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o ··· 67 65 obj-$(CONFIG_TOUCHSCREEN_PIXCIR) += pixcir_i2c_ts.o 68 66 obj-$(CONFIG_TOUCHSCREEN_RM_TS) += raydium_i2c_ts.o 69 67 obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o 68 + obj-$(CONFIG_TOUCHSCREEN_S6SY761) += s6sy761.o 70 69 obj-$(CONFIG_TOUCHSCREEN_SILEAD) += silead.o 71 70 obj-$(CONFIG_TOUCHSCREEN_SIS_I2C) += sis_i2c.o 72 71 obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o
+3 -3
drivers/input/touchscreen/ad7877.c
··· 385 385 input_sync(input_dev); 386 386 } 387 387 388 - static void ad7877_timer(unsigned long handle) 388 + static void ad7877_timer(struct timer_list *t) 389 389 { 390 - struct ad7877 *ts = (void *)handle; 390 + struct ad7877 *ts = from_timer(ts, t, timer); 391 391 unsigned long flags; 392 392 393 393 spin_lock_irqsave(&ts->lock, flags); ··· 718 718 ts->spi = spi; 719 719 ts->input = input_dev; 720 720 721 - setup_timer(&ts->timer, ad7877_timer, (unsigned long) ts); 721 + timer_setup(&ts->timer, ad7877_timer, 0); 722 722 mutex_init(&ts->mutex); 723 723 spin_lock_init(&ts->lock); 724 724
+4 -15
drivers/input/touchscreen/ad7879.c
··· 237 237 input_sync(input_dev); 238 238 } 239 239 240 - static void ad7879_timer(unsigned long handle) 240 + static void ad7879_timer(struct timer_list *t) 241 241 { 242 - struct ad7879 *ts = (void *)handle; 242 + struct ad7879 *ts = from_timer(ts, t, timer); 243 243 244 244 ad7879_ts_event_release(ts); 245 245 } ··· 524 524 return 0; 525 525 } 526 526 527 - static void ad7879_cleanup_sysfs(void *_ts) 528 - { 529 - struct ad7879 *ts = _ts; 530 - 531 - sysfs_remove_group(&ts->dev->kobj, &ad7879_attr_group); 532 - } 533 - 534 527 int ad7879_probe(struct device *dev, struct regmap *regmap, 535 528 int irq, u16 bustype, u8 devid) 536 529 { ··· 570 577 ts->irq = irq; 571 578 ts->regmap = regmap; 572 579 573 - setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts); 580 + timer_setup(&ts->timer, ad7879_timer, 0); 574 581 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev)); 575 582 576 583 input_dev->name = "AD7879 Touchscreen"; ··· 651 658 652 659 __ad7879_disable(ts); 653 660 654 - err = sysfs_create_group(&dev->kobj, &ad7879_attr_group); 655 - if (err) 656 - return err; 657 - 658 - err = devm_add_action_or_reset(dev, ad7879_cleanup_sysfs, ts); 661 + err = devm_device_add_group(dev, &ad7879_attr_group); 659 662 if (err) 660 663 return err; 661 664
+6 -4
drivers/input/touchscreen/atmel-wm97xx.c
··· 208 208 } 209 209 } 210 210 211 - static void atmel_wm97xx_pen_timer(unsigned long data) 211 + static void atmel_wm97xx_pen_timer(struct timer_list *t) 212 212 { 213 - atmel_wm97xx_acc_pen_up((struct wm97xx *)data); 213 + struct atmel_wm97xx *atmel_wm97xx = from_timer(atmel_wm97xx, t, 214 + pen_timer); 215 + 216 + atmel_wm97xx_acc_pen_up(atmel_wm97xx->wm); 214 217 } 215 218 216 219 static int atmel_wm97xx_acc_startup(struct wm97xx *wm) ··· 351 348 atmel_wm97xx->gpio_pen = atmel_gpio_line; 352 349 atmel_wm97xx->gpio_irq = gpio_to_irq(atmel_wm97xx->gpio_pen); 353 350 354 - setup_timer(&atmel_wm97xx->pen_timer, atmel_wm97xx_pen_timer, 355 - (unsigned long)wm); 351 + timer_setup(&atmel_wm97xx->pen_timer, atmel_wm97xx_pen_timer, 0); 356 352 357 353 ret = request_irq(atmel_wm97xx->ac97c_irq, 358 354 atmel_wm97xx_channel_b_interrupt,
+43 -16
drivers/input/touchscreen/cyttsp4_core.c
··· 201 201 void *p; 202 202 int rc; 203 203 204 + if (si->si_ofs.test_ofs <= si->si_ofs.cydata_ofs) { 205 + dev_err(cd->dev, 206 + "%s: invalid offset test_ofs: %zu, cydata_ofs: %zu\n", 207 + __func__, si->si_ofs.test_ofs, si->si_ofs.cydata_ofs); 208 + return -EINVAL; 209 + } 210 + 204 211 si->si_ofs.cydata_size = si->si_ofs.test_ofs - si->si_ofs.cydata_ofs; 205 212 dev_dbg(cd->dev, "%s: cydata size: %zd\n", __func__, 206 213 si->si_ofs.cydata_size); 207 214 208 215 p = krealloc(si->si_ptrs.cydata, si->si_ofs.cydata_size, GFP_KERNEL); 209 216 if (p == NULL) { 210 - dev_err(cd->dev, "%s: fail alloc cydata memory\n", __func__); 217 + dev_err(cd->dev, "%s: failed to allocate cydata memory\n", 218 + __func__); 211 219 return -ENOMEM; 212 220 } 213 221 si->si_ptrs.cydata = p; ··· 278 270 void *p; 279 271 int rc; 280 272 273 + if (si->si_ofs.pcfg_ofs <= si->si_ofs.test_ofs) { 274 + dev_err(cd->dev, 275 + "%s: invalid offset pcfg_ofs: %zu, test_ofs: %zu\n", 276 + __func__, si->si_ofs.pcfg_ofs, si->si_ofs.test_ofs); 277 + return -EINVAL; 278 + } 279 + 281 280 si->si_ofs.test_size = si->si_ofs.pcfg_ofs - si->si_ofs.test_ofs; 282 281 283 282 p = krealloc(si->si_ptrs.test, si->si_ofs.test_size, GFP_KERNEL); 284 283 if (p == NULL) { 285 - dev_err(cd->dev, "%s: fail alloc test memory\n", __func__); 284 + dev_err(cd->dev, "%s: failed to allocate test memory\n", 285 + __func__); 286 286 return -ENOMEM; 287 287 } 288 288 si->si_ptrs.test = p; ··· 337 321 void *p; 338 322 int rc; 339 323 324 + if (si->si_ofs.opcfg_ofs <= si->si_ofs.pcfg_ofs) { 325 + dev_err(cd->dev, 326 + "%s: invalid offset opcfg_ofs: %zu, pcfg_ofs: %zu\n", 327 + __func__, si->si_ofs.opcfg_ofs, si->si_ofs.pcfg_ofs); 328 + return -EINVAL; 329 + } 330 + 340 331 si->si_ofs.pcfg_size = si->si_ofs.opcfg_ofs - si->si_ofs.pcfg_ofs; 341 332 342 333 p = krealloc(si->si_ptrs.pcfg, si->si_ofs.pcfg_size, GFP_KERNEL); 343 334 if (p == NULL) { 344 - rc = -ENOMEM; 345 - dev_err(cd->dev, "%s: fail alloc pcfg memory r=%d\n", 346 - __func__, rc); 347 - return rc; 335 + dev_err(cd->dev, "%s: failed to allocate pcfg memory\n", 336 + __func__); 337 + return -ENOMEM; 348 338 } 349 339 si->si_ptrs.pcfg = p; 350 340 ··· 389 367 void *p; 390 368 int rc; 391 369 370 + if (si->si_ofs.ddata_ofs <= si->si_ofs.opcfg_ofs) { 371 + dev_err(cd->dev, 372 + "%s: invalid offset ddata_ofs: %zu, opcfg_ofs: %zu\n", 373 + __func__, si->si_ofs.ddata_ofs, si->si_ofs.opcfg_ofs); 374 + return -EINVAL; 375 + } 376 + 392 377 si->si_ofs.opcfg_size = si->si_ofs.ddata_ofs - si->si_ofs.opcfg_ofs; 393 378 394 379 p = krealloc(si->si_ptrs.opcfg, si->si_ofs.opcfg_size, GFP_KERNEL); 395 380 if (p == NULL) { 396 - dev_err(cd->dev, "%s: fail alloc opcfg memory\n", __func__); 397 - rc = -ENOMEM; 398 - goto cyttsp4_si_get_opcfg_data_exit; 381 + dev_err(cd->dev, "%s: failed to allocate opcfg memory\n", 382 + __func__); 383 + return -ENOMEM; 399 384 } 400 385 si->si_ptrs.opcfg = p; 401 386 ··· 411 382 if (rc < 0) { 412 383 dev_err(cd->dev, "%s: fail read opcfg data r=%d\n", 413 384 __func__, rc); 414 - goto cyttsp4_si_get_opcfg_data_exit; 385 + return rc; 415 386 } 416 387 si->si_ofs.cmd_ofs = si->si_ptrs.opcfg->cmd_ofs; 417 388 si->si_ofs.rep_ofs = si->si_ptrs.opcfg->rep_ofs; ··· 476 447 cyttsp4_pr_buf(cd->dev, cd->pr_buf, (u8 *)si->si_ptrs.opcfg, 477 448 si->si_ofs.opcfg_size, "sysinfo_opcfg_data"); 478 449 479 - cyttsp4_si_get_opcfg_data_exit: 480 - return rc; 450 + return 0; 481 451 } 482 452 483 453 static int cyttsp4_si_get_ddata(struct cyttsp4 *cd) ··· 1265 1237 del_timer_sync(&cd->watchdog_timer); 1266 1238 } 1267 1239 1268 - static void cyttsp4_watchdog_timer(unsigned long handle) 1240 + static void cyttsp4_watchdog_timer(struct timer_list *t) 1269 1241 { 1270 - struct cyttsp4 *cd = (struct cyttsp4 *)handle; 1242 + struct cyttsp4 *cd = from_timer(cd, t, watchdog_timer); 1271 1243 1272 1244 dev_vdbg(cd->dev, "%s: Watchdog timer triggered\n", __func__); 1273 1245 ··· 2102 2074 } 2103 2075 2104 2076 /* Setup watchdog timer */ 2105 - setup_timer(&cd->watchdog_timer, cyttsp4_watchdog_timer, 2106 - (unsigned long)cd); 2077 + timer_setup(&cd->watchdog_timer, cyttsp4_watchdog_timer, 0); 2107 2078 2108 2079 /* 2109 2080 * call startup directly to ensure that the device
+130 -43
drivers/input/touchscreen/edt-ft5x06.c
··· 70 70 #define EDT_RAW_DATA_DELAY 1000 /* usec */ 71 71 72 72 enum edt_ver { 73 - M06, 74 - M09, 73 + EDT_M06, 74 + EDT_M09, 75 + EDT_M12, 76 + GENERIC_FT, 75 77 }; 76 78 77 79 struct edt_reg_addr { ··· 181 179 int error; 182 180 183 181 switch (tsdata->version) { 184 - case M06: 182 + case EDT_M06: 185 183 cmd = 0xf9; /* tell the controller to send touch data */ 186 184 offset = 5; /* where the actual touch data starts */ 187 185 tplen = 4; /* data comes in so called frames */ 188 186 crclen = 1; /* length of the crc data */ 189 187 break; 190 188 191 - case M09: 189 + case EDT_M09: 190 + case EDT_M12: 191 + case GENERIC_FT: 192 192 cmd = 0x0; 193 193 offset = 3; 194 194 tplen = 6; ··· 213 209 goto out; 214 210 } 215 211 216 - /* M09 does not send header or CRC */ 217 - if (tsdata->version == M06) { 212 + /* M09/M12 does not send header or CRC */ 213 + if (tsdata->version == EDT_M06) { 218 214 if (rdbuf[0] != 0xaa || rdbuf[1] != 0xaa || 219 215 rdbuf[2] != datalen) { 220 216 dev_err_ratelimited(dev, ··· 237 233 continue; 238 234 239 235 /* M06 sometimes sends bogus coordinates in TOUCH_DOWN */ 240 - if (tsdata->version == M06 && type == TOUCH_EVENT_DOWN) 236 + if (tsdata->version == EDT_M06 && type == TOUCH_EVENT_DOWN) 241 237 continue; 242 238 243 239 x = ((buf[0] << 8) | buf[1]) & 0x0fff; ··· 268 264 u8 wrbuf[4]; 269 265 270 266 switch (tsdata->version) { 271 - case M06: 267 + case EDT_M06: 272 268 wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc; 273 269 wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f; 274 270 wrbuf[2] = value; 275 271 wrbuf[3] = wrbuf[0] ^ wrbuf[1] ^ wrbuf[2]; 276 272 return edt_ft5x06_ts_readwrite(tsdata->client, 4, 277 273 wrbuf, 0, NULL); 278 - case M09: 274 + case EDT_M09: 275 + case EDT_M12: 276 + case GENERIC_FT: 279 277 wrbuf[0] = addr; 280 278 wrbuf[1] = value; 281 279 ··· 296 290 int error; 297 291 298 292 switch (tsdata->version) { 299 - case M06: 293 + case EDT_M06: 300 294 wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc; 301 295 wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f; 302 296 wrbuf[1] |= tsdata->factory_mode ? 0x80 : 0x40; ··· 315 309 } 316 310 break; 317 311 318 - case M09: 312 + case EDT_M09: 313 + case EDT_M12: 314 + case GENERIC_FT: 319 315 wrbuf[0] = addr; 320 316 error = edt_ft5x06_ts_readwrite(tsdata->client, 1, 321 317 wrbuf, 1, rdbuf); ··· 376 368 } 377 369 378 370 switch (tsdata->version) { 379 - case M06: 371 + case EDT_M06: 380 372 addr = attr->addr_m06; 381 373 break; 382 374 383 - case M09: 375 + case EDT_M09: 376 + case EDT_M12: 377 + case GENERIC_FT: 384 378 addr = attr->addr_m09; 385 379 break; 386 380 ··· 447 437 } 448 438 449 439 switch (tsdata->version) { 450 - case M06: 440 + case EDT_M06: 451 441 addr = attr->addr_m06; 452 442 break; 453 443 454 - case M09: 444 + case EDT_M09: 445 + case EDT_M12: 446 + case GENERIC_FT: 455 447 addr = attr->addr_m09; 456 448 break; 457 449 ··· 478 466 return error ?: count; 479 467 } 480 468 469 + /* m06, m09: range 0-31, m12: range 0-5 */ 481 470 static EDT_ATTR(gain, S_IWUSR | S_IRUGO, WORK_REGISTER_GAIN, 482 471 M09_REGISTER_GAIN, 0, 31); 472 + /* m06, m09: range 0-31, m12: range 0-16 */ 483 473 static EDT_ATTR(offset, S_IWUSR | S_IRUGO, WORK_REGISTER_OFFSET, 484 474 M09_REGISTER_OFFSET, 0, 31); 475 + /* m06: range 20 to 80, m09: range 0 to 30, m12: range 1 to 255... */ 485 476 static EDT_ATTR(threshold, S_IWUSR | S_IRUGO, WORK_REGISTER_THRESHOLD, 486 - M09_REGISTER_THRESHOLD, 0, 80); 477 + M09_REGISTER_THRESHOLD, 0, 255); 478 + /* m06: range 3 to 14, m12: (0x64: 100Hz) */ 487 479 static EDT_ATTR(report_rate, S_IWUSR | S_IRUGO, WORK_REGISTER_REPORT_RATE, 488 - NO_REGISTER, 3, 14); 480 + NO_REGISTER, 0, 255); 489 481 490 482 static struct attribute *edt_ft5x06_attrs[] = { 491 483 &edt_ft5x06_attr_gain.dattr.attr, ··· 524 508 } 525 509 526 510 /* mode register is 0x3c when in the work mode */ 527 - if (tsdata->version == M09) 511 + if (tsdata->version != EDT_M06) 528 512 goto m09_out; 529 513 530 514 error = edt_ft5x06_register_write(tsdata, WORK_REGISTER_OPMODE, 0x03); ··· 561 545 return error; 562 546 563 547 m09_out: 564 - dev_err(&client->dev, "No factory mode support for M09\n"); 548 + dev_err(&client->dev, "No factory mode support for M09/M12/GENERIC_FT\n"); 565 549 return -EINVAL; 566 550 567 551 } ··· 786 770 * to have garbage in there 787 771 */ 788 772 memset(rdbuf, 0, sizeof(rdbuf)); 789 - error = edt_ft5x06_ts_readwrite(client, 1, "\xbb", 773 + error = edt_ft5x06_ts_readwrite(client, 1, "\xBB", 790 774 EDT_NAME_LEN - 1, rdbuf); 791 775 if (error) 792 776 return error; 793 777 794 - /* if we find something consistent, stay with that assumption 795 - * at least M09 won't send 3 bytes here 778 + /* Probe content for something consistent. 779 + * M06 starts with a response byte, M12 gives the data directly. 780 + * M09/Generic does not provide model number information. 796 781 */ 797 - if (!(strncasecmp(rdbuf + 1, "EP0", 3))) { 798 - tsdata->version = M06; 782 + if (!strncasecmp(rdbuf + 1, "EP0", 3)) { 783 + tsdata->version = EDT_M06; 799 784 800 785 /* remove last '$' end marker */ 801 786 rdbuf[EDT_NAME_LEN - 1] = '\0'; ··· 809 792 *p++ = '\0'; 810 793 strlcpy(model_name, rdbuf + 1, EDT_NAME_LEN); 811 794 strlcpy(fw_version, p ? p : "", EDT_NAME_LEN); 795 + } else if (!strncasecmp(rdbuf, "EP0", 3)) { 796 + tsdata->version = EDT_M12; 797 + 798 + /* remove last '$' end marker */ 799 + rdbuf[EDT_NAME_LEN - 2] = '\0'; 800 + if (rdbuf[EDT_NAME_LEN - 3] == '$') 801 + rdbuf[EDT_NAME_LEN - 3] = '\0'; 802 + 803 + /* look for Model/Version separator */ 804 + p = strchr(rdbuf, '*'); 805 + if (p) 806 + *p++ = '\0'; 807 + strlcpy(model_name, rdbuf, EDT_NAME_LEN); 808 + strlcpy(fw_version, p ? p : "", EDT_NAME_LEN); 812 809 } else { 813 - /* since there are only two versions around (M06, M09) */ 814 - tsdata->version = M09; 810 + /* If it is not an EDT M06/M12 touchscreen, then the model 811 + * detection is a bit hairy. The different ft5x06 812 + * firmares around don't reliably implement the 813 + * identification registers. Well, we'll take a shot. 814 + * 815 + * The main difference between generic focaltec based 816 + * touches and EDT M09 is that we know how to retrieve 817 + * the max coordinates for the latter. 818 + */ 819 + tsdata->version = GENERIC_FT; 815 820 816 821 error = edt_ft5x06_ts_readwrite(client, 1, "\xA6", 817 822 2, rdbuf); ··· 847 808 if (error) 848 809 return error; 849 810 850 - snprintf(model_name, EDT_NAME_LEN, "EP0%i%i0M09", 851 - rdbuf[0] >> 4, rdbuf[0] & 0x0F); 811 + /* This "model identification" is not exact. Unfortunately 812 + * not all firmwares for the ft5x06 put useful values in 813 + * the identification registers. 814 + */ 815 + switch (rdbuf[0]) { 816 + case 0x35: /* EDT EP0350M09 */ 817 + case 0x43: /* EDT EP0430M09 */ 818 + case 0x50: /* EDT EP0500M09 */ 819 + case 0x57: /* EDT EP0570M09 */ 820 + case 0x70: /* EDT EP0700M09 */ 821 + tsdata->version = EDT_M09; 822 + snprintf(model_name, EDT_NAME_LEN, "EP0%i%i0M09", 823 + rdbuf[0] >> 4, rdbuf[0] & 0x0F); 824 + break; 825 + case 0xa1: /* EDT EP1010ML00 */ 826 + tsdata->version = EDT_M09; 827 + snprintf(model_name, EDT_NAME_LEN, "EP%i%i0ML00", 828 + rdbuf[0] >> 4, rdbuf[0] & 0x0F); 829 + break; 830 + case 0x5a: /* Solomon Goldentek Display */ 831 + snprintf(model_name, EDT_NAME_LEN, "GKTW50SCED1R0"); 832 + break; 833 + default: 834 + snprintf(model_name, EDT_NAME_LEN, 835 + "generic ft5x06 (%02x)", 836 + rdbuf[0]); 837 + break; 838 + } 852 839 } 853 840 854 841 return 0; ··· 918 853 if (reg_addr->reg_report_rate != NO_REGISTER) 919 854 tsdata->report_rate = edt_ft5x06_register_read(tsdata, 920 855 reg_addr->reg_report_rate); 921 - tsdata->num_x = edt_ft5x06_register_read(tsdata, reg_addr->reg_num_x); 922 - tsdata->num_y = edt_ft5x06_register_read(tsdata, reg_addr->reg_num_y); 856 + if (tsdata->version == EDT_M06 || 857 + tsdata->version == EDT_M09 || 858 + tsdata->version == EDT_M12) { 859 + tsdata->num_x = edt_ft5x06_register_read(tsdata, 860 + reg_addr->reg_num_x); 861 + tsdata->num_y = edt_ft5x06_register_read(tsdata, 862 + reg_addr->reg_num_y); 863 + } else { 864 + tsdata->num_x = -1; 865 + tsdata->num_y = -1; 866 + } 923 867 } 924 868 925 869 static void ··· 937 863 struct edt_reg_addr *reg_addr = &tsdata->reg_addr; 938 864 939 865 switch (tsdata->version) { 940 - case M06: 866 + case EDT_M06: 941 867 reg_addr->reg_threshold = WORK_REGISTER_THRESHOLD; 942 868 reg_addr->reg_report_rate = WORK_REGISTER_REPORT_RATE; 943 869 reg_addr->reg_gain = WORK_REGISTER_GAIN; ··· 946 872 reg_addr->reg_num_y = WORK_REGISTER_NUM_Y; 947 873 break; 948 874 949 - case M09: 875 + case EDT_M09: 876 + case EDT_M12: 950 877 reg_addr->reg_threshold = M09_REGISTER_THRESHOLD; 951 878 reg_addr->reg_report_rate = NO_REGISTER; 952 879 reg_addr->reg_gain = M09_REGISTER_GAIN; 953 880 reg_addr->reg_offset = M09_REGISTER_OFFSET; 954 881 reg_addr->reg_num_x = M09_REGISTER_NUM_X; 955 882 reg_addr->reg_num_y = M09_REGISTER_NUM_Y; 883 + break; 884 + 885 + case GENERIC_FT: 886 + /* this is a guesswork */ 887 + reg_addr->reg_threshold = M09_REGISTER_THRESHOLD; 888 + reg_addr->reg_gain = M09_REGISTER_GAIN; 889 + reg_addr->reg_offset = M09_REGISTER_OFFSET; 956 890 break; 957 891 } 958 892 } ··· 1051 969 input->id.bustype = BUS_I2C; 1052 970 input->dev.parent = &client->dev; 1053 971 1054 - input_set_abs_params(input, ABS_MT_POSITION_X, 1055 - 0, tsdata->num_x * 64 - 1, 0, 0); 1056 - input_set_abs_params(input, ABS_MT_POSITION_Y, 1057 - 0, tsdata->num_y * 64 - 1, 0, 0); 972 + if (tsdata->version == EDT_M06 || 973 + tsdata->version == EDT_M09 || 974 + tsdata->version == EDT_M12) { 975 + input_set_abs_params(input, ABS_MT_POSITION_X, 976 + 0, tsdata->num_x * 64 - 1, 0, 0); 977 + input_set_abs_params(input, ABS_MT_POSITION_Y, 978 + 0, tsdata->num_y * 64 - 1, 0, 0); 979 + } else { 980 + /* Unknown maximum values. Specify via devicetree */ 981 + input_set_abs_params(input, ABS_MT_POSITION_X, 982 + 0, 65535, 0, 0); 983 + input_set_abs_params(input, ABS_MT_POSITION_Y, 984 + 0, 65535, 0, 0); 985 + } 1058 986 1059 987 touchscreen_parse_properties(input, true, &tsdata->prop); 1060 988 ··· 1090 998 return error; 1091 999 } 1092 1000 1093 - error = sysfs_create_group(&client->dev.kobj, &edt_ft5x06_attr_group); 1001 + error = devm_device_add_group(&client->dev, &edt_ft5x06_attr_group); 1094 1002 if (error) 1095 1003 return error; 1096 1004 1097 1005 error = input_register_device(input); 1098 1006 if (error) 1099 - goto err_remove_attrs; 1007 + return error; 1100 1008 1101 1009 edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev)); 1102 1010 device_init_wakeup(&client->dev, 1); ··· 1108 1016 tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); 1109 1017 1110 1018 return 0; 1111 - 1112 - err_remove_attrs: 1113 - sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group); 1114 - return error; 1115 1019 } 1116 1020 1117 1021 static int edt_ft5x06_ts_remove(struct i2c_client *client) ··· 1115 1027 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); 1116 1028 1117 1029 edt_ft5x06_ts_teardown_debugfs(tsdata); 1118 - sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group); 1119 1030 1120 1031 return 0; 1121 1032 }
+1 -18
drivers/input/touchscreen/elants_i2c.c
··· 1070 1070 .attrs = elants_attributes, 1071 1071 }; 1072 1072 1073 - static void elants_i2c_remove_sysfs_group(void *_data) 1074 - { 1075 - struct elants_data *ts = _data; 1076 - 1077 - sysfs_remove_group(&ts->client->dev.kobj, &elants_attribute_group); 1078 - } 1079 - 1080 1073 static int elants_i2c_power_on(struct elants_data *ts) 1081 1074 { 1082 1075 int error; ··· 1282 1289 if (!client->dev.of_node) 1283 1290 device_init_wakeup(&client->dev, true); 1284 1291 1285 - error = sysfs_create_group(&client->dev.kobj, &elants_attribute_group); 1292 + error = devm_device_add_group(&client->dev, &elants_attribute_group); 1286 1293 if (error) { 1287 1294 dev_err(&client->dev, "failed to create sysfs attributes: %d\n", 1288 - error); 1289 - return error; 1290 - } 1291 - 1292 - error = devm_add_action(&client->dev, 1293 - elants_i2c_remove_sysfs_group, ts); 1294 - if (error) { 1295 - elants_i2c_remove_sysfs_group(ts); 1296 - dev_err(&client->dev, 1297 - "Failed to add sysfs cleanup action: %d\n", 1298 1295 error); 1299 1296 return error; 1300 1297 }
+223
drivers/input/touchscreen/exc3000.c
··· 1 + /* 2 + * Driver for I2C connected EETI EXC3000 multiple touch controller 3 + * 4 + * Copyright (C) 2017 Ahmet Inan <inan@distec.de> 5 + * 6 + * minimal implementation based on egalax_ts.c and egalax_i2c.c 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + */ 12 + 13 + #include <linux/bitops.h> 14 + #include <linux/device.h> 15 + #include <linux/i2c.h> 16 + #include <linux/input.h> 17 + #include <linux/input/mt.h> 18 + #include <linux/input/touchscreen.h> 19 + #include <linux/interrupt.h> 20 + #include <linux/module.h> 21 + #include <linux/of.h> 22 + #include <linux/timer.h> 23 + #include <asm/unaligned.h> 24 + 25 + #define EXC3000_NUM_SLOTS 10 26 + #define EXC3000_SLOTS_PER_FRAME 5 27 + #define EXC3000_LEN_FRAME 66 28 + #define EXC3000_LEN_POINT 10 29 + #define EXC3000_MT_EVENT 6 30 + #define EXC3000_TIMEOUT_MS 100 31 + 32 + struct exc3000_data { 33 + struct i2c_client *client; 34 + struct input_dev *input; 35 + struct touchscreen_properties prop; 36 + struct timer_list timer; 37 + u8 buf[2 * EXC3000_LEN_FRAME]; 38 + }; 39 + 40 + static void exc3000_report_slots(struct input_dev *input, 41 + struct touchscreen_properties *prop, 42 + const u8 *buf, int num) 43 + { 44 + for (; num--; buf += EXC3000_LEN_POINT) { 45 + if (buf[0] & BIT(0)) { 46 + input_mt_slot(input, buf[1]); 47 + input_mt_report_slot_state(input, MT_TOOL_FINGER, true); 48 + touchscreen_report_pos(input, prop, 49 + get_unaligned_le16(buf + 2), 50 + get_unaligned_le16(buf + 4), 51 + true); 52 + } 53 + } 54 + } 55 + 56 + static void exc3000_timer(struct timer_list *t) 57 + { 58 + struct exc3000_data *data = from_timer(data, t, timer); 59 + 60 + input_mt_sync_frame(data->input); 61 + input_sync(data->input); 62 + } 63 + 64 + static int exc3000_read_frame(struct i2c_client *client, u8 *buf) 65 + { 66 + int ret; 67 + 68 + ret = i2c_master_send(client, "'", 2); 69 + if (ret < 0) 70 + return ret; 71 + 72 + if (ret != 2) 73 + return -EIO; 74 + 75 + ret = i2c_master_recv(client, buf, EXC3000_LEN_FRAME); 76 + if (ret < 0) 77 + return ret; 78 + 79 + if (ret != EXC3000_LEN_FRAME) 80 + return -EIO; 81 + 82 + if (get_unaligned_le16(buf) != EXC3000_LEN_FRAME || 83 + buf[2] != EXC3000_MT_EVENT) 84 + return -EINVAL; 85 + 86 + return 0; 87 + } 88 + 89 + static int exc3000_read_data(struct i2c_client *client, 90 + u8 *buf, int *n_slots) 91 + { 92 + int error; 93 + 94 + error = exc3000_read_frame(client, buf); 95 + if (error) 96 + return error; 97 + 98 + *n_slots = buf[3]; 99 + if (!*n_slots || *n_slots > EXC3000_NUM_SLOTS) 100 + return -EINVAL; 101 + 102 + if (*n_slots > EXC3000_SLOTS_PER_FRAME) { 103 + /* Read 2nd frame to get the rest of the contacts. */ 104 + error = exc3000_read_frame(client, buf + EXC3000_LEN_FRAME); 105 + if (error) 106 + return error; 107 + 108 + /* 2nd chunk must have number of contacts set to 0. */ 109 + if (buf[EXC3000_LEN_FRAME + 3] != 0) 110 + return -EINVAL; 111 + } 112 + 113 + return 0; 114 + } 115 + 116 + static irqreturn_t exc3000_interrupt(int irq, void *dev_id) 117 + { 118 + struct exc3000_data *data = dev_id; 119 + struct input_dev *input = data->input; 120 + u8 *buf = data->buf; 121 + int slots, total_slots; 122 + int error; 123 + 124 + error = exc3000_read_data(data->client, buf, &total_slots); 125 + if (error) { 126 + /* Schedule a timer to release "stuck" contacts */ 127 + mod_timer(&data->timer, 128 + jiffies + msecs_to_jiffies(EXC3000_TIMEOUT_MS)); 129 + goto out; 130 + } 131 + 132 + /* 133 + * We read full state successfully, no contacts will be "stuck". 134 + */ 135 + del_timer_sync(&data->timer); 136 + 137 + while (total_slots > 0) { 138 + slots = min(total_slots, EXC3000_SLOTS_PER_FRAME); 139 + exc3000_report_slots(input, &data->prop, buf + 4, slots); 140 + total_slots -= slots; 141 + buf += EXC3000_LEN_FRAME; 142 + } 143 + 144 + input_mt_sync_frame(input); 145 + input_sync(input); 146 + 147 + out: 148 + return IRQ_HANDLED; 149 + } 150 + 151 + static int exc3000_probe(struct i2c_client *client, 152 + const struct i2c_device_id *id) 153 + { 154 + struct exc3000_data *data; 155 + struct input_dev *input; 156 + int error; 157 + 158 + data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); 159 + if (!data) 160 + return -ENOMEM; 161 + 162 + data->client = client; 163 + timer_setup(&data->timer, exc3000_timer, 0); 164 + 165 + input = devm_input_allocate_device(&client->dev); 166 + if (!input) 167 + return -ENOMEM; 168 + 169 + data->input = input; 170 + 171 + input->name = "EETI EXC3000 Touch Screen"; 172 + input->id.bustype = BUS_I2C; 173 + 174 + input_set_abs_params(input, ABS_MT_POSITION_X, 0, 4095, 0, 0); 175 + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 4095, 0, 0); 176 + touchscreen_parse_properties(input, true, &data->prop); 177 + 178 + error = input_mt_init_slots(input, EXC3000_NUM_SLOTS, 179 + INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); 180 + if (error) 181 + return error; 182 + 183 + error = input_register_device(input); 184 + if (error) 185 + return error; 186 + 187 + error = devm_request_threaded_irq(&client->dev, client->irq, 188 + NULL, exc3000_interrupt, IRQF_ONESHOT, 189 + client->name, data); 190 + if (error) 191 + return error; 192 + 193 + return 0; 194 + } 195 + 196 + static const struct i2c_device_id exc3000_id[] = { 197 + { "exc3000", 0 }, 198 + { } 199 + }; 200 + MODULE_DEVICE_TABLE(i2c, exc3000_id); 201 + 202 + #ifdef CONFIG_OF 203 + static const struct of_device_id exc3000_of_match[] = { 204 + { .compatible = "eeti,exc3000" }, 205 + { } 206 + }; 207 + MODULE_DEVICE_TABLE(of, exc3000_of_match); 208 + #endif 209 + 210 + static struct i2c_driver exc3000_driver = { 211 + .driver = { 212 + .name = "exc3000", 213 + .of_match_table = of_match_ptr(exc3000_of_match), 214 + }, 215 + .id_table = exc3000_id, 216 + .probe = exc3000_probe, 217 + }; 218 + 219 + module_i2c_driver(exc3000_driver); 220 + 221 + MODULE_AUTHOR("Ahmet Inan <inan@distec.de>"); 222 + MODULE_DESCRIPTION("I2C connected EETI EXC3000 multiple touch controller driver"); 223 + MODULE_LICENSE("GPL v2");
+98 -27
drivers/input/touchscreen/goodix.c
··· 31 31 #include <linux/of.h> 32 32 #include <asm/unaligned.h> 33 33 34 + struct goodix_ts_data; 35 + 36 + struct goodix_chip_data { 37 + u16 config_addr; 38 + int config_len; 39 + int (*check_config)(struct goodix_ts_data *, const struct firmware *); 40 + }; 41 + 34 42 struct goodix_ts_data { 35 43 struct i2c_client *client; 36 44 struct input_dev *input_dev; 45 + const struct goodix_chip_data *chip; 37 46 int abs_x_max; 38 47 int abs_y_max; 39 48 bool swapped_x_y; ··· 50 41 bool inverted_y; 51 42 unsigned int max_touch_num; 52 43 unsigned int int_trigger_type; 53 - int cfg_len; 54 44 struct gpio_desc *gpiod_int; 55 45 struct gpio_desc *gpiod_rst; 56 46 u16 id; ··· 77 69 #define GOODIX_CMD_SCREEN_OFF 0x05 78 70 79 71 #define GOODIX_READ_COOR_ADDR 0x814E 80 - #define GOODIX_REG_CONFIG_DATA 0x8047 72 + #define GOODIX_GT1X_REG_CONFIG_DATA 0x8050 73 + #define GOODIX_GT9X_REG_CONFIG_DATA 0x8047 81 74 #define GOODIX_REG_ID 0x8140 82 75 83 76 #define GOODIX_BUFFER_STATUS_READY BIT(7) ··· 87 78 #define RESOLUTION_LOC 1 88 79 #define MAX_CONTACTS_LOC 5 89 80 #define TRIGGER_LOC 6 81 + 82 + static int goodix_check_cfg_8(struct goodix_ts_data *ts, 83 + const struct firmware *cfg); 84 + static int goodix_check_cfg_16(struct goodix_ts_data *ts, 85 + const struct firmware *cfg); 86 + 87 + static const struct goodix_chip_data gt1x_chip_data = { 88 + .config_addr = GOODIX_GT1X_REG_CONFIG_DATA, 89 + .config_len = GOODIX_CONFIG_MAX_LENGTH, 90 + .check_config = goodix_check_cfg_16, 91 + }; 92 + 93 + static const struct goodix_chip_data gt911_chip_data = { 94 + .config_addr = GOODIX_GT9X_REG_CONFIG_DATA, 95 + .config_len = GOODIX_CONFIG_911_LENGTH, 96 + .check_config = goodix_check_cfg_8, 97 + }; 98 + 99 + static const struct goodix_chip_data gt967_chip_data = { 100 + .config_addr = GOODIX_GT9X_REG_CONFIG_DATA, 101 + .config_len = GOODIX_CONFIG_967_LENGTH, 102 + .check_config = goodix_check_cfg_8, 103 + }; 104 + 105 + static const struct goodix_chip_data gt9x_chip_data = { 106 + .config_addr = GOODIX_GT9X_REG_CONFIG_DATA, 107 + .config_len = GOODIX_CONFIG_MAX_LENGTH, 108 + .check_config = goodix_check_cfg_8, 109 + }; 90 110 91 111 static const unsigned long goodix_irq_flags[] = { 92 112 IRQ_TYPE_EDGE_RISING, ··· 215 177 return goodix_i2c_write(client, reg, &value, sizeof(value)); 216 178 } 217 179 218 - static int goodix_get_cfg_len(u16 id) 180 + static const struct goodix_chip_data *goodix_get_chip_data(u16 id) 219 181 { 220 182 switch (id) { 183 + case 1151: 184 + return &gt1x_chip_data; 185 + 221 186 case 911: 222 187 case 9271: 223 188 case 9110: 224 189 case 927: 225 190 case 928: 226 - return GOODIX_CONFIG_911_LENGTH; 191 + return &gt911_chip_data; 227 192 228 193 case 912: 229 194 case 967: 230 - return GOODIX_CONFIG_967_LENGTH; 195 + return &gt967_chip_data; 231 196 232 197 default: 233 - return GOODIX_CONFIG_MAX_LENGTH; 198 + return &gt9x_chip_data; 234 199 } 235 200 } 236 201 ··· 373 332 ts->irq_flags, ts->client->name, ts); 374 333 } 375 334 376 - /** 377 - * goodix_check_cfg - Checks if config fw is valid 378 - * 379 - * @ts: goodix_ts_data pointer 380 - * @cfg: firmware config data 381 - */ 382 - static int goodix_check_cfg(struct goodix_ts_data *ts, 383 - const struct firmware *cfg) 335 + static int goodix_check_cfg_8(struct goodix_ts_data *ts, 336 + const struct firmware *cfg) 384 337 { 385 - int i, raw_cfg_len; 338 + int i, raw_cfg_len = cfg->size - 2; 386 339 u8 check_sum = 0; 387 340 388 - if (cfg->size > GOODIX_CONFIG_MAX_LENGTH) { 389 - dev_err(&ts->client->dev, 390 - "The length of the config fw is not correct"); 391 - return -EINVAL; 392 - } 393 - 394 - raw_cfg_len = cfg->size - 2; 395 341 for (i = 0; i < raw_cfg_len; i++) 396 342 check_sum += cfg->data[i]; 397 343 check_sum = (~check_sum) + 1; ··· 397 369 return 0; 398 370 } 399 371 372 + static int goodix_check_cfg_16(struct goodix_ts_data *ts, 373 + const struct firmware *cfg) 374 + { 375 + int i, raw_cfg_len = cfg->size - 3; 376 + u16 check_sum = 0; 377 + 378 + for (i = 0; i < raw_cfg_len; i += 2) 379 + check_sum += get_unaligned_be16(&cfg->data[i]); 380 + check_sum = (~check_sum) + 1; 381 + if (check_sum != get_unaligned_be16(&cfg->data[raw_cfg_len])) { 382 + dev_err(&ts->client->dev, 383 + "The checksum of the config fw is not correct"); 384 + return -EINVAL; 385 + } 386 + 387 + if (cfg->data[raw_cfg_len + 2] != 1) { 388 + dev_err(&ts->client->dev, 389 + "Config fw must have Config_Fresh register set"); 390 + return -EINVAL; 391 + } 392 + 393 + return 0; 394 + } 395 + 396 + /** 397 + * goodix_check_cfg - Checks if config fw is valid 398 + * 399 + * @ts: goodix_ts_data pointer 400 + * @cfg: firmware config data 401 + */ 402 + static int goodix_check_cfg(struct goodix_ts_data *ts, 403 + const struct firmware *cfg) 404 + { 405 + if (cfg->size > GOODIX_CONFIG_MAX_LENGTH) { 406 + dev_err(&ts->client->dev, 407 + "The length of the config fw is not correct"); 408 + return -EINVAL; 409 + } 410 + 411 + return ts->chip->check_config(ts, cfg); 412 + } 413 + 400 414 /** 401 415 * goodix_send_cfg - Write fw config to device 402 416 * ··· 454 384 if (error) 455 385 return error; 456 386 457 - error = goodix_i2c_write(ts->client, GOODIX_REG_CONFIG_DATA, cfg->data, 387 + error = goodix_i2c_write(ts->client, ts->chip->config_addr, cfg->data, 458 388 cfg->size); 459 389 if (error) { 460 390 dev_err(&ts->client->dev, "Failed to write config data: %d", ··· 581 511 u8 config[GOODIX_CONFIG_MAX_LENGTH]; 582 512 int error; 583 513 584 - error = goodix_i2c_read(ts->client, GOODIX_REG_CONFIG_DATA, 585 - config, ts->cfg_len); 514 + error = goodix_i2c_read(ts->client, ts->chip->config_addr, 515 + config, ts->chip->config_len); 586 516 if (error) { 587 517 dev_warn(&ts->client->dev, 588 518 "Error reading config (%d), using defaults\n", ··· 662 592 u8 test; 663 593 664 594 while (retry++ < 2) { 665 - error = goodix_i2c_read(client, GOODIX_REG_CONFIG_DATA, 595 + error = goodix_i2c_read(client, GOODIX_REG_ID, 666 596 &test, 1); 667 597 if (!error) 668 598 return 0; ··· 832 762 return error; 833 763 } 834 764 835 - ts->cfg_len = goodix_get_cfg_len(ts->id); 765 + ts->chip = goodix_get_chip_data(ts->id); 836 766 837 767 if (ts->gpiod_int && ts->gpiod_rst) { 838 768 /* update device config */ ··· 961 891 962 892 #ifdef CONFIG_OF 963 893 static const struct of_device_id goodix_of_match[] = { 894 + { .compatible = "goodix,gt1151" }, 964 895 { .compatible = "goodix,gt911" }, 965 896 { .compatible = "goodix,gt9110" }, 966 897 { .compatible = "goodix,gt912" },
+1120
drivers/input/touchscreen/hideep.c
··· 1 + /* 2 + * Copyright (C) 2012-2017 Hideep, Inc. 3 + * 4 + * This program is free software; you can redistribute it and/or modify it 5 + * under the terms of the GNU General Public License version 2 6 + * as published by the Free Software Foudation. 7 + */ 8 + 9 + #include <linux/module.h> 10 + #include <linux/of.h> 11 + #include <linux/firmware.h> 12 + #include <linux/delay.h> 13 + #include <linux/gpio.h> 14 + #include <linux/gpio/machine.h> 15 + #include <linux/i2c.h> 16 + #include <linux/acpi.h> 17 + #include <linux/interrupt.h> 18 + #include <linux/regmap.h> 19 + #include <linux/sysfs.h> 20 + #include <linux/input.h> 21 + #include <linux/input/mt.h> 22 + #include <linux/input/touchscreen.h> 23 + #include <linux/regulator/consumer.h> 24 + #include <asm/unaligned.h> 25 + 26 + #define HIDEEP_TS_NAME "HiDeep Touchscreen" 27 + #define HIDEEP_I2C_NAME "hideep_ts" 28 + 29 + #define HIDEEP_MT_MAX 10 30 + #define HIDEEP_KEY_MAX 3 31 + 32 + /* count(2) + touch data(100) + key data(6) */ 33 + #define HIDEEP_MAX_EVENT 108UL 34 + 35 + #define HIDEEP_TOUCH_EVENT_INDEX 2 36 + #define HIDEEP_KEY_EVENT_INDEX 102 37 + 38 + /* Touch & key event */ 39 + #define HIDEEP_EVENT_ADDR 0x240 40 + 41 + /* command list */ 42 + #define HIDEEP_RESET_CMD 0x9800 43 + 44 + /* event bit */ 45 + #define HIDEEP_MT_RELEASED BIT(4) 46 + #define HIDEEP_KEY_PRESSED BIT(7) 47 + #define HIDEEP_KEY_FIRST_PRESSED BIT(8) 48 + #define HIDEEP_KEY_PRESSED_MASK (HIDEEP_KEY_PRESSED | \ 49 + HIDEEP_KEY_FIRST_PRESSED) 50 + 51 + #define HIDEEP_KEY_IDX_MASK 0x0f 52 + 53 + /* For NVM */ 54 + #define HIDEEP_YRAM_BASE 0x40000000 55 + #define HIDEEP_PERIPHERAL_BASE 0x50000000 56 + #define HIDEEP_ESI_BASE (HIDEEP_PERIPHERAL_BASE + 0x00000000) 57 + #define HIDEEP_FLASH_BASE (HIDEEP_PERIPHERAL_BASE + 0x01000000) 58 + #define HIDEEP_SYSCON_BASE (HIDEEP_PERIPHERAL_BASE + 0x02000000) 59 + 60 + #define HIDEEP_SYSCON_MOD_CON (HIDEEP_SYSCON_BASE + 0x0000) 61 + #define HIDEEP_SYSCON_SPC_CON (HIDEEP_SYSCON_BASE + 0x0004) 62 + #define HIDEEP_SYSCON_CLK_CON (HIDEEP_SYSCON_BASE + 0x0008) 63 + #define HIDEEP_SYSCON_CLK_ENA (HIDEEP_SYSCON_BASE + 0x000C) 64 + #define HIDEEP_SYSCON_RST_CON (HIDEEP_SYSCON_BASE + 0x0010) 65 + #define HIDEEP_SYSCON_WDT_CON (HIDEEP_SYSCON_BASE + 0x0014) 66 + #define HIDEEP_SYSCON_WDT_CNT (HIDEEP_SYSCON_BASE + 0x0018) 67 + #define HIDEEP_SYSCON_PWR_CON (HIDEEP_SYSCON_BASE + 0x0020) 68 + #define HIDEEP_SYSCON_PGM_ID (HIDEEP_SYSCON_BASE + 0x00F4) 69 + 70 + #define HIDEEP_FLASH_CON (HIDEEP_FLASH_BASE + 0x0000) 71 + #define HIDEEP_FLASH_STA (HIDEEP_FLASH_BASE + 0x0004) 72 + #define HIDEEP_FLASH_CFG (HIDEEP_FLASH_BASE + 0x0008) 73 + #define HIDEEP_FLASH_TIM (HIDEEP_FLASH_BASE + 0x000C) 74 + #define HIDEEP_FLASH_CACHE_CFG (HIDEEP_FLASH_BASE + 0x0010) 75 + #define HIDEEP_FLASH_PIO_SIG (HIDEEP_FLASH_BASE + 0x400000) 76 + 77 + #define HIDEEP_ESI_TX_INVALID (HIDEEP_ESI_BASE + 0x0008) 78 + 79 + #define HIDEEP_PERASE 0x00040000 80 + #define HIDEEP_WRONLY 0x00100000 81 + 82 + #define HIDEEP_NVM_MASK_OFS 0x0000000C 83 + #define HIDEEP_NVM_DEFAULT_PAGE 0 84 + #define HIDEEP_NVM_SFR_WPAGE 1 85 + #define HIDEEP_NVM_SFR_RPAGE 2 86 + 87 + #define HIDEEP_PIO_SIG 0x00400000 88 + #define HIDEEP_PROT_MODE 0x03400000 89 + 90 + #define HIDEEP_NVM_PAGE_SIZE 128 91 + 92 + #define HIDEEP_DWZ_INFO 0x000002C0 93 + 94 + struct hideep_event { 95 + __le16 x; 96 + __le16 y; 97 + __le16 z; 98 + u8 w; 99 + u8 flag; 100 + u8 type; 101 + u8 index; 102 + }; 103 + 104 + struct dwz_info { 105 + __be32 code_start; 106 + u8 code_crc[12]; 107 + 108 + __be32 c_code_start; 109 + __be16 gen_ver; 110 + __be16 c_code_len; 111 + 112 + __be32 vr_start; 113 + __be16 rsv0; 114 + __be16 vr_len; 115 + 116 + __be32 ft_start; 117 + __be16 vr_version; 118 + __be16 ft_len; 119 + 120 + __be16 core_ver; 121 + __be16 boot_ver; 122 + 123 + __be16 release_ver; 124 + __be16 custom_ver; 125 + 126 + u8 factory_id; 127 + u8 panel_type; 128 + u8 model_name[6]; 129 + 130 + __be16 extra_option; 131 + __be16 product_code; 132 + 133 + __be16 vendor_id; 134 + __be16 product_id; 135 + }; 136 + 137 + struct pgm_packet { 138 + struct { 139 + u8 unused[3]; 140 + u8 len; 141 + __be32 addr; 142 + } header; 143 + __be32 payload[HIDEEP_NVM_PAGE_SIZE / sizeof(__be32)]; 144 + }; 145 + 146 + #define HIDEEP_XFER_BUF_SIZE sizeof(struct pgm_packet) 147 + 148 + struct hideep_ts { 149 + struct i2c_client *client; 150 + struct input_dev *input_dev; 151 + struct regmap *reg; 152 + 153 + struct touchscreen_properties prop; 154 + 155 + struct gpio_desc *reset_gpio; 156 + 157 + struct regulator *vcc_vdd; 158 + struct regulator *vcc_vid; 159 + 160 + struct mutex dev_mutex; 161 + 162 + u32 tch_count; 163 + u32 lpm_count; 164 + 165 + /* 166 + * Data buffer to read packet from the device (contacts and key 167 + * states). We align it on double-word boundary to keep word-sized 168 + * fields in contact data and double-word-sized fields in program 169 + * packet aligned. 170 + */ 171 + u8 xfer_buf[HIDEEP_XFER_BUF_SIZE] __aligned(4); 172 + 173 + int key_num; 174 + u32 key_codes[HIDEEP_KEY_MAX]; 175 + 176 + struct dwz_info dwz_info; 177 + 178 + unsigned int fw_size; 179 + u32 nvm_mask; 180 + }; 181 + 182 + static int hideep_pgm_w_mem(struct hideep_ts *ts, u32 addr, 183 + const __be32 *data, size_t count) 184 + { 185 + struct pgm_packet *packet = (void *)ts->xfer_buf; 186 + size_t len = count * sizeof(*data); 187 + struct i2c_msg msg = { 188 + .addr = ts->client->addr, 189 + .len = len + sizeof(packet->header.len) + 190 + sizeof(packet->header.addr), 191 + .buf = &packet->header.len, 192 + }; 193 + int ret; 194 + 195 + if (len > HIDEEP_NVM_PAGE_SIZE) 196 + return -EINVAL; 197 + 198 + packet->header.len = 0x80 | (count - 1); 199 + packet->header.addr = cpu_to_be32(addr); 200 + memcpy(packet->payload, data, len); 201 + 202 + ret = i2c_transfer(ts->client->adapter, &msg, 1); 203 + if (ret != 1) 204 + return ret < 0 ? ret : -EIO; 205 + 206 + return 0; 207 + } 208 + 209 + static int hideep_pgm_r_mem(struct hideep_ts *ts, u32 addr, 210 + __be32 *data, size_t count) 211 + { 212 + struct pgm_packet *packet = (void *)ts->xfer_buf; 213 + size_t len = count * sizeof(*data); 214 + struct i2c_msg msg[] = { 215 + { 216 + .addr = ts->client->addr, 217 + .len = sizeof(packet->header.len) + 218 + sizeof(packet->header.addr), 219 + .buf = &packet->header.len, 220 + }, 221 + { 222 + .addr = ts->client->addr, 223 + .flags = I2C_M_RD, 224 + .len = len, 225 + .buf = (u8 *)data, 226 + }, 227 + }; 228 + int ret; 229 + 230 + if (len > HIDEEP_NVM_PAGE_SIZE) 231 + return -EINVAL; 232 + 233 + packet->header.len = count - 1; 234 + packet->header.addr = cpu_to_be32(addr); 235 + 236 + ret = i2c_transfer(ts->client->adapter, msg, ARRAY_SIZE(msg)); 237 + if (ret != ARRAY_SIZE(msg)) 238 + return ret < 0 ? ret : -EIO; 239 + 240 + return 0; 241 + } 242 + 243 + static int hideep_pgm_r_reg(struct hideep_ts *ts, u32 addr, u32 *val) 244 + { 245 + __be32 data; 246 + int error; 247 + 248 + error = hideep_pgm_r_mem(ts, addr, &data, 1); 249 + if (error) { 250 + dev_err(&ts->client->dev, 251 + "read of register %#08x failed: %d\n", 252 + addr, error); 253 + return error; 254 + } 255 + 256 + *val = be32_to_cpu(data); 257 + return 0; 258 + } 259 + 260 + static int hideep_pgm_w_reg(struct hideep_ts *ts, u32 addr, u32 val) 261 + { 262 + __be32 data = cpu_to_be32(val); 263 + int error; 264 + 265 + error = hideep_pgm_w_mem(ts, addr, &data, 1); 266 + if (error) { 267 + dev_err(&ts->client->dev, 268 + "write to register %#08x (%#08x) failed: %d\n", 269 + addr, val, error); 270 + return error; 271 + } 272 + 273 + return 0; 274 + } 275 + 276 + #define SW_RESET_IN_PGM(clk) \ 277 + { \ 278 + hideep_pgm_w_reg(ts, HIDEEP_SYSCON_WDT_CNT, (clk)); \ 279 + hideep_pgm_w_reg(ts, HIDEEP_SYSCON_WDT_CON, 0x03); \ 280 + hideep_pgm_w_reg(ts, HIDEEP_SYSCON_WDT_CON, 0x01); \ 281 + } 282 + 283 + #define SET_FLASH_PIO(ce) \ 284 + hideep_pgm_w_reg(ts, HIDEEP_FLASH_CON, \ 285 + 0x01 | ((ce) << 1)) 286 + 287 + #define SET_PIO_SIG(x, y) \ 288 + hideep_pgm_w_reg(ts, HIDEEP_FLASH_PIO_SIG + (x), (y)) 289 + 290 + #define SET_FLASH_HWCONTROL() \ 291 + hideep_pgm_w_reg(ts, HIDEEP_FLASH_CON, 0x00) 292 + 293 + #define NVM_W_SFR(x, y) \ 294 + { \ 295 + SET_FLASH_PIO(1); \ 296 + SET_PIO_SIG(x, y); \ 297 + SET_FLASH_PIO(0); \ 298 + } 299 + 300 + static void hideep_pgm_set(struct hideep_ts *ts) 301 + { 302 + hideep_pgm_w_reg(ts, HIDEEP_SYSCON_WDT_CON, 0x00); 303 + hideep_pgm_w_reg(ts, HIDEEP_SYSCON_SPC_CON, 0x00); 304 + hideep_pgm_w_reg(ts, HIDEEP_SYSCON_CLK_ENA, 0xFF); 305 + hideep_pgm_w_reg(ts, HIDEEP_SYSCON_CLK_CON, 0x01); 306 + hideep_pgm_w_reg(ts, HIDEEP_SYSCON_PWR_CON, 0x01); 307 + hideep_pgm_w_reg(ts, HIDEEP_FLASH_TIM, 0x03); 308 + hideep_pgm_w_reg(ts, HIDEEP_FLASH_CACHE_CFG, 0x00); 309 + } 310 + 311 + static int hideep_pgm_get_pattern(struct hideep_ts *ts, u32 *pattern) 312 + { 313 + u16 p1 = 0xAF39; 314 + u16 p2 = 0xDF9D; 315 + int error; 316 + 317 + error = regmap_bulk_write(ts->reg, p1, &p2, 1); 318 + if (error) { 319 + dev_err(&ts->client->dev, 320 + "%s: regmap_bulk_write() failed with %d\n", 321 + __func__, error); 322 + return error; 323 + } 324 + 325 + usleep_range(1000, 1100); 326 + 327 + /* flush invalid Tx load register */ 328 + error = hideep_pgm_w_reg(ts, HIDEEP_ESI_TX_INVALID, 0x01); 329 + if (error) 330 + return error; 331 + 332 + error = hideep_pgm_r_reg(ts, HIDEEP_SYSCON_PGM_ID, pattern); 333 + if (error) 334 + return error; 335 + 336 + return 0; 337 + } 338 + 339 + static int hideep_enter_pgm(struct hideep_ts *ts) 340 + { 341 + int retry_count = 10; 342 + u32 pattern; 343 + int error; 344 + 345 + while (retry_count--) { 346 + error = hideep_pgm_get_pattern(ts, &pattern); 347 + if (error) { 348 + dev_err(&ts->client->dev, 349 + "hideep_pgm_get_pattern failed: %d\n", error); 350 + } else if (pattern != 0x39AF9DDF) { 351 + dev_err(&ts->client->dev, "%s: bad pattern: %#08x\n", 352 + __func__, pattern); 353 + } else { 354 + dev_dbg(&ts->client->dev, "found magic code"); 355 + 356 + hideep_pgm_set(ts); 357 + usleep_range(1000, 1100); 358 + 359 + return 0; 360 + } 361 + } 362 + 363 + dev_err(&ts->client->dev, "failed to enter pgm mode\n"); 364 + SW_RESET_IN_PGM(1000); 365 + return -EIO; 366 + } 367 + 368 + static void hideep_nvm_unlock(struct hideep_ts *ts) 369 + { 370 + u32 unmask_code; 371 + 372 + hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_SFR_RPAGE); 373 + hideep_pgm_r_reg(ts, 0x0000000C, &unmask_code); 374 + hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE); 375 + 376 + /* make it unprotected code */ 377 + unmask_code &= ~HIDEEP_PROT_MODE; 378 + 379 + /* compare unmask code */ 380 + if (unmask_code != ts->nvm_mask) 381 + dev_warn(&ts->client->dev, 382 + "read mask code different %#08x vs %#08x", 383 + unmask_code, ts->nvm_mask); 384 + 385 + hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_SFR_WPAGE); 386 + SET_FLASH_PIO(0); 387 + 388 + NVM_W_SFR(HIDEEP_NVM_MASK_OFS, ts->nvm_mask); 389 + SET_FLASH_HWCONTROL(); 390 + hideep_pgm_w_reg(ts, HIDEEP_FLASH_CFG, HIDEEP_NVM_DEFAULT_PAGE); 391 + } 392 + 393 + static int hideep_check_status(struct hideep_ts *ts) 394 + { 395 + int time_out = 100; 396 + int status; 397 + int error; 398 + 399 + while (time_out--) { 400 + error = hideep_pgm_r_reg(ts, HIDEEP_FLASH_STA, &status); 401 + if (!error && status) 402 + return 0; 403 + 404 + usleep_range(1000, 1100); 405 + } 406 + 407 + return -ETIMEDOUT; 408 + } 409 + 410 + static int hideep_program_page(struct hideep_ts *ts, u32 addr, 411 + const __be32 *ucode, size_t xfer_count) 412 + { 413 + u32 val; 414 + int error; 415 + 416 + error = hideep_check_status(ts); 417 + if (error) 418 + return -EBUSY; 419 + 420 + addr &= ~(HIDEEP_NVM_PAGE_SIZE - 1); 421 + 422 + SET_FLASH_PIO(0); 423 + SET_FLASH_PIO(1); 424 + 425 + /* erase page */ 426 + SET_PIO_SIG(HIDEEP_PERASE | addr, 0xFFFFFFFF); 427 + 428 + SET_FLASH_PIO(0); 429 + 430 + error = hideep_check_status(ts); 431 + if (error) 432 + return -EBUSY; 433 + 434 + /* write page */ 435 + SET_FLASH_PIO(1); 436 + 437 + val = be32_to_cpu(ucode[0]); 438 + SET_PIO_SIG(HIDEEP_WRONLY | addr, val); 439 + 440 + hideep_pgm_w_mem(ts, HIDEEP_FLASH_PIO_SIG | HIDEEP_WRONLY, 441 + ucode, xfer_count); 442 + 443 + val = be32_to_cpu(ucode[xfer_count - 1]); 444 + SET_PIO_SIG(124, val); 445 + 446 + SET_FLASH_PIO(0); 447 + 448 + usleep_range(1000, 1100); 449 + 450 + error = hideep_check_status(ts); 451 + if (error) 452 + return -EBUSY; 453 + 454 + SET_FLASH_HWCONTROL(); 455 + 456 + return 0; 457 + } 458 + 459 + static int hideep_program_nvm(struct hideep_ts *ts, 460 + const __be32 *ucode, size_t ucode_len) 461 + { 462 + struct pgm_packet *packet_r = (void *)ts->xfer_buf; 463 + __be32 *current_ucode = packet_r->payload; 464 + size_t xfer_len; 465 + size_t xfer_count; 466 + u32 addr = 0; 467 + int error; 468 + 469 + hideep_nvm_unlock(ts); 470 + 471 + while (ucode_len > 0) { 472 + xfer_len = min_t(size_t, ucode_len, HIDEEP_NVM_PAGE_SIZE); 473 + xfer_count = xfer_len / sizeof(*ucode); 474 + 475 + error = hideep_pgm_r_mem(ts, 0x00000000 + addr, 476 + current_ucode, xfer_count); 477 + if (error) { 478 + dev_err(&ts->client->dev, 479 + "%s: failed to read page at offset %#08x: %d\n", 480 + __func__, addr, error); 481 + return error; 482 + } 483 + 484 + /* See if the page needs updating */ 485 + if (memcmp(ucode, current_ucode, xfer_len)) { 486 + error = hideep_program_page(ts, addr, 487 + ucode, xfer_count); 488 + if (error) { 489 + dev_err(&ts->client->dev, 490 + "%s: iwrite failure @%#08x: %d\n", 491 + __func__, addr, error); 492 + return error; 493 + } 494 + 495 + usleep_range(1000, 1100); 496 + } 497 + 498 + ucode += xfer_count; 499 + addr += xfer_len; 500 + ucode_len -= xfer_len; 501 + } 502 + 503 + return 0; 504 + } 505 + 506 + static int hideep_verify_nvm(struct hideep_ts *ts, 507 + const __be32 *ucode, size_t ucode_len) 508 + { 509 + struct pgm_packet *packet_r = (void *)ts->xfer_buf; 510 + __be32 *current_ucode = packet_r->payload; 511 + size_t xfer_len; 512 + size_t xfer_count; 513 + u32 addr = 0; 514 + int i; 515 + int error; 516 + 517 + while (ucode_len > 0) { 518 + xfer_len = min_t(size_t, ucode_len, HIDEEP_NVM_PAGE_SIZE); 519 + xfer_count = xfer_len / sizeof(*ucode); 520 + 521 + error = hideep_pgm_r_mem(ts, 0x00000000 + addr, 522 + current_ucode, xfer_count); 523 + if (error) { 524 + dev_err(&ts->client->dev, 525 + "%s: failed to read page at offset %#08x: %d\n", 526 + __func__, addr, error); 527 + return error; 528 + } 529 + 530 + if (memcmp(ucode, current_ucode, xfer_len)) { 531 + const u8 *ucode_bytes = (const u8 *)ucode; 532 + const u8 *current_bytes = (const u8 *)current_ucode; 533 + 534 + for (i = 0; i < xfer_len; i++) 535 + if (ucode_bytes[i] != current_bytes[i]) 536 + dev_err(&ts->client->dev, 537 + "%s: mismatch @%#08x: (%#02x vs %#02x)\n", 538 + __func__, addr + i, 539 + ucode_bytes[i], 540 + current_bytes[i]); 541 + 542 + return -EIO; 543 + } 544 + 545 + ucode += xfer_count; 546 + addr += xfer_len; 547 + ucode_len -= xfer_len; 548 + } 549 + 550 + return 0; 551 + } 552 + 553 + static int hideep_load_dwz(struct hideep_ts *ts) 554 + { 555 + u16 product_code; 556 + int error; 557 + 558 + error = hideep_enter_pgm(ts); 559 + if (error) 560 + return error; 561 + 562 + msleep(50); 563 + 564 + error = hideep_pgm_r_mem(ts, HIDEEP_DWZ_INFO, 565 + (void *)&ts->dwz_info, 566 + sizeof(ts->dwz_info) / sizeof(__be32)); 567 + 568 + SW_RESET_IN_PGM(10); 569 + msleep(50); 570 + 571 + if (error) { 572 + dev_err(&ts->client->dev, 573 + "failed to fetch DWZ data: %d\n", error); 574 + return error; 575 + } 576 + 577 + product_code = be16_to_cpu(ts->dwz_info.product_code); 578 + 579 + switch (product_code & 0xF0) { 580 + case 0x40: 581 + dev_dbg(&ts->client->dev, "used crimson IC"); 582 + ts->fw_size = 1024 * 48; 583 + ts->nvm_mask = 0x00310000; 584 + break; 585 + case 0x60: 586 + dev_dbg(&ts->client->dev, "used lime IC"); 587 + ts->fw_size = 1024 * 64; 588 + ts->nvm_mask = 0x0030027B; 589 + break; 590 + default: 591 + dev_err(&ts->client->dev, "product code is wrong: %#04x", 592 + product_code); 593 + return -EINVAL; 594 + } 595 + 596 + dev_dbg(&ts->client->dev, "firmware release version: %#04x", 597 + be16_to_cpu(ts->dwz_info.release_ver)); 598 + 599 + return 0; 600 + } 601 + 602 + static int hideep_flash_firmware(struct hideep_ts *ts, 603 + const __be32 *ucode, size_t ucode_len) 604 + { 605 + int retry_cnt = 3; 606 + int error; 607 + 608 + while (retry_cnt--) { 609 + error = hideep_program_nvm(ts, ucode, ucode_len); 610 + if (!error) { 611 + error = hideep_verify_nvm(ts, ucode, ucode_len); 612 + if (!error) 613 + return 0; 614 + } 615 + } 616 + 617 + return error; 618 + } 619 + 620 + static int hideep_update_firmware(struct hideep_ts *ts, 621 + const __be32 *ucode, size_t ucode_len) 622 + { 623 + int error, error2; 624 + 625 + dev_dbg(&ts->client->dev, "starting firmware update"); 626 + 627 + /* enter program mode */ 628 + error = hideep_enter_pgm(ts); 629 + if (error) 630 + return error; 631 + 632 + error = hideep_flash_firmware(ts, ucode, ucode_len); 633 + if (error) 634 + dev_err(&ts->client->dev, 635 + "firmware update failed: %d\n", error); 636 + else 637 + dev_dbg(&ts->client->dev, "firmware updated successfully\n"); 638 + 639 + SW_RESET_IN_PGM(1000); 640 + 641 + error2 = hideep_load_dwz(ts); 642 + if (error2) 643 + dev_err(&ts->client->dev, 644 + "failed to load dwz after firmware update: %d\n", 645 + error2); 646 + 647 + return error ?: error2; 648 + } 649 + 650 + static int hideep_power_on(struct hideep_ts *ts) 651 + { 652 + int error = 0; 653 + 654 + error = regulator_enable(ts->vcc_vdd); 655 + if (error) 656 + dev_err(&ts->client->dev, 657 + "failed to enable 'vdd' regulator: %d", error); 658 + 659 + usleep_range(999, 1000); 660 + 661 + error = regulator_enable(ts->vcc_vid); 662 + if (error) 663 + dev_err(&ts->client->dev, 664 + "failed to enable 'vcc_vid' regulator: %d", 665 + error); 666 + 667 + msleep(30); 668 + 669 + if (ts->reset_gpio) { 670 + gpiod_set_value_cansleep(ts->reset_gpio, 0); 671 + } else { 672 + error = regmap_write(ts->reg, HIDEEP_RESET_CMD, 0x01); 673 + if (error) 674 + dev_err(&ts->client->dev, 675 + "failed to send 'reset' command: %d\n", error); 676 + } 677 + 678 + msleep(50); 679 + 680 + return error; 681 + } 682 + 683 + static void hideep_power_off(void *data) 684 + { 685 + struct hideep_ts *ts = data; 686 + 687 + if (ts->reset_gpio) 688 + gpiod_set_value(ts->reset_gpio, 1); 689 + 690 + regulator_disable(ts->vcc_vid); 691 + regulator_disable(ts->vcc_vdd); 692 + } 693 + 694 + #define __GET_MT_TOOL_TYPE(type) ((type) == 0x01 ? MT_TOOL_FINGER : MT_TOOL_PEN) 695 + 696 + static void hideep_report_slot(struct input_dev *input, 697 + const struct hideep_event *event) 698 + { 699 + input_mt_slot(input, event->index & 0x0f); 700 + input_mt_report_slot_state(input, 701 + __GET_MT_TOOL_TYPE(event->type), 702 + !(event->flag & HIDEEP_MT_RELEASED)); 703 + if (!(event->flag & HIDEEP_MT_RELEASED)) { 704 + input_report_abs(input, ABS_MT_POSITION_X, 705 + le16_to_cpup(&event->x)); 706 + input_report_abs(input, ABS_MT_POSITION_Y, 707 + le16_to_cpup(&event->y)); 708 + input_report_abs(input, ABS_MT_PRESSURE, 709 + le16_to_cpup(&event->z)); 710 + input_report_abs(input, ABS_MT_TOUCH_MAJOR, event->w); 711 + } 712 + } 713 + 714 + static void hideep_parse_and_report(struct hideep_ts *ts) 715 + { 716 + const struct hideep_event *events = 717 + (void *)&ts->xfer_buf[HIDEEP_TOUCH_EVENT_INDEX]; 718 + const u8 *keys = &ts->xfer_buf[HIDEEP_KEY_EVENT_INDEX]; 719 + int touch_count = ts->xfer_buf[0]; 720 + int key_count = ts->xfer_buf[1] & 0x0f; 721 + int lpm_count = ts->xfer_buf[1] & 0xf0; 722 + int i; 723 + 724 + /* get touch event count */ 725 + dev_dbg(&ts->client->dev, "mt = %d, key = %d, lpm = %02x", 726 + touch_count, key_count, lpm_count); 727 + 728 + touch_count = min(touch_count, HIDEEP_MT_MAX); 729 + for (i = 0; i < touch_count; i++) 730 + hideep_report_slot(ts->input_dev, events + i); 731 + 732 + key_count = min(key_count, HIDEEP_KEY_MAX); 733 + for (i = 0; i < key_count; i++) { 734 + u8 key_data = keys[i * 2]; 735 + 736 + input_report_key(ts->input_dev, 737 + ts->key_codes[key_data & HIDEEP_KEY_IDX_MASK], 738 + key_data & HIDEEP_KEY_PRESSED_MASK); 739 + } 740 + 741 + input_mt_sync_frame(ts->input_dev); 742 + input_sync(ts->input_dev); 743 + } 744 + 745 + static irqreturn_t hideep_irq(int irq, void *handle) 746 + { 747 + struct hideep_ts *ts = handle; 748 + int error; 749 + 750 + BUILD_BUG_ON(HIDEEP_MAX_EVENT > HIDEEP_XFER_BUF_SIZE); 751 + 752 + error = regmap_bulk_read(ts->reg, HIDEEP_EVENT_ADDR, 753 + ts->xfer_buf, HIDEEP_MAX_EVENT / 2); 754 + if (error) { 755 + dev_err(&ts->client->dev, "failed to read events: %d\n", error); 756 + goto out; 757 + } 758 + 759 + hideep_parse_and_report(ts); 760 + 761 + out: 762 + return IRQ_HANDLED; 763 + } 764 + 765 + static int hideep_get_axis_info(struct hideep_ts *ts) 766 + { 767 + __le16 val[2]; 768 + int error; 769 + 770 + error = regmap_bulk_read(ts->reg, 0x28, val, ARRAY_SIZE(val)); 771 + if (error) 772 + return error; 773 + 774 + ts->prop.max_x = le16_to_cpup(val); 775 + ts->prop.max_y = le16_to_cpup(val + 1); 776 + 777 + dev_dbg(&ts->client->dev, "X: %d, Y: %d", 778 + ts->prop.max_x, ts->prop.max_y); 779 + 780 + return 0; 781 + } 782 + 783 + static int hideep_init_input(struct hideep_ts *ts) 784 + { 785 + struct device *dev = &ts->client->dev; 786 + int i; 787 + int error; 788 + 789 + ts->input_dev = devm_input_allocate_device(dev); 790 + if (!ts->input_dev) { 791 + dev_err(dev, "failed to allocate input device\n"); 792 + return -ENOMEM; 793 + } 794 + 795 + ts->input_dev->name = HIDEEP_TS_NAME; 796 + ts->input_dev->id.bustype = BUS_I2C; 797 + input_set_drvdata(ts->input_dev, ts); 798 + 799 + input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_X); 800 + input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_Y); 801 + input_set_abs_params(ts->input_dev, ABS_MT_PRESSURE, 0, 65535, 0, 0); 802 + input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); 803 + input_set_abs_params(ts->input_dev, ABS_MT_TOOL_TYPE, 804 + 0, MT_TOOL_MAX, 0, 0); 805 + touchscreen_parse_properties(ts->input_dev, true, &ts->prop); 806 + 807 + if (ts->prop.max_x == 0 || ts->prop.max_y == 0) { 808 + error = hideep_get_axis_info(ts); 809 + if (error) 810 + return error; 811 + } 812 + 813 + error = input_mt_init_slots(ts->input_dev, HIDEEP_MT_MAX, 814 + INPUT_MT_DIRECT); 815 + if (error) 816 + return error; 817 + 818 + ts->key_num = device_property_read_u32_array(dev, "linux,keycodes", 819 + NULL, 0); 820 + if (ts->key_num > HIDEEP_KEY_MAX) { 821 + dev_err(dev, "too many keys defined: %d\n", 822 + ts->key_num); 823 + return -EINVAL; 824 + } 825 + 826 + if (ts->key_num <= 0) { 827 + dev_dbg(dev, 828 + "missing or malformed 'linux,keycodes' property\n"); 829 + } else { 830 + error = device_property_read_u32_array(dev, "linux,keycodes", 831 + ts->key_codes, 832 + ts->key_num); 833 + if (error) { 834 + dev_dbg(dev, "failed to read keymap: %d", error); 835 + return error; 836 + } 837 + 838 + if (ts->key_num) { 839 + ts->input_dev->keycode = ts->key_codes; 840 + ts->input_dev->keycodesize = sizeof(ts->key_codes[0]); 841 + ts->input_dev->keycodemax = ts->key_num; 842 + 843 + for (i = 0; i < ts->key_num; i++) 844 + input_set_capability(ts->input_dev, EV_KEY, 845 + ts->key_codes[i]); 846 + } 847 + } 848 + 849 + error = input_register_device(ts->input_dev); 850 + if (error) { 851 + dev_err(dev, "failed to register input device: %d", error); 852 + return error; 853 + } 854 + 855 + return 0; 856 + } 857 + 858 + static ssize_t hideep_update_fw(struct device *dev, 859 + struct device_attribute *attr, 860 + const char *buf, size_t count) 861 + { 862 + struct i2c_client *client = to_i2c_client(dev); 863 + struct hideep_ts *ts = i2c_get_clientdata(client); 864 + const struct firmware *fw_entry; 865 + char *fw_name; 866 + int mode; 867 + int error; 868 + 869 + error = kstrtoint(buf, 0, &mode); 870 + if (error) 871 + return error; 872 + 873 + fw_name = kasprintf(GFP_KERNEL, "hideep_ts_%04x.bin", 874 + be16_to_cpu(ts->dwz_info.product_id)); 875 + if (!fw_name) 876 + return -ENOMEM; 877 + 878 + error = request_firmware(&fw_entry, fw_name, dev); 879 + if (error) { 880 + dev_err(dev, "failed to request firmware %s: %d", 881 + fw_name, error); 882 + goto out_free_fw_name; 883 + } 884 + 885 + if (fw_entry->size % sizeof(__be32)) { 886 + dev_err(dev, "invalid firmware size %zu\n", fw_entry->size); 887 + error = -EINVAL; 888 + goto out_release_fw; 889 + } 890 + 891 + if (fw_entry->size > ts->fw_size) { 892 + dev_err(dev, "fw size (%zu) is too big (memory size %d)\n", 893 + fw_entry->size, ts->fw_size); 894 + error = -EFBIG; 895 + goto out_release_fw; 896 + } 897 + 898 + mutex_lock(&ts->dev_mutex); 899 + disable_irq(client->irq); 900 + 901 + error = hideep_update_firmware(ts, (const __be32 *)fw_entry->data, 902 + fw_entry->size); 903 + 904 + enable_irq(client->irq); 905 + mutex_unlock(&ts->dev_mutex); 906 + 907 + out_release_fw: 908 + release_firmware(fw_entry); 909 + out_free_fw_name: 910 + kfree(fw_name); 911 + 912 + return error ?: count; 913 + } 914 + 915 + static ssize_t hideep_fw_version_show(struct device *dev, 916 + struct device_attribute *attr, char *buf) 917 + { 918 + struct i2c_client *client = to_i2c_client(dev); 919 + struct hideep_ts *ts = i2c_get_clientdata(client); 920 + ssize_t len; 921 + 922 + mutex_lock(&ts->dev_mutex); 923 + len = scnprintf(buf, PAGE_SIZE, "%04x\n", 924 + be16_to_cpu(ts->dwz_info.release_ver)); 925 + mutex_unlock(&ts->dev_mutex); 926 + 927 + return len; 928 + } 929 + 930 + static ssize_t hideep_product_id_show(struct device *dev, 931 + struct device_attribute *attr, char *buf) 932 + { 933 + struct i2c_client *client = to_i2c_client(dev); 934 + struct hideep_ts *ts = i2c_get_clientdata(client); 935 + ssize_t len; 936 + 937 + mutex_lock(&ts->dev_mutex); 938 + len = scnprintf(buf, PAGE_SIZE, "%04x\n", 939 + be16_to_cpu(ts->dwz_info.product_id)); 940 + mutex_unlock(&ts->dev_mutex); 941 + 942 + return len; 943 + } 944 + 945 + static DEVICE_ATTR(version, 0664, hideep_fw_version_show, NULL); 946 + static DEVICE_ATTR(product_id, 0664, hideep_product_id_show, NULL); 947 + static DEVICE_ATTR(update_fw, 0664, NULL, hideep_update_fw); 948 + 949 + static struct attribute *hideep_ts_sysfs_entries[] = { 950 + &dev_attr_version.attr, 951 + &dev_attr_product_id.attr, 952 + &dev_attr_update_fw.attr, 953 + NULL, 954 + }; 955 + 956 + static const struct attribute_group hideep_ts_attr_group = { 957 + .attrs = hideep_ts_sysfs_entries, 958 + }; 959 + 960 + static int __maybe_unused hideep_suspend(struct device *dev) 961 + { 962 + struct i2c_client *client = to_i2c_client(dev); 963 + struct hideep_ts *ts = i2c_get_clientdata(client); 964 + 965 + disable_irq(client->irq); 966 + hideep_power_off(ts); 967 + 968 + return 0; 969 + } 970 + 971 + static int __maybe_unused hideep_resume(struct device *dev) 972 + { 973 + struct i2c_client *client = to_i2c_client(dev); 974 + struct hideep_ts *ts = i2c_get_clientdata(client); 975 + int error; 976 + 977 + error = hideep_power_on(ts); 978 + if (error) { 979 + dev_err(&client->dev, "power on failed"); 980 + return error; 981 + } 982 + 983 + enable_irq(client->irq); 984 + 985 + return 0; 986 + } 987 + 988 + static SIMPLE_DEV_PM_OPS(hideep_pm_ops, hideep_suspend, hideep_resume); 989 + 990 + static const struct regmap_config hideep_regmap_config = { 991 + .reg_bits = 16, 992 + .reg_format_endian = REGMAP_ENDIAN_LITTLE, 993 + .val_bits = 16, 994 + .val_format_endian = REGMAP_ENDIAN_LITTLE, 995 + .max_register = 0xffff, 996 + }; 997 + 998 + static int hideep_probe(struct i2c_client *client, 999 + const struct i2c_device_id *id) 1000 + { 1001 + struct hideep_ts *ts; 1002 + int error; 1003 + 1004 + /* check i2c bus */ 1005 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 1006 + dev_err(&client->dev, "check i2c device error"); 1007 + return -ENODEV; 1008 + } 1009 + 1010 + if (client->irq <= 0) { 1011 + dev_err(&client->dev, "missing irq: %d\n", client->irq); 1012 + return -EINVAL; 1013 + } 1014 + 1015 + ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); 1016 + if (!ts) 1017 + return -ENOMEM; 1018 + 1019 + ts->client = client; 1020 + i2c_set_clientdata(client, ts); 1021 + mutex_init(&ts->dev_mutex); 1022 + 1023 + ts->reg = devm_regmap_init_i2c(client, &hideep_regmap_config); 1024 + if (IS_ERR(ts->reg)) { 1025 + error = PTR_ERR(ts->reg); 1026 + dev_err(&client->dev, 1027 + "failed to initialize regmap: %d\n", error); 1028 + return error; 1029 + } 1030 + 1031 + ts->vcc_vdd = devm_regulator_get(&client->dev, "vdd"); 1032 + if (IS_ERR(ts->vcc_vdd)) 1033 + return PTR_ERR(ts->vcc_vdd); 1034 + 1035 + ts->vcc_vid = devm_regulator_get(&client->dev, "vid"); 1036 + if (IS_ERR(ts->vcc_vid)) 1037 + return PTR_ERR(ts->vcc_vid); 1038 + 1039 + ts->reset_gpio = devm_gpiod_get_optional(&client->dev, 1040 + "reset", GPIOD_OUT_HIGH); 1041 + if (IS_ERR(ts->reset_gpio)) 1042 + return PTR_ERR(ts->reset_gpio); 1043 + 1044 + error = hideep_power_on(ts); 1045 + if (error) { 1046 + dev_err(&client->dev, "power on failed: %d\n", error); 1047 + return error; 1048 + } 1049 + 1050 + error = devm_add_action_or_reset(&client->dev, hideep_power_off, ts); 1051 + if (error) 1052 + return error; 1053 + 1054 + error = hideep_load_dwz(ts); 1055 + if (error) { 1056 + dev_err(&client->dev, "failed to load dwz: %d", error); 1057 + return error; 1058 + } 1059 + 1060 + error = hideep_init_input(ts); 1061 + if (error) 1062 + return error; 1063 + 1064 + error = devm_request_threaded_irq(&client->dev, client->irq, 1065 + NULL, hideep_irq, IRQF_ONESHOT, 1066 + client->name, ts); 1067 + if (error) { 1068 + dev_err(&client->dev, "failed to request irq %d: %d\n", 1069 + client->irq, error); 1070 + return error; 1071 + } 1072 + 1073 + error = devm_device_add_group(&client->dev, &hideep_ts_attr_group); 1074 + if (error) { 1075 + dev_err(&client->dev, 1076 + "failed to add sysfs attributes: %d\n", error); 1077 + return error; 1078 + } 1079 + 1080 + return 0; 1081 + } 1082 + 1083 + static const struct i2c_device_id hideep_i2c_id[] = { 1084 + { HIDEEP_I2C_NAME, 0 }, 1085 + { } 1086 + }; 1087 + MODULE_DEVICE_TABLE(i2c, hideep_i2c_id); 1088 + 1089 + #ifdef CONFIG_ACPI 1090 + static const struct acpi_device_id hideep_acpi_id[] = { 1091 + { "HIDP0001", 0 }, 1092 + { } 1093 + }; 1094 + MODULE_DEVICE_TABLE(acpi, hideep_acpi_id); 1095 + #endif 1096 + 1097 + #ifdef CONFIG_OF 1098 + static const struct of_device_id hideep_match_table[] = { 1099 + { .compatible = "hideep,hideep-ts" }, 1100 + { } 1101 + }; 1102 + MODULE_DEVICE_TABLE(of, hideep_match_table); 1103 + #endif 1104 + 1105 + static struct i2c_driver hideep_driver = { 1106 + .driver = { 1107 + .name = HIDEEP_I2C_NAME, 1108 + .of_match_table = of_match_ptr(hideep_match_table), 1109 + .acpi_match_table = ACPI_PTR(hideep_acpi_id), 1110 + .pm = &hideep_pm_ops, 1111 + }, 1112 + .id_table = hideep_i2c_id, 1113 + .probe = hideep_probe, 1114 + }; 1115 + 1116 + module_i2c_driver(hideep_driver); 1117 + 1118 + MODULE_DESCRIPTION("Driver for HiDeep Touchscreen Controller"); 1119 + MODULE_AUTHOR("anthony.kim@hideep.com"); 1120 + MODULE_LICENSE("GPL v2");
+1 -16
drivers/input/touchscreen/melfas_mip4.c
··· 1433 1433 .attrs = mip4_attrs, 1434 1434 }; 1435 1435 1436 - static void mip4_sysfs_remove(void *_data) 1437 - { 1438 - struct mip4_ts *ts = _data; 1439 - 1440 - sysfs_remove_group(&ts->client->dev.kobj, &mip4_attr_group); 1441 - } 1442 - 1443 1436 static int mip4_probe(struct i2c_client *client, const struct i2c_device_id *id) 1444 1437 { 1445 1438 struct mip4_ts *ts; ··· 1528 1535 return error; 1529 1536 } 1530 1537 1531 - error = sysfs_create_group(&client->dev.kobj, &mip4_attr_group); 1538 + error = devm_device_add_group(&client->dev, &mip4_attr_group); 1532 1539 if (error) { 1533 1540 dev_err(&client->dev, 1534 1541 "Failed to create sysfs attribute group: %d\n", error); 1535 - return error; 1536 - } 1537 - 1538 - error = devm_add_action(&client->dev, mip4_sysfs_remove, ts); 1539 - if (error) { 1540 - mip4_sysfs_remove(ts); 1541 - dev_err(&client->dev, 1542 - "Failed to install sysfs remoce action: %d\n", error); 1543 1542 return error; 1544 1543 } 1545 1544
+1 -1
drivers/input/touchscreen/mxs-lradc-ts.c
··· 584 584 585 585 static int mxs_lradc_ts_register(struct mxs_lradc_ts *ts) 586 586 { 587 - struct input_dev *input = ts->ts_input; 587 + struct input_dev *input; 588 588 struct device *dev = ts->dev; 589 589 590 590 input = devm_input_allocate_device(dev);
+1 -17
drivers/input/touchscreen/raydium_i2c_ts.c
··· 943 943 .attrs = raydium_i2c_attributes, 944 944 }; 945 945 946 - static void raydium_i2c_remove_sysfs_group(void *_data) 947 - { 948 - struct raydium_data *ts = _data; 949 - 950 - sysfs_remove_group(&ts->client->dev.kobj, &raydium_i2c_attribute_group); 951 - } 952 - 953 946 static int raydium_i2c_power_on(struct raydium_data *ts) 954 947 { 955 948 int error; ··· 1113 1120 return error; 1114 1121 } 1115 1122 1116 - error = sysfs_create_group(&client->dev.kobj, 1123 + error = devm_device_add_group(&client->dev, 1117 1124 &raydium_i2c_attribute_group); 1118 1125 if (error) { 1119 1126 dev_err(&client->dev, "failed to create sysfs attributes: %d\n", 1120 1127 error); 1121 - return error; 1122 - } 1123 - 1124 - error = devm_add_action(&client->dev, 1125 - raydium_i2c_remove_sysfs_group, ts); 1126 - if (error) { 1127 - raydium_i2c_remove_sysfs_group(ts); 1128 - dev_err(&client->dev, 1129 - "Failed to add sysfs cleanup action: %d\n", error); 1130 1128 return error; 1131 1129 } 1132 1130
+1 -16
drivers/input/touchscreen/rohm_bu21023.c
··· 1103 1103 ts->initialized = false; 1104 1104 } 1105 1105 1106 - static void rohm_ts_remove_sysfs_group(void *_dev) 1107 - { 1108 - struct device *dev = _dev; 1109 - 1110 - sysfs_remove_group(&dev->kobj, &rohm_ts_attr_group); 1111 - } 1112 - 1113 1106 static int rohm_bu21023_i2c_probe(struct i2c_client *client, 1114 1107 const struct i2c_device_id *id) 1115 1108 { ··· 1173 1180 return error; 1174 1181 } 1175 1182 1176 - error = sysfs_create_group(&dev->kobj, &rohm_ts_attr_group); 1183 + error = devm_device_add_group(dev, &rohm_ts_attr_group); 1177 1184 if (error) { 1178 1185 dev_err(dev, "failed to create sysfs group: %d\n", error); 1179 - return error; 1180 - } 1181 - 1182 - error = devm_add_action(dev, rohm_ts_remove_sysfs_group, dev); 1183 - if (error) { 1184 - rohm_ts_remove_sysfs_group(dev); 1185 - dev_err(dev, "Failed to add sysfs cleanup action: %d\n", 1186 - error); 1187 1186 return error; 1188 1187 } 1189 1188
+559
drivers/input/touchscreen/s6sy761.c
··· 1 + /* 2 + * Copyright (c) 2017 Samsung Electronics Co., Ltd. 3 + * Author: Andi Shyti <andi.shyti@samsung.com> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License version 2 as 7 + * published by the Free Software Foundation. 8 + * 9 + * Samsung S6SY761 Touchscreen device driver 10 + */ 11 + 12 + #include <asm/unaligned.h> 13 + #include <linux/delay.h> 14 + #include <linux/i2c.h> 15 + #include <linux/input/mt.h> 16 + #include <linux/input/touchscreen.h> 17 + #include <linux/interrupt.h> 18 + #include <linux/irq.h> 19 + #include <linux/module.h> 20 + #include <linux/pm_runtime.h> 21 + #include <linux/regulator/consumer.h> 22 + 23 + /* commands */ 24 + #define S6SY761_SENSE_ON 0x10 25 + #define S6SY761_SENSE_OFF 0x11 26 + #define S6SY761_TOUCH_FUNCTION 0x30 /* R/W for get/set */ 27 + #define S6SY761_FIRMWARE_INTEGRITY 0x21 28 + #define S6SY761_PANEL_INFO 0x23 29 + #define S6SY761_DEVICE_ID 0x52 30 + #define S6SY761_BOOT_STATUS 0x55 31 + #define S6SY761_READ_ONE_EVENT 0x60 32 + #define S6SY761_READ_ALL_EVENT 0x61 33 + #define S6SY761_CLEAR_EVENT_STACK 0x62 34 + #define S6SY761_APPLICATION_MODE 0xe4 35 + 36 + /* events */ 37 + #define S6SY761_EVENT_INFO 0x02 38 + #define S6SY761_EVENT_VENDOR_INFO 0x07 39 + 40 + /* info */ 41 + #define S6SY761_INFO_BOOT_COMPLETE 0x00 42 + 43 + /* firmware status */ 44 + #define S6SY761_FW_OK 0x80 45 + 46 + /* 47 + * the functionalities are put as a reference 48 + * as in the device I am using none of them 49 + * works therefore not used in this driver yet. 50 + */ 51 + /* touchscreen functionalities */ 52 + #define S6SY761_MASK_TOUCH BIT(0) 53 + #define S6SY761_MASK_HOVER BIT(1) 54 + #define S6SY761_MASK_COVER BIT(2) 55 + #define S6SY761_MASK_GLOVE BIT(3) 56 + #define S6SY761_MASK_STYLUS BIT(4) 57 + #define S6SY761_MASK_PALM BIT(5) 58 + #define S6SY761_MASK_WET BIT(6) 59 + #define S6SY761_MASK_PROXIMITY BIT(7) 60 + 61 + /* boot status (BS) */ 62 + #define S6SY761_BS_BOOT_LOADER 0x10 63 + #define S6SY761_BS_APPLICATION 0x20 64 + 65 + /* event id */ 66 + #define S6SY761_EVENT_ID_COORDINATE 0x00 67 + #define S6SY761_EVENT_ID_STATUS 0x01 68 + 69 + /* event register masks */ 70 + #define S6SY761_MASK_TOUCH_STATE 0xc0 /* byte 0 */ 71 + #define S6SY761_MASK_TID 0x3c 72 + #define S6SY761_MASK_EID 0x03 73 + #define S6SY761_MASK_X 0xf0 /* byte 3 */ 74 + #define S6SY761_MASK_Y 0x0f 75 + #define S6SY761_MASK_Z 0x3f /* byte 6 */ 76 + #define S6SY761_MASK_LEFT_EVENTS 0x3f /* byte 7 */ 77 + #define S6SY761_MASK_TOUCH_TYPE 0xc0 /* MSB in byte 6, LSB in byte 7 */ 78 + 79 + /* event touch state values */ 80 + #define S6SY761_TS_NONE 0x00 81 + #define S6SY761_TS_PRESS 0x01 82 + #define S6SY761_TS_MOVE 0x02 83 + #define S6SY761_TS_RELEASE 0x03 84 + 85 + /* application modes */ 86 + #define S6SY761_APP_NORMAL 0x0 87 + #define S6SY761_APP_LOW_POWER 0x1 88 + #define S6SY761_APP_TEST 0x2 89 + #define S6SY761_APP_FLASH 0x3 90 + #define S6SY761_APP_SLEEP 0x4 91 + 92 + #define S6SY761_EVENT_SIZE 8 93 + #define S6SY761_EVENT_COUNT 32 94 + #define S6SY761_DEVID_SIZE 3 95 + #define S6SY761_PANEL_ID_SIZE 11 96 + #define S6SY761_TS_STATUS_SIZE 5 97 + #define S6SY761_MAX_FINGERS 10 98 + 99 + #define S6SY761_DEV_NAME "s6sy761" 100 + 101 + enum s6sy761_regulators { 102 + S6SY761_REGULATOR_VDD, 103 + S6SY761_REGULATOR_AVDD, 104 + }; 105 + 106 + struct s6sy761_data { 107 + struct i2c_client *client; 108 + struct regulator_bulk_data regulators[2]; 109 + struct input_dev *input; 110 + struct touchscreen_properties prop; 111 + 112 + u8 data[S6SY761_EVENT_SIZE * S6SY761_EVENT_COUNT]; 113 + 114 + u16 devid; 115 + u8 tx_channel; 116 + }; 117 + 118 + /* 119 + * We can't simply use i2c_smbus_read_i2c_block_data because we 120 + * need to read more than 255 bytes 121 + */ 122 + static int s6sy761_read_events(struct s6sy761_data *sdata, u16 n_events) 123 + { 124 + u8 cmd = S6SY761_READ_ALL_EVENT; 125 + struct i2c_msg msgs[2] = { 126 + { 127 + .addr = sdata->client->addr, 128 + .len = 1, 129 + .buf = &cmd, 130 + }, 131 + { 132 + .addr = sdata->client->addr, 133 + .flags = I2C_M_RD, 134 + .len = (n_events * S6SY761_EVENT_SIZE), 135 + .buf = sdata->data + S6SY761_EVENT_SIZE, 136 + }, 137 + }; 138 + int ret; 139 + 140 + ret = i2c_transfer(sdata->client->adapter, msgs, ARRAY_SIZE(msgs)); 141 + if (ret < 0) 142 + return ret; 143 + 144 + return ret == ARRAY_SIZE(msgs) ? 0 : -EIO; 145 + } 146 + 147 + static void s6sy761_report_coordinates(struct s6sy761_data *sdata, 148 + u8 *event, u8 tid) 149 + { 150 + u8 major = event[4]; 151 + u8 minor = event[5]; 152 + u8 z = event[6] & S6SY761_MASK_Z; 153 + u16 x = (event[1] << 3) | ((event[3] & S6SY761_MASK_X) >> 4); 154 + u16 y = (event[2] << 3) | (event[3] & S6SY761_MASK_Y); 155 + 156 + input_mt_slot(sdata->input, tid); 157 + 158 + input_mt_report_slot_state(sdata->input, MT_TOOL_FINGER, true); 159 + input_report_abs(sdata->input, ABS_MT_POSITION_X, x); 160 + input_report_abs(sdata->input, ABS_MT_POSITION_Y, y); 161 + input_report_abs(sdata->input, ABS_MT_TOUCH_MAJOR, major); 162 + input_report_abs(sdata->input, ABS_MT_TOUCH_MINOR, minor); 163 + input_report_abs(sdata->input, ABS_MT_PRESSURE, z); 164 + 165 + input_sync(sdata->input); 166 + } 167 + 168 + static void s6sy761_report_release(struct s6sy761_data *sdata, 169 + u8 *event, u8 tid) 170 + { 171 + input_mt_slot(sdata->input, tid); 172 + input_mt_report_slot_state(sdata->input, MT_TOOL_FINGER, false); 173 + 174 + input_sync(sdata->input); 175 + } 176 + 177 + static void s6sy761_handle_coordinates(struct s6sy761_data *sdata, u8 *event) 178 + { 179 + u8 tid; 180 + u8 touch_state; 181 + 182 + if (unlikely(!(event[0] & S6SY761_MASK_TID))) 183 + return; 184 + 185 + tid = ((event[0] & S6SY761_MASK_TID) >> 2) - 1; 186 + touch_state = (event[0] & S6SY761_MASK_TOUCH_STATE) >> 6; 187 + 188 + switch (touch_state) { 189 + 190 + case S6SY761_TS_NONE: 191 + break; 192 + case S6SY761_TS_RELEASE: 193 + s6sy761_report_release(sdata, event, tid); 194 + break; 195 + case S6SY761_TS_PRESS: 196 + case S6SY761_TS_MOVE: 197 + s6sy761_report_coordinates(sdata, event, tid); 198 + break; 199 + } 200 + } 201 + 202 + static void s6sy761_handle_events(struct s6sy761_data *sdata, u8 n_events) 203 + { 204 + int i; 205 + 206 + for (i = 0; i < n_events; i++) { 207 + u8 *event = &sdata->data[i * S6SY761_EVENT_SIZE]; 208 + u8 event_id = event[0] & S6SY761_MASK_EID; 209 + 210 + if (!event[0]) 211 + return; 212 + 213 + switch (event_id) { 214 + 215 + case S6SY761_EVENT_ID_COORDINATE: 216 + s6sy761_handle_coordinates(sdata, event); 217 + break; 218 + 219 + case S6SY761_EVENT_ID_STATUS: 220 + break; 221 + 222 + default: 223 + break; 224 + } 225 + } 226 + } 227 + 228 + static irqreturn_t s6sy761_irq_handler(int irq, void *dev) 229 + { 230 + struct s6sy761_data *sdata = dev; 231 + int ret; 232 + u8 n_events; 233 + 234 + ret = i2c_smbus_read_i2c_block_data(sdata->client, 235 + S6SY761_READ_ONE_EVENT, 236 + S6SY761_EVENT_SIZE, 237 + sdata->data); 238 + if (ret < 0) { 239 + dev_err(&sdata->client->dev, "failed to read events\n"); 240 + return IRQ_HANDLED; 241 + } 242 + 243 + if (!sdata->data[0]) 244 + return IRQ_HANDLED; 245 + 246 + n_events = sdata->data[7] & S6SY761_MASK_LEFT_EVENTS; 247 + if (unlikely(n_events > S6SY761_EVENT_COUNT - 1)) 248 + return IRQ_HANDLED; 249 + 250 + if (n_events) { 251 + ret = s6sy761_read_events(sdata, n_events); 252 + if (ret < 0) { 253 + dev_err(&sdata->client->dev, "failed to read events\n"); 254 + return IRQ_HANDLED; 255 + } 256 + } 257 + 258 + s6sy761_handle_events(sdata, n_events + 1); 259 + 260 + return IRQ_HANDLED; 261 + } 262 + 263 + static int s6sy761_input_open(struct input_dev *dev) 264 + { 265 + struct s6sy761_data *sdata = input_get_drvdata(dev); 266 + 267 + return i2c_smbus_write_byte(sdata->client, S6SY761_SENSE_ON); 268 + } 269 + 270 + static void s6sy761_input_close(struct input_dev *dev) 271 + { 272 + struct s6sy761_data *sdata = input_get_drvdata(dev); 273 + int ret; 274 + 275 + ret = i2c_smbus_write_byte(sdata->client, S6SY761_SENSE_OFF); 276 + if (ret) 277 + dev_err(&sdata->client->dev, "failed to turn off sensing\n"); 278 + } 279 + 280 + static ssize_t s6sy761_sysfs_devid(struct device *dev, 281 + struct device_attribute *attr, char *buf) 282 + { 283 + struct s6sy761_data *sdata = dev_get_drvdata(dev); 284 + 285 + return sprintf(buf, "%#x\n", sdata->devid); 286 + } 287 + 288 + static DEVICE_ATTR(devid, 0444, s6sy761_sysfs_devid, NULL); 289 + 290 + static struct attribute *s6sy761_sysfs_attrs[] = { 291 + &dev_attr_devid.attr, 292 + NULL 293 + }; 294 + 295 + static struct attribute_group s6sy761_attribute_group = { 296 + .attrs = s6sy761_sysfs_attrs 297 + }; 298 + 299 + static int s6sy761_power_on(struct s6sy761_data *sdata) 300 + { 301 + u8 buffer[S6SY761_EVENT_SIZE]; 302 + u8 event; 303 + int ret; 304 + 305 + ret = regulator_bulk_enable(ARRAY_SIZE(sdata->regulators), 306 + sdata->regulators); 307 + if (ret) 308 + return ret; 309 + 310 + msleep(140); 311 + 312 + /* double check whether the touch is functional */ 313 + ret = i2c_smbus_read_i2c_block_data(sdata->client, 314 + S6SY761_READ_ONE_EVENT, 315 + S6SY761_EVENT_SIZE, 316 + buffer); 317 + if (ret < 0) 318 + return ret; 319 + 320 + event = (buffer[0] >> 2) & 0xf; 321 + 322 + if ((event != S6SY761_EVENT_INFO && 323 + event != S6SY761_EVENT_VENDOR_INFO) || 324 + buffer[1] != S6SY761_INFO_BOOT_COMPLETE) { 325 + return -ENODEV; 326 + } 327 + 328 + ret = i2c_smbus_read_byte_data(sdata->client, S6SY761_BOOT_STATUS); 329 + if (ret < 0) 330 + return ret; 331 + 332 + /* for some reasons the device might be stuck in the bootloader */ 333 + if (ret != S6SY761_BS_APPLICATION) 334 + return -ENODEV; 335 + 336 + /* enable touch functionality */ 337 + ret = i2c_smbus_write_word_data(sdata->client, 338 + S6SY761_TOUCH_FUNCTION, 339 + S6SY761_MASK_TOUCH); 340 + if (ret) 341 + return ret; 342 + 343 + return 0; 344 + } 345 + 346 + static int s6sy761_hw_init(struct s6sy761_data *sdata, 347 + unsigned int *max_x, unsigned int *max_y) 348 + { 349 + u8 buffer[S6SY761_PANEL_ID_SIZE]; /* larger read size */ 350 + int ret; 351 + 352 + ret = s6sy761_power_on(sdata); 353 + if (ret) 354 + return ret; 355 + 356 + ret = i2c_smbus_read_i2c_block_data(sdata->client, 357 + S6SY761_DEVICE_ID, 358 + S6SY761_DEVID_SIZE, 359 + buffer); 360 + if (ret < 0) 361 + return ret; 362 + 363 + sdata->devid = get_unaligned_be16(buffer + 1); 364 + 365 + ret = i2c_smbus_read_i2c_block_data(sdata->client, 366 + S6SY761_PANEL_INFO, 367 + S6SY761_PANEL_ID_SIZE, 368 + buffer); 369 + if (ret < 0) 370 + return ret; 371 + 372 + *max_x = get_unaligned_be16(buffer); 373 + *max_y = get_unaligned_be16(buffer + 2); 374 + 375 + /* if no tx channels defined, at least keep one */ 376 + sdata->tx_channel = max_t(u8, buffer[8], 1); 377 + 378 + ret = i2c_smbus_read_byte_data(sdata->client, 379 + S6SY761_FIRMWARE_INTEGRITY); 380 + if (ret < 0) 381 + return ret; 382 + else if (ret != S6SY761_FW_OK) 383 + return -ENODEV; 384 + 385 + return 0; 386 + } 387 + 388 + static void s6sy761_power_off(void *data) 389 + { 390 + struct s6sy761_data *sdata = data; 391 + 392 + disable_irq(sdata->client->irq); 393 + regulator_bulk_disable(ARRAY_SIZE(sdata->regulators), 394 + sdata->regulators); 395 + } 396 + 397 + static int s6sy761_probe(struct i2c_client *client, 398 + const struct i2c_device_id *id) 399 + { 400 + struct s6sy761_data *sdata; 401 + unsigned int max_x, max_y; 402 + int err; 403 + 404 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | 405 + I2C_FUNC_SMBUS_BYTE_DATA | 406 + I2C_FUNC_SMBUS_I2C_BLOCK)) 407 + return -ENODEV; 408 + 409 + sdata = devm_kzalloc(&client->dev, sizeof(*sdata), GFP_KERNEL); 410 + if (!sdata) 411 + return -ENOMEM; 412 + 413 + i2c_set_clientdata(client, sdata); 414 + sdata->client = client; 415 + 416 + sdata->regulators[S6SY761_REGULATOR_VDD].supply = "vdd"; 417 + sdata->regulators[S6SY761_REGULATOR_AVDD].supply = "avdd"; 418 + err = devm_regulator_bulk_get(&client->dev, 419 + ARRAY_SIZE(sdata->regulators), 420 + sdata->regulators); 421 + if (err) 422 + return err; 423 + 424 + err = devm_add_action_or_reset(&client->dev, s6sy761_power_off, sdata); 425 + if (err) 426 + return err; 427 + 428 + err = s6sy761_hw_init(sdata, &max_x, &max_y); 429 + if (err) 430 + return err; 431 + 432 + sdata->input = devm_input_allocate_device(&client->dev); 433 + if (!sdata->input) 434 + return -ENOMEM; 435 + 436 + sdata->input->name = S6SY761_DEV_NAME; 437 + sdata->input->id.bustype = BUS_I2C; 438 + sdata->input->open = s6sy761_input_open; 439 + sdata->input->close = s6sy761_input_close; 440 + 441 + input_set_abs_params(sdata->input, ABS_MT_POSITION_X, 0, max_x, 0, 0); 442 + input_set_abs_params(sdata->input, ABS_MT_POSITION_Y, 0, max_y, 0, 0); 443 + input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); 444 + input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); 445 + input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); 446 + input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); 447 + input_set_abs_params(sdata->input, ABS_MT_PRESSURE, 0, 255, 0, 0); 448 + 449 + touchscreen_parse_properties(sdata->input, true, &sdata->prop); 450 + 451 + if (!input_abs_get_max(sdata->input, ABS_X) || 452 + !input_abs_get_max(sdata->input, ABS_Y)) { 453 + dev_warn(&client->dev, "the axis have not been set\n"); 454 + } 455 + 456 + err = input_mt_init_slots(sdata->input, sdata->tx_channel, 457 + INPUT_MT_DIRECT); 458 + if (err) 459 + return err; 460 + 461 + input_set_drvdata(sdata->input, sdata); 462 + 463 + err = input_register_device(sdata->input); 464 + if (err) 465 + return err; 466 + 467 + err = devm_request_threaded_irq(&client->dev, client->irq, NULL, 468 + s6sy761_irq_handler, 469 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 470 + "s6sy761_irq", sdata); 471 + if (err) 472 + return err; 473 + 474 + err = devm_device_add_group(&client->dev, &s6sy761_attribute_group); 475 + if (err) 476 + return err; 477 + 478 + pm_runtime_enable(&client->dev); 479 + 480 + return 0; 481 + } 482 + 483 + static int s6sy761_remove(struct i2c_client *client) 484 + { 485 + pm_runtime_disable(&client->dev); 486 + 487 + return 0; 488 + } 489 + 490 + static int __maybe_unused s6sy761_runtime_suspend(struct device *dev) 491 + { 492 + struct s6sy761_data *sdata = dev_get_drvdata(dev); 493 + 494 + return i2c_smbus_write_byte_data(sdata->client, 495 + S6SY761_APPLICATION_MODE, S6SY761_APP_SLEEP); 496 + } 497 + 498 + static int __maybe_unused s6sy761_runtime_resume(struct device *dev) 499 + { 500 + struct s6sy761_data *sdata = dev_get_drvdata(dev); 501 + 502 + return i2c_smbus_write_byte_data(sdata->client, 503 + S6SY761_APPLICATION_MODE, S6SY761_APP_NORMAL); 504 + } 505 + 506 + static int __maybe_unused s6sy761_suspend(struct device *dev) 507 + { 508 + struct s6sy761_data *sdata = dev_get_drvdata(dev); 509 + 510 + s6sy761_power_off(sdata); 511 + 512 + return 0; 513 + } 514 + 515 + static int __maybe_unused s6sy761_resume(struct device *dev) 516 + { 517 + struct s6sy761_data *sdata = dev_get_drvdata(dev); 518 + 519 + enable_irq(sdata->client->irq); 520 + 521 + return s6sy761_power_on(sdata); 522 + } 523 + 524 + static const struct dev_pm_ops s6sy761_pm_ops = { 525 + SET_SYSTEM_SLEEP_PM_OPS(s6sy761_suspend, s6sy761_resume) 526 + SET_RUNTIME_PM_OPS(s6sy761_runtime_suspend, 527 + s6sy761_runtime_resume, NULL) 528 + }; 529 + 530 + #ifdef CONFIG_OF 531 + static const struct of_device_id s6sy761_of_match[] = { 532 + { .compatible = "samsung,s6sy761", }, 533 + { }, 534 + }; 535 + MODULE_DEVICE_TABLE(of, s6sy761_of_match); 536 + #endif 537 + 538 + static const struct i2c_device_id s6sy761_id[] = { 539 + { "s6sy761", 0 }, 540 + { }, 541 + }; 542 + MODULE_DEVICE_TABLE(i2c, s6sy761_id); 543 + 544 + static struct i2c_driver s6sy761_driver = { 545 + .driver = { 546 + .name = S6SY761_DEV_NAME, 547 + .of_match_table = of_match_ptr(s6sy761_of_match), 548 + .pm = &s6sy761_pm_ops, 549 + }, 550 + .probe = s6sy761_probe, 551 + .remove = s6sy761_remove, 552 + .id_table = s6sy761_id, 553 + }; 554 + 555 + module_i2c_driver(s6sy761_driver); 556 + 557 + MODULE_AUTHOR("Andi Shyti <andi.shyti@samsung.com>"); 558 + MODULE_DESCRIPTION("Samsung S6SY761 Touch Screen"); 559 + MODULE_LICENSE("GPL v2");
+3 -13
drivers/input/touchscreen/st1232.c
··· 29 29 #include <linux/pm_qos.h> 30 30 #include <linux/slab.h> 31 31 #include <linux/types.h> 32 - #include <linux/platform_data/st1232_pdata.h> 33 32 34 33 #define ST1232_TS_NAME "st1232-ts" 35 34 ··· 151 152 } 152 153 153 154 static int st1232_ts_probe(struct i2c_client *client, 154 - const struct i2c_device_id *id) 155 + const struct i2c_device_id *id) 155 156 { 156 157 struct st1232_ts_data *ts; 157 - struct st1232_pdata *pdata = dev_get_platdata(&client->dev); 158 158 struct input_dev *input_dev; 159 159 int error; 160 160 ··· 178 180 ts->client = client; 179 181 ts->input_dev = input_dev; 180 182 181 - if (pdata) 182 - ts->reset_gpio = pdata->reset_gpio; 183 - else if (client->dev.of_node) 184 - ts->reset_gpio = of_get_gpio(client->dev.of_node, 0); 185 - else 186 - ts->reset_gpio = -ENODEV; 187 - 183 + ts->reset_gpio = of_get_gpio(client->dev.of_node, 0); 188 184 if (gpio_is_valid(ts->reset_gpio)) { 189 185 error = devm_gpio_request(&client->dev, ts->reset_gpio, NULL); 190 186 if (error) { ··· 273 281 }; 274 282 MODULE_DEVICE_TABLE(i2c, st1232_ts_id); 275 283 276 - #ifdef CONFIG_OF 277 284 static const struct of_device_id st1232_ts_dt_ids[] = { 278 285 { .compatible = "sitronix,st1232", }, 279 286 { } 280 287 }; 281 288 MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids); 282 - #endif 283 289 284 290 static struct i2c_driver st1232_ts_driver = { 285 291 .probe = st1232_ts_probe, ··· 285 295 .id_table = st1232_ts_id, 286 296 .driver = { 287 297 .name = ST1232_TS_NAME, 288 - .of_match_table = of_match_ptr(st1232_ts_dt_ids), 298 + .of_match_table = st1232_ts_dt_ids, 289 299 .pm = &st1232_ts_pm_ops, 290 300 }, 291 301 };
+1 -3
drivers/input/touchscreen/stmfts.c
··· 725 725 } 726 726 } 727 727 728 - err = sysfs_create_group(&sdata->client->dev.kobj, 729 - &stmfts_attribute_group); 728 + err = devm_device_add_group(&client->dev, &stmfts_attribute_group); 730 729 if (err) 731 730 return err; 732 731 ··· 737 738 static int stmfts_remove(struct i2c_client *client) 738 739 { 739 740 pm_runtime_disable(&client->dev); 740 - sysfs_remove_group(&client->dev.kobj, &stmfts_attribute_group); 741 741 742 742 return 0; 743 743 }
+3 -3
drivers/input/touchscreen/tsc200x-core.c
··· 202 202 return IRQ_HANDLED; 203 203 } 204 204 205 - static void tsc200x_penup_timer(unsigned long data) 205 + static void tsc200x_penup_timer(struct timer_list *t) 206 206 { 207 - struct tsc200x *ts = (struct tsc200x *)data; 207 + struct tsc200x *ts = from_timer(ts, t, penup_timer); 208 208 unsigned long flags; 209 209 210 210 spin_lock_irqsave(&ts->lock, flags); ··· 506 506 mutex_init(&ts->mutex); 507 507 508 508 spin_lock_init(&ts->lock); 509 - setup_timer(&ts->penup_timer, tsc200x_penup_timer, (unsigned long)ts); 509 + timer_setup(&ts->penup_timer, tsc200x_penup_timer, 0); 510 510 511 511 INIT_DELAYED_WORK(&ts->esd_work, tsc200x_esd_work); 512 512
+3 -4
drivers/input/touchscreen/w90p910_ts.c
··· 146 146 return IRQ_HANDLED; 147 147 } 148 148 149 - static void w90p910_check_pen_up(unsigned long data) 149 + static void w90p910_check_pen_up(struct timer_list *t) 150 150 { 151 - struct w90p910_ts *w90p910_ts = (struct w90p910_ts *) data; 151 + struct w90p910_ts *w90p910_ts = from_timer(w90p910_ts, t, timer); 152 152 unsigned long flags; 153 153 154 154 spin_lock_irqsave(&w90p910_ts->lock, flags); ··· 232 232 w90p910_ts->input = input_dev; 233 233 w90p910_ts->state = TS_IDLE; 234 234 spin_lock_init(&w90p910_ts->lock); 235 - setup_timer(&w90p910_ts->timer, w90p910_check_pen_up, 236 - (unsigned long)w90p910_ts); 235 + timer_setup(&w90p910_ts->timer, w90p910_check_pen_up, 0); 237 236 238 237 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 239 238 if (!res) {
+1 -9
drivers/input/touchscreen/wdt87xx_i2c.c
··· 1106 1106 return error; 1107 1107 } 1108 1108 1109 - error = sysfs_create_group(&client->dev.kobj, &wdt87xx_attr_group); 1109 + error = devm_device_add_group(&client->dev, &wdt87xx_attr_group); 1110 1110 if (error) { 1111 1111 dev_err(&client->dev, "create sysfs failed: %d\n", error); 1112 1112 return error; 1113 1113 } 1114 - 1115 - return 0; 1116 - } 1117 - 1118 - static int wdt87xx_ts_remove(struct i2c_client *client) 1119 - { 1120 - sysfs_remove_group(&client->dev.kobj, &wdt87xx_attr_group); 1121 1114 1122 1115 return 0; 1123 1116 } ··· 1172 1179 1173 1180 static struct i2c_driver wdt87xx_driver = { 1174 1181 .probe = wdt87xx_ts_probe, 1175 - .remove = wdt87xx_ts_remove, 1176 1182 .id_table = wdt87xx_dev_id, 1177 1183 .driver = { 1178 1184 .name = WDT87XX_NAME,
+1 -1
drivers/media/pci/ttpci/av7110.h
··· 94 94 u8 inversion; 95 95 u16 last_key; 96 96 u16 last_toggle; 97 - u8 delay_timer_finished; 97 + bool keypressed; 98 98 }; 99 99 100 100
+20 -36
drivers/media/pci/ttpci/av7110_ir.c
··· 84 84 85 85 86 86 /* key-up timer */ 87 - static void av7110_emit_keyup(unsigned long parm) 87 + static void av7110_emit_keyup(struct timer_list *t) 88 88 { 89 - struct infrared *ir = (struct infrared *) parm; 89 + struct infrared *ir = from_timer(ir, t, keyup_timer); 90 90 91 - if (!ir || !test_bit(ir->last_key, ir->input_dev->key)) 91 + if (!ir || !ir->keypressed) 92 92 return; 93 93 94 94 input_report_key(ir->input_dev, ir->last_key, 0); 95 95 input_sync(ir->input_dev); 96 + ir->keypressed = false; 96 97 } 97 98 98 99 ··· 153 152 return; 154 153 } 155 154 156 - if (timer_pending(&ir->keyup_timer)) { 157 - del_timer(&ir->keyup_timer); 158 - if (ir->last_key != keycode || toggle != ir->last_toggle) { 159 - ir->delay_timer_finished = 0; 160 - input_event(ir->input_dev, EV_KEY, ir->last_key, 0); 161 - input_event(ir->input_dev, EV_KEY, keycode, 1); 162 - input_sync(ir->input_dev); 163 - } else if (ir->delay_timer_finished) { 164 - input_event(ir->input_dev, EV_KEY, keycode, 2); 165 - input_sync(ir->input_dev); 166 - } 167 - } else { 168 - ir->delay_timer_finished = 0; 169 - input_event(ir->input_dev, EV_KEY, keycode, 1); 170 - input_sync(ir->input_dev); 171 - } 155 + if (ir->keypressed && 156 + (ir->last_key != keycode || toggle != ir->last_toggle)) 157 + input_event(ir->input_dev, EV_KEY, ir->last_key, 0); 172 158 159 + input_event(ir->input_dev, EV_KEY, keycode, 1); 160 + input_sync(ir->input_dev); 161 + 162 + ir->keypressed = true; 173 163 ir->last_key = keycode; 174 164 ir->last_toggle = toggle; 175 165 176 - ir->keyup_timer.expires = jiffies + UP_TIMEOUT; 177 - add_timer(&ir->keyup_timer); 178 - 166 + mod_timer(&ir->keyup_timer, jiffies + UP_TIMEOUT); 179 167 } 180 168 181 169 ··· 193 203 ir->input_dev->keycodesize = sizeof(ir->key_map[0]); 194 204 ir->input_dev->keycodemax = ARRAY_SIZE(ir->key_map); 195 205 } 196 - 197 - 198 - /* called by the input driver after rep[REP_DELAY] ms */ 199 - static void input_repeat_key(unsigned long parm) 200 - { 201 - struct infrared *ir = (struct infrared *) parm; 202 - 203 - ir->delay_timer_finished = 1; 204 - } 205 - 206 206 207 207 /* check for configuration changes */ 208 208 int av7110_check_ir_config(struct av7110 *av7110, int force) ··· 313 333 av_list[av_cnt++] = av7110; 314 334 av7110_check_ir_config(av7110, true); 315 335 316 - setup_timer(&av7110->ir.keyup_timer, av7110_emit_keyup, 317 - (unsigned long)&av7110->ir); 336 + timer_setup(&av7110->ir.keyup_timer, av7110_emit_keyup, 0); 318 337 319 338 input_dev = input_allocate_device(); 320 339 if (!input_dev) ··· 344 365 input_free_device(input_dev); 345 366 return err; 346 367 } 347 - input_dev->timer.function = input_repeat_key; 348 - input_dev->timer.data = (unsigned long) &av7110->ir; 368 + 369 + /* 370 + * Input core's default autorepeat is 33 cps with 250 msec 371 + * delay, let's adjust to numbers more suitable for remote 372 + * control. 373 + */ 374 + input_enable_softrepeat(input_dev, 250, 125); 349 375 350 376 if (av_cnt == 1) { 351 377 e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops);
-61
include/linux/gpio_mouse.h
··· 1 - /* 2 - * Driver for simulating a mouse on GPIO lines. 3 - * 4 - * Copyright (C) 2007 Atmel Corporation 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License version 2 as 8 - * published by the Free Software Foundation. 9 - */ 10 - 11 - #ifndef _GPIO_MOUSE_H 12 - #define _GPIO_MOUSE_H 13 - 14 - #define GPIO_MOUSE_POLARITY_ACT_HIGH 0x00 15 - #define GPIO_MOUSE_POLARITY_ACT_LOW 0x01 16 - 17 - #define GPIO_MOUSE_PIN_UP 0 18 - #define GPIO_MOUSE_PIN_DOWN 1 19 - #define GPIO_MOUSE_PIN_LEFT 2 20 - #define GPIO_MOUSE_PIN_RIGHT 3 21 - #define GPIO_MOUSE_PIN_BLEFT 4 22 - #define GPIO_MOUSE_PIN_BMIDDLE 5 23 - #define GPIO_MOUSE_PIN_BRIGHT 6 24 - #define GPIO_MOUSE_PIN_MAX 7 25 - 26 - /** 27 - * struct gpio_mouse_platform_data 28 - * @scan_ms: integer in ms specifying the scan periode. 29 - * @polarity: Pin polarity, active high or low. 30 - * @up: GPIO line for up value. 31 - * @down: GPIO line for down value. 32 - * @left: GPIO line for left value. 33 - * @right: GPIO line for right value. 34 - * @bleft: GPIO line for left button. 35 - * @bmiddle: GPIO line for middle button. 36 - * @bright: GPIO line for right button. 37 - * 38 - * This struct must be added to the platform_device in the board code. 39 - * It is used by the gpio_mouse driver to setup GPIO lines and to 40 - * calculate mouse movement. 41 - */ 42 - struct gpio_mouse_platform_data { 43 - int scan_ms; 44 - int polarity; 45 - 46 - union { 47 - struct { 48 - int up; 49 - int down; 50 - int left; 51 - int right; 52 - 53 - int bleft; 54 - int bmiddle; 55 - int bright; 56 - }; 57 - int pins[GPIO_MOUSE_PIN_MAX]; 58 - }; 59 - }; 60 - 61 - #endif /* _GPIO_MOUSE_H */
-14
include/linux/platform_data/st1232_pdata.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _LINUX_ST1232_PDATA_H 3 - #define _LINUX_ST1232_PDATA_H 4 - 5 - /* 6 - * Optional platform data 7 - * 8 - * Use this if you want the driver to drive the reset pin. 9 - */ 10 - struct st1232_pdata { 11 - int reset_gpio; 12 - }; 13 - 14 - #endif
-81
include/linux/uinput.h
··· 1 - /* 2 - * User level driver support for input subsystem 3 - * 4 - * Heavily based on evdev.c by Vojtech Pavlik 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License as published by 8 - * the Free Software Foundation; either version 2 of the License, or 9 - * (at your option) any later version. 10 - * 11 - * This program is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 - * GNU General Public License for more details. 15 - * 16 - * You should have received a copy of the GNU General Public License 17 - * along with this program; if not, write to the Free Software 18 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 - * 20 - * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org> 21 - * 22 - * Changes/Revisions: 23 - * 0.5 08/13/2015 (David Herrmann <dh.herrmann@gmail.com> & 24 - * Benjamin Tissoires <benjamin.tissoires@redhat.com>) 25 - * - add UI_DEV_SETUP ioctl 26 - * - add UI_ABS_SETUP ioctl 27 - * - add UI_GET_VERSION ioctl 28 - * 0.4 01/09/2014 (Benjamin Tissoires <benjamin.tissoires@redhat.com>) 29 - * - add UI_GET_SYSNAME ioctl 30 - * 0.3 24/05/2006 (Anssi Hannula <anssi.hannulagmail.com>) 31 - * - update ff support for the changes in kernel interface 32 - * - add UINPUT_VERSION 33 - * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>) 34 - * - added force feedback support 35 - * - added UI_SET_PHYS 36 - * 0.1 20/06/2002 37 - * - first public version 38 - */ 39 - #ifndef __UINPUT_H_ 40 - #define __UINPUT_H_ 41 - 42 - #include <uapi/linux/uinput.h> 43 - 44 - #define UINPUT_NAME "uinput" 45 - #define UINPUT_BUFFER_SIZE 16 46 - #define UINPUT_NUM_REQUESTS 16 47 - 48 - enum uinput_state { UIST_NEW_DEVICE, UIST_SETUP_COMPLETE, UIST_CREATED }; 49 - 50 - struct uinput_request { 51 - unsigned int id; 52 - unsigned int code; /* UI_FF_UPLOAD, UI_FF_ERASE */ 53 - 54 - int retval; 55 - struct completion done; 56 - 57 - union { 58 - unsigned int effect_id; 59 - struct { 60 - struct ff_effect *effect; 61 - struct ff_effect *old; 62 - } upload; 63 - } u; 64 - }; 65 - 66 - struct uinput_device { 67 - struct input_dev *dev; 68 - struct mutex mutex; 69 - enum uinput_state state; 70 - wait_queue_head_t waitq; 71 - unsigned char ready; 72 - unsigned char head; 73 - unsigned char tail; 74 - struct input_event buff[UINPUT_BUFFER_SIZE]; 75 - unsigned int ff_effects_max; 76 - 77 - struct uinput_request *requests[UINPUT_NUM_REQUESTS]; 78 - wait_queue_head_t requests_waitq; 79 - spinlock_t requests_lock; 80 - }; 81 - #endif /* __UINPUT_H_ */