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

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (57 commits)
Input: adp5588-keypad - fix NULL dereference in adp5588_gpio_add()
Input: cy8ctmg110 - capacitive touchscreen support
Input: keyboard - also match braille-only keyboards
Input: adp5588-keys - export unused GPIO pins
Input: xpad - add product ID for Hori Fighting Stick EX2
Input: adxl34x - fix leak and use after free
Input: samsung-keypad - Add samsung keypad driver
Input: i8042 - reset keyboard controller wehen resuming from S2R
Input: synaptics - set min/max for finger width
Input: synaptics - only report width on hardware that supports it
Input: evdev - signal that device is writable in evdev_poll()
Input: mousedev - signal that device is writable in mousedev_poll()
Input: change input handlers to use bool when possible
Input: document the MT event slot protocol
Input: introduce MT event slots
Input: usbtouchscreen - implement reset_resume
Input: usbtouchscreen - implement runtime power management
Input: usbtouchscreen - implement basic suspend/resume
Input: Add ATMEL QT602240 touchscreen driver
Input: fix signedness warning in input_set_keycode()
...

+6501 -988
+148 -68
Documentation/input/multi-touch-protocol.txt
··· 6 Introduction 7 ------------ 8 9 - In order to utilize the full power of the new multi-touch devices, a way to 10 - report detailed finger data to user space is needed. This document 11 - describes the multi-touch (MT) protocol which allows kernel drivers to 12 - report details for an arbitrary number of fingers. 13 14 15 - Usage 16 - ----- 17 18 - Anonymous finger details are sent sequentially as separate packets of ABS 19 - events. Only the ABS_MT events are recognized as part of a finger 20 - packet. The end of a packet is marked by calling the input_mt_sync() 21 - function, which generates a SYN_MT_REPORT event. This instructs the 22 - receiver to accept the data for the current finger and prepare to receive 23 - another. The end of a multi-touch transfer is marked by calling the usual 24 input_sync() function. This instructs the receiver to act upon events 25 - accumulated since last EV_SYN/SYN_REPORT and prepare to receive a new 26 - set of events/packets. 27 28 A set of ABS_MT events with the desired properties is defined. The events 29 are divided into categories, to allow for partial implementation. The 30 minimum set consists of ABS_MT_POSITION_X and ABS_MT_POSITION_Y, which 31 - allows for multiple fingers to be tracked. If the device supports it, the 32 ABS_MT_TOUCH_MAJOR and ABS_MT_WIDTH_MAJOR may be used to provide the size 33 - of the contact area and approaching finger, respectively. 34 35 The TOUCH and WIDTH parameters have a geometrical interpretation; imagine 36 looking through a window at someone gently holding a finger against the ··· 159 ABS_MT_WIDTH_MAJOR. Now imagine the person pressing the finger harder 160 against the glass. The inner region will increase, and in general, the 161 ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR, which is always smaller than 162 - unity, is related to the finger pressure. For pressure-based devices, 163 ABS_MT_PRESSURE may be used to provide the pressure on the contact area 164 instead. 165 166 - In addition to the MAJOR parameters, the oval shape of the finger can be 167 described by adding the MINOR parameters, such that MAJOR and MINOR are the 168 major and minor axis of an ellipse. Finally, the orientation of the oval 169 shape can be describe with the ORIENTATION parameter. 170 171 The ABS_MT_TOOL_TYPE may be used to specify whether the touching tool is a 172 - finger or a pen or something else. Devices with more granular information 173 may specify general shapes as blobs, i.e., as a sequence of rectangular 174 shapes grouped together by an ABS_MT_BLOB_ID. Finally, for the few devices 175 that currently support it, the ABS_MT_TRACKING_ID event may be used to 176 - report finger tracking from hardware [5]. 177 178 - Here is what a minimal event sequence for a two-finger touch would look 179 - like: 180 - 181 - ABS_MT_POSITION_X 182 - ABS_MT_POSITION_Y 183 - SYN_MT_REPORT 184 - ABS_MT_POSITION_X 185 - ABS_MT_POSITION_Y 186 - SYN_MT_REPORT 187 - SYN_REPORT 188 - 189 - Here is the sequence after lifting one of the fingers: 190 - 191 - ABS_MT_POSITION_X 192 - ABS_MT_POSITION_Y 193 - SYN_MT_REPORT 194 - SYN_REPORT 195 - 196 - And here is the sequence after lifting the remaining finger: 197 - 198 - SYN_MT_REPORT 199 - SYN_REPORT 200 - 201 - If the driver reports one of BTN_TOUCH or ABS_PRESSURE in addition to the 202 - ABS_MT events, the last SYN_MT_REPORT event may be omitted. Otherwise, the 203 - last SYN_REPORT will be dropped by the input core, resulting in no 204 - zero-finger event reaching userland. 205 206 Event Semantics 207 --------------- 208 - 209 - The word "contact" is used to describe a tool which is in direct contact 210 - with the surface. A finger, a pen or a rubber all classify as contacts. 211 212 ABS_MT_TOUCH_MAJOR 213 ··· 245 ABS_MT_BLOB_ID 246 247 The BLOB_ID groups several packets together into one arbitrarily shaped 248 - contact. This is a low-level anonymous grouping, and should not be confused 249 - with the high-level trackingID [5]. Most kernel drivers will not have blob 250 - capability, and can safely omit the event. 251 252 ABS_MT_TRACKING_ID 253 254 The TRACKING_ID identifies an initiated contact throughout its life cycle 255 - [5]. There are currently only a few devices that support it, so this event 256 - should normally be omitted. 257 258 259 Event Computation ··· 281 Finger Tracking 282 --------------- 283 284 - The kernel driver should generate an arbitrary enumeration of the set of 285 - anonymous contacts currently on the surface. The order in which the packets 286 - appear in the event stream is not important. 287 - 288 The process of finger tracking, i.e., to assign a unique trackingID to each 289 - initiated contact on the surface, is left to user space; preferably the 290 - multi-touch X driver [3]. In that driver, the trackingID stays the same and 291 - unique until the contact vanishes (when the finger leaves the surface). The 292 - problem of assigning a set of anonymous fingers to a set of identified 293 - fingers is a euclidian bipartite matching problem at each event update, and 294 - relies on a sufficiently rapid update rate. 295 - 296 - There are a few devices that support trackingID in hardware. User space can 297 - make use of these native identifiers to reduce bandwidth and cpu usage. 298 299 300 Gestures
··· 6 Introduction 7 ------------ 8 9 + In order to utilize the full power of the new multi-touch and multi-user 10 + devices, a way to report detailed data from multiple contacts, i.e., 11 + objects in direct contact with the device surface, is needed. This 12 + document describes the multi-touch (MT) protocol which allows kernel 13 + drivers to report details for an arbitrary number of contacts. 14 + 15 + The protocol is divided into two types, depending on the capabilities of the 16 + hardware. For devices handling anonymous contacts (type A), the protocol 17 + describes how to send the raw data for all contacts to the receiver. For 18 + devices capable of tracking identifiable contacts (type B), the protocol 19 + describes how to send updates for individual contacts via event slots. 20 21 22 + Protocol Usage 23 + -------------- 24 25 + Contact details are sent sequentially as separate packets of ABS_MT 26 + events. Only the ABS_MT events are recognized as part of a contact 27 + packet. Since these events are ignored by current single-touch (ST) 28 + applications, the MT protocol can be implemented on top of the ST protocol 29 + in an existing driver. 30 + 31 + Drivers for type A devices separate contact packets by calling 32 + input_mt_sync() at the end of each packet. This generates a SYN_MT_REPORT 33 + event, which instructs the receiver to accept the data for the current 34 + contact and prepare to receive another. 35 + 36 + Drivers for type B devices separate contact packets by calling 37 + input_mt_slot(), with a slot as argument, at the beginning of each packet. 38 + This generates an ABS_MT_SLOT event, which instructs the receiver to 39 + prepare for updates of the given slot. 40 + 41 + All drivers mark the end of a multi-touch transfer by calling the usual 42 input_sync() function. This instructs the receiver to act upon events 43 + accumulated since last EV_SYN/SYN_REPORT and prepare to receive a new set 44 + of events/packets. 45 + 46 + The main difference between the stateless type A protocol and the stateful 47 + type B slot protocol lies in the usage of identifiable contacts to reduce 48 + the amount of data sent to userspace. The slot protocol requires the use of 49 + the ABS_MT_TRACKING_ID, either provided by the hardware or computed from 50 + the raw data [5]. 51 + 52 + For type A devices, the kernel driver should generate an arbitrary 53 + enumeration of the full set of anonymous contacts currently on the 54 + surface. The order in which the packets appear in the event stream is not 55 + important. Event filtering and finger tracking is left to user space [3]. 56 + 57 + For type B devices, the kernel driver should associate a slot with each 58 + identified contact, and use that slot to propagate changes for the contact. 59 + Creation, replacement and destruction of contacts is achieved by modifying 60 + the ABS_MT_TRACKING_ID of the associated slot. A non-negative tracking id 61 + is interpreted as a contact, and the value -1 denotes an unused slot. A 62 + tracking id not previously present is considered new, and a tracking id no 63 + longer present is considered removed. Since only changes are propagated, 64 + the full state of each initiated contact has to reside in the receiving 65 + end. Upon receiving an MT event, one simply updates the appropriate 66 + attribute of the current slot. 67 + 68 + 69 + Protocol Example A 70 + ------------------ 71 + 72 + Here is what a minimal event sequence for a two-contact touch would look 73 + like for a type A device: 74 + 75 + ABS_MT_POSITION_X x[0] 76 + ABS_MT_POSITION_Y y[0] 77 + SYN_MT_REPORT 78 + ABS_MT_POSITION_X x[1] 79 + ABS_MT_POSITION_Y y[1] 80 + SYN_MT_REPORT 81 + SYN_REPORT 82 + 83 + The sequence after moving one of the contacts looks exactly the same; the 84 + raw data for all present contacts are sent between every synchronization 85 + with SYN_REPORT. 86 + 87 + Here is the sequence after lifting the first contact: 88 + 89 + ABS_MT_POSITION_X x[1] 90 + ABS_MT_POSITION_Y y[1] 91 + SYN_MT_REPORT 92 + SYN_REPORT 93 + 94 + And here is the sequence after lifting the second contact: 95 + 96 + SYN_MT_REPORT 97 + SYN_REPORT 98 + 99 + If the driver reports one of BTN_TOUCH or ABS_PRESSURE in addition to the 100 + ABS_MT events, the last SYN_MT_REPORT event may be omitted. Otherwise, the 101 + last SYN_REPORT will be dropped by the input core, resulting in no 102 + zero-contact event reaching userland. 103 + 104 + 105 + Protocol Example B 106 + ------------------ 107 + 108 + Here is what a minimal event sequence for a two-contact touch would look 109 + like for a type B device: 110 + 111 + ABS_MT_SLOT 0 112 + ABS_MT_TRACKING_ID 45 113 + ABS_MT_POSITION_X x[0] 114 + ABS_MT_POSITION_Y y[0] 115 + ABS_MT_SLOT 1 116 + ABS_MT_TRACKING_ID 46 117 + ABS_MT_POSITION_X x[1] 118 + ABS_MT_POSITION_Y y[1] 119 + SYN_REPORT 120 + 121 + Here is the sequence after moving contact 45 in the x direction: 122 + 123 + ABS_MT_SLOT 0 124 + ABS_MT_POSITION_X x[0] 125 + SYN_REPORT 126 + 127 + Here is the sequence after lifting the contact in slot 0: 128 + 129 + ABS_MT_TRACKING_ID -1 130 + SYN_REPORT 131 + 132 + The slot being modified is already 0, so the ABS_MT_SLOT is omitted. The 133 + message removes the association of slot 0 with contact 45, thereby 134 + destroying contact 45 and freeing slot 0 to be reused for another contact. 135 + 136 + Finally, here is the sequence after lifting the second contact: 137 + 138 + ABS_MT_SLOT 1 139 + ABS_MT_TRACKING_ID -1 140 + SYN_REPORT 141 + 142 + 143 + Event Usage 144 + ----------- 145 146 A set of ABS_MT events with the desired properties is defined. The events 147 are divided into categories, to allow for partial implementation. The 148 minimum set consists of ABS_MT_POSITION_X and ABS_MT_POSITION_Y, which 149 + allows for multiple contacts to be tracked. If the device supports it, the 150 ABS_MT_TOUCH_MAJOR and ABS_MT_WIDTH_MAJOR may be used to provide the size 151 + of the contact area and approaching contact, respectively. 152 153 The TOUCH and WIDTH parameters have a geometrical interpretation; imagine 154 looking through a window at someone gently holding a finger against the ··· 41 ABS_MT_WIDTH_MAJOR. Now imagine the person pressing the finger harder 42 against the glass. The inner region will increase, and in general, the 43 ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR, which is always smaller than 44 + unity, is related to the contact pressure. For pressure-based devices, 45 ABS_MT_PRESSURE may be used to provide the pressure on the contact area 46 instead. 47 48 + In addition to the MAJOR parameters, the oval shape of the contact can be 49 described by adding the MINOR parameters, such that MAJOR and MINOR are the 50 major and minor axis of an ellipse. Finally, the orientation of the oval 51 shape can be describe with the ORIENTATION parameter. 52 53 The ABS_MT_TOOL_TYPE may be used to specify whether the touching tool is a 54 + contact or a pen or something else. Devices with more granular information 55 may specify general shapes as blobs, i.e., as a sequence of rectangular 56 shapes grouped together by an ABS_MT_BLOB_ID. Finally, for the few devices 57 that currently support it, the ABS_MT_TRACKING_ID event may be used to 58 + report contact tracking from hardware [5]. 59 60 61 Event Semantics 62 --------------- 63 64 ABS_MT_TOUCH_MAJOR 65 ··· 157 ABS_MT_BLOB_ID 158 159 The BLOB_ID groups several packets together into one arbitrarily shaped 160 + contact. This is a low-level anonymous grouping for type A devices, and 161 + should not be confused with the high-level trackingID [5]. Most type A 162 + devices do not have blob capability, so drivers can safely omit this event. 163 164 ABS_MT_TRACKING_ID 165 166 The TRACKING_ID identifies an initiated contact throughout its life cycle 167 + [5]. This event is mandatory for type B devices. The value range of the 168 + TRACKING_ID should be large enough to ensure unique identification of a 169 + contact maintained over an extended period of time. 170 171 172 Event Computation ··· 192 Finger Tracking 193 --------------- 194 195 The process of finger tracking, i.e., to assign a unique trackingID to each 196 + initiated contact on the surface, is a Euclidian Bipartite Matching 197 + problem. At each event synchronization, the set of actual contacts is 198 + matched to the set of contacts from the previous synchronization. A full 199 + implementation can be found in [3]. 200 201 202 Gestures
+43
arch/arm/plat-samsung/include/plat/keypad.h
···
··· 1 + /* 2 + * Samsung Platform - Keypad platform data definitions 3 + * 4 + * Copyright (C) 2010 Samsung Electronics Co.Ltd 5 + * Author: Joonyoung Shim <jy0922.shim@samsung.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; either version 2 of the License, or (at your 10 + * option) any later version. 11 + */ 12 + 13 + #ifndef __PLAT_SAMSUNG_KEYPAD_H 14 + #define __PLAT_SAMSUNG_KEYPAD_H 15 + 16 + #include <linux/input/matrix_keypad.h> 17 + 18 + #define SAMSUNG_MAX_ROWS 8 19 + #define SAMSUNG_MAX_COLS 8 20 + 21 + /** 22 + * struct samsung_keypad_platdata - Platform device data for Samsung Keypad. 23 + * @keymap_data: pointer to &matrix_keymap_data. 24 + * @rows: number of keypad row supported. 25 + * @cols: number of keypad col supported. 26 + * @no_autorepeat: disable key autorepeat. 27 + * @wakeup: controls whether the device should be set up as wakeup source. 28 + * @cfg_gpio: configure the GPIO. 29 + * 30 + * Initialisation data specific to either the machine or the platform 31 + * for the device driver to use or call-back when configuring gpio. 32 + */ 33 + struct samsung_keypad_platdata { 34 + const struct matrix_keymap_data *keymap_data; 35 + unsigned int rows; 36 + unsigned int cols; 37 + bool no_autorepeat; 38 + bool wakeup; 39 + 40 + void (*cfg_gpio)(unsigned int rows, unsigned int cols); 41 + }; 42 + 43 + #endif /* __PLAT_SAMSUNG_KEYPAD_H */
+5 -1
drivers/char/keyboard.c
··· 1315 if (test_bit(EV_SND, dev->evbit)) 1316 return true; 1317 1318 - if (test_bit(EV_KEY, dev->evbit)) 1319 for (i = KEY_RESERVED; i < BTN_MISC; i++) 1320 if (test_bit(i, dev->keybit)) 1321 return true; 1322 1323 return false; 1324 }
··· 1315 if (test_bit(EV_SND, dev->evbit)) 1316 return true; 1317 1318 + if (test_bit(EV_KEY, dev->evbit)) { 1319 for (i = KEY_RESERVED; i < BTN_MISC; i++) 1320 if (test_bit(i, dev->keybit)) 1321 return true; 1322 + for (i = KEY_BRL_DOT1; i <= KEY_BRL_DOT10; i++) 1323 + if (test_bit(i, dev->keybit)) 1324 + return true; 1325 + } 1326 1327 return false; 1328 }
+1
drivers/hid/hid-core.c
··· 1586 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 1587 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 1588 { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) }, 1589 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, 1590 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 1591 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) },
··· 1586 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 1587 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 1588 { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) }, 1589 + { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) }, 1590 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, 1591 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, 1592 { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) },
+1
drivers/hid/hid-ids.h
··· 198 199 #define USB_VENDOR_ID_ETT 0x0664 200 #define USB_DEVICE_ID_TC5UH 0x0309 201 202 #define USB_VENDOR_ID_EZKEY 0x0518 203 #define USB_DEVICE_ID_BTC_8193 0x0002
··· 198 199 #define USB_VENDOR_ID_ETT 0x0664 200 #define USB_DEVICE_ID_TC5UH 0x0309 201 + #define USB_DEVICE_ID_TC4UM 0x0306 202 203 #define USB_VENDOR_ID_EZKEY 0x0518 204 #define USB_DEVICE_ID_BTC_8193 0x0002
+3
drivers/hid/hid-input.c
··· 534 input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4); 535 else input_set_abs_params(input, usage->code, a, b, 0, 0); 536 537 } 538 539 if (usage->type == EV_ABS &&
··· 534 input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4); 535 else input_set_abs_params(input, usage->code, a, b, 0, 0); 536 537 + /* use a larger default input buffer for MT devices */ 538 + if (usage->code == ABS_MT_POSITION_X && input->hint_events_per_packet == 0) 539 + input_set_events_per_packet(input, 60); 540 } 541 542 if (usage->type == EV_ABS &&
+42 -12
drivers/input/evdev.c
··· 10 11 #define EVDEV_MINOR_BASE 64 12 #define EVDEV_MINORS 32 13 - #define EVDEV_BUFFER_SIZE 64 14 15 #include <linux/poll.h> 16 #include <linux/sched.h> ··· 24 #include "input-compat.h" 25 26 struct evdev { 27 - int exist; 28 int open; 29 int minor; 30 struct input_handle handle; ··· 33 spinlock_t client_lock; /* protects client_list */ 34 struct mutex mutex; 35 struct device dev; 36 }; 37 38 struct evdev_client { 39 - struct input_event buffer[EVDEV_BUFFER_SIZE]; 40 int head; 41 int tail; 42 spinlock_t buffer_lock; /* protects access to buffer, head and tail */ 43 struct fasync_struct *fasync; 44 struct evdev *evdev; 45 struct list_head node; 46 }; 47 48 static struct evdev *evdev_table[EVDEV_MINORS]; ··· 54 struct input_event *event) 55 { 56 /* 57 - * Interrupts are disabled, just acquire the lock 58 */ 59 spin_lock(&client->buffer_lock); 60 - client->buffer[client->head++] = *event; 61 - client->head &= EVDEV_BUFFER_SIZE - 1; 62 spin_unlock(&client->buffer_lock); 63 64 if (event->type == EV_SYN) ··· 248 return 0; 249 } 250 251 static int evdev_open(struct inode *inode, struct file *file) 252 { 253 struct evdev *evdev; 254 struct evdev_client *client; 255 int i = iminor(inode) - EVDEV_MINOR_BASE; 256 int error; 257 258 if (i >= EVDEV_MINORS) ··· 279 if (!evdev) 280 return -ENODEV; 281 282 - client = kzalloc(sizeof(struct evdev_client), GFP_KERNEL); 283 if (!client) { 284 error = -ENOMEM; 285 goto err_put_evdev; 286 } 287 288 spin_lock_init(&client->buffer_lock); 289 client->evdev = evdev; 290 evdev_attach_client(evdev, client); ··· 355 have_event = client->head != client->tail; 356 if (have_event) { 357 *event = client->buffer[client->tail++]; 358 - client->tail &= EVDEV_BUFFER_SIZE - 1; 359 } 360 361 spin_unlock_irq(&client->buffer_lock); ··· 403 { 404 struct evdev_client *client = file->private_data; 405 struct evdev *evdev = client->evdev; 406 407 poll_wait(file, &evdev->wait, wait); 408 - return ((client->head == client->tail) ? 0 : (POLLIN | POLLRDNORM)) | 409 - (evdev->exist ? 0 : (POLLHUP | POLLERR)); 410 } 411 412 #ifdef CONFIG_COMPAT ··· 691 sizeof(struct input_absinfo)))) 692 return -EFAULT; 693 694 /* 695 * Take event lock to ensure that we are not 696 * changing device parameters in the middle ··· 798 static void evdev_mark_dead(struct evdev *evdev) 799 { 800 mutex_lock(&evdev->mutex); 801 - evdev->exist = 0; 802 mutex_unlock(&evdev->mutex); 803 } 804 ··· 847 init_waitqueue_head(&evdev->wait); 848 849 dev_set_name(&evdev->dev, "event%d", minor); 850 - evdev->exist = 1; 851 evdev->minor = minor; 852 853 evdev->handle.dev = input_get_device(dev);
··· 10 11 #define EVDEV_MINOR_BASE 64 12 #define EVDEV_MINORS 32 13 + #define EVDEV_MIN_BUFFER_SIZE 64U 14 + #define EVDEV_BUF_PACKETS 8 15 16 #include <linux/poll.h> 17 #include <linux/sched.h> ··· 23 #include "input-compat.h" 24 25 struct evdev { 26 int open; 27 int minor; 28 struct input_handle handle; ··· 33 spinlock_t client_lock; /* protects client_list */ 34 struct mutex mutex; 35 struct device dev; 36 + bool exist; 37 }; 38 39 struct evdev_client { 40 int head; 41 int tail; 42 spinlock_t buffer_lock; /* protects access to buffer, head and tail */ 43 struct fasync_struct *fasync; 44 struct evdev *evdev; 45 struct list_head node; 46 + int bufsize; 47 + struct input_event buffer[]; 48 }; 49 50 static struct evdev *evdev_table[EVDEV_MINORS]; ··· 52 struct input_event *event) 53 { 54 /* 55 + * Interrupts are disabled, just acquire the lock. 56 + * Make sure we don't leave with the client buffer 57 + * "empty" by having client->head == client->tail. 58 */ 59 spin_lock(&client->buffer_lock); 60 + do { 61 + client->buffer[client->head++] = *event; 62 + client->head &= client->bufsize - 1; 63 + } while (client->head == client->tail); 64 spin_unlock(&client->buffer_lock); 65 66 if (event->type == EV_SYN) ··· 242 return 0; 243 } 244 245 + static unsigned int evdev_compute_buffer_size(struct input_dev *dev) 246 + { 247 + unsigned int n_events = 248 + max(dev->hint_events_per_packet * EVDEV_BUF_PACKETS, 249 + EVDEV_MIN_BUFFER_SIZE); 250 + 251 + return roundup_pow_of_two(n_events); 252 + } 253 + 254 static int evdev_open(struct inode *inode, struct file *file) 255 { 256 struct evdev *evdev; 257 struct evdev_client *client; 258 int i = iminor(inode) - EVDEV_MINOR_BASE; 259 + unsigned int bufsize; 260 int error; 261 262 if (i >= EVDEV_MINORS) ··· 263 if (!evdev) 264 return -ENODEV; 265 266 + bufsize = evdev_compute_buffer_size(evdev->handle.dev); 267 + 268 + client = kzalloc(sizeof(struct evdev_client) + 269 + bufsize * sizeof(struct input_event), 270 + GFP_KERNEL); 271 if (!client) { 272 error = -ENOMEM; 273 goto err_put_evdev; 274 } 275 276 + client->bufsize = bufsize; 277 spin_lock_init(&client->buffer_lock); 278 client->evdev = evdev; 279 evdev_attach_client(evdev, client); ··· 334 have_event = client->head != client->tail; 335 if (have_event) { 336 *event = client->buffer[client->tail++]; 337 + client->tail &= client->bufsize - 1; 338 } 339 340 spin_unlock_irq(&client->buffer_lock); ··· 382 { 383 struct evdev_client *client = file->private_data; 384 struct evdev *evdev = client->evdev; 385 + unsigned int mask; 386 387 poll_wait(file, &evdev->wait, wait); 388 + 389 + mask = evdev->exist ? POLLOUT | POLLWRNORM : POLLHUP | POLLERR; 390 + if (client->head != client->tail) 391 + mask |= POLLIN | POLLRDNORM; 392 + 393 + return mask; 394 } 395 396 #ifdef CONFIG_COMPAT ··· 665 sizeof(struct input_absinfo)))) 666 return -EFAULT; 667 668 + /* We can't change number of reserved MT slots */ 669 + if (t == ABS_MT_SLOT) 670 + return -EINVAL; 671 + 672 /* 673 * Take event lock to ensure that we are not 674 * changing device parameters in the middle ··· 768 static void evdev_mark_dead(struct evdev *evdev) 769 { 770 mutex_lock(&evdev->mutex); 771 + evdev->exist = false; 772 mutex_unlock(&evdev->mutex); 773 } 774 ··· 817 init_waitqueue_head(&evdev->wait); 818 819 dev_set_name(&evdev->dev, "event%d", minor); 820 + evdev->exist = true; 821 evdev->minor = minor; 822 823 evdev->handle.dev = input_get_device(dev);
+125 -57
drivers/input/input.c
··· 33 34 #define INPUT_DEVICES 256 35 36 - /* 37 - * EV_ABS events which should not be cached are listed here. 38 - */ 39 - static unsigned int input_abs_bypass_init_data[] __initdata = { 40 - ABS_MT_TOUCH_MAJOR, 41 - ABS_MT_TOUCH_MINOR, 42 - ABS_MT_WIDTH_MAJOR, 43 - ABS_MT_WIDTH_MINOR, 44 - ABS_MT_ORIENTATION, 45 - ABS_MT_POSITION_X, 46 - ABS_MT_POSITION_Y, 47 - ABS_MT_TOOL_TYPE, 48 - ABS_MT_BLOB_ID, 49 - ABS_MT_TRACKING_ID, 50 - ABS_MT_PRESSURE, 51 - 0 52 - }; 53 - static unsigned long input_abs_bypass[BITS_TO_LONGS(ABS_CNT)]; 54 - 55 static LIST_HEAD(input_dev_list); 56 static LIST_HEAD(input_handler_list); 57 ··· 162 #define INPUT_PASS_TO_DEVICE 2 163 #define INPUT_PASS_TO_ALL (INPUT_PASS_TO_HANDLERS | INPUT_PASS_TO_DEVICE) 164 165 static void input_handle_event(struct input_dev *dev, 166 unsigned int type, unsigned int code, int value) 167 { ··· 227 228 case SYN_REPORT: 229 if (!dev->sync) { 230 - dev->sync = 1; 231 disposition = INPUT_PASS_TO_HANDLERS; 232 } 233 break; 234 case SYN_MT_REPORT: 235 - dev->sync = 0; 236 disposition = INPUT_PASS_TO_HANDLERS; 237 break; 238 } ··· 264 break; 265 266 case EV_ABS: 267 - if (is_event_supported(code, dev->absbit, ABS_MAX)) { 268 269 - if (test_bit(code, input_abs_bypass)) { 270 - disposition = INPUT_PASS_TO_HANDLERS; 271 - break; 272 - } 273 - 274 - value = input_defuzz_abs_event(value, 275 - dev->abs[code], dev->absfuzz[code]); 276 - 277 - if (dev->abs[code] != value) { 278 - dev->abs[code] = value; 279 - disposition = INPUT_PASS_TO_HANDLERS; 280 - } 281 - } 282 break; 283 284 case EV_REL: ··· 317 } 318 319 if (disposition != INPUT_IGNORE_EVENT && type != EV_SYN) 320 - dev->sync = 0; 321 322 if ((disposition & INPUT_PASS_TO_DEVICE) && dev->event) 323 dev->event(dev, type, code, value); ··· 547 EXPORT_SYMBOL(input_close_device); 548 549 /* 550 * Prepare device for unregistering 551 */ 552 static void input_disconnect_device(struct input_dev *dev) 553 { 554 struct input_handle *handle; 555 - int code; 556 557 /* 558 * Mark device as going away. Note that we take dev->mutex here ··· 589 * generate events even after we done here but they will not 590 * reach any handlers. 591 */ 592 - if (is_event_supported(EV_KEY, dev->evbit, EV_MAX)) { 593 - for (code = 0; code <= KEY_MAX; code++) { 594 - if (is_event_supported(code, dev->keybit, KEY_MAX) && 595 - __test_and_clear_bit(code, dev->key)) { 596 - input_pass_event(dev, EV_KEY, code, 0); 597 - } 598 - } 599 - input_pass_event(dev, EV_SYN, SYN_REPORT, 1); 600 - } 601 602 list_for_each_entry(handle, &dev->h_list, d_node) 603 handle->open = 0; ··· 713 unsigned int scancode, unsigned int keycode) 714 { 715 unsigned long flags; 716 - int old_keycode; 717 int retval; 718 719 if (keycode > KEY_MAX) ··· 1307 struct input_dev *dev = to_input_dev(device); 1308 1309 input_ff_destroy(dev); 1310 kfree(dev); 1311 1312 module_put(THIS_MODULE); ··· 1463 1464 mutex_lock(&input_dev->mutex); 1465 input_dev_reset(input_dev, true); 1466 mutex_unlock(&input_dev->mutex); 1467 1468 return 0; ··· 1555 input_put_device(dev); 1556 } 1557 EXPORT_SYMBOL(input_free_device); 1558 1559 /** 1560 * input_set_capability - mark device as capable of a certain event ··· 2004 .open = input_open_file, 2005 }; 2006 2007 - static void __init input_init_abs_bypass(void) 2008 - { 2009 - const unsigned int *p; 2010 - 2011 - for (p = input_abs_bypass_init_data; *p; p++) 2012 - input_abs_bypass[BIT_WORD(*p)] |= BIT_MASK(*p); 2013 - } 2014 - 2015 static int __init input_init(void) 2016 { 2017 int err; 2018 - 2019 - input_init_abs_bypass(); 2020 2021 err = class_register(&input_class); 2022 if (err) {
··· 33 34 #define INPUT_DEVICES 256 35 36 static LIST_HEAD(input_dev_list); 37 static LIST_HEAD(input_handler_list); 38 ··· 181 #define INPUT_PASS_TO_DEVICE 2 182 #define INPUT_PASS_TO_ALL (INPUT_PASS_TO_HANDLERS | INPUT_PASS_TO_DEVICE) 183 184 + static int input_handle_abs_event(struct input_dev *dev, 185 + unsigned int code, int *pval) 186 + { 187 + bool is_mt_event; 188 + int *pold; 189 + 190 + if (code == ABS_MT_SLOT) { 191 + /* 192 + * "Stage" the event; we'll flush it later, when we 193 + * get actiual touch data. 194 + */ 195 + if (*pval >= 0 && *pval < dev->mtsize) 196 + dev->slot = *pval; 197 + 198 + return INPUT_IGNORE_EVENT; 199 + } 200 + 201 + is_mt_event = code >= ABS_MT_FIRST && code <= ABS_MT_LAST; 202 + 203 + if (!is_mt_event) { 204 + pold = &dev->abs[code]; 205 + } else if (dev->mt) { 206 + struct input_mt_slot *mtslot = &dev->mt[dev->slot]; 207 + pold = &mtslot->abs[code - ABS_MT_FIRST]; 208 + } else { 209 + /* 210 + * Bypass filtering for multitouch events when 211 + * not employing slots. 212 + */ 213 + pold = NULL; 214 + } 215 + 216 + if (pold) { 217 + *pval = input_defuzz_abs_event(*pval, *pold, 218 + dev->absfuzz[code]); 219 + if (*pold == *pval) 220 + return INPUT_IGNORE_EVENT; 221 + 222 + *pold = *pval; 223 + } 224 + 225 + /* Flush pending "slot" event */ 226 + if (is_mt_event && dev->slot != dev->abs[ABS_MT_SLOT]) { 227 + dev->abs[ABS_MT_SLOT] = dev->slot; 228 + input_pass_event(dev, EV_ABS, ABS_MT_SLOT, dev->slot); 229 + } 230 + 231 + return INPUT_PASS_TO_HANDLERS; 232 + } 233 + 234 static void input_handle_event(struct input_dev *dev, 235 unsigned int type, unsigned int code, int value) 236 { ··· 196 197 case SYN_REPORT: 198 if (!dev->sync) { 199 + dev->sync = true; 200 disposition = INPUT_PASS_TO_HANDLERS; 201 } 202 break; 203 case SYN_MT_REPORT: 204 + dev->sync = false; 205 disposition = INPUT_PASS_TO_HANDLERS; 206 break; 207 } ··· 233 break; 234 235 case EV_ABS: 236 + if (is_event_supported(code, dev->absbit, ABS_MAX)) 237 + disposition = input_handle_abs_event(dev, code, &value); 238 239 break; 240 241 case EV_REL: ··· 298 } 299 300 if (disposition != INPUT_IGNORE_EVENT && type != EV_SYN) 301 + dev->sync = false; 302 303 if ((disposition & INPUT_PASS_TO_DEVICE) && dev->event) 304 dev->event(dev, type, code, value); ··· 528 EXPORT_SYMBOL(input_close_device); 529 530 /* 531 + * Simulate keyup events for all keys that are marked as pressed. 532 + * The function must be called with dev->event_lock held. 533 + */ 534 + static void input_dev_release_keys(struct input_dev *dev) 535 + { 536 + int code; 537 + 538 + if (is_event_supported(EV_KEY, dev->evbit, EV_MAX)) { 539 + for (code = 0; code <= KEY_MAX; code++) { 540 + if (is_event_supported(code, dev->keybit, KEY_MAX) && 541 + __test_and_clear_bit(code, dev->key)) { 542 + input_pass_event(dev, EV_KEY, code, 0); 543 + } 544 + } 545 + input_pass_event(dev, EV_SYN, SYN_REPORT, 1); 546 + } 547 + } 548 + 549 + /* 550 * Prepare device for unregistering 551 */ 552 static void input_disconnect_device(struct input_dev *dev) 553 { 554 struct input_handle *handle; 555 556 /* 557 * Mark device as going away. Note that we take dev->mutex here ··· 552 * generate events even after we done here but they will not 553 * reach any handlers. 554 */ 555 + input_dev_release_keys(dev); 556 557 list_for_each_entry(handle, &dev->h_list, d_node) 558 handle->open = 0; ··· 684 unsigned int scancode, unsigned int keycode) 685 { 686 unsigned long flags; 687 + unsigned int old_keycode; 688 int retval; 689 690 if (keycode > KEY_MAX) ··· 1278 struct input_dev *dev = to_input_dev(device); 1279 1280 input_ff_destroy(dev); 1281 + input_mt_destroy_slots(dev); 1282 kfree(dev); 1283 1284 module_put(THIS_MODULE); ··· 1433 1434 mutex_lock(&input_dev->mutex); 1435 input_dev_reset(input_dev, true); 1436 + 1437 + /* 1438 + * Keys that have been pressed at suspend time are unlikely 1439 + * to be still pressed when we resume. 1440 + */ 1441 + spin_lock_irq(&input_dev->event_lock); 1442 + input_dev_release_keys(input_dev); 1443 + spin_unlock_irq(&input_dev->event_lock); 1444 + 1445 mutex_unlock(&input_dev->mutex); 1446 1447 return 0; ··· 1516 input_put_device(dev); 1517 } 1518 EXPORT_SYMBOL(input_free_device); 1519 + 1520 + /** 1521 + * input_mt_create_slots() - create MT input slots 1522 + * @dev: input device supporting MT events and finger tracking 1523 + * @num_slots: number of slots used by the device 1524 + * 1525 + * This function allocates all necessary memory for MT slot handling 1526 + * in the input device, and adds ABS_MT_SLOT to the device capabilities. 1527 + */ 1528 + int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots) 1529 + { 1530 + if (!num_slots) 1531 + return 0; 1532 + 1533 + dev->mt = kcalloc(num_slots, sizeof(struct input_mt_slot), GFP_KERNEL); 1534 + if (!dev->mt) 1535 + return -ENOMEM; 1536 + 1537 + dev->mtsize = num_slots; 1538 + input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0); 1539 + 1540 + return 0; 1541 + } 1542 + EXPORT_SYMBOL(input_mt_create_slots); 1543 + 1544 + /** 1545 + * input_mt_destroy_slots() - frees the MT slots of the input device 1546 + * @dev: input device with allocated MT slots 1547 + * 1548 + * This function is only needed in error path as the input core will 1549 + * automatically free the MT slots when the device is destroyed. 1550 + */ 1551 + void input_mt_destroy_slots(struct input_dev *dev) 1552 + { 1553 + kfree(dev->mt); 1554 + dev->mt = NULL; 1555 + dev->mtsize = 0; 1556 + } 1557 + EXPORT_SYMBOL(input_mt_destroy_slots); 1558 1559 /** 1560 * input_set_capability - mark device as capable of a certain event ··· 1926 .open = input_open_file, 1927 }; 1928 1929 static int __init input_init(void) 1930 { 1931 int err; 1932 1933 err = class_register(&input_class); 1934 if (err) {
+3 -4
drivers/input/joydev.c
··· 37 #define JOYDEV_BUFFER_SIZE 64 38 39 struct joydev { 40 - int exist; 41 int open; 42 int minor; 43 struct input_handle handle; ··· 45 spinlock_t client_lock; /* protects client_list */ 46 struct mutex mutex; 47 struct device dev; 48 49 struct js_corr corr[ABS_CNT]; 50 struct JS_DATA_SAVE_TYPE glue; ··· 760 static void joydev_mark_dead(struct joydev *joydev) 761 { 762 mutex_lock(&joydev->mutex); 763 - joydev->exist = 0; 764 mutex_unlock(&joydev->mutex); 765 } 766 ··· 817 init_waitqueue_head(&joydev->wait); 818 819 dev_set_name(&joydev->dev, "js%d", minor); 820 - joydev->exist = 1; 821 joydev->minor = minor; 822 823 - joydev->exist = 1; 824 joydev->handle.dev = input_get_device(dev); 825 joydev->handle.name = dev_name(&joydev->dev); 826 joydev->handle.handler = handler;
··· 37 #define JOYDEV_BUFFER_SIZE 64 38 39 struct joydev { 40 int open; 41 int minor; 42 struct input_handle handle; ··· 46 spinlock_t client_lock; /* protects client_list */ 47 struct mutex mutex; 48 struct device dev; 49 + bool exist; 50 51 struct js_corr corr[ABS_CNT]; 52 struct JS_DATA_SAVE_TYPE glue; ··· 760 static void joydev_mark_dead(struct joydev *joydev) 761 { 762 mutex_lock(&joydev->mutex); 763 + joydev->exist = false; 764 mutex_unlock(&joydev->mutex); 765 } 766 ··· 817 init_waitqueue_head(&joydev->wait); 818 819 dev_set_name(&joydev->dev, "js%d", minor); 820 + joydev->exist = true; 821 joydev->minor = minor; 822 823 joydev->handle.dev = input_get_device(dev); 824 joydev->handle.name = dev_name(&joydev->dev); 825 joydev->handle.handler = handler;
+62 -42
drivers/input/joystick/xpad.c
··· 9 * 2005 Dominic Cerquetti <binary1230@yahoo.com> 10 * 2006 Adam Buchbinder <adam.buchbinder@gmail.com> 11 * 2007 Jan Kratochvil <honza@jikos.cz> 12 * 13 * This program is free software; you can redistribute it and/or 14 * modify it under the terms of the GNU General Public License as ··· 89 but we map them to axes when possible to simplify things */ 90 #define MAP_DPAD_TO_BUTTONS (1 << 0) 91 #define MAP_TRIGGERS_TO_BUTTONS (1 << 1) 92 93 #define XTYPE_XBOX 0 94 #define XTYPE_XBOX360 1 ··· 106 module_param(triggers_to_buttons, bool, S_IRUGO); 107 MODULE_PARM_DESC(triggers_to_buttons, "Map triggers to buttons rather than axes for unknown pads"); 108 109 static const struct xpad_device { 110 u16 idVendor; 111 u16 idProduct; ··· 122 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX }, 123 { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX }, 124 { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, 125 - { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 126 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, 127 { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 }, 128 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX }, ··· 159 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 }, 160 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 161 { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 162 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, 163 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } 164 }; ··· 167 /* buttons shared with xbox and xbox360 */ 168 static const signed short xpad_common_btn[] = { 169 BTN_A, BTN_B, BTN_X, BTN_Y, /* "analog" buttons */ 170 - BTN_START, BTN_BACK, BTN_THUMBL, BTN_THUMBR, /* start/back/sticks */ 171 -1 /* terminating entry */ 172 }; 173 ··· 177 -1 /* terminating entry */ 178 }; 179 180 - /* used when dpad is mapped to nuttons */ 181 static const signed short xpad_btn_pad[] = { 182 - BTN_LEFT, BTN_RIGHT, /* d-pad left, right */ 183 - BTN_0, BTN_1, /* d-pad up, down (XXX names??) */ 184 -1 /* terminating entry */ 185 }; 186 ··· 288 { 289 struct input_dev *dev = xpad->dev; 290 291 - /* left stick */ 292 - input_report_abs(dev, ABS_X, 293 - (__s16) le16_to_cpup((__le16 *)(data + 12))); 294 - input_report_abs(dev, ABS_Y, 295 - ~(__s16) le16_to_cpup((__le16 *)(data + 14))); 296 297 - /* right stick */ 298 - input_report_abs(dev, ABS_RX, 299 - (__s16) le16_to_cpup((__le16 *)(data + 16))); 300 - input_report_abs(dev, ABS_RY, 301 - ~(__s16) le16_to_cpup((__le16 *)(data + 18))); 302 303 /* triggers left/right */ 304 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { ··· 313 314 /* digital pad */ 315 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 316 - input_report_key(dev, BTN_LEFT, data[2] & 0x04); 317 - input_report_key(dev, BTN_RIGHT, data[2] & 0x08); 318 - input_report_key(dev, BTN_0, data[2] & 0x01); /* up */ 319 - input_report_key(dev, BTN_1, data[2] & 0x02); /* down */ 320 } else { 321 input_report_abs(dev, ABS_HAT0X, 322 !!(data[2] & 0x08) - !!(data[2] & 0x04)); ··· 327 328 /* start/back buttons and stick press left/right */ 329 input_report_key(dev, BTN_START, data[2] & 0x10); 330 - input_report_key(dev, BTN_BACK, data[2] & 0x20); 331 input_report_key(dev, BTN_THUMBL, data[2] & 0x40); 332 input_report_key(dev, BTN_THUMBR, data[2] & 0x80); 333 ··· 361 362 /* digital pad */ 363 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 364 - /* dpad as buttons (right, left, down, up) */ 365 - input_report_key(dev, BTN_LEFT, data[2] & 0x04); 366 - input_report_key(dev, BTN_RIGHT, data[2] & 0x08); 367 - input_report_key(dev, BTN_0, data[2] & 0x01); /* up */ 368 - input_report_key(dev, BTN_1, data[2] & 0x02); /* down */ 369 } else { 370 input_report_abs(dev, ABS_HAT0X, 371 !!(data[2] & 0x08) - !!(data[2] & 0x04)); ··· 375 376 /* start/back buttons */ 377 input_report_key(dev, BTN_START, data[2] & 0x10); 378 - input_report_key(dev, BTN_BACK, data[2] & 0x20); 379 380 /* stick press left/right */ 381 input_report_key(dev, BTN_THUMBL, data[2] & 0x40); ··· 390 input_report_key(dev, BTN_TR, data[3] & 0x02); 391 input_report_key(dev, BTN_MODE, data[3] & 0x04); 392 393 - /* left stick */ 394 - input_report_abs(dev, ABS_X, 395 - (__s16) le16_to_cpup((__le16 *)(data + 6))); 396 - input_report_abs(dev, ABS_Y, 397 - ~(__s16) le16_to_cpup((__le16 *)(data + 8))); 398 399 - /* right stick */ 400 - input_report_abs(dev, ABS_RX, 401 - (__s16) le16_to_cpup((__le16 *)(data + 10))); 402 - input_report_abs(dev, ABS_RY, 403 - ~(__s16) le16_to_cpup((__le16 *)(data + 12))); 404 405 /* triggers left/right */ 406 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { ··· 828 xpad->mapping |= MAP_DPAD_TO_BUTTONS; 829 if (triggers_to_buttons) 830 xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; 831 } 832 833 xpad->dev = input_dev; ··· 846 input_dev->open = xpad_open; 847 input_dev->close = xpad_close; 848 849 - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 850 851 - /* set up standard buttons and axes */ 852 for (i = 0; xpad_common_btn[i] >= 0; i++) 853 __set_bit(xpad_common_btn[i], input_dev->keybit); 854 855 - for (i = 0; xpad_abs[i] >= 0; i++) 856 - xpad_set_up_abs(input_dev, xpad_abs[i]); 857 - 858 - /* Now set up model-specific ones */ 859 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) { 860 for (i = 0; xpad360_btn[i] >= 0; i++) 861 __set_bit(xpad360_btn[i], input_dev->keybit);
··· 9 * 2005 Dominic Cerquetti <binary1230@yahoo.com> 10 * 2006 Adam Buchbinder <adam.buchbinder@gmail.com> 11 * 2007 Jan Kratochvil <honza@jikos.cz> 12 + * 2010 Christoph Fritz <chf.fritz@googlemail.com> 13 * 14 * This program is free software; you can redistribute it and/or 15 * modify it under the terms of the GNU General Public License as ··· 88 but we map them to axes when possible to simplify things */ 89 #define MAP_DPAD_TO_BUTTONS (1 << 0) 90 #define MAP_TRIGGERS_TO_BUTTONS (1 << 1) 91 + #define MAP_STICKS_TO_NULL (1 << 2) 92 + #define DANCEPAD_MAP_CONFIG (MAP_DPAD_TO_BUTTONS | \ 93 + MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL) 94 95 #define XTYPE_XBOX 0 96 #define XTYPE_XBOX360 1 ··· 102 module_param(triggers_to_buttons, bool, S_IRUGO); 103 MODULE_PARM_DESC(triggers_to_buttons, "Map triggers to buttons rather than axes for unknown pads"); 104 105 + static int sticks_to_null; 106 + module_param(sticks_to_null, bool, S_IRUGO); 107 + MODULE_PARM_DESC(sticks_to_null, "Do not map sticks at all for unknown pads"); 108 + 109 static const struct xpad_device { 110 u16 idVendor; 111 u16 idProduct; ··· 114 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX }, 115 { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX }, 116 { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, 117 + { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", DANCEPAD_MAP_CONFIG, XTYPE_XBOX }, 118 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, 119 { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 }, 120 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX }, ··· 151 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 }, 152 { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, 153 { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 154 + { 0x0f0d, 0x000d, "Hori Fighting Stick EX2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, 155 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, 156 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } 157 }; ··· 158 /* buttons shared with xbox and xbox360 */ 159 static const signed short xpad_common_btn[] = { 160 BTN_A, BTN_B, BTN_X, BTN_Y, /* "analog" buttons */ 161 + BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR, /* start/back/sticks */ 162 -1 /* terminating entry */ 163 }; 164 ··· 168 -1 /* terminating entry */ 169 }; 170 171 + /* used when dpad is mapped to buttons */ 172 static const signed short xpad_btn_pad[] = { 173 + BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, /* d-pad left, right */ 174 + BTN_TRIGGER_HAPPY3, BTN_TRIGGER_HAPPY4, /* d-pad up, down */ 175 -1 /* terminating entry */ 176 }; 177 ··· 279 { 280 struct input_dev *dev = xpad->dev; 281 282 + if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { 283 + /* left stick */ 284 + input_report_abs(dev, ABS_X, 285 + (__s16) le16_to_cpup((__le16 *)(data + 12))); 286 + input_report_abs(dev, ABS_Y, 287 + ~(__s16) le16_to_cpup((__le16 *)(data + 14))); 288 289 + /* right stick */ 290 + input_report_abs(dev, ABS_RX, 291 + (__s16) le16_to_cpup((__le16 *)(data + 16))); 292 + input_report_abs(dev, ABS_RY, 293 + ~(__s16) le16_to_cpup((__le16 *)(data + 18))); 294 + } 295 296 /* triggers left/right */ 297 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { ··· 302 303 /* digital pad */ 304 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 305 + /* dpad as buttons (left, right, up, down) */ 306 + input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); 307 + input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); 308 + input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); 309 + input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); 310 } else { 311 input_report_abs(dev, ABS_HAT0X, 312 !!(data[2] & 0x08) - !!(data[2] & 0x04)); ··· 315 316 /* start/back buttons and stick press left/right */ 317 input_report_key(dev, BTN_START, data[2] & 0x10); 318 + input_report_key(dev, BTN_SELECT, data[2] & 0x20); 319 input_report_key(dev, BTN_THUMBL, data[2] & 0x40); 320 input_report_key(dev, BTN_THUMBR, data[2] & 0x80); 321 ··· 349 350 /* digital pad */ 351 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { 352 + /* dpad as buttons (left, right, up, down) */ 353 + input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); 354 + input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); 355 + input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); 356 + input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); 357 } else { 358 input_report_abs(dev, ABS_HAT0X, 359 !!(data[2] & 0x08) - !!(data[2] & 0x04)); ··· 363 364 /* start/back buttons */ 365 input_report_key(dev, BTN_START, data[2] & 0x10); 366 + input_report_key(dev, BTN_SELECT, data[2] & 0x20); 367 368 /* stick press left/right */ 369 input_report_key(dev, BTN_THUMBL, data[2] & 0x40); ··· 378 input_report_key(dev, BTN_TR, data[3] & 0x02); 379 input_report_key(dev, BTN_MODE, data[3] & 0x04); 380 381 + if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { 382 + /* left stick */ 383 + input_report_abs(dev, ABS_X, 384 + (__s16) le16_to_cpup((__le16 *)(data + 6))); 385 + input_report_abs(dev, ABS_Y, 386 + ~(__s16) le16_to_cpup((__le16 *)(data + 8))); 387 388 + /* right stick */ 389 + input_report_abs(dev, ABS_RX, 390 + (__s16) le16_to_cpup((__le16 *)(data + 10))); 391 + input_report_abs(dev, ABS_RY, 392 + ~(__s16) le16_to_cpup((__le16 *)(data + 12))); 393 + } 394 395 /* triggers left/right */ 396 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { ··· 814 xpad->mapping |= MAP_DPAD_TO_BUTTONS; 815 if (triggers_to_buttons) 816 xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; 817 + if (sticks_to_null) 818 + xpad->mapping |= MAP_STICKS_TO_NULL; 819 } 820 821 xpad->dev = input_dev; ··· 830 input_dev->open = xpad_open; 831 input_dev->close = xpad_close; 832 833 + input_dev->evbit[0] = BIT_MASK(EV_KEY); 834 835 + if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { 836 + input_dev->evbit[0] |= BIT_MASK(EV_ABS); 837 + /* set up axes */ 838 + for (i = 0; xpad_abs[i] >= 0; i++) 839 + xpad_set_up_abs(input_dev, xpad_abs[i]); 840 + } 841 + 842 + /* set up standard buttons */ 843 for (i = 0; xpad_common_btn[i] >= 0; i++) 844 __set_bit(xpad_common_btn[i], input_dev->keybit); 845 846 + /* set up model-specific ones */ 847 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) { 848 for (i = 0; xpad360_btn[i] >= 0; i++) 849 __set_bit(xpad360_btn[i], input_dev->keybit);
+21
drivers/input/keyboard/Kconfig
··· 297 To compile this driver as a module, choose M here: the 298 module will be called max7359_keypad. 299 300 config KEYBOARD_IMX 301 tristate "IMX keypad support" 302 depends on ARCH_MXC ··· 353 354 To compile this driver as a module, choose M here: the 355 module will be called pxa930_rotary. 356 357 config KEYBOARD_STOWAWAY 358 tristate "Stowaway keyboard"
··· 297 To compile this driver as a module, choose M here: the 298 module will be called max7359_keypad. 299 300 + config KEYBOARD_MCS 301 + tristate "MELFAS MCS Touchkey" 302 + depends on I2C 303 + help 304 + Say Y here if you have the MELFAS MCS5000/5080 touchkey controller 305 + chip in your system. 306 + 307 + If unsure, say N. 308 + 309 + To compile this driver as a module, choose M here: the 310 + module will be called mcs_touchkey. 311 + 312 config KEYBOARD_IMX 313 tristate "IMX keypad support" 314 depends on ARCH_MXC ··· 341 342 To compile this driver as a module, choose M here: the 343 module will be called pxa930_rotary. 344 + 345 + config KEYBOARD_SAMSUNG 346 + tristate "Samsung keypad support" 347 + depends on SAMSUNG_DEV_KEYPAD 348 + help 349 + Say Y here if you want to use the Samsung keypad. 350 + 351 + To compile this driver as a module, choose M here: the 352 + module will be called samsung-keypad. 353 354 config KEYBOARD_STOWAWAY 355 tristate "Stowaway keyboard"
+2
drivers/input/keyboard/Makefile
··· 26 obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o 27 obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o 28 obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o 29 obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o 30 obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o 31 obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o 32 obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o 33 obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o 34 obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o 35 obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o 36 obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o 37 obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o
··· 26 obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o 27 obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o 28 obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o 29 + obj-$(CONFIG_KEYBOARD_MCS) += mcs_touchkey.o 30 obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o 31 obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o 32 obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o 33 obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o 34 obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o 35 obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o 36 + obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o 37 obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o 38 obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o 39 obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o
+342 -9
drivers/input/keyboard/adp5588-keys.c
··· 19 #include <linux/platform_device.h> 20 #include <linux/input.h> 21 #include <linux/i2c.h> 22 #include <linux/slab.h> 23 24 #include <linux/i2c/adp5588.h> ··· 55 56 #define KEYP_MAX_EVENT 10 57 58 /* 59 * Early pre 4.0 Silicon required to delay readout by at least 25ms, 60 * since the Event Counter Register updated 25ms after the interrupt ··· 72 struct delayed_work work; 73 unsigned long delay; 74 unsigned short keycode[ADP5588_KEYMAPSIZE]; 75 }; 76 77 static int adp5588_read(struct i2c_client *client, u8 reg) ··· 99 return i2c_smbus_write_byte_data(client, reg, val); 100 } 101 102 static void adp5588_work(struct work_struct *work) 103 { 104 struct adp5588_kpad *kpad = container_of(work, 105 struct adp5588_kpad, work.work); 106 struct i2c_client *client = kpad->client; 107 - int i, key, status, ev_cnt; 108 109 status = adp5588_read(client, INT_STAT); 110 ··· 324 if (status & KE_INT) { 325 ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & KEC; 326 if (ev_cnt) { 327 - for (i = 0; i < ev_cnt; i++) { 328 - key = adp5588_read(client, Key_EVENTA + i); 329 - input_report_key(kpad->input, 330 - kpad->keycode[(key & KEY_EV_MASK) - 1], 331 - key & KEY_EV_PRESSED); 332 - } 333 input_sync(kpad->input); 334 } 335 } ··· 348 349 static int __devinit adp5588_setup(struct i2c_client *client) 350 { 351 - struct adp5588_kpad_platform_data *pdata = client->dev.platform_data; 352 int i, ret; 353 354 ret = adp5588_write(client, KP_GPIO1, KP_SEL(pdata->rows)); 355 ret |= adp5588_write(client, KP_GPIO2, KP_SEL(pdata->cols) & 0xFF); ··· 365 366 for (i = 0; i < KEYP_MAX_EVENT; i++) 367 ret |= adp5588_read(client, Key_EVENTA); 368 369 ret |= adp5588_write(client, INT_STAT, CMP2_INT | CMP1_INT | 370 OVR_FLOW_INT | K_LCK_INT | ··· 406 return 0; 407 } 408 409 static int __devinit adp5588_probe(struct i2c_client *client, 410 const struct i2c_device_id *id) 411 { 412 struct adp5588_kpad *kpad; 413 - struct adp5588_kpad_platform_data *pdata = client->dev.platform_data; 414 struct input_dev *input; 415 unsigned int revid; 416 int ret, i; ··· 473 if (pdata->keymapsize != ADP5588_KEYMAPSIZE) { 474 dev_err(&client->dev, "invalid keymapsize\n"); 475 return -EINVAL; 476 } 477 478 if (!client->irq) { ··· 550 memcpy(kpad->keycode, pdata->keymap, 551 pdata->keymapsize * input->keycodesize); 552 553 /* setup input device */ 554 __set_bit(EV_KEY, input->evbit); 555 ··· 562 for (i = 0; i < input->keycodemax; i++) 563 __set_bit(kpad->keycode[i] & KEY_MAX, input->keybit); 564 __clear_bit(KEY_RESERVED, input->keybit); 565 566 error = input_register_device(input); 567 if (error) { ··· 583 } 584 585 error = adp5588_setup(client); 586 if (error) 587 goto err_free_irq; 588 ··· 619 free_irq(client->irq, kpad); 620 cancel_delayed_work_sync(&kpad->work); 621 input_unregister_device(kpad->input); 622 kfree(kpad); 623 624 return 0;
··· 19 #include <linux/platform_device.h> 20 #include <linux/input.h> 21 #include <linux/i2c.h> 22 + #include <linux/gpio.h> 23 #include <linux/slab.h> 24 25 #include <linux/i2c/adp5588.h> ··· 54 55 #define KEYP_MAX_EVENT 10 56 57 + #define MAXGPIO 18 58 + #define ADP_BANK(offs) ((offs) >> 3) 59 + #define ADP_BIT(offs) (1u << ((offs) & 0x7)) 60 + 61 /* 62 * Early pre 4.0 Silicon required to delay readout by at least 25ms, 63 * since the Event Counter Register updated 25ms after the interrupt ··· 67 struct delayed_work work; 68 unsigned long delay; 69 unsigned short keycode[ADP5588_KEYMAPSIZE]; 70 + const struct adp5588_gpi_map *gpimap; 71 + unsigned short gpimapsize; 72 + #ifdef CONFIG_GPIOLIB 73 + unsigned char gpiomap[MAXGPIO]; 74 + bool export_gpio; 75 + struct gpio_chip gc; 76 + struct mutex gpio_lock; /* Protect cached dir, dat_out */ 77 + u8 dat_out[3]; 78 + u8 dir[3]; 79 + #endif 80 }; 81 82 static int adp5588_read(struct i2c_client *client, u8 reg) ··· 84 return i2c_smbus_write_byte_data(client, reg, val); 85 } 86 87 + #ifdef CONFIG_GPIOLIB 88 + static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) 89 + { 90 + struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 91 + unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 92 + unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 93 + 94 + return !!(adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank) & bit); 95 + } 96 + 97 + static void adp5588_gpio_set_value(struct gpio_chip *chip, 98 + unsigned off, int val) 99 + { 100 + struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 101 + unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 102 + unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 103 + 104 + mutex_lock(&kpad->gpio_lock); 105 + 106 + if (val) 107 + kpad->dat_out[bank] |= bit; 108 + else 109 + kpad->dat_out[bank] &= ~bit; 110 + 111 + adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank, 112 + kpad->dat_out[bank]); 113 + 114 + mutex_unlock(&kpad->gpio_lock); 115 + } 116 + 117 + static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off) 118 + { 119 + struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 120 + unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 121 + unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 122 + int ret; 123 + 124 + mutex_lock(&kpad->gpio_lock); 125 + 126 + kpad->dir[bank] &= ~bit; 127 + ret = adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]); 128 + 129 + mutex_unlock(&kpad->gpio_lock); 130 + 131 + return ret; 132 + } 133 + 134 + static int adp5588_gpio_direction_output(struct gpio_chip *chip, 135 + unsigned off, int val) 136 + { 137 + struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 138 + unsigned int bank = ADP_BANK(kpad->gpiomap[off]); 139 + unsigned int bit = ADP_BIT(kpad->gpiomap[off]); 140 + int ret; 141 + 142 + mutex_lock(&kpad->gpio_lock); 143 + 144 + kpad->dir[bank] |= bit; 145 + 146 + if (val) 147 + kpad->dat_out[bank] |= bit; 148 + else 149 + kpad->dat_out[bank] &= ~bit; 150 + 151 + ret = adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank, 152 + kpad->dat_out[bank]); 153 + ret |= adp5588_write(kpad->client, GPIO_DIR1 + bank, 154 + kpad->dir[bank]); 155 + 156 + mutex_unlock(&kpad->gpio_lock); 157 + 158 + return ret; 159 + } 160 + 161 + static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad, 162 + const struct adp5588_kpad_platform_data *pdata) 163 + { 164 + bool pin_used[MAXGPIO]; 165 + int n_unused = 0; 166 + int i; 167 + 168 + memset(pin_used, 0, sizeof(pin_used)); 169 + 170 + for (i = 0; i < pdata->rows; i++) 171 + pin_used[i] = true; 172 + 173 + for (i = 0; i < pdata->cols; i++) 174 + pin_used[i + GPI_PIN_COL_BASE - GPI_PIN_BASE] = true; 175 + 176 + for (i = 0; i < kpad->gpimapsize; i++) 177 + pin_used[kpad->gpimap[i].pin - GPI_PIN_BASE] = true; 178 + 179 + for (i = 0; i < MAXGPIO; i++) 180 + if (!pin_used[i]) 181 + kpad->gpiomap[n_unused++] = i; 182 + 183 + return n_unused; 184 + } 185 + 186 + static int __devinit adp5588_gpio_add(struct adp5588_kpad *kpad) 187 + { 188 + struct device *dev = &kpad->client->dev; 189 + const struct adp5588_kpad_platform_data *pdata = dev->platform_data; 190 + const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data; 191 + int i, error; 192 + 193 + if (!gpio_data) 194 + return 0; 195 + 196 + kpad->gc.ngpio = adp5588_build_gpiomap(kpad, pdata); 197 + if (kpad->gc.ngpio == 0) { 198 + dev_info(dev, "No unused gpios left to export\n"); 199 + return 0; 200 + } 201 + 202 + kpad->export_gpio = true; 203 + 204 + kpad->gc.direction_input = adp5588_gpio_direction_input; 205 + kpad->gc.direction_output = adp5588_gpio_direction_output; 206 + kpad->gc.get = adp5588_gpio_get_value; 207 + kpad->gc.set = adp5588_gpio_set_value; 208 + kpad->gc.can_sleep = 1; 209 + 210 + kpad->gc.base = gpio_data->gpio_start; 211 + kpad->gc.label = kpad->client->name; 212 + kpad->gc.owner = THIS_MODULE; 213 + 214 + mutex_init(&kpad->gpio_lock); 215 + 216 + error = gpiochip_add(&kpad->gc); 217 + if (error) { 218 + dev_err(dev, "gpiochip_add failed, err: %d\n", error); 219 + return error; 220 + } 221 + 222 + for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { 223 + kpad->dat_out[i] = adp5588_read(kpad->client, 224 + GPIO_DAT_OUT1 + i); 225 + kpad->dir[i] = adp5588_read(kpad->client, GPIO_DIR1 + i); 226 + } 227 + 228 + if (gpio_data->setup) { 229 + error = gpio_data->setup(kpad->client, 230 + kpad->gc.base, kpad->gc.ngpio, 231 + gpio_data->context); 232 + if (error) 233 + dev_warn(dev, "setup failed, %d\n", error); 234 + } 235 + 236 + return 0; 237 + } 238 + 239 + static void __devexit adp5588_gpio_remove(struct adp5588_kpad *kpad) 240 + { 241 + struct device *dev = &kpad->client->dev; 242 + const struct adp5588_kpad_platform_data *pdata = dev->platform_data; 243 + const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data; 244 + int error; 245 + 246 + if (!kpad->export_gpio) 247 + return; 248 + 249 + if (gpio_data->teardown) { 250 + error = gpio_data->teardown(kpad->client, 251 + kpad->gc.base, kpad->gc.ngpio, 252 + gpio_data->context); 253 + if (error) 254 + dev_warn(dev, "teardown failed %d\n", error); 255 + } 256 + 257 + error = gpiochip_remove(&kpad->gc); 258 + if (error) 259 + dev_warn(dev, "gpiochip_remove failed %d\n", error); 260 + } 261 + #else 262 + static inline int adp5588_gpio_add(struct adp5588_kpad *kpad) 263 + { 264 + return 0; 265 + } 266 + 267 + static inline void adp5588_gpio_remove(struct adp5588_kpad *kpad) 268 + { 269 + } 270 + #endif 271 + 272 + static void adp5588_report_events(struct adp5588_kpad *kpad, int ev_cnt) 273 + { 274 + int i, j; 275 + 276 + for (i = 0; i < ev_cnt; i++) { 277 + int key = adp5588_read(kpad->client, Key_EVENTA + i); 278 + int key_val = key & KEY_EV_MASK; 279 + 280 + if (key_val >= GPI_PIN_BASE && key_val <= GPI_PIN_END) { 281 + for (j = 0; j < kpad->gpimapsize; j++) { 282 + if (key_val == kpad->gpimap[j].pin) { 283 + input_report_switch(kpad->input, 284 + kpad->gpimap[j].sw_evt, 285 + key & KEY_EV_PRESSED); 286 + break; 287 + } 288 + } 289 + } else { 290 + input_report_key(kpad->input, 291 + kpad->keycode[key_val - 1], 292 + key & KEY_EV_PRESSED); 293 + } 294 + } 295 + } 296 + 297 static void adp5588_work(struct work_struct *work) 298 { 299 struct adp5588_kpad *kpad = container_of(work, 300 struct adp5588_kpad, work.work); 301 struct i2c_client *client = kpad->client; 302 + int status, ev_cnt; 303 304 status = adp5588_read(client, INT_STAT); 305 ··· 99 if (status & KE_INT) { 100 ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & KEC; 101 if (ev_cnt) { 102 + adp5588_report_events(kpad, ev_cnt); 103 input_sync(kpad->input); 104 } 105 } ··· 128 129 static int __devinit adp5588_setup(struct i2c_client *client) 130 { 131 + const struct adp5588_kpad_platform_data *pdata = client->dev.platform_data; 132 + const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data; 133 int i, ret; 134 + unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0; 135 136 ret = adp5588_write(client, KP_GPIO1, KP_SEL(pdata->rows)); 137 ret |= adp5588_write(client, KP_GPIO2, KP_SEL(pdata->cols) & 0xFF); ··· 143 144 for (i = 0; i < KEYP_MAX_EVENT; i++) 145 ret |= adp5588_read(client, Key_EVENTA); 146 + 147 + for (i = 0; i < pdata->gpimapsize; i++) { 148 + unsigned short pin = pdata->gpimap[i].pin; 149 + 150 + if (pin <= GPI_PIN_ROW_END) { 151 + evt_mode1 |= (1 << (pin - GPI_PIN_ROW_BASE)); 152 + } else { 153 + evt_mode2 |= ((1 << (pin - GPI_PIN_COL_BASE)) & 0xFF); 154 + evt_mode3 |= ((1 << (pin - GPI_PIN_COL_BASE)) >> 8); 155 + } 156 + } 157 + 158 + if (pdata->gpimapsize) { 159 + ret |= adp5588_write(client, GPI_EM1, evt_mode1); 160 + ret |= adp5588_write(client, GPI_EM2, evt_mode2); 161 + ret |= adp5588_write(client, GPI_EM3, evt_mode3); 162 + } 163 + 164 + if (gpio_data) { 165 + for (i = 0; i <= ADP_BANK(MAXGPIO); i++) { 166 + int pull_mask = gpio_data->pullup_dis_mask; 167 + 168 + ret |= adp5588_write(client, GPIO_PULL1 + i, 169 + (pull_mask >> (8 * i)) & 0xFF); 170 + } 171 + } 172 173 ret |= adp5588_write(client, INT_STAT, CMP2_INT | CMP1_INT | 174 OVR_FLOW_INT | K_LCK_INT | ··· 158 return 0; 159 } 160 161 + static void __devinit adp5588_report_switch_state(struct adp5588_kpad *kpad) 162 + { 163 + int gpi_stat1 = adp5588_read(kpad->client, GPIO_DAT_STAT1); 164 + int gpi_stat2 = adp5588_read(kpad->client, GPIO_DAT_STAT2); 165 + int gpi_stat3 = adp5588_read(kpad->client, GPIO_DAT_STAT3); 166 + int gpi_stat_tmp, pin_loc; 167 + int i; 168 + 169 + for (i = 0; i < kpad->gpimapsize; i++) { 170 + unsigned short pin = kpad->gpimap[i].pin; 171 + 172 + if (pin <= GPI_PIN_ROW_END) { 173 + gpi_stat_tmp = gpi_stat1; 174 + pin_loc = pin - GPI_PIN_ROW_BASE; 175 + } else if ((pin - GPI_PIN_COL_BASE) < 8) { 176 + gpi_stat_tmp = gpi_stat2; 177 + pin_loc = pin - GPI_PIN_COL_BASE; 178 + } else { 179 + gpi_stat_tmp = gpi_stat3; 180 + pin_loc = pin - GPI_PIN_COL_BASE - 8; 181 + } 182 + 183 + if (gpi_stat_tmp < 0) { 184 + dev_err(&kpad->client->dev, 185 + "Can't read GPIO_DAT_STAT switch %d default to OFF\n", 186 + pin); 187 + gpi_stat_tmp = 0; 188 + } 189 + 190 + input_report_switch(kpad->input, 191 + kpad->gpimap[i].sw_evt, 192 + !(gpi_stat_tmp & (1 << pin_loc))); 193 + } 194 + 195 + input_sync(kpad->input); 196 + } 197 + 198 + 199 static int __devinit adp5588_probe(struct i2c_client *client, 200 const struct i2c_device_id *id) 201 { 202 struct adp5588_kpad *kpad; 203 + const struct adp5588_kpad_platform_data *pdata = client->dev.platform_data; 204 struct input_dev *input; 205 unsigned int revid; 206 int ret, i; ··· 187 if (pdata->keymapsize != ADP5588_KEYMAPSIZE) { 188 dev_err(&client->dev, "invalid keymapsize\n"); 189 return -EINVAL; 190 + } 191 + 192 + if (!pdata->gpimap && pdata->gpimapsize) { 193 + dev_err(&client->dev, "invalid gpimap from pdata\n"); 194 + return -EINVAL; 195 + } 196 + 197 + if (pdata->gpimapsize > ADP5588_GPIMAPSIZE_MAX) { 198 + dev_err(&client->dev, "invalid gpimapsize\n"); 199 + return -EINVAL; 200 + } 201 + 202 + for (i = 0; i < pdata->gpimapsize; i++) { 203 + unsigned short pin = pdata->gpimap[i].pin; 204 + 205 + if (pin < GPI_PIN_BASE || pin > GPI_PIN_END) { 206 + dev_err(&client->dev, "invalid gpi pin data\n"); 207 + return -EINVAL; 208 + } 209 + 210 + if (pin <= GPI_PIN_ROW_END) { 211 + if (pin - GPI_PIN_ROW_BASE + 1 <= pdata->rows) { 212 + dev_err(&client->dev, "invalid gpi row data\n"); 213 + return -EINVAL; 214 + } 215 + } else { 216 + if (pin - GPI_PIN_COL_BASE + 1 <= pdata->cols) { 217 + dev_err(&client->dev, "invalid gpi col data\n"); 218 + return -EINVAL; 219 + } 220 + } 221 } 222 223 if (!client->irq) { ··· 233 memcpy(kpad->keycode, pdata->keymap, 234 pdata->keymapsize * input->keycodesize); 235 236 + kpad->gpimap = pdata->gpimap; 237 + kpad->gpimapsize = pdata->gpimapsize; 238 + 239 /* setup input device */ 240 __set_bit(EV_KEY, input->evbit); 241 ··· 242 for (i = 0; i < input->keycodemax; i++) 243 __set_bit(kpad->keycode[i] & KEY_MAX, input->keybit); 244 __clear_bit(KEY_RESERVED, input->keybit); 245 + 246 + if (kpad->gpimapsize) 247 + __set_bit(EV_SW, input->evbit); 248 + for (i = 0; i < kpad->gpimapsize; i++) 249 + __set_bit(kpad->gpimap[i].sw_evt, input->swbit); 250 251 error = input_register_device(input); 252 if (error) { ··· 258 } 259 260 error = adp5588_setup(client); 261 + if (error) 262 + goto err_free_irq; 263 + 264 + if (kpad->gpimapsize) 265 + adp5588_report_switch_state(kpad); 266 + 267 + error = adp5588_gpio_add(kpad); 268 if (error) 269 goto err_free_irq; 270 ··· 287 free_irq(client->irq, kpad); 288 cancel_delayed_work_sync(&kpad->work); 289 input_unregister_device(kpad->input); 290 + adp5588_gpio_remove(kpad); 291 kfree(kpad); 292 293 return 0;
+14 -5
drivers/input/keyboard/gpio_keys.c
··· 31 struct input_dev *input; 32 struct timer_list timer; 33 struct work_struct work; 34 bool disabled; 35 }; 36 ··· 110 * Disable IRQ and possible debouncing timer. 111 */ 112 disable_irq(gpio_to_irq(bdata->button->gpio)); 113 - if (bdata->button->debounce_interval) 114 del_timer_sync(&bdata->timer); 115 116 bdata->disabled = true; ··· 348 349 BUG_ON(irq != gpio_to_irq(button->gpio)); 350 351 - if (button->debounce_interval) 352 mod_timer(&bdata->timer, 353 - jiffies + msecs_to_jiffies(button->debounce_interval)); 354 else 355 schedule_work(&bdata->work); 356 ··· 382 " direction for GPIO %d, error %d\n", 383 button->gpio, error); 384 goto fail3; 385 } 386 387 irq = gpio_to_irq(button->gpio); ··· 507 fail2: 508 while (--i >= 0) { 509 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); 510 - if (pdata->buttons[i].debounce_interval) 511 del_timer_sync(&ddata->data[i].timer); 512 cancel_work_sync(&ddata->data[i].work); 513 gpio_free(pdata->buttons[i].gpio); ··· 535 for (i = 0; i < pdata->nbuttons; i++) { 536 int irq = gpio_to_irq(pdata->buttons[i].gpio); 537 free_irq(irq, &ddata->data[i]); 538 - if (pdata->buttons[i].debounce_interval) 539 del_timer_sync(&ddata->data[i].timer); 540 cancel_work_sync(&ddata->data[i].work); 541 gpio_free(pdata->buttons[i].gpio);
··· 31 struct input_dev *input; 32 struct timer_list timer; 33 struct work_struct work; 34 + int timer_debounce; /* in msecs */ 35 bool disabled; 36 }; 37 ··· 109 * Disable IRQ and possible debouncing timer. 110 */ 111 disable_irq(gpio_to_irq(bdata->button->gpio)); 112 + if (bdata->timer_debounce) 113 del_timer_sync(&bdata->timer); 114 115 bdata->disabled = true; ··· 347 348 BUG_ON(irq != gpio_to_irq(button->gpio)); 349 350 + if (bdata->timer_debounce) 351 mod_timer(&bdata->timer, 352 + jiffies + msecs_to_jiffies(bdata->timer_debounce)); 353 else 354 schedule_work(&bdata->work); 355 ··· 381 " direction for GPIO %d, error %d\n", 382 button->gpio, error); 383 goto fail3; 384 + } 385 + 386 + if (button->debounce_interval) { 387 + error = gpio_set_debounce(button->gpio, 388 + button->debounce_interval * 1000); 389 + /* use timer if gpiolib doesn't provide debounce */ 390 + if (error < 0) 391 + bdata->timer_debounce = button->debounce_interval; 392 } 393 394 irq = gpio_to_irq(button->gpio); ··· 498 fail2: 499 while (--i >= 0) { 500 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); 501 + if (ddata->data[i].timer_debounce) 502 del_timer_sync(&ddata->data[i].timer); 503 cancel_work_sync(&ddata->data[i].work); 504 gpio_free(pdata->buttons[i].gpio); ··· 526 for (i = 0; i < pdata->nbuttons; i++) { 527 int irq = gpio_to_irq(pdata->buttons[i].gpio); 528 free_irq(irq, &ddata->data[i]); 529 + if (ddata->data[i].timer_debounce) 530 del_timer_sync(&ddata->data[i].timer); 531 cancel_work_sync(&ddata->data[i].work); 532 gpio_free(pdata->buttons[i].gpio);
+7 -5
drivers/input/keyboard/lm8323.c
··· 642 struct lm8323_platform_data *pdata = client->dev.platform_data; 643 struct input_dev *idev; 644 struct lm8323_chip *lm; 645 int i, err; 646 unsigned long tmo; 647 u8 data[2]; ··· 711 goto fail1; 712 } 713 714 - for (i = 0; i < LM8323_NUM_PWMS; i++) { 715 - err = init_pwm(lm, i + 1, &client->dev, pdata->pwm_names[i]); 716 if (err < 0) 717 goto fail2; 718 } ··· 766 fail3: 767 device_remove_file(&client->dev, &dev_attr_disable_kp); 768 fail2: 769 - while (--i >= 0) 770 - if (lm->pwm[i].enabled) 771 - led_classdev_unregister(&lm->pwm[i].cdev); 772 fail1: 773 input_free_device(idev); 774 kfree(lm);
··· 642 struct lm8323_platform_data *pdata = client->dev.platform_data; 643 struct input_dev *idev; 644 struct lm8323_chip *lm; 645 + int pwm; 646 int i, err; 647 unsigned long tmo; 648 u8 data[2]; ··· 710 goto fail1; 711 } 712 713 + for (pwm = 0; pwm < LM8323_NUM_PWMS; pwm++) { 714 + err = init_pwm(lm, pwm + 1, &client->dev, 715 + pdata->pwm_names[pwm]); 716 if (err < 0) 717 goto fail2; 718 } ··· 764 fail3: 765 device_remove_file(&client->dev, &dev_attr_disable_kp); 766 fail2: 767 + while (--pwm >= 0) 768 + if (lm->pwm[pwm].enabled) 769 + led_classdev_unregister(&lm->pwm[pwm].cdev); 770 fail1: 771 input_free_device(idev); 772 kfree(lm);
+83 -31
drivers/input/keyboard/matrix_keypad.c
··· 37 spinlock_t lock; 38 bool scan_pending; 39 bool stopped; 40 }; 41 42 /* ··· 88 const struct matrix_keypad_platform_data *pdata = keypad->pdata; 89 int i; 90 91 - for (i = 0; i < pdata->num_row_gpios; i++) 92 - enable_irq(gpio_to_irq(pdata->row_gpios[i])); 93 } 94 95 static void disable_row_irqs(struct matrix_keypad *keypad) ··· 101 const struct matrix_keypad_platform_data *pdata = keypad->pdata; 102 int i; 103 104 - for (i = 0; i < pdata->num_row_gpios; i++) 105 - disable_irq_nosync(gpio_to_irq(pdata->row_gpios[i])); 106 } 107 108 /* ··· 225 } 226 227 #ifdef CONFIG_PM 228 - static int matrix_keypad_suspend(struct device *dev) 229 { 230 - struct platform_device *pdev = to_platform_device(dev); 231 - struct matrix_keypad *keypad = platform_get_drvdata(pdev); 232 const struct matrix_keypad_platform_data *pdata = keypad->pdata; 233 int i; 234 235 - matrix_keypad_stop(keypad->input_dev); 236 237 - if (device_may_wakeup(&pdev->dev)) { 238 for (i = 0; i < pdata->num_row_gpios; i++) { 239 if (!test_bit(i, keypad->disabled_gpios)) { 240 - unsigned int gpio = pdata->row_gpios[i]; 241 242 if (enable_irq_wake(gpio_to_irq(gpio)) == 0) 243 __set_bit(i, keypad->disabled_gpios); 244 } 245 } 246 } 247 248 return 0; 249 } ··· 285 { 286 struct platform_device *pdev = to_platform_device(dev); 287 struct matrix_keypad *keypad = platform_get_drvdata(pdev); 288 - const struct matrix_keypad_platform_data *pdata = keypad->pdata; 289 - int i; 290 291 - if (device_may_wakeup(&pdev->dev)) { 292 - for (i = 0; i < pdata->num_row_gpios; i++) { 293 - if (test_and_clear_bit(i, keypad->disabled_gpios)) { 294 - unsigned int gpio = pdata->row_gpios[i]; 295 - 296 - disable_irq_wake(gpio_to_irq(gpio)); 297 - } 298 - } 299 - } 300 301 matrix_keypad_start(keypad->input_dev); 302 ··· 329 gpio_direction_input(pdata->row_gpios[i]); 330 } 331 332 - for (i = 0; i < pdata->num_row_gpios; i++) { 333 - err = request_irq(gpio_to_irq(pdata->row_gpios[i]), 334 matrix_keypad_interrupt, 335 - IRQF_DISABLED | 336 - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 337 "matrix-keypad", keypad); 338 if (err) { 339 dev_err(&pdev->dev, 340 - "Unable to acquire interrupt for GPIO line %i\n", 341 - pdata->row_gpios[i]); 342 - goto err_free_irqs; 343 } 344 } 345 ··· 465 466 device_init_wakeup(&pdev->dev, 0); 467 468 - for (i = 0; i < pdata->num_row_gpios; i++) { 469 - free_irq(gpio_to_irq(pdata->row_gpios[i]), keypad); 470 - gpio_free(pdata->row_gpios[i]); 471 } 472 473 for (i = 0; i < pdata->num_col_gpios; i++) 474 gpio_free(pdata->col_gpios[i]);
··· 37 spinlock_t lock; 38 bool scan_pending; 39 bool stopped; 40 + bool gpio_all_disabled; 41 }; 42 43 /* ··· 87 const struct matrix_keypad_platform_data *pdata = keypad->pdata; 88 int i; 89 90 + if (pdata->clustered_irq > 0) 91 + enable_irq(pdata->clustered_irq); 92 + else { 93 + for (i = 0; i < pdata->num_row_gpios; i++) 94 + enable_irq(gpio_to_irq(pdata->row_gpios[i])); 95 + } 96 } 97 98 static void disable_row_irqs(struct matrix_keypad *keypad) ··· 96 const struct matrix_keypad_platform_data *pdata = keypad->pdata; 97 int i; 98 99 + if (pdata->clustered_irq > 0) 100 + disable_irq_nosync(pdata->clustered_irq); 101 + else { 102 + for (i = 0; i < pdata->num_row_gpios; i++) 103 + disable_irq_nosync(gpio_to_irq(pdata->row_gpios[i])); 104 + } 105 } 106 107 /* ··· 216 } 217 218 #ifdef CONFIG_PM 219 + static void matrix_keypad_enable_wakeup(struct matrix_keypad *keypad) 220 { 221 const struct matrix_keypad_platform_data *pdata = keypad->pdata; 222 + unsigned int gpio; 223 int i; 224 225 + if (pdata->clustered_irq > 0) { 226 + if (enable_irq_wake(pdata->clustered_irq) == 0) 227 + keypad->gpio_all_disabled = true; 228 + } else { 229 230 for (i = 0; i < pdata->num_row_gpios; i++) { 231 if (!test_bit(i, keypad->disabled_gpios)) { 232 + gpio = pdata->row_gpios[i]; 233 234 if (enable_irq_wake(gpio_to_irq(gpio)) == 0) 235 __set_bit(i, keypad->disabled_gpios); 236 } 237 } 238 } 239 + } 240 + 241 + static void matrix_keypad_disable_wakeup(struct matrix_keypad *keypad) 242 + { 243 + const struct matrix_keypad_platform_data *pdata = keypad->pdata; 244 + unsigned int gpio; 245 + int i; 246 + 247 + if (pdata->clustered_irq > 0) { 248 + if (keypad->gpio_all_disabled) { 249 + disable_irq_wake(pdata->clustered_irq); 250 + keypad->gpio_all_disabled = false; 251 + } 252 + } else { 253 + for (i = 0; i < pdata->num_row_gpios; i++) { 254 + if (test_and_clear_bit(i, keypad->disabled_gpios)) { 255 + gpio = pdata->row_gpios[i]; 256 + disable_irq_wake(gpio_to_irq(gpio)); 257 + } 258 + } 259 + } 260 + } 261 + 262 + static int matrix_keypad_suspend(struct device *dev) 263 + { 264 + struct platform_device *pdev = to_platform_device(dev); 265 + struct matrix_keypad *keypad = platform_get_drvdata(pdev); 266 + 267 + matrix_keypad_stop(keypad->input_dev); 268 + 269 + if (device_may_wakeup(&pdev->dev)) 270 + matrix_keypad_enable_wakeup(keypad); 271 272 return 0; 273 } ··· 243 { 244 struct platform_device *pdev = to_platform_device(dev); 245 struct matrix_keypad *keypad = platform_get_drvdata(pdev); 246 247 + if (device_may_wakeup(&pdev->dev)) 248 + matrix_keypad_disable_wakeup(keypad); 249 250 matrix_keypad_start(keypad->input_dev); 251 ··· 296 gpio_direction_input(pdata->row_gpios[i]); 297 } 298 299 + if (pdata->clustered_irq > 0) { 300 + err = request_irq(pdata->clustered_irq, 301 matrix_keypad_interrupt, 302 + pdata->clustered_irq_flags, 303 "matrix-keypad", keypad); 304 if (err) { 305 dev_err(&pdev->dev, 306 + "Unable to acquire clustered interrupt\n"); 307 + goto err_free_rows; 308 + } 309 + } else { 310 + for (i = 0; i < pdata->num_row_gpios; i++) { 311 + err = request_irq(gpio_to_irq(pdata->row_gpios[i]), 312 + matrix_keypad_interrupt, 313 + IRQF_DISABLED | 314 + IRQF_TRIGGER_RISING | 315 + IRQF_TRIGGER_FALLING, 316 + "matrix-keypad", keypad); 317 + if (err) { 318 + dev_err(&pdev->dev, 319 + "Unable to acquire interrupt " 320 + "for GPIO line %i\n", 321 + pdata->row_gpios[i]); 322 + goto err_free_irqs; 323 + } 324 } 325 } 326 ··· 418 419 device_init_wakeup(&pdev->dev, 0); 420 421 + if (pdata->clustered_irq > 0) { 422 + free_irq(pdata->clustered_irq, keypad); 423 + } else { 424 + for (i = 0; i < pdata->num_row_gpios; i++) 425 + free_irq(gpio_to_irq(pdata->row_gpios[i]), keypad); 426 } 427 + 428 + for (i = 0; i < pdata->num_row_gpios; i++) 429 + gpio_free(pdata->row_gpios[i]); 430 431 for (i = 0; i < pdata->num_col_gpios; i++) 432 gpio_free(pdata->col_gpios[i]);
+239
drivers/input/keyboard/mcs_touchkey.c
···
··· 1 + /* 2 + * mcs_touchkey.c - Touchkey driver for MELFAS MCS5000/5080 controller 3 + * 4 + * Copyright (C) 2010 Samsung Electronics Co.Ltd 5 + * Author: HeungJun Kim <riverful.kim@samsung.com> 6 + * Author: Joonyoung Shim <jy0922.shim@samsung.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms of the GNU General Public License as published by the 10 + * Free Software Foundation; either version 2 of the License, or (at your 11 + * option) any later version. 12 + */ 13 + 14 + #include <linux/module.h> 15 + #include <linux/init.h> 16 + #include <linux/i2c.h> 17 + #include <linux/i2c/mcs.h> 18 + #include <linux/interrupt.h> 19 + #include <linux/input.h> 20 + #include <linux/irq.h> 21 + #include <linux/slab.h> 22 + 23 + /* MCS5000 Touchkey */ 24 + #define MCS5000_TOUCHKEY_STATUS 0x04 25 + #define MCS5000_TOUCHKEY_STATUS_PRESS 7 26 + #define MCS5000_TOUCHKEY_FW 0x0a 27 + #define MCS5000_TOUCHKEY_BASE_VAL 0x61 28 + 29 + /* MCS5080 Touchkey */ 30 + #define MCS5080_TOUCHKEY_STATUS 0x00 31 + #define MCS5080_TOUCHKEY_STATUS_PRESS 3 32 + #define MCS5080_TOUCHKEY_FW 0x01 33 + #define MCS5080_TOUCHKEY_BASE_VAL 0x1 34 + 35 + enum mcs_touchkey_type { 36 + MCS5000_TOUCHKEY, 37 + MCS5080_TOUCHKEY, 38 + }; 39 + 40 + struct mcs_touchkey_chip { 41 + unsigned int status_reg; 42 + unsigned int pressbit; 43 + unsigned int press_invert; 44 + unsigned int baseval; 45 + }; 46 + 47 + struct mcs_touchkey_data { 48 + struct i2c_client *client; 49 + struct input_dev *input_dev; 50 + struct mcs_touchkey_chip chip; 51 + unsigned int key_code; 52 + unsigned int key_val; 53 + unsigned short keycodes[]; 54 + }; 55 + 56 + static irqreturn_t mcs_touchkey_interrupt(int irq, void *dev_id) 57 + { 58 + struct mcs_touchkey_data *data = dev_id; 59 + struct mcs_touchkey_chip *chip = &data->chip; 60 + struct i2c_client *client = data->client; 61 + struct input_dev *input = data->input_dev; 62 + unsigned int key_val; 63 + unsigned int pressed; 64 + int val; 65 + 66 + val = i2c_smbus_read_byte_data(client, chip->status_reg); 67 + if (val < 0) { 68 + dev_err(&client->dev, "i2c read error [%d]\n", val); 69 + goto out; 70 + } 71 + 72 + pressed = (val & (1 << chip->pressbit)) >> chip->pressbit; 73 + if (chip->press_invert) 74 + pressed ^= chip->press_invert; 75 + 76 + /* key_val is 0 when released, so we should use key_val of press. */ 77 + if (pressed) { 78 + key_val = val & (0xff >> (8 - chip->pressbit)); 79 + if (!key_val) 80 + goto out; 81 + key_val -= chip->baseval; 82 + data->key_code = data->keycodes[key_val]; 83 + data->key_val = key_val; 84 + } 85 + 86 + input_event(input, EV_MSC, MSC_SCAN, data->key_val); 87 + input_report_key(input, data->key_code, pressed); 88 + input_sync(input); 89 + 90 + dev_dbg(&client->dev, "key %d %d %s\n", data->key_val, data->key_code, 91 + pressed ? "pressed" : "released"); 92 + 93 + out: 94 + return IRQ_HANDLED; 95 + } 96 + 97 + static int __devinit mcs_touchkey_probe(struct i2c_client *client, 98 + const struct i2c_device_id *id) 99 + { 100 + const struct mcs_platform_data *pdata; 101 + struct mcs_touchkey_data *data; 102 + struct input_dev *input_dev; 103 + unsigned int fw_reg; 104 + int fw_ver; 105 + int error; 106 + int i; 107 + 108 + pdata = client->dev.platform_data; 109 + if (!pdata) { 110 + dev_err(&client->dev, "no platform data defined\n"); 111 + return -EINVAL; 112 + } 113 + 114 + data = kzalloc(sizeof(struct mcs_touchkey_data) + 115 + sizeof(data->keycodes[0]) * (pdata->key_maxval + 1), 116 + GFP_KERNEL); 117 + input_dev = input_allocate_device(); 118 + if (!data || !input_dev) { 119 + dev_err(&client->dev, "Failed to allocate memory\n"); 120 + error = -ENOMEM; 121 + goto err_free_mem; 122 + } 123 + 124 + data->client = client; 125 + data->input_dev = input_dev; 126 + 127 + if (id->driver_data == MCS5000_TOUCHKEY) { 128 + data->chip.status_reg = MCS5000_TOUCHKEY_STATUS; 129 + data->chip.pressbit = MCS5000_TOUCHKEY_STATUS_PRESS; 130 + data->chip.baseval = MCS5000_TOUCHKEY_BASE_VAL; 131 + fw_reg = MCS5000_TOUCHKEY_FW; 132 + } else { 133 + data->chip.status_reg = MCS5080_TOUCHKEY_STATUS; 134 + data->chip.pressbit = MCS5080_TOUCHKEY_STATUS_PRESS; 135 + data->chip.press_invert = 1; 136 + data->chip.baseval = MCS5080_TOUCHKEY_BASE_VAL; 137 + fw_reg = MCS5080_TOUCHKEY_FW; 138 + } 139 + 140 + fw_ver = i2c_smbus_read_byte_data(client, fw_reg); 141 + if (fw_ver < 0) { 142 + error = fw_ver; 143 + dev_err(&client->dev, "i2c read error[%d]\n", error); 144 + goto err_free_mem; 145 + } 146 + dev_info(&client->dev, "Firmware version: %d\n", fw_ver); 147 + 148 + input_dev->name = "MELPAS MCS Touchkey"; 149 + input_dev->id.bustype = BUS_I2C; 150 + input_dev->dev.parent = &client->dev; 151 + input_dev->evbit[0] = BIT_MASK(EV_KEY); 152 + if (!pdata->no_autorepeat) 153 + input_dev->evbit[0] |= BIT_MASK(EV_REP); 154 + input_dev->keycode = data->keycodes; 155 + input_dev->keycodesize = sizeof(data->keycodes[0]); 156 + input_dev->keycodemax = pdata->key_maxval + 1; 157 + 158 + for (i = 0; i < pdata->keymap_size; i++) { 159 + unsigned int val = MCS_KEY_VAL(pdata->keymap[i]); 160 + unsigned int code = MCS_KEY_CODE(pdata->keymap[i]); 161 + 162 + data->keycodes[val] = code; 163 + __set_bit(code, input_dev->keybit); 164 + } 165 + 166 + input_set_capability(input_dev, EV_MSC, MSC_SCAN); 167 + input_set_drvdata(input_dev, data); 168 + 169 + if (pdata->cfg_pin) 170 + pdata->cfg_pin(); 171 + 172 + error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt, 173 + IRQF_TRIGGER_FALLING, client->dev.driver->name, data); 174 + if (error) { 175 + dev_err(&client->dev, "Failed to register interrupt\n"); 176 + goto err_free_mem; 177 + } 178 + 179 + error = input_register_device(input_dev); 180 + if (error) 181 + goto err_free_irq; 182 + 183 + i2c_set_clientdata(client, data); 184 + return 0; 185 + 186 + err_free_irq: 187 + free_irq(client->irq, data); 188 + err_free_mem: 189 + input_free_device(input_dev); 190 + kfree(data); 191 + return error; 192 + } 193 + 194 + static int __devexit mcs_touchkey_remove(struct i2c_client *client) 195 + { 196 + struct mcs_touchkey_data *data = i2c_get_clientdata(client); 197 + 198 + free_irq(client->irq, data); 199 + input_unregister_device(data->input_dev); 200 + kfree(data); 201 + 202 + return 0; 203 + } 204 + 205 + static const struct i2c_device_id mcs_touchkey_id[] = { 206 + { "mcs5000_touchkey", MCS5000_TOUCHKEY }, 207 + { "mcs5080_touchkey", MCS5080_TOUCHKEY }, 208 + { } 209 + }; 210 + MODULE_DEVICE_TABLE(i2c, mcs_touchkey_id); 211 + 212 + static struct i2c_driver mcs_touchkey_driver = { 213 + .driver = { 214 + .name = "mcs_touchkey", 215 + .owner = THIS_MODULE, 216 + }, 217 + .probe = mcs_touchkey_probe, 218 + .remove = __devexit_p(mcs_touchkey_remove), 219 + .id_table = mcs_touchkey_id, 220 + }; 221 + 222 + static int __init mcs_touchkey_init(void) 223 + { 224 + return i2c_add_driver(&mcs_touchkey_driver); 225 + } 226 + 227 + static void __exit mcs_touchkey_exit(void) 228 + { 229 + i2c_del_driver(&mcs_touchkey_driver); 230 + } 231 + 232 + module_init(mcs_touchkey_init); 233 + module_exit(mcs_touchkey_exit); 234 + 235 + /* Module information */ 236 + MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); 237 + MODULE_AUTHOR("HeungJun Kim <riverful.kim@samsung.com>"); 238 + MODULE_DESCRIPTION("Touchkey driver for MELFAS MCS5000/5080 controller"); 239 + MODULE_LICENSE("GPL");
+491
drivers/input/keyboard/samsung-keypad.c
···
··· 1 + /* 2 + * Samsung keypad driver 3 + * 4 + * Copyright (C) 2010 Samsung Electronics Co.Ltd 5 + * Author: Joonyoung Shim <jy0922.shim@samsung.com> 6 + * Author: Donghwa Lee <dh09.lee@samsung.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms of the GNU General Public License as published by the 10 + * Free Software Foundation; either version 2 of the License, or (at your 11 + * option) any later version. 12 + */ 13 + 14 + #include <linux/clk.h> 15 + #include <linux/delay.h> 16 + #include <linux/err.h> 17 + #include <linux/init.h> 18 + #include <linux/input.h> 19 + #include <linux/interrupt.h> 20 + #include <linux/io.h> 21 + #include <linux/module.h> 22 + #include <linux/platform_device.h> 23 + #include <linux/slab.h> 24 + #include <linux/sched.h> 25 + #include <plat/keypad.h> 26 + 27 + #define SAMSUNG_KEYIFCON 0x00 28 + #define SAMSUNG_KEYIFSTSCLR 0x04 29 + #define SAMSUNG_KEYIFCOL 0x08 30 + #define SAMSUNG_KEYIFROW 0x0c 31 + #define SAMSUNG_KEYIFFC 0x10 32 + 33 + /* SAMSUNG_KEYIFCON */ 34 + #define SAMSUNG_KEYIFCON_INT_F_EN (1 << 0) 35 + #define SAMSUNG_KEYIFCON_INT_R_EN (1 << 1) 36 + #define SAMSUNG_KEYIFCON_DF_EN (1 << 2) 37 + #define SAMSUNG_KEYIFCON_FC_EN (1 << 3) 38 + #define SAMSUNG_KEYIFCON_WAKEUPEN (1 << 4) 39 + 40 + /* SAMSUNG_KEYIFSTSCLR */ 41 + #define SAMSUNG_KEYIFSTSCLR_P_INT_MASK (0xff << 0) 42 + #define SAMSUNG_KEYIFSTSCLR_R_INT_MASK (0xff << 8) 43 + #define SAMSUNG_KEYIFSTSCLR_R_INT_OFFSET 8 44 + #define S5PV210_KEYIFSTSCLR_P_INT_MASK (0x3fff << 0) 45 + #define S5PV210_KEYIFSTSCLR_R_INT_MASK (0x3fff << 16) 46 + #define S5PV210_KEYIFSTSCLR_R_INT_OFFSET 16 47 + 48 + /* SAMSUNG_KEYIFCOL */ 49 + #define SAMSUNG_KEYIFCOL_MASK (0xff << 0) 50 + #define S5PV210_KEYIFCOLEN_MASK (0xff << 8) 51 + 52 + /* SAMSUNG_KEYIFROW */ 53 + #define SAMSUNG_KEYIFROW_MASK (0xff << 0) 54 + #define S5PV210_KEYIFROW_MASK (0x3fff << 0) 55 + 56 + /* SAMSUNG_KEYIFFC */ 57 + #define SAMSUNG_KEYIFFC_MASK (0x3ff << 0) 58 + 59 + enum samsung_keypad_type { 60 + KEYPAD_TYPE_SAMSUNG, 61 + KEYPAD_TYPE_S5PV210, 62 + }; 63 + 64 + struct samsung_keypad { 65 + struct input_dev *input_dev; 66 + struct clk *clk; 67 + void __iomem *base; 68 + wait_queue_head_t wait; 69 + bool stopped; 70 + int irq; 71 + unsigned int row_shift; 72 + unsigned int rows; 73 + unsigned int cols; 74 + unsigned int row_state[SAMSUNG_MAX_COLS]; 75 + unsigned short keycodes[]; 76 + }; 77 + 78 + static int samsung_keypad_is_s5pv210(struct device *dev) 79 + { 80 + struct platform_device *pdev = to_platform_device(dev); 81 + enum samsung_keypad_type type = 82 + platform_get_device_id(pdev)->driver_data; 83 + 84 + return type == KEYPAD_TYPE_S5PV210; 85 + } 86 + 87 + static void samsung_keypad_scan(struct samsung_keypad *keypad, 88 + unsigned int *row_state) 89 + { 90 + struct device *dev = keypad->input_dev->dev.parent; 91 + unsigned int col; 92 + unsigned int val; 93 + 94 + for (col = 0; col < keypad->cols; col++) { 95 + if (samsung_keypad_is_s5pv210(dev)) { 96 + val = S5PV210_KEYIFCOLEN_MASK; 97 + val &= ~(1 << col) << 8; 98 + } else { 99 + val = SAMSUNG_KEYIFCOL_MASK; 100 + val &= ~(1 << col); 101 + } 102 + 103 + writel(val, keypad->base + SAMSUNG_KEYIFCOL); 104 + mdelay(1); 105 + 106 + val = readl(keypad->base + SAMSUNG_KEYIFROW); 107 + row_state[col] = ~val & ((1 << keypad->rows) - 1); 108 + } 109 + 110 + /* KEYIFCOL reg clear */ 111 + writel(0, keypad->base + SAMSUNG_KEYIFCOL); 112 + } 113 + 114 + static bool samsung_keypad_report(struct samsung_keypad *keypad, 115 + unsigned int *row_state) 116 + { 117 + struct input_dev *input_dev = keypad->input_dev; 118 + unsigned int changed; 119 + unsigned int pressed; 120 + unsigned int key_down = 0; 121 + unsigned int val; 122 + unsigned int col, row; 123 + 124 + for (col = 0; col < keypad->cols; col++) { 125 + changed = row_state[col] ^ keypad->row_state[col]; 126 + key_down |= row_state[col]; 127 + if (!changed) 128 + continue; 129 + 130 + for (row = 0; row < keypad->rows; row++) { 131 + if (!(changed & (1 << row))) 132 + continue; 133 + 134 + pressed = row_state[col] & (1 << row); 135 + 136 + dev_dbg(&keypad->input_dev->dev, 137 + "key %s, row: %d, col: %d\n", 138 + pressed ? "pressed" : "released", row, col); 139 + 140 + val = MATRIX_SCAN_CODE(row, col, keypad->row_shift); 141 + 142 + input_event(input_dev, EV_MSC, MSC_SCAN, val); 143 + input_report_key(input_dev, 144 + keypad->keycodes[val], pressed); 145 + } 146 + input_sync(keypad->input_dev); 147 + } 148 + 149 + memcpy(keypad->row_state, row_state, sizeof(keypad->row_state)); 150 + 151 + return key_down; 152 + } 153 + 154 + static irqreturn_t samsung_keypad_irq(int irq, void *dev_id) 155 + { 156 + struct samsung_keypad *keypad = dev_id; 157 + unsigned int row_state[SAMSUNG_MAX_COLS]; 158 + unsigned int val; 159 + bool key_down; 160 + 161 + do { 162 + val = readl(keypad->base + SAMSUNG_KEYIFSTSCLR); 163 + /* Clear interrupt. */ 164 + writel(~0x0, keypad->base + SAMSUNG_KEYIFSTSCLR); 165 + 166 + samsung_keypad_scan(keypad, row_state); 167 + 168 + key_down = samsung_keypad_report(keypad, row_state); 169 + if (key_down) 170 + wait_event_timeout(keypad->wait, keypad->stopped, 171 + msecs_to_jiffies(50)); 172 + 173 + } while (key_down && !keypad->stopped); 174 + 175 + return IRQ_HANDLED; 176 + } 177 + 178 + static void samsung_keypad_start(struct samsung_keypad *keypad) 179 + { 180 + unsigned int val; 181 + 182 + /* Tell IRQ thread that it may poll the device. */ 183 + keypad->stopped = false; 184 + 185 + clk_enable(keypad->clk); 186 + 187 + /* Enable interrupt bits. */ 188 + val = readl(keypad->base + SAMSUNG_KEYIFCON); 189 + val |= SAMSUNG_KEYIFCON_INT_F_EN | SAMSUNG_KEYIFCON_INT_R_EN; 190 + writel(val, keypad->base + SAMSUNG_KEYIFCON); 191 + 192 + /* KEYIFCOL reg clear. */ 193 + writel(0, keypad->base + SAMSUNG_KEYIFCOL); 194 + } 195 + 196 + static void samsung_keypad_stop(struct samsung_keypad *keypad) 197 + { 198 + unsigned int val; 199 + 200 + /* Signal IRQ thread to stop polling and disable the handler. */ 201 + keypad->stopped = true; 202 + wake_up(&keypad->wait); 203 + disable_irq(keypad->irq); 204 + 205 + /* Clear interrupt. */ 206 + writel(~0x0, keypad->base + SAMSUNG_KEYIFSTSCLR); 207 + 208 + /* Disable interrupt bits. */ 209 + val = readl(keypad->base + SAMSUNG_KEYIFCON); 210 + val &= ~(SAMSUNG_KEYIFCON_INT_F_EN | SAMSUNG_KEYIFCON_INT_R_EN); 211 + writel(val, keypad->base + SAMSUNG_KEYIFCON); 212 + 213 + clk_disable(keypad->clk); 214 + 215 + /* 216 + * Now that chip should not generate interrupts we can safely 217 + * re-enable the handler. 218 + */ 219 + enable_irq(keypad->irq); 220 + } 221 + 222 + static int samsung_keypad_open(struct input_dev *input_dev) 223 + { 224 + struct samsung_keypad *keypad = input_get_drvdata(input_dev); 225 + 226 + samsung_keypad_start(keypad); 227 + 228 + return 0; 229 + } 230 + 231 + static void samsung_keypad_close(struct input_dev *input_dev) 232 + { 233 + struct samsung_keypad *keypad = input_get_drvdata(input_dev); 234 + 235 + samsung_keypad_stop(keypad); 236 + } 237 + 238 + static int __devinit samsung_keypad_probe(struct platform_device *pdev) 239 + { 240 + const struct samsung_keypad_platdata *pdata; 241 + const struct matrix_keymap_data *keymap_data; 242 + struct samsung_keypad *keypad; 243 + struct resource *res; 244 + struct input_dev *input_dev; 245 + unsigned int row_shift; 246 + unsigned int keymap_size; 247 + int error; 248 + 249 + pdata = pdev->dev.platform_data; 250 + if (!pdata) { 251 + dev_err(&pdev->dev, "no platform data defined\n"); 252 + return -EINVAL; 253 + } 254 + 255 + keymap_data = pdata->keymap_data; 256 + if (!keymap_data) { 257 + dev_err(&pdev->dev, "no keymap data defined\n"); 258 + return -EINVAL; 259 + } 260 + 261 + if (!pdata->rows || pdata->rows > SAMSUNG_MAX_ROWS) 262 + return -EINVAL; 263 + 264 + if (!pdata->cols || pdata->cols > SAMSUNG_MAX_COLS) 265 + return -EINVAL; 266 + 267 + /* initialize the gpio */ 268 + if (pdata->cfg_gpio) 269 + pdata->cfg_gpio(pdata->rows, pdata->cols); 270 + 271 + row_shift = get_count_order(pdata->cols); 272 + keymap_size = (pdata->rows << row_shift) * sizeof(keypad->keycodes[0]); 273 + 274 + keypad = kzalloc(sizeof(*keypad) + keymap_size, GFP_KERNEL); 275 + input_dev = input_allocate_device(); 276 + if (!keypad || !input_dev) { 277 + error = -ENOMEM; 278 + goto err_free_mem; 279 + } 280 + 281 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 282 + if (!res) { 283 + error = -ENODEV; 284 + goto err_free_mem; 285 + } 286 + 287 + keypad->base = ioremap(res->start, resource_size(res)); 288 + if (!keypad->base) { 289 + error = -EBUSY; 290 + goto err_free_mem; 291 + } 292 + 293 + keypad->clk = clk_get(&pdev->dev, "keypad"); 294 + if (IS_ERR(keypad->clk)) { 295 + dev_err(&pdev->dev, "failed to get keypad clk\n"); 296 + error = PTR_ERR(keypad->clk); 297 + goto err_unmap_base; 298 + } 299 + 300 + keypad->input_dev = input_dev; 301 + keypad->row_shift = row_shift; 302 + keypad->rows = pdata->rows; 303 + keypad->cols = pdata->cols; 304 + init_waitqueue_head(&keypad->wait); 305 + 306 + input_dev->name = pdev->name; 307 + input_dev->id.bustype = BUS_HOST; 308 + input_dev->dev.parent = &pdev->dev; 309 + input_set_drvdata(input_dev, keypad); 310 + 311 + input_dev->open = samsung_keypad_open; 312 + input_dev->close = samsung_keypad_close; 313 + 314 + input_dev->evbit[0] = BIT_MASK(EV_KEY); 315 + if (!pdata->no_autorepeat) 316 + input_dev->evbit[0] |= BIT_MASK(EV_REP); 317 + 318 + input_set_capability(input_dev, EV_MSC, MSC_SCAN); 319 + 320 + input_dev->keycode = keypad->keycodes; 321 + input_dev->keycodesize = sizeof(keypad->keycodes[0]); 322 + input_dev->keycodemax = pdata->rows << row_shift; 323 + 324 + matrix_keypad_build_keymap(keymap_data, row_shift, 325 + input_dev->keycode, input_dev->keybit); 326 + 327 + keypad->irq = platform_get_irq(pdev, 0); 328 + if (keypad->irq < 0) { 329 + error = keypad->irq; 330 + goto err_put_clk; 331 + } 332 + 333 + error = request_threaded_irq(keypad->irq, NULL, samsung_keypad_irq, 334 + IRQF_ONESHOT, dev_name(&pdev->dev), keypad); 335 + if (error) { 336 + dev_err(&pdev->dev, "failed to register keypad interrupt\n"); 337 + goto err_put_clk; 338 + } 339 + 340 + error = input_register_device(keypad->input_dev); 341 + if (error) 342 + goto err_free_irq; 343 + 344 + device_init_wakeup(&pdev->dev, pdata->wakeup); 345 + platform_set_drvdata(pdev, keypad); 346 + return 0; 347 + 348 + err_free_irq: 349 + free_irq(keypad->irq, keypad); 350 + err_put_clk: 351 + clk_put(keypad->clk); 352 + err_unmap_base: 353 + iounmap(keypad->base); 354 + err_free_mem: 355 + input_free_device(input_dev); 356 + kfree(keypad); 357 + 358 + return error; 359 + } 360 + 361 + static int __devexit samsung_keypad_remove(struct platform_device *pdev) 362 + { 363 + struct samsung_keypad *keypad = platform_get_drvdata(pdev); 364 + 365 + device_init_wakeup(&pdev->dev, 0); 366 + platform_set_drvdata(pdev, NULL); 367 + 368 + input_unregister_device(keypad->input_dev); 369 + 370 + /* 371 + * It is safe to free IRQ after unregistering device because 372 + * samsung_keypad_close will shut off interrupts. 373 + */ 374 + free_irq(keypad->irq, keypad); 375 + 376 + clk_put(keypad->clk); 377 + 378 + iounmap(keypad->base); 379 + kfree(keypad); 380 + 381 + return 0; 382 + } 383 + 384 + #ifdef CONFIG_PM 385 + static void samsung_keypad_toggle_wakeup(struct samsung_keypad *keypad, 386 + bool enable) 387 + { 388 + struct device *dev = keypad->input_dev->dev.parent; 389 + unsigned int val; 390 + 391 + clk_enable(keypad->clk); 392 + 393 + val = readl(keypad->base + SAMSUNG_KEYIFCON); 394 + if (enable) { 395 + val |= SAMSUNG_KEYIFCON_WAKEUPEN; 396 + if (device_may_wakeup(dev)) 397 + enable_irq_wake(keypad->irq); 398 + } else { 399 + val &= ~SAMSUNG_KEYIFCON_WAKEUPEN; 400 + if (device_may_wakeup(dev)) 401 + disable_irq_wake(keypad->irq); 402 + } 403 + writel(val, keypad->base + SAMSUNG_KEYIFCON); 404 + 405 + clk_disable(keypad->clk); 406 + } 407 + 408 + static int samsung_keypad_suspend(struct device *dev) 409 + { 410 + struct platform_device *pdev = to_platform_device(dev); 411 + struct samsung_keypad *keypad = platform_get_drvdata(pdev); 412 + struct input_dev *input_dev = keypad->input_dev; 413 + 414 + mutex_lock(&input_dev->mutex); 415 + 416 + if (input_dev->users) 417 + samsung_keypad_stop(keypad); 418 + 419 + samsung_keypad_toggle_wakeup(keypad, true); 420 + 421 + mutex_unlock(&input_dev->mutex); 422 + 423 + return 0; 424 + } 425 + 426 + static int samsung_keypad_resume(struct device *dev) 427 + { 428 + struct platform_device *pdev = to_platform_device(dev); 429 + struct samsung_keypad *keypad = platform_get_drvdata(pdev); 430 + struct input_dev *input_dev = keypad->input_dev; 431 + 432 + mutex_lock(&input_dev->mutex); 433 + 434 + samsung_keypad_toggle_wakeup(keypad, false); 435 + 436 + if (input_dev->users) 437 + samsung_keypad_start(keypad); 438 + 439 + mutex_unlock(&input_dev->mutex); 440 + 441 + return 0; 442 + } 443 + 444 + static const struct dev_pm_ops samsung_keypad_pm_ops = { 445 + .suspend = samsung_keypad_suspend, 446 + .resume = samsung_keypad_resume, 447 + }; 448 + #endif 449 + 450 + static struct platform_device_id samsung_keypad_driver_ids[] = { 451 + { 452 + .name = "samsung-keypad", 453 + .driver_data = KEYPAD_TYPE_SAMSUNG, 454 + }, { 455 + .name = "s5pv210-keypad", 456 + .driver_data = KEYPAD_TYPE_S5PV210, 457 + }, 458 + { }, 459 + }; 460 + MODULE_DEVICE_TABLE(platform, samsung_keypad_driver_ids); 461 + 462 + static struct platform_driver samsung_keypad_driver = { 463 + .probe = samsung_keypad_probe, 464 + .remove = __devexit_p(samsung_keypad_remove), 465 + .driver = { 466 + .name = "samsung-keypad", 467 + .owner = THIS_MODULE, 468 + #ifdef CONFIG_PM 469 + .pm = &samsung_keypad_pm_ops, 470 + #endif 471 + }, 472 + .id_table = samsung_keypad_driver_ids, 473 + }; 474 + 475 + static int __init samsung_keypad_init(void) 476 + { 477 + return platform_driver_register(&samsung_keypad_driver); 478 + } 479 + module_init(samsung_keypad_init); 480 + 481 + static void __exit samsung_keypad_exit(void) 482 + { 483 + platform_driver_unregister(&samsung_keypad_driver); 484 + } 485 + module_exit(samsung_keypad_exit); 486 + 487 + MODULE_DESCRIPTION("Samsung keypad driver"); 488 + MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); 489 + MODULE_AUTHOR("Donghwa Lee <dh09.lee@samsung.com>"); 490 + MODULE_LICENSE("GPL"); 491 + MODULE_ALIAS("platform:samsung-keypad");
+48
drivers/input/misc/Kconfig
··· 327 To compile this driver as a module, choose M here: the 328 module will be called pcf8574_keypad. 329 330 config INPUT_GPIO_ROTARY_ENCODER 331 tristate "Rotary encoders connected to GPIO pins" 332 depends on GPIOLIB && GENERIC_GPIO ··· 400 401 To compile this driver as a module, choose M here: the 402 module will be called pcap_keys. 403 404 endif
··· 327 To compile this driver as a module, choose M here: the 328 module will be called pcf8574_keypad. 329 330 + config INPUT_PWM_BEEPER 331 + tristate "PWM beeper support" 332 + depends on HAVE_PWM 333 + help 334 + Say Y here to get support for PWM based beeper devices. 335 + 336 + If unsure, say N. 337 + 338 + To compile this driver as a module, choose M here: the module will be 339 + called pwm-beeper. 340 + 341 config INPUT_GPIO_ROTARY_ENCODER 342 tristate "Rotary encoders connected to GPIO pins" 343 depends on GPIOLIB && GENERIC_GPIO ··· 389 390 To compile this driver as a module, choose M here: the 391 module will be called pcap_keys. 392 + 393 + config INPUT_ADXL34X 394 + tristate "Analog Devices ADXL34x Three-Axis Digital Accelerometer" 395 + default n 396 + help 397 + Say Y here if you have a Accelerometer interface using the 398 + ADXL345/6 controller, and your board-specific initialization 399 + code includes that in its table of devices. 400 + 401 + This driver can use either I2C or SPI communication to the 402 + ADXL345/6 controller. Select the appropriate method for 403 + your system. 404 + 405 + If unsure, say N (but it's safe to say "Y"). 406 + 407 + To compile this driver as a module, choose M here: the 408 + module will be called adxl34x. 409 + 410 + config INPUT_ADXL34X_I2C 411 + tristate "support I2C bus connection" 412 + depends on INPUT_ADXL34X && I2C 413 + default y 414 + help 415 + Say Y here if you have ADXL345/6 hooked to an I2C bus. 416 + 417 + To compile this driver as a module, choose M here: the 418 + module will be called adxl34x-i2c. 419 + 420 + config INPUT_ADXL34X_SPI 421 + tristate "support SPI bus connection" 422 + depends on INPUT_ADXL34X && SPI 423 + default y 424 + help 425 + Say Y here if you have ADXL345/6 hooked to a SPI bus. 426 + 427 + To compile this driver as a module, choose M here: the 428 + module will be called adxl34x-spi. 429 430 endif
+4
drivers/input/misc/Makefile
··· 8 obj-$(CONFIG_INPUT_AD714X) += ad714x.o 9 obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o 10 obj-$(CONFIG_INPUT_AD714X_SPI) += ad714x-spi.o 11 obj-$(CONFIG_INPUT_APANEL) += apanel.o 12 obj-$(CONFIG_INPUT_ATI_REMOTE) += ati_remote.o 13 obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o ··· 29 obj-$(CONFIG_INPUT_PCF8574) += pcf8574_keypad.o 30 obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o 31 obj-$(CONFIG_INPUT_POWERMATE) += powermate.o 32 obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o 33 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o 34 obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
··· 8 obj-$(CONFIG_INPUT_AD714X) += ad714x.o 9 obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o 10 obj-$(CONFIG_INPUT_AD714X_SPI) += ad714x-spi.o 11 + obj-$(CONFIG_INPUT_ADXL34X) += adxl34x.o 12 + obj-$(CONFIG_INPUT_ADXL34X_I2C) += adxl34x-i2c.o 13 + obj-$(CONFIG_INPUT_ADXL34X_SPI) += adxl34x-spi.o 14 obj-$(CONFIG_INPUT_APANEL) += apanel.o 15 obj-$(CONFIG_INPUT_ATI_REMOTE) += ati_remote.o 16 obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o ··· 26 obj-$(CONFIG_INPUT_PCF8574) += pcf8574_keypad.o 27 obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o 28 obj-$(CONFIG_INPUT_POWERMATE) += powermate.o 29 + obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o 30 obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o 31 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o 32 obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
+163
drivers/input/misc/adxl34x-i2c.c
···
··· 1 + /* 2 + * ADLX345/346 Three-Axis Digital Accelerometers (I2C Interface) 3 + * 4 + * Enter bugs at http://blackfin.uclinux.org/ 5 + * 6 + * Copyright (C) 2009 Michael Hennerich, Analog Devices Inc. 7 + * Licensed under the GPL-2 or later. 8 + */ 9 + 10 + #include <linux/input.h> /* BUS_I2C */ 11 + #include <linux/i2c.h> 12 + #include <linux/module.h> 13 + #include <linux/types.h> 14 + #include "adxl34x.h" 15 + 16 + static int adxl34x_smbus_read(struct device *dev, unsigned char reg) 17 + { 18 + struct i2c_client *client = to_i2c_client(dev); 19 + 20 + return i2c_smbus_read_byte_data(client, reg); 21 + } 22 + 23 + static int adxl34x_smbus_write(struct device *dev, 24 + unsigned char reg, unsigned char val) 25 + { 26 + struct i2c_client *client = to_i2c_client(dev); 27 + 28 + return i2c_smbus_write_byte_data(client, reg, val); 29 + } 30 + 31 + static int adxl34x_smbus_read_block(struct device *dev, 32 + unsigned char reg, int count, 33 + void *buf) 34 + { 35 + struct i2c_client *client = to_i2c_client(dev); 36 + 37 + return i2c_smbus_read_i2c_block_data(client, reg, count, buf); 38 + } 39 + 40 + static int adxl34x_i2c_read_block(struct device *dev, 41 + unsigned char reg, int count, 42 + void *buf) 43 + { 44 + struct i2c_client *client = to_i2c_client(dev); 45 + int ret; 46 + 47 + ret = i2c_master_send(client, &reg, 1); 48 + if (ret < 0) 49 + return ret; 50 + 51 + ret = i2c_master_recv(client, buf, count); 52 + if (ret < 0) 53 + return ret; 54 + 55 + if (ret != count) 56 + return -EIO; 57 + 58 + return 0; 59 + } 60 + 61 + static const struct adxl34x_bus_ops adxl34x_smbus_bops = { 62 + .bustype = BUS_I2C, 63 + .write = adxl34x_smbus_write, 64 + .read = adxl34x_smbus_read, 65 + .read_block = adxl34x_smbus_read_block, 66 + }; 67 + 68 + static const struct adxl34x_bus_ops adxl34x_i2c_bops = { 69 + .bustype = BUS_I2C, 70 + .write = adxl34x_smbus_write, 71 + .read = adxl34x_smbus_read, 72 + .read_block = adxl34x_i2c_read_block, 73 + }; 74 + 75 + static int __devinit adxl34x_i2c_probe(struct i2c_client *client, 76 + const struct i2c_device_id *id) 77 + { 78 + struct adxl34x *ac; 79 + int error; 80 + 81 + error = i2c_check_functionality(client->adapter, 82 + I2C_FUNC_SMBUS_BYTE_DATA); 83 + if (!error) { 84 + dev_err(&client->dev, "SMBUS Byte Data not Supported\n"); 85 + return -EIO; 86 + } 87 + 88 + ac = adxl34x_probe(&client->dev, client->irq, false, 89 + i2c_check_functionality(client->adapter, 90 + I2C_FUNC_SMBUS_READ_I2C_BLOCK) ? 91 + &adxl34x_smbus_bops : &adxl34x_i2c_bops); 92 + if (IS_ERR(ac)) 93 + return PTR_ERR(ac); 94 + 95 + i2c_set_clientdata(client, ac); 96 + 97 + return 0; 98 + } 99 + 100 + static int __devexit adxl34x_i2c_remove(struct i2c_client *client) 101 + { 102 + struct adxl34x *ac = i2c_get_clientdata(client); 103 + 104 + return adxl34x_remove(ac); 105 + } 106 + 107 + #ifdef CONFIG_PM 108 + static int adxl34x_i2c_suspend(struct i2c_client *client, pm_message_t message) 109 + { 110 + struct adxl34x *ac = i2c_get_clientdata(client); 111 + 112 + adxl34x_suspend(ac); 113 + 114 + return 0; 115 + } 116 + 117 + static int adxl34x_i2c_resume(struct i2c_client *client) 118 + { 119 + struct adxl34x *ac = i2c_get_clientdata(client); 120 + 121 + adxl34x_resume(ac); 122 + 123 + return 0; 124 + } 125 + #else 126 + # define adxl34x_i2c_suspend NULL 127 + # define adxl34x_i2c_resume NULL 128 + #endif 129 + 130 + static const struct i2c_device_id adxl34x_id[] = { 131 + { "adxl34x", 0 }, 132 + { } 133 + }; 134 + 135 + MODULE_DEVICE_TABLE(i2c, adxl34x_id); 136 + 137 + static struct i2c_driver adxl34x_driver = { 138 + .driver = { 139 + .name = "adxl34x", 140 + .owner = THIS_MODULE, 141 + }, 142 + .probe = adxl34x_i2c_probe, 143 + .remove = __devexit_p(adxl34x_i2c_remove), 144 + .suspend = adxl34x_i2c_suspend, 145 + .resume = adxl34x_i2c_resume, 146 + .id_table = adxl34x_id, 147 + }; 148 + 149 + static int __init adxl34x_i2c_init(void) 150 + { 151 + return i2c_add_driver(&adxl34x_driver); 152 + } 153 + module_init(adxl34x_i2c_init); 154 + 155 + static void __exit adxl34x_i2c_exit(void) 156 + { 157 + i2c_del_driver(&adxl34x_driver); 158 + } 159 + module_exit(adxl34x_i2c_exit); 160 + 161 + MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 162 + MODULE_DESCRIPTION("ADXL345/346 Three-Axis Digital Accelerometer I2C Bus Driver"); 163 + MODULE_LICENSE("GPL");
+145
drivers/input/misc/adxl34x-spi.c
···
··· 1 + /* 2 + * ADLX345/346 Three-Axis Digital Accelerometers (SPI Interface) 3 + * 4 + * Enter bugs at http://blackfin.uclinux.org/ 5 + * 6 + * Copyright (C) 2009 Michael Hennerich, Analog Devices Inc. 7 + * Licensed under the GPL-2 or later. 8 + */ 9 + 10 + #include <linux/input.h> /* BUS_SPI */ 11 + #include <linux/module.h> 12 + #include <linux/spi/spi.h> 13 + #include <linux/types.h> 14 + #include "adxl34x.h" 15 + 16 + #define MAX_SPI_FREQ_HZ 5000000 17 + #define MAX_FREQ_NO_FIFODELAY 1500000 18 + #define ADXL34X_CMD_MULTB (1 << 6) 19 + #define ADXL34X_CMD_READ (1 << 7) 20 + #define ADXL34X_WRITECMD(reg) (reg & 0x3F) 21 + #define ADXL34X_READCMD(reg) (ADXL34X_CMD_READ | (reg & 0x3F)) 22 + #define ADXL34X_READMB_CMD(reg) (ADXL34X_CMD_READ | ADXL34X_CMD_MULTB \ 23 + | (reg & 0x3F)) 24 + 25 + static int adxl34x_spi_read(struct device *dev, unsigned char reg) 26 + { 27 + struct spi_device *spi = to_spi_device(dev); 28 + unsigned char cmd; 29 + 30 + cmd = ADXL34X_READCMD(reg); 31 + 32 + return spi_w8r8(spi, cmd); 33 + } 34 + 35 + static int adxl34x_spi_write(struct device *dev, 36 + unsigned char reg, unsigned char val) 37 + { 38 + struct spi_device *spi = to_spi_device(dev); 39 + unsigned char buf[2]; 40 + 41 + buf[0] = ADXL34X_WRITECMD(reg); 42 + buf[1] = val; 43 + 44 + return spi_write(spi, buf, sizeof(buf)); 45 + } 46 + 47 + static int adxl34x_spi_read_block(struct device *dev, 48 + unsigned char reg, int count, 49 + void *buf) 50 + { 51 + struct spi_device *spi = to_spi_device(dev); 52 + ssize_t status; 53 + 54 + reg = ADXL34X_READMB_CMD(reg); 55 + status = spi_write_then_read(spi, &reg, 1, buf, count); 56 + 57 + return (status < 0) ? status : 0; 58 + } 59 + 60 + static const struct adxl34x_bus_ops adx134x_spi_bops = { 61 + .bustype = BUS_SPI, 62 + .write = adxl34x_spi_write, 63 + .read = adxl34x_spi_read, 64 + .read_block = adxl34x_spi_read_block, 65 + }; 66 + 67 + static int __devinit adxl34x_spi_probe(struct spi_device *spi) 68 + { 69 + struct adxl34x *ac; 70 + 71 + /* don't exceed max specified SPI CLK frequency */ 72 + if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) { 73 + dev_err(&spi->dev, "SPI CLK %d Hz too fast\n", spi->max_speed_hz); 74 + return -EINVAL; 75 + } 76 + 77 + ac = adxl34x_probe(&spi->dev, spi->irq, 78 + spi->max_speed_hz > MAX_FREQ_NO_FIFODELAY, 79 + &adx134x_spi_bops); 80 + 81 + if (IS_ERR(ac)) 82 + return PTR_ERR(ac); 83 + 84 + spi_set_drvdata(spi, ac); 85 + 86 + return 0; 87 + } 88 + 89 + static int __devexit adxl34x_spi_remove(struct spi_device *spi) 90 + { 91 + struct adxl34x *ac = dev_get_drvdata(&spi->dev); 92 + 93 + return adxl34x_remove(ac); 94 + } 95 + 96 + #ifdef CONFIG_PM 97 + static int adxl34x_spi_suspend(struct spi_device *spi, pm_message_t message) 98 + { 99 + struct adxl34x *ac = dev_get_drvdata(&spi->dev); 100 + 101 + adxl34x_suspend(ac); 102 + 103 + return 0; 104 + } 105 + 106 + static int adxl34x_spi_resume(struct spi_device *spi) 107 + { 108 + struct adxl34x *ac = dev_get_drvdata(&spi->dev); 109 + 110 + adxl34x_resume(ac); 111 + 112 + return 0; 113 + } 114 + #else 115 + # define adxl34x_spi_suspend NULL 116 + # define adxl34x_spi_resume NULL 117 + #endif 118 + 119 + static struct spi_driver adxl34x_driver = { 120 + .driver = { 121 + .name = "adxl34x", 122 + .bus = &spi_bus_type, 123 + .owner = THIS_MODULE, 124 + }, 125 + .probe = adxl34x_spi_probe, 126 + .remove = __devexit_p(adxl34x_spi_remove), 127 + .suspend = adxl34x_spi_suspend, 128 + .resume = adxl34x_spi_resume, 129 + }; 130 + 131 + static int __init adxl34x_spi_init(void) 132 + { 133 + return spi_register_driver(&adxl34x_driver); 134 + } 135 + module_init(adxl34x_spi_init); 136 + 137 + static void __exit adxl34x_spi_exit(void) 138 + { 139 + spi_unregister_driver(&adxl34x_driver); 140 + } 141 + module_exit(adxl34x_spi_exit); 142 + 143 + MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 144 + MODULE_DESCRIPTION("ADXL345/346 Three-Axis Digital Accelerometer SPI Bus Driver"); 145 + MODULE_LICENSE("GPL");
+915
drivers/input/misc/adxl34x.c
···
··· 1 + /* 2 + * ADXL345/346 Three-Axis Digital Accelerometers 3 + * 4 + * Enter bugs at http://blackfin.uclinux.org/ 5 + * 6 + * Copyright (C) 2009 Michael Hennerich, Analog Devices Inc. 7 + * Licensed under the GPL-2 or later. 8 + */ 9 + 10 + #include <linux/device.h> 11 + #include <linux/init.h> 12 + #include <linux/delay.h> 13 + #include <linux/input.h> 14 + #include <linux/interrupt.h> 15 + #include <linux/irq.h> 16 + #include <linux/slab.h> 17 + #include <linux/workqueue.h> 18 + #include <linux/input/adxl34x.h> 19 + 20 + #include "adxl34x.h" 21 + 22 + /* ADXL345/6 Register Map */ 23 + #define DEVID 0x00 /* R Device ID */ 24 + #define THRESH_TAP 0x1D /* R/W Tap threshold */ 25 + #define OFSX 0x1E /* R/W X-axis offset */ 26 + #define OFSY 0x1F /* R/W Y-axis offset */ 27 + #define OFSZ 0x20 /* R/W Z-axis offset */ 28 + #define DUR 0x21 /* R/W Tap duration */ 29 + #define LATENT 0x22 /* R/W Tap latency */ 30 + #define WINDOW 0x23 /* R/W Tap window */ 31 + #define THRESH_ACT 0x24 /* R/W Activity threshold */ 32 + #define THRESH_INACT 0x25 /* R/W Inactivity threshold */ 33 + #define TIME_INACT 0x26 /* R/W Inactivity time */ 34 + #define ACT_INACT_CTL 0x27 /* R/W Axis enable control for activity and */ 35 + /* inactivity detection */ 36 + #define THRESH_FF 0x28 /* R/W Free-fall threshold */ 37 + #define TIME_FF 0x29 /* R/W Free-fall time */ 38 + #define TAP_AXES 0x2A /* R/W Axis control for tap/double tap */ 39 + #define ACT_TAP_STATUS 0x2B /* R Source of tap/double tap */ 40 + #define BW_RATE 0x2C /* R/W Data rate and power mode control */ 41 + #define POWER_CTL 0x2D /* R/W Power saving features control */ 42 + #define INT_ENABLE 0x2E /* R/W Interrupt enable control */ 43 + #define INT_MAP 0x2F /* R/W Interrupt mapping control */ 44 + #define INT_SOURCE 0x30 /* R Source of interrupts */ 45 + #define DATA_FORMAT 0x31 /* R/W Data format control */ 46 + #define DATAX0 0x32 /* R X-Axis Data 0 */ 47 + #define DATAX1 0x33 /* R X-Axis Data 1 */ 48 + #define DATAY0 0x34 /* R Y-Axis Data 0 */ 49 + #define DATAY1 0x35 /* R Y-Axis Data 1 */ 50 + #define DATAZ0 0x36 /* R Z-Axis Data 0 */ 51 + #define DATAZ1 0x37 /* R Z-Axis Data 1 */ 52 + #define FIFO_CTL 0x38 /* R/W FIFO control */ 53 + #define FIFO_STATUS 0x39 /* R FIFO status */ 54 + #define TAP_SIGN 0x3A /* R Sign and source for tap/double tap */ 55 + /* Orientation ADXL346 only */ 56 + #define ORIENT_CONF 0x3B /* R/W Orientation configuration */ 57 + #define ORIENT 0x3C /* R Orientation status */ 58 + 59 + /* DEVIDs */ 60 + #define ID_ADXL345 0xE5 61 + #define ID_ADXL346 0xE6 62 + 63 + /* INT_ENABLE/INT_MAP/INT_SOURCE Bits */ 64 + #define DATA_READY (1 << 7) 65 + #define SINGLE_TAP (1 << 6) 66 + #define DOUBLE_TAP (1 << 5) 67 + #define ACTIVITY (1 << 4) 68 + #define INACTIVITY (1 << 3) 69 + #define FREE_FALL (1 << 2) 70 + #define WATERMARK (1 << 1) 71 + #define OVERRUN (1 << 0) 72 + 73 + /* ACT_INACT_CONTROL Bits */ 74 + #define ACT_ACDC (1 << 7) 75 + #define ACT_X_EN (1 << 6) 76 + #define ACT_Y_EN (1 << 5) 77 + #define ACT_Z_EN (1 << 4) 78 + #define INACT_ACDC (1 << 3) 79 + #define INACT_X_EN (1 << 2) 80 + #define INACT_Y_EN (1 << 1) 81 + #define INACT_Z_EN (1 << 0) 82 + 83 + /* TAP_AXES Bits */ 84 + #define SUPPRESS (1 << 3) 85 + #define TAP_X_EN (1 << 2) 86 + #define TAP_Y_EN (1 << 1) 87 + #define TAP_Z_EN (1 << 0) 88 + 89 + /* ACT_TAP_STATUS Bits */ 90 + #define ACT_X_SRC (1 << 6) 91 + #define ACT_Y_SRC (1 << 5) 92 + #define ACT_Z_SRC (1 << 4) 93 + #define ASLEEP (1 << 3) 94 + #define TAP_X_SRC (1 << 2) 95 + #define TAP_Y_SRC (1 << 1) 96 + #define TAP_Z_SRC (1 << 0) 97 + 98 + /* BW_RATE Bits */ 99 + #define LOW_POWER (1 << 4) 100 + #define RATE(x) ((x) & 0xF) 101 + 102 + /* POWER_CTL Bits */ 103 + #define PCTL_LINK (1 << 5) 104 + #define PCTL_AUTO_SLEEP (1 << 4) 105 + #define PCTL_MEASURE (1 << 3) 106 + #define PCTL_SLEEP (1 << 2) 107 + #define PCTL_WAKEUP(x) ((x) & 0x3) 108 + 109 + /* DATA_FORMAT Bits */ 110 + #define SELF_TEST (1 << 7) 111 + #define SPI (1 << 6) 112 + #define INT_INVERT (1 << 5) 113 + #define FULL_RES (1 << 3) 114 + #define JUSTIFY (1 << 2) 115 + #define RANGE(x) ((x) & 0x3) 116 + #define RANGE_PM_2g 0 117 + #define RANGE_PM_4g 1 118 + #define RANGE_PM_8g 2 119 + #define RANGE_PM_16g 3 120 + 121 + /* 122 + * Maximum value our axis may get in full res mode for the input device 123 + * (signed 13 bits) 124 + */ 125 + #define ADXL_FULLRES_MAX_VAL 4096 126 + 127 + /* 128 + * Maximum value our axis may get in fixed res mode for the input device 129 + * (signed 10 bits) 130 + */ 131 + #define ADXL_FIXEDRES_MAX_VAL 512 132 + 133 + /* FIFO_CTL Bits */ 134 + #define FIFO_MODE(x) (((x) & 0x3) << 6) 135 + #define FIFO_BYPASS 0 136 + #define FIFO_FIFO 1 137 + #define FIFO_STREAM 2 138 + #define FIFO_TRIGGER 3 139 + #define TRIGGER (1 << 5) 140 + #define SAMPLES(x) ((x) & 0x1F) 141 + 142 + /* FIFO_STATUS Bits */ 143 + #define FIFO_TRIG (1 << 7) 144 + #define ENTRIES(x) ((x) & 0x3F) 145 + 146 + /* TAP_SIGN Bits ADXL346 only */ 147 + #define XSIGN (1 << 6) 148 + #define YSIGN (1 << 5) 149 + #define ZSIGN (1 << 4) 150 + #define XTAP (1 << 3) 151 + #define YTAP (1 << 2) 152 + #define ZTAP (1 << 1) 153 + 154 + /* ORIENT_CONF ADXL346 only */ 155 + #define ORIENT_DEADZONE(x) (((x) & 0x7) << 4) 156 + #define ORIENT_DIVISOR(x) ((x) & 0x7) 157 + 158 + /* ORIENT ADXL346 only */ 159 + #define ADXL346_2D_VALID (1 << 6) 160 + #define ADXL346_2D_ORIENT(x) (((x) & 0x3) >> 4) 161 + #define ADXL346_3D_VALID (1 << 3) 162 + #define ADXL346_3D_ORIENT(x) ((x) & 0x7) 163 + #define ADXL346_2D_PORTRAIT_POS 0 /* +X */ 164 + #define ADXL346_2D_PORTRAIT_NEG 1 /* -X */ 165 + #define ADXL346_2D_LANDSCAPE_POS 2 /* +Y */ 166 + #define ADXL346_2D_LANDSCAPE_NEG 3 /* -Y */ 167 + 168 + #define ADXL346_3D_FRONT 3 /* +X */ 169 + #define ADXL346_3D_BACK 4 /* -X */ 170 + #define ADXL346_3D_RIGHT 2 /* +Y */ 171 + #define ADXL346_3D_LEFT 5 /* -Y */ 172 + #define ADXL346_3D_TOP 1 /* +Z */ 173 + #define ADXL346_3D_BOTTOM 6 /* -Z */ 174 + 175 + #undef ADXL_DEBUG 176 + 177 + #define ADXL_X_AXIS 0 178 + #define ADXL_Y_AXIS 1 179 + #define ADXL_Z_AXIS 2 180 + 181 + #define AC_READ(ac, reg) ((ac)->bops->read((ac)->dev, reg)) 182 + #define AC_WRITE(ac, reg, val) ((ac)->bops->write((ac)->dev, reg, val)) 183 + 184 + struct axis_triple { 185 + int x; 186 + int y; 187 + int z; 188 + }; 189 + 190 + struct adxl34x { 191 + struct device *dev; 192 + struct input_dev *input; 193 + struct mutex mutex; /* reentrant protection for struct */ 194 + struct adxl34x_platform_data pdata; 195 + struct axis_triple swcal; 196 + struct axis_triple hwcal; 197 + struct axis_triple saved; 198 + char phys[32]; 199 + unsigned orient2d_saved; 200 + unsigned orient3d_saved; 201 + bool disabled; /* P: mutex */ 202 + bool opened; /* P: mutex */ 203 + bool suspended; /* P: mutex */ 204 + bool fifo_delay; 205 + int irq; 206 + unsigned model; 207 + unsigned int_mask; 208 + 209 + const struct adxl34x_bus_ops *bops; 210 + }; 211 + 212 + static const struct adxl34x_platform_data adxl34x_default_init = { 213 + .tap_threshold = 35, 214 + .tap_duration = 3, 215 + .tap_latency = 20, 216 + .tap_window = 20, 217 + .tap_axis_control = ADXL_TAP_X_EN | ADXL_TAP_Y_EN | ADXL_TAP_Z_EN, 218 + .act_axis_control = 0xFF, 219 + .activity_threshold = 6, 220 + .inactivity_threshold = 4, 221 + .inactivity_time = 3, 222 + .free_fall_threshold = 8, 223 + .free_fall_time = 0x20, 224 + .data_rate = 8, 225 + .data_range = ADXL_FULL_RES, 226 + 227 + .ev_type = EV_ABS, 228 + .ev_code_x = ABS_X, /* EV_REL */ 229 + .ev_code_y = ABS_Y, /* EV_REL */ 230 + .ev_code_z = ABS_Z, /* EV_REL */ 231 + 232 + .ev_code_tap = {BTN_TOUCH, BTN_TOUCH, BTN_TOUCH}, /* EV_KEY {x,y,z} */ 233 + .power_mode = ADXL_AUTO_SLEEP | ADXL_LINK, 234 + .fifo_mode = FIFO_STREAM, 235 + .watermark = 0, 236 + }; 237 + 238 + static void adxl34x_get_triple(struct adxl34x *ac, struct axis_triple *axis) 239 + { 240 + short buf[3]; 241 + 242 + ac->bops->read_block(ac->dev, DATAX0, DATAZ1 - DATAX0 + 1, buf); 243 + 244 + mutex_lock(&ac->mutex); 245 + ac->saved.x = (s16) le16_to_cpu(buf[0]); 246 + axis->x = ac->saved.x; 247 + 248 + ac->saved.y = (s16) le16_to_cpu(buf[1]); 249 + axis->y = ac->saved.y; 250 + 251 + ac->saved.z = (s16) le16_to_cpu(buf[2]); 252 + axis->z = ac->saved.z; 253 + mutex_unlock(&ac->mutex); 254 + } 255 + 256 + static void adxl34x_service_ev_fifo(struct adxl34x *ac) 257 + { 258 + struct adxl34x_platform_data *pdata = &ac->pdata; 259 + struct axis_triple axis; 260 + 261 + adxl34x_get_triple(ac, &axis); 262 + 263 + input_event(ac->input, pdata->ev_type, pdata->ev_code_x, 264 + axis.x - ac->swcal.x); 265 + input_event(ac->input, pdata->ev_type, pdata->ev_code_y, 266 + axis.y - ac->swcal.y); 267 + input_event(ac->input, pdata->ev_type, pdata->ev_code_z, 268 + axis.z - ac->swcal.z); 269 + } 270 + 271 + static void adxl34x_report_key_single(struct input_dev *input, int key) 272 + { 273 + input_report_key(input, key, true); 274 + input_sync(input); 275 + input_report_key(input, key, false); 276 + } 277 + 278 + static void adxl34x_send_key_events(struct adxl34x *ac, 279 + struct adxl34x_platform_data *pdata, int status, int press) 280 + { 281 + int i; 282 + 283 + for (i = ADXL_X_AXIS; i <= ADXL_Z_AXIS; i++) { 284 + if (status & (1 << (ADXL_Z_AXIS - i))) 285 + input_report_key(ac->input, 286 + pdata->ev_code_tap[i], press); 287 + } 288 + } 289 + 290 + static void adxl34x_do_tap(struct adxl34x *ac, 291 + struct adxl34x_platform_data *pdata, int status) 292 + { 293 + adxl34x_send_key_events(ac, pdata, status, true); 294 + input_sync(ac->input); 295 + adxl34x_send_key_events(ac, pdata, status, false); 296 + } 297 + 298 + static irqreturn_t adxl34x_irq(int irq, void *handle) 299 + { 300 + struct adxl34x *ac = handle; 301 + struct adxl34x_platform_data *pdata = &ac->pdata; 302 + int int_stat, tap_stat, samples, orient, orient_code; 303 + 304 + /* 305 + * ACT_TAP_STATUS should be read before clearing the interrupt 306 + * Avoid reading ACT_TAP_STATUS in case TAP detection is disabled 307 + */ 308 + 309 + if (pdata->tap_axis_control & (TAP_X_EN | TAP_Y_EN | TAP_Z_EN)) 310 + tap_stat = AC_READ(ac, ACT_TAP_STATUS); 311 + else 312 + tap_stat = 0; 313 + 314 + int_stat = AC_READ(ac, INT_SOURCE); 315 + 316 + if (int_stat & FREE_FALL) 317 + adxl34x_report_key_single(ac->input, pdata->ev_code_ff); 318 + 319 + if (int_stat & OVERRUN) 320 + dev_dbg(ac->dev, "OVERRUN\n"); 321 + 322 + if (int_stat & (SINGLE_TAP | DOUBLE_TAP)) { 323 + adxl34x_do_tap(ac, pdata, tap_stat); 324 + 325 + if (int_stat & DOUBLE_TAP) 326 + adxl34x_do_tap(ac, pdata, tap_stat); 327 + } 328 + 329 + if (pdata->ev_code_act_inactivity) { 330 + if (int_stat & ACTIVITY) 331 + input_report_key(ac->input, 332 + pdata->ev_code_act_inactivity, 1); 333 + if (int_stat & INACTIVITY) 334 + input_report_key(ac->input, 335 + pdata->ev_code_act_inactivity, 0); 336 + } 337 + 338 + /* 339 + * ORIENTATION SENSING ADXL346 only 340 + */ 341 + if (pdata->orientation_enable) { 342 + orient = AC_READ(ac, ORIENT); 343 + if ((pdata->orientation_enable & ADXL_EN_ORIENTATION_2D) && 344 + (orient & ADXL346_2D_VALID)) { 345 + 346 + orient_code = ADXL346_2D_ORIENT(orient); 347 + /* Report orientation only when it changes */ 348 + if (ac->orient2d_saved != orient_code) { 349 + ac->orient2d_saved = orient_code; 350 + adxl34x_report_key_single(ac->input, 351 + pdata->ev_codes_orient_2d[orient_code]); 352 + } 353 + } 354 + 355 + if ((pdata->orientation_enable & ADXL_EN_ORIENTATION_3D) && 356 + (orient & ADXL346_3D_VALID)) { 357 + 358 + orient_code = ADXL346_3D_ORIENT(orient) - 1; 359 + /* Report orientation only when it changes */ 360 + if (ac->orient3d_saved != orient_code) { 361 + ac->orient3d_saved = orient_code; 362 + adxl34x_report_key_single(ac->input, 363 + pdata->ev_codes_orient_3d[orient_code]); 364 + } 365 + } 366 + } 367 + 368 + if (int_stat & (DATA_READY | WATERMARK)) { 369 + 370 + if (pdata->fifo_mode) 371 + samples = ENTRIES(AC_READ(ac, FIFO_STATUS)) + 1; 372 + else 373 + samples = 1; 374 + 375 + for (; samples > 0; samples--) { 376 + adxl34x_service_ev_fifo(ac); 377 + /* 378 + * To ensure that the FIFO has 379 + * completely popped, there must be at least 5 us between 380 + * the end of reading the data registers, signified by the 381 + * transition to register 0x38 from 0x37 or the CS pin 382 + * going high, and the start of new reads of the FIFO or 383 + * reading the FIFO_STATUS register. For SPI operation at 384 + * 1.5 MHz or lower, the register addressing portion of the 385 + * transmission is sufficient delay to ensure the FIFO has 386 + * completely popped. It is necessary for SPI operation 387 + * greater than 1.5 MHz to de-assert the CS pin to ensure a 388 + * total of 5 us, which is at most 3.4 us at 5 MHz 389 + * operation. 390 + */ 391 + if (ac->fifo_delay && (samples > 1)) 392 + udelay(3); 393 + } 394 + } 395 + 396 + input_sync(ac->input); 397 + 398 + return IRQ_HANDLED; 399 + } 400 + 401 + static void __adxl34x_disable(struct adxl34x *ac) 402 + { 403 + /* 404 + * A '0' places the ADXL34x into standby mode 405 + * with minimum power consumption. 406 + */ 407 + AC_WRITE(ac, POWER_CTL, 0); 408 + } 409 + 410 + static void __adxl34x_enable(struct adxl34x *ac) 411 + { 412 + AC_WRITE(ac, POWER_CTL, ac->pdata.power_mode | PCTL_MEASURE); 413 + } 414 + 415 + void adxl34x_suspend(struct adxl34x *ac) 416 + { 417 + mutex_lock(&ac->mutex); 418 + 419 + if (!ac->suspended && !ac->disabled && ac->opened) 420 + __adxl34x_disable(ac); 421 + 422 + ac->suspended = true; 423 + 424 + mutex_unlock(&ac->mutex); 425 + } 426 + EXPORT_SYMBOL_GPL(adxl34x_suspend); 427 + 428 + void adxl34x_resume(struct adxl34x *ac) 429 + { 430 + mutex_lock(&ac->mutex); 431 + 432 + if (ac->suspended && !ac->disabled && ac->opened) 433 + __adxl34x_enable(ac); 434 + 435 + ac->suspended = false; 436 + 437 + mutex_unlock(&ac->mutex); 438 + } 439 + EXPORT_SYMBOL_GPL(adxl34x_resume); 440 + 441 + static ssize_t adxl34x_disable_show(struct device *dev, 442 + struct device_attribute *attr, char *buf) 443 + { 444 + struct adxl34x *ac = dev_get_drvdata(dev); 445 + 446 + return sprintf(buf, "%u\n", ac->disabled); 447 + } 448 + 449 + static ssize_t adxl34x_disable_store(struct device *dev, 450 + struct device_attribute *attr, 451 + const char *buf, size_t count) 452 + { 453 + struct adxl34x *ac = dev_get_drvdata(dev); 454 + unsigned long val; 455 + int error; 456 + 457 + error = strict_strtoul(buf, 10, &val); 458 + if (error) 459 + return error; 460 + 461 + mutex_lock(&ac->mutex); 462 + 463 + if (!ac->suspended && ac->opened) { 464 + if (val) { 465 + if (!ac->disabled) 466 + __adxl34x_disable(ac); 467 + } else { 468 + if (ac->disabled) 469 + __adxl34x_enable(ac); 470 + } 471 + } 472 + 473 + ac->disabled = !!val; 474 + 475 + mutex_unlock(&ac->mutex); 476 + 477 + return count; 478 + } 479 + 480 + static DEVICE_ATTR(disable, 0664, adxl34x_disable_show, adxl34x_disable_store); 481 + 482 + static ssize_t adxl34x_calibrate_show(struct device *dev, 483 + struct device_attribute *attr, char *buf) 484 + { 485 + struct adxl34x *ac = dev_get_drvdata(dev); 486 + ssize_t count; 487 + 488 + mutex_lock(&ac->mutex); 489 + count = sprintf(buf, "%d,%d,%d\n", 490 + ac->hwcal.x * 4 + ac->swcal.x, 491 + ac->hwcal.y * 4 + ac->swcal.y, 492 + ac->hwcal.z * 4 + ac->swcal.z); 493 + mutex_unlock(&ac->mutex); 494 + 495 + return count; 496 + } 497 + 498 + static ssize_t adxl34x_calibrate_store(struct device *dev, 499 + struct device_attribute *attr, 500 + const char *buf, size_t count) 501 + { 502 + struct adxl34x *ac = dev_get_drvdata(dev); 503 + 504 + /* 505 + * Hardware offset calibration has a resolution of 15.6 mg/LSB. 506 + * We use HW calibration and handle the remaining bits in SW. (4mg/LSB) 507 + */ 508 + 509 + mutex_lock(&ac->mutex); 510 + ac->hwcal.x -= (ac->saved.x / 4); 511 + ac->swcal.x = ac->saved.x % 4; 512 + 513 + ac->hwcal.y -= (ac->saved.y / 4); 514 + ac->swcal.y = ac->saved.y % 4; 515 + 516 + ac->hwcal.z -= (ac->saved.z / 4); 517 + ac->swcal.z = ac->saved.z % 4; 518 + 519 + AC_WRITE(ac, OFSX, (s8) ac->hwcal.x); 520 + AC_WRITE(ac, OFSY, (s8) ac->hwcal.y); 521 + AC_WRITE(ac, OFSZ, (s8) ac->hwcal.z); 522 + mutex_unlock(&ac->mutex); 523 + 524 + return count; 525 + } 526 + 527 + static DEVICE_ATTR(calibrate, 0664, 528 + adxl34x_calibrate_show, adxl34x_calibrate_store); 529 + 530 + static ssize_t adxl34x_rate_show(struct device *dev, 531 + struct device_attribute *attr, char *buf) 532 + { 533 + struct adxl34x *ac = dev_get_drvdata(dev); 534 + 535 + return sprintf(buf, "%u\n", RATE(ac->pdata.data_rate)); 536 + } 537 + 538 + static ssize_t adxl34x_rate_store(struct device *dev, 539 + struct device_attribute *attr, 540 + const char *buf, size_t count) 541 + { 542 + struct adxl34x *ac = dev_get_drvdata(dev); 543 + unsigned long val; 544 + int error; 545 + 546 + error = strict_strtoul(buf, 10, &val); 547 + if (error) 548 + return error; 549 + 550 + mutex_lock(&ac->mutex); 551 + 552 + ac->pdata.data_rate = RATE(val); 553 + AC_WRITE(ac, BW_RATE, 554 + ac->pdata.data_rate | 555 + (ac->pdata.low_power_mode ? LOW_POWER : 0)); 556 + 557 + mutex_unlock(&ac->mutex); 558 + 559 + return count; 560 + } 561 + 562 + static DEVICE_ATTR(rate, 0664, adxl34x_rate_show, adxl34x_rate_store); 563 + 564 + static ssize_t adxl34x_autosleep_show(struct device *dev, 565 + struct device_attribute *attr, char *buf) 566 + { 567 + struct adxl34x *ac = dev_get_drvdata(dev); 568 + 569 + return sprintf(buf, "%u\n", 570 + ac->pdata.power_mode & (PCTL_AUTO_SLEEP | PCTL_LINK) ? 1 : 0); 571 + } 572 + 573 + static ssize_t adxl34x_autosleep_store(struct device *dev, 574 + struct device_attribute *attr, 575 + const char *buf, size_t count) 576 + { 577 + struct adxl34x *ac = dev_get_drvdata(dev); 578 + unsigned long val; 579 + int error; 580 + 581 + error = strict_strtoul(buf, 10, &val); 582 + if (error) 583 + return error; 584 + 585 + mutex_lock(&ac->mutex); 586 + 587 + if (val) 588 + ac->pdata.power_mode |= (PCTL_AUTO_SLEEP | PCTL_LINK); 589 + else 590 + ac->pdata.power_mode &= ~(PCTL_AUTO_SLEEP | PCTL_LINK); 591 + 592 + if (!ac->disabled && !ac->suspended && ac->opened) 593 + AC_WRITE(ac, POWER_CTL, ac->pdata.power_mode | PCTL_MEASURE); 594 + 595 + mutex_unlock(&ac->mutex); 596 + 597 + return count; 598 + } 599 + 600 + static DEVICE_ATTR(autosleep, 0664, 601 + adxl34x_autosleep_show, adxl34x_autosleep_store); 602 + 603 + static ssize_t adxl34x_position_show(struct device *dev, 604 + struct device_attribute *attr, char *buf) 605 + { 606 + struct adxl34x *ac = dev_get_drvdata(dev); 607 + ssize_t count; 608 + 609 + mutex_lock(&ac->mutex); 610 + count = sprintf(buf, "(%d, %d, %d)\n", 611 + ac->saved.x, ac->saved.y, ac->saved.z); 612 + mutex_unlock(&ac->mutex); 613 + 614 + return count; 615 + } 616 + 617 + static DEVICE_ATTR(position, S_IRUGO, adxl34x_position_show, NULL); 618 + 619 + #ifdef ADXL_DEBUG 620 + static ssize_t adxl34x_write_store(struct device *dev, 621 + struct device_attribute *attr, 622 + const char *buf, size_t count) 623 + { 624 + struct adxl34x *ac = dev_get_drvdata(dev); 625 + unsigned long val; 626 + int error; 627 + 628 + /* 629 + * This allows basic ADXL register write access for debug purposes. 630 + */ 631 + error = strict_strtoul(buf, 16, &val); 632 + if (error) 633 + return error; 634 + 635 + mutex_lock(&ac->mutex); 636 + AC_WRITE(ac, val >> 8, val & 0xFF); 637 + mutex_unlock(&ac->mutex); 638 + 639 + return count; 640 + } 641 + 642 + static DEVICE_ATTR(write, 0664, NULL, adxl34x_write_store); 643 + #endif 644 + 645 + static struct attribute *adxl34x_attributes[] = { 646 + &dev_attr_disable.attr, 647 + &dev_attr_calibrate.attr, 648 + &dev_attr_rate.attr, 649 + &dev_attr_autosleep.attr, 650 + &dev_attr_position.attr, 651 + #ifdef ADXL_DEBUG 652 + &dev_attr_write.attr, 653 + #endif 654 + NULL 655 + }; 656 + 657 + static const struct attribute_group adxl34x_attr_group = { 658 + .attrs = adxl34x_attributes, 659 + }; 660 + 661 + static int adxl34x_input_open(struct input_dev *input) 662 + { 663 + struct adxl34x *ac = input_get_drvdata(input); 664 + 665 + mutex_lock(&ac->mutex); 666 + 667 + if (!ac->suspended && !ac->disabled) 668 + __adxl34x_enable(ac); 669 + 670 + ac->opened = true; 671 + 672 + mutex_unlock(&ac->mutex); 673 + 674 + return 0; 675 + } 676 + 677 + static void adxl34x_input_close(struct input_dev *input) 678 + { 679 + struct adxl34x *ac = input_get_drvdata(input); 680 + 681 + mutex_lock(&ac->mutex); 682 + 683 + if (!ac->suspended && !ac->disabled) 684 + __adxl34x_disable(ac); 685 + 686 + ac->opened = false; 687 + 688 + mutex_unlock(&ac->mutex); 689 + } 690 + 691 + struct adxl34x *adxl34x_probe(struct device *dev, int irq, 692 + bool fifo_delay_default, 693 + const struct adxl34x_bus_ops *bops) 694 + { 695 + struct adxl34x *ac; 696 + struct input_dev *input_dev; 697 + const struct adxl34x_platform_data *pdata; 698 + int err, range, i; 699 + unsigned char revid; 700 + 701 + if (!irq) { 702 + dev_err(dev, "no IRQ?\n"); 703 + err = -ENODEV; 704 + goto err_out; 705 + } 706 + 707 + ac = kzalloc(sizeof(*ac), GFP_KERNEL); 708 + input_dev = input_allocate_device(); 709 + if (!ac || !input_dev) { 710 + err = -ENOMEM; 711 + goto err_free_mem; 712 + } 713 + 714 + ac->fifo_delay = fifo_delay_default; 715 + 716 + pdata = dev->platform_data; 717 + if (!pdata) { 718 + dev_dbg(dev, 719 + "No platfrom data: Using default initialization\n"); 720 + pdata = &adxl34x_default_init; 721 + } 722 + 723 + ac->pdata = *pdata; 724 + pdata = &ac->pdata; 725 + 726 + ac->input = input_dev; 727 + ac->disabled = true; 728 + ac->dev = dev; 729 + ac->irq = irq; 730 + ac->bops = bops; 731 + 732 + mutex_init(&ac->mutex); 733 + 734 + input_dev->name = "ADXL34x accelerometer"; 735 + revid = ac->bops->read(dev, DEVID); 736 + 737 + switch (revid) { 738 + case ID_ADXL345: 739 + ac->model = 345; 740 + break; 741 + case ID_ADXL346: 742 + ac->model = 346; 743 + break; 744 + default: 745 + dev_err(dev, "Failed to probe %s\n", input_dev->name); 746 + err = -ENODEV; 747 + goto err_free_mem; 748 + } 749 + 750 + snprintf(ac->phys, sizeof(ac->phys), "%s/input0", dev_name(dev)); 751 + 752 + input_dev->phys = ac->phys; 753 + input_dev->dev.parent = dev; 754 + input_dev->id.product = ac->model; 755 + input_dev->id.bustype = bops->bustype; 756 + input_dev->open = adxl34x_input_open; 757 + input_dev->close = adxl34x_input_close; 758 + 759 + input_set_drvdata(input_dev, ac); 760 + 761 + __set_bit(ac->pdata.ev_type, input_dev->evbit); 762 + 763 + if (ac->pdata.ev_type == EV_REL) { 764 + __set_bit(REL_X, input_dev->relbit); 765 + __set_bit(REL_Y, input_dev->relbit); 766 + __set_bit(REL_Z, input_dev->relbit); 767 + } else { 768 + /* EV_ABS */ 769 + __set_bit(ABS_X, input_dev->absbit); 770 + __set_bit(ABS_Y, input_dev->absbit); 771 + __set_bit(ABS_Z, input_dev->absbit); 772 + 773 + if (pdata->data_range & FULL_RES) 774 + range = ADXL_FULLRES_MAX_VAL; /* Signed 13-bit */ 775 + else 776 + range = ADXL_FIXEDRES_MAX_VAL; /* Signed 10-bit */ 777 + 778 + input_set_abs_params(input_dev, ABS_X, -range, range, 3, 3); 779 + input_set_abs_params(input_dev, ABS_Y, -range, range, 3, 3); 780 + input_set_abs_params(input_dev, ABS_Z, -range, range, 3, 3); 781 + } 782 + 783 + __set_bit(EV_KEY, input_dev->evbit); 784 + __set_bit(pdata->ev_code_tap[ADXL_X_AXIS], input_dev->keybit); 785 + __set_bit(pdata->ev_code_tap[ADXL_Y_AXIS], input_dev->keybit); 786 + __set_bit(pdata->ev_code_tap[ADXL_Z_AXIS], input_dev->keybit); 787 + 788 + if (pdata->ev_code_ff) { 789 + ac->int_mask = FREE_FALL; 790 + __set_bit(pdata->ev_code_ff, input_dev->keybit); 791 + } 792 + 793 + if (pdata->ev_code_act_inactivity) 794 + __set_bit(pdata->ev_code_act_inactivity, input_dev->keybit); 795 + 796 + ac->int_mask |= ACTIVITY | INACTIVITY; 797 + 798 + if (pdata->watermark) { 799 + ac->int_mask |= WATERMARK; 800 + if (!FIFO_MODE(pdata->fifo_mode)) 801 + ac->pdata.fifo_mode |= FIFO_STREAM; 802 + } else { 803 + ac->int_mask |= DATA_READY; 804 + } 805 + 806 + if (pdata->tap_axis_control & (TAP_X_EN | TAP_Y_EN | TAP_Z_EN)) 807 + ac->int_mask |= SINGLE_TAP | DOUBLE_TAP; 808 + 809 + if (FIFO_MODE(pdata->fifo_mode) == FIFO_BYPASS) 810 + ac->fifo_delay = false; 811 + 812 + ac->bops->write(dev, POWER_CTL, 0); 813 + 814 + err = request_threaded_irq(ac->irq, NULL, adxl34x_irq, 815 + IRQF_TRIGGER_HIGH | IRQF_ONESHOT, 816 + dev_name(dev), ac); 817 + if (err) { 818 + dev_err(dev, "irq %d busy?\n", ac->irq); 819 + goto err_free_mem; 820 + } 821 + 822 + err = sysfs_create_group(&dev->kobj, &adxl34x_attr_group); 823 + if (err) 824 + goto err_free_irq; 825 + 826 + err = input_register_device(input_dev); 827 + if (err) 828 + goto err_remove_attr; 829 + 830 + AC_WRITE(ac, THRESH_TAP, pdata->tap_threshold); 831 + AC_WRITE(ac, OFSX, pdata->x_axis_offset); 832 + ac->hwcal.x = pdata->x_axis_offset; 833 + AC_WRITE(ac, OFSY, pdata->y_axis_offset); 834 + ac->hwcal.y = pdata->y_axis_offset; 835 + AC_WRITE(ac, OFSZ, pdata->z_axis_offset); 836 + ac->hwcal.z = pdata->z_axis_offset; 837 + AC_WRITE(ac, THRESH_TAP, pdata->tap_threshold); 838 + AC_WRITE(ac, DUR, pdata->tap_duration); 839 + AC_WRITE(ac, LATENT, pdata->tap_latency); 840 + AC_WRITE(ac, WINDOW, pdata->tap_window); 841 + AC_WRITE(ac, THRESH_ACT, pdata->activity_threshold); 842 + AC_WRITE(ac, THRESH_INACT, pdata->inactivity_threshold); 843 + AC_WRITE(ac, TIME_INACT, pdata->inactivity_time); 844 + AC_WRITE(ac, THRESH_FF, pdata->free_fall_threshold); 845 + AC_WRITE(ac, TIME_FF, pdata->free_fall_time); 846 + AC_WRITE(ac, TAP_AXES, pdata->tap_axis_control); 847 + AC_WRITE(ac, ACT_INACT_CTL, pdata->act_axis_control); 848 + AC_WRITE(ac, BW_RATE, RATE(ac->pdata.data_rate) | 849 + (pdata->low_power_mode ? LOW_POWER : 0)); 850 + AC_WRITE(ac, DATA_FORMAT, pdata->data_range); 851 + AC_WRITE(ac, FIFO_CTL, FIFO_MODE(pdata->fifo_mode) | 852 + SAMPLES(pdata->watermark)); 853 + 854 + if (pdata->use_int2) { 855 + /* Map all INTs to INT2 */ 856 + AC_WRITE(ac, INT_MAP, ac->int_mask | OVERRUN); 857 + } else { 858 + /* Map all INTs to INT1 */ 859 + AC_WRITE(ac, INT_MAP, 0); 860 + } 861 + 862 + if (ac->model == 346 && ac->pdata.orientation_enable) { 863 + AC_WRITE(ac, ORIENT_CONF, 864 + ORIENT_DEADZONE(ac->pdata.deadzone_angle) | 865 + ORIENT_DIVISOR(ac->pdata.divisor_length)); 866 + 867 + ac->orient2d_saved = 1234; 868 + ac->orient3d_saved = 1234; 869 + 870 + if (pdata->orientation_enable & ADXL_EN_ORIENTATION_3D) 871 + for (i = 0; i < ARRAY_SIZE(pdata->ev_codes_orient_3d); i++) 872 + __set_bit(pdata->ev_codes_orient_3d[i], 873 + input_dev->keybit); 874 + 875 + if (pdata->orientation_enable & ADXL_EN_ORIENTATION_2D) 876 + for (i = 0; i < ARRAY_SIZE(pdata->ev_codes_orient_2d); i++) 877 + __set_bit(pdata->ev_codes_orient_2d[i], 878 + input_dev->keybit); 879 + } else { 880 + ac->pdata.orientation_enable = 0; 881 + } 882 + 883 + AC_WRITE(ac, INT_ENABLE, ac->int_mask | OVERRUN); 884 + 885 + ac->pdata.power_mode &= (PCTL_AUTO_SLEEP | PCTL_LINK); 886 + 887 + return ac; 888 + 889 + err_remove_attr: 890 + sysfs_remove_group(&dev->kobj, &adxl34x_attr_group); 891 + err_free_irq: 892 + free_irq(ac->irq, ac); 893 + err_free_mem: 894 + input_free_device(input_dev); 895 + kfree(ac); 896 + err_out: 897 + return ERR_PTR(err); 898 + } 899 + EXPORT_SYMBOL_GPL(adxl34x_probe); 900 + 901 + int adxl34x_remove(struct adxl34x *ac) 902 + { 903 + sysfs_remove_group(&ac->dev->kobj, &adxl34x_attr_group); 904 + free_irq(ac->irq, ac); 905 + input_unregister_device(ac->input); 906 + dev_dbg(ac->dev, "unregistered accelerometer\n"); 907 + kfree(ac); 908 + 909 + return 0; 910 + } 911 + EXPORT_SYMBOL_GPL(adxl34x_remove); 912 + 913 + MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 914 + MODULE_DESCRIPTION("ADXL345/346 Three-Axis Digital Accelerometer Driver"); 915 + MODULE_LICENSE("GPL");
+30
drivers/input/misc/adxl34x.h
···
··· 1 + /* 2 + * ADXL345/346 Three-Axis Digital Accelerometers (I2C/SPI Interface) 3 + * 4 + * Enter bugs at http://blackfin.uclinux.org/ 5 + * 6 + * Copyright (C) 2009 Michael Hennerich, Analog Devices Inc. 7 + * Licensed under the GPL-2 or later. 8 + */ 9 + 10 + #ifndef _ADXL34X_H_ 11 + #define _ADXL34X_H_ 12 + 13 + struct device; 14 + struct adxl34x; 15 + 16 + struct adxl34x_bus_ops { 17 + u16 bustype; 18 + int (*read)(struct device *, unsigned char); 19 + int (*read_block)(struct device *, unsigned char, int, void *); 20 + int (*write)(struct device *, unsigned char, unsigned char); 21 + }; 22 + 23 + void adxl34x_suspend(struct adxl34x *ac); 24 + void adxl34x_resume(struct adxl34x *ac); 25 + struct adxl34x *adxl34x_probe(struct device *dev, int irq, 26 + bool fifo_delay_default, 27 + const struct adxl34x_bus_ops *bops); 28 + int adxl34x_remove(struct adxl34x *ac); 29 + 30 + #endif
+15 -23
drivers/input/misc/atlas_btns.c
··· 21 * 22 */ 23 24 #include <linux/kernel.h> 25 #include <linux/module.h> 26 #include <linux/init.h> ··· 62 input_report_key(input_dev, atlas_keymap[code], key_down); 63 input_sync(input_dev); 64 65 - status = 0; 66 } else { 67 - printk(KERN_WARNING "atlas: shrugged on unexpected function" 68 - ":function=%x,address=%lx,value=%x\n", 69 function, (unsigned long)address, (u32)*value); 70 - status = -EINVAL; 71 } 72 73 return status; ··· 80 81 input_dev = input_allocate_device(); 82 if (!input_dev) { 83 - printk(KERN_ERR "atlas: unable to allocate input device\n"); 84 return -ENOMEM; 85 } 86 ··· 103 104 err = input_register_device(input_dev); 105 if (err) { 106 - printk(KERN_ERR "atlas: couldn't register input device\n"); 107 input_free_device(input_dev); 108 return err; 109 } ··· 113 0x81, &acpi_atlas_button_handler, 114 &acpi_atlas_button_setup, device); 115 if (ACPI_FAILURE(status)) { 116 - printk(KERN_ERR "Atlas: Error installing addr spc handler\n"); 117 input_unregister_device(input_dev); 118 - status = -EINVAL; 119 } 120 121 - return status; 122 } 123 124 static int atlas_acpi_button_remove(struct acpi_device *device, int type) ··· 127 128 status = acpi_remove_address_space_handler(device->handle, 129 0x81, &acpi_atlas_button_handler); 130 - if (ACPI_FAILURE(status)) { 131 - printk(KERN_ERR "Atlas: Error removing addr spc handler\n"); 132 - status = -EINVAL; 133 - } 134 135 input_unregister_device(input_dev); 136 137 - return status; 138 } 139 140 static const struct acpi_device_id atlas_device_ids[] = { ··· 144 static struct acpi_driver atlas_acpi_driver = { 145 .name = ACPI_ATLAS_NAME, 146 .class = ACPI_ATLAS_CLASS, 147 .ids = atlas_device_ids, 148 .ops = { 149 .add = atlas_acpi_button_add, ··· 154 155 static int __init atlas_acpi_init(void) 156 { 157 - int result; 158 - 159 if (acpi_disabled) 160 return -ENODEV; 161 162 - result = acpi_bus_register_driver(&atlas_acpi_driver); 163 - if (result < 0) { 164 - printk(KERN_ERR "Atlas ACPI: Unable to register driver\n"); 165 - return -ENODEV; 166 - } 167 - 168 - return 0; 169 } 170 171 static void __exit atlas_acpi_exit(void)
··· 21 * 22 */ 23 24 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 25 + 26 #include <linux/kernel.h> 27 #include <linux/module.h> 28 #include <linux/init.h> ··· 60 input_report_key(input_dev, atlas_keymap[code], key_down); 61 input_sync(input_dev); 62 63 + status = AE_OK; 64 } else { 65 + pr_warn("shrugged on unexpected function: function=%x,address=%lx,value=%x\n", 66 function, (unsigned long)address, (u32)*value); 67 + status = AE_BAD_PARAMETER; 68 } 69 70 return status; ··· 79 80 input_dev = input_allocate_device(); 81 if (!input_dev) { 82 + pr_err("unable to allocate input device\n"); 83 return -ENOMEM; 84 } 85 ··· 102 103 err = input_register_device(input_dev); 104 if (err) { 105 + pr_err("couldn't register input device\n"); 106 input_free_device(input_dev); 107 return err; 108 } ··· 112 0x81, &acpi_atlas_button_handler, 113 &acpi_atlas_button_setup, device); 114 if (ACPI_FAILURE(status)) { 115 + pr_err("error installing addr spc handler\n"); 116 input_unregister_device(input_dev); 117 + err = -EINVAL; 118 } 119 120 + return err; 121 } 122 123 static int atlas_acpi_button_remove(struct acpi_device *device, int type) ··· 126 127 status = acpi_remove_address_space_handler(device->handle, 128 0x81, &acpi_atlas_button_handler); 129 + if (ACPI_FAILURE(status)) 130 + pr_err("error removing addr spc handler\n"); 131 132 input_unregister_device(input_dev); 133 134 + return 0; 135 } 136 137 static const struct acpi_device_id atlas_device_ids[] = { ··· 145 static struct acpi_driver atlas_acpi_driver = { 146 .name = ACPI_ATLAS_NAME, 147 .class = ACPI_ATLAS_CLASS, 148 + .owner = THIS_MODULE, 149 .ids = atlas_device_ids, 150 .ops = { 151 .add = atlas_acpi_button_add, ··· 154 155 static int __init atlas_acpi_init(void) 156 { 157 if (acpi_disabled) 158 return -ENODEV; 159 160 + return acpi_bus_register_driver(&atlas_acpi_driver); 161 } 162 163 static void __exit atlas_acpi_exit(void)
+199
drivers/input/misc/pwm-beeper.c
···
··· 1 + /* 2 + * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> 3 + * PWM beeper driver 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License as published by the 7 + * Free Software Foundation; either version 2 of the License, or (at your 8 + * option) any later version. 9 + * 10 + * You should have received a copy of the GNU General Public License along 11 + * with this program; if not, write to the Free Software Foundation, Inc., 12 + * 675 Mass Ave, Cambridge, MA 02139, USA. 13 + * 14 + */ 15 + 16 + #include <linux/input.h> 17 + #include <linux/module.h> 18 + #include <linux/kernel.h> 19 + #include <linux/platform_device.h> 20 + #include <linux/pwm.h> 21 + #include <linux/slab.h> 22 + 23 + struct pwm_beeper { 24 + struct input_dev *input; 25 + struct pwm_device *pwm; 26 + unsigned long period; 27 + }; 28 + 29 + #define HZ_TO_NANOSECONDS(x) (1000000000UL/(x)) 30 + 31 + static int pwm_beeper_event(struct input_dev *input, 32 + unsigned int type, unsigned int code, int value) 33 + { 34 + int ret = 0; 35 + struct pwm_beeper *beeper = input_get_drvdata(input); 36 + unsigned long period; 37 + 38 + if (type != EV_SND || value < 0) 39 + return -EINVAL; 40 + 41 + switch (code) { 42 + case SND_BELL: 43 + value = value ? 1000 : 0; 44 + break; 45 + case SND_TONE: 46 + break; 47 + default: 48 + return -EINVAL; 49 + } 50 + 51 + if (value == 0) { 52 + pwm_config(beeper->pwm, 0, 0); 53 + pwm_disable(beeper->pwm); 54 + } else { 55 + period = HZ_TO_NANOSECONDS(value); 56 + ret = pwm_config(beeper->pwm, period / 2, period); 57 + if (ret) 58 + return ret; 59 + ret = pwm_enable(beeper->pwm); 60 + if (ret) 61 + return ret; 62 + beeper->period = period; 63 + } 64 + 65 + return 0; 66 + } 67 + 68 + static int __devinit pwm_beeper_probe(struct platform_device *pdev) 69 + { 70 + unsigned long pwm_id = (unsigned long)pdev->dev.platform_data; 71 + struct pwm_beeper *beeper; 72 + int error; 73 + 74 + beeper = kzalloc(sizeof(*beeper), GFP_KERNEL); 75 + if (!beeper) 76 + return -ENOMEM; 77 + 78 + beeper->pwm = pwm_request(pwm_id, "pwm beeper"); 79 + 80 + if (IS_ERR(beeper->pwm)) { 81 + error = PTR_ERR(beeper->pwm); 82 + dev_err(&pdev->dev, "Failed to request pwm device: %d\n", error); 83 + goto err_free; 84 + } 85 + 86 + beeper->input = input_allocate_device(); 87 + if (!beeper->input) { 88 + dev_err(&pdev->dev, "Failed to allocate input device\n"); 89 + error = -ENOMEM; 90 + goto err_pwm_free; 91 + } 92 + beeper->input->dev.parent = &pdev->dev; 93 + 94 + beeper->input->name = "pwm-beeper"; 95 + beeper->input->phys = "pwm/input0"; 96 + beeper->input->id.bustype = BUS_HOST; 97 + beeper->input->id.vendor = 0x001f; 98 + beeper->input->id.product = 0x0001; 99 + beeper->input->id.version = 0x0100; 100 + 101 + beeper->input->evbit[0] = BIT(EV_SND); 102 + beeper->input->sndbit[0] = BIT(SND_TONE) | BIT(SND_BELL); 103 + 104 + beeper->input->event = pwm_beeper_event; 105 + 106 + input_set_drvdata(beeper->input, beeper); 107 + 108 + error = input_register_device(beeper->input); 109 + if (error) { 110 + dev_err(&pdev->dev, "Failed to register input device: %d\n", error); 111 + goto err_input_free; 112 + } 113 + 114 + platform_set_drvdata(pdev, beeper); 115 + 116 + return 0; 117 + 118 + err_input_free: 119 + input_free_device(beeper->input); 120 + err_pwm_free: 121 + pwm_free(beeper->pwm); 122 + err_free: 123 + kfree(beeper); 124 + 125 + return error; 126 + } 127 + 128 + static int __devexit pwm_beeper_remove(struct platform_device *pdev) 129 + { 130 + struct pwm_beeper *beeper = platform_get_drvdata(pdev); 131 + 132 + platform_set_drvdata(pdev, NULL); 133 + input_unregister_device(beeper->input); 134 + 135 + pwm_disable(beeper->pwm); 136 + pwm_free(beeper->pwm); 137 + 138 + kfree(beeper); 139 + 140 + return 0; 141 + } 142 + 143 + #ifdef CONFIG_PM 144 + static int pwm_beeper_suspend(struct device *dev) 145 + { 146 + struct pwm_beeper *beeper = dev_get_drvdata(dev); 147 + 148 + if (beeper->period) 149 + pwm_disable(beeper->pwm); 150 + 151 + return 0; 152 + } 153 + 154 + static int pwm_beeper_resume(struct device *dev) 155 + { 156 + struct pwm_beeper *beeper = dev_get_drvdata(dev); 157 + 158 + if (beeper->period) { 159 + pwm_config(beeper->pwm, beeper->period / 2, beeper->period); 160 + pwm_enable(beeper->pwm); 161 + } 162 + 163 + return 0; 164 + } 165 + 166 + static SIMPLE_DEV_PM_OPS(pwm_beeper_pm_ops, 167 + pwm_beeper_suspend, pwm_beeper_resume); 168 + 169 + #define PWM_BEEPER_PM_OPS (&pwm_beeper_pm_ops) 170 + #else 171 + #define PWM_BEEPER_PM_OPS NULL 172 + #endif 173 + 174 + static struct platform_driver pwm_beeper_driver = { 175 + .probe = pwm_beeper_probe, 176 + .remove = __devexit_p(pwm_beeper_remove), 177 + .driver = { 178 + .name = "pwm-beeper", 179 + .owner = THIS_MODULE, 180 + .pm = PWM_BEEPER_PM_OPS, 181 + }, 182 + }; 183 + 184 + static int __init pwm_beeper_init(void) 185 + { 186 + return platform_driver_register(&pwm_beeper_driver); 187 + } 188 + module_init(pwm_beeper_init); 189 + 190 + static void __exit pwm_beeper_exit(void) 191 + { 192 + platform_driver_unregister(&pwm_beeper_driver); 193 + } 194 + module_exit(pwm_beeper_exit); 195 + 196 + MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); 197 + MODULE_DESCRIPTION("PWM beeper driver"); 198 + MODULE_LICENSE("GPL"); 199 + MODULE_ALIAS("platform:pwm-beeper");
+6 -6
drivers/input/misc/twl4030-pwrbutton.c
··· 52 return IRQ_HANDLED; 53 } 54 55 - static int __devinit twl4030_pwrbutton_probe(struct platform_device *pdev) 56 { 57 struct input_dev *pwr; 58 int irq = platform_get_irq(pdev, 0); ··· 95 return err; 96 } 97 98 - static int __devexit twl4030_pwrbutton_remove(struct platform_device *pdev) 99 { 100 struct input_dev *pwr = platform_get_drvdata(pdev); 101 int irq = platform_get_irq(pdev, 0); ··· 106 return 0; 107 } 108 109 - struct platform_driver twl4030_pwrbutton_driver = { 110 - .probe = twl4030_pwrbutton_probe, 111 - .remove = __devexit_p(twl4030_pwrbutton_remove), 112 .driver = { 113 .name = "twl4030_pwrbutton", 114 .owner = THIS_MODULE, ··· 116 117 static int __init twl4030_pwrbutton_init(void) 118 { 119 - return platform_driver_register(&twl4030_pwrbutton_driver); 120 } 121 module_init(twl4030_pwrbutton_init); 122
··· 52 return IRQ_HANDLED; 53 } 54 55 + static int __init twl4030_pwrbutton_probe(struct platform_device *pdev) 56 { 57 struct input_dev *pwr; 58 int irq = platform_get_irq(pdev, 0); ··· 95 return err; 96 } 97 98 + static int __exit twl4030_pwrbutton_remove(struct platform_device *pdev) 99 { 100 struct input_dev *pwr = platform_get_drvdata(pdev); 101 int irq = platform_get_irq(pdev, 0); ··· 106 return 0; 107 } 108 109 + static struct platform_driver twl4030_pwrbutton_driver = { 110 + .remove = __exit_p(twl4030_pwrbutton_remove), 111 .driver = { 112 .name = "twl4030_pwrbutton", 113 .owner = THIS_MODULE, ··· 117 118 static int __init twl4030_pwrbutton_init(void) 119 { 120 + return platform_driver_probe(&twl4030_pwrbutton_driver, 121 + twl4030_pwrbutton_probe); 122 } 123 module_init(twl4030_pwrbutton_init); 124
+3 -1
drivers/input/misc/wistron_btns.c
··· 1347 1348 err = map_bios(); 1349 if (err) 1350 - return err; 1351 1352 err = platform_driver_register(&wistron_driver); 1353 if (err) ··· 1371 platform_driver_unregister(&wistron_driver); 1372 err_unmap_bios: 1373 unmap_bios(); 1374 1375 return err; 1376 }
··· 1347 1348 err = map_bios(); 1349 if (err) 1350 + goto err_free_keymap; 1351 1352 err = platform_driver_register(&wistron_driver); 1353 if (err) ··· 1371 platform_driver_unregister(&wistron_driver); 1372 err_unmap_bios: 1373 unmap_bios(); 1374 + err_free_keymap: 1375 + kfree(keymap); 1376 1377 return err; 1378 }
+16 -7
drivers/input/mouse/bcm5974.c
··· 312 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); 313 __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); 314 __set_bit(BTN_LEFT, input_dev->keybit); 315 } 316 317 /* report button data as logical button state */ ··· 582 */ 583 static int bcm5974_start_traffic(struct bcm5974 *dev) 584 { 585 - if (bcm5974_wellspring_mode(dev, true)) { 586 dprintk(1, "bcm5974: mode switch failed\n"); 587 - goto error; 588 } 589 590 - if (usb_submit_urb(dev->bt_urb, GFP_KERNEL)) 591 - goto error; 592 593 - if (usb_submit_urb(dev->tp_urb, GFP_KERNEL)) 594 goto err_kill_bt; 595 596 return 0; 597 598 err_kill_bt: 599 usb_kill_urb(dev->bt_urb); 600 - error: 601 - return -EIO; 602 } 603 604 static void bcm5974_pause_traffic(struct bcm5974 *dev)
··· 312 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); 313 __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); 314 __set_bit(BTN_LEFT, input_dev->keybit); 315 + 316 + input_set_events_per_packet(input_dev, 60); 317 } 318 319 /* report button data as logical button state */ ··· 580 */ 581 static int bcm5974_start_traffic(struct bcm5974 *dev) 582 { 583 + int error; 584 + 585 + error = bcm5974_wellspring_mode(dev, true); 586 + if (error) { 587 dprintk(1, "bcm5974: mode switch failed\n"); 588 + goto err_out; 589 } 590 591 + error = usb_submit_urb(dev->bt_urb, GFP_KERNEL); 592 + if (error) 593 + goto err_reset_mode; 594 595 + error = usb_submit_urb(dev->tp_urb, GFP_KERNEL); 596 + if (error) 597 goto err_kill_bt; 598 599 return 0; 600 601 err_kill_bt: 602 usb_kill_urb(dev->bt_urb); 603 + err_reset_mode: 604 + bcm5974_wellspring_mode(dev, false); 605 + err_out: 606 + return error; 607 } 608 609 static void bcm5974_pause_traffic(struct bcm5974 *dev)
+6 -2
drivers/input/mouse/synaptics.c
··· 502 } 503 input_report_abs(dev, ABS_PRESSURE, hw.z); 504 505 - input_report_abs(dev, ABS_TOOL_WIDTH, finger_width); 506 input_report_key(dev, BTN_TOOL_FINGER, num_fingers == 1); 507 input_report_key(dev, BTN_LEFT, hw.left); 508 input_report_key(dev, BTN_RIGHT, hw.right); ··· 604 input_set_abs_params(dev, ABS_Y, 605 YMIN_NOMINAL, priv->y_max ?: YMAX_NOMINAL, 0, 0); 606 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); 607 - __set_bit(ABS_TOOL_WIDTH, dev->absbit); 608 609 __set_bit(EV_KEY, dev->evbit); 610 __set_bit(BTN_TOUCH, dev->keybit);
··· 502 } 503 input_report_abs(dev, ABS_PRESSURE, hw.z); 504 505 + if (SYN_CAP_PALMDETECT(priv->capabilities)) 506 + input_report_abs(dev, ABS_TOOL_WIDTH, finger_width); 507 + 508 input_report_key(dev, BTN_TOOL_FINGER, num_fingers == 1); 509 input_report_key(dev, BTN_LEFT, hw.left); 510 input_report_key(dev, BTN_RIGHT, hw.right); ··· 602 input_set_abs_params(dev, ABS_Y, 603 YMIN_NOMINAL, priv->y_max ?: YMAX_NOMINAL, 0, 0); 604 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); 605 + 606 + if (SYN_CAP_PALMDETECT(priv->capabilities)) 607 + input_set_abs_params(dev, ABS_TOOL_WIDTH, 0, 15, 0, 0); 608 609 __set_bit(EV_KEY, dev->evbit); 610 __set_bit(BTN_TOUCH, dev->keybit);
+10 -5
drivers/input/mousedev.c
··· 57 }; 58 59 struct mousedev { 60 - int exist; 61 int open; 62 int minor; 63 struct input_handle handle; ··· 65 spinlock_t client_lock; /* protects client_list */ 66 struct mutex mutex; 67 struct device dev; 68 69 struct list_head mixdev_node; 70 int mixdev_open; ··· 765 { 766 struct mousedev_client *client = file->private_data; 767 struct mousedev *mousedev = client->mousedev; 768 769 poll_wait(file, &mousedev->wait, wait); 770 - return ((client->ready || client->buffer) ? (POLLIN | POLLRDNORM) : 0) | 771 - (mousedev->exist ? 0 : (POLLHUP | POLLERR)); 772 } 773 774 static const struct file_operations mousedev_fops = { ··· 807 static void mousedev_mark_dead(struct mousedev *mousedev) 808 { 809 mutex_lock(&mousedev->mutex); 810 - mousedev->exist = 0; 811 mutex_unlock(&mousedev->mutex); 812 } 813 ··· 867 dev_set_name(&mousedev->dev, "mouse%d", minor); 868 869 mousedev->minor = minor; 870 - mousedev->exist = 1; 871 mousedev->handle.dev = input_get_device(dev); 872 mousedev->handle.name = dev_name(&mousedev->dev); 873 mousedev->handle.handler = handler;
··· 57 }; 58 59 struct mousedev { 60 int open; 61 int minor; 62 struct input_handle handle; ··· 66 spinlock_t client_lock; /* protects client_list */ 67 struct mutex mutex; 68 struct device dev; 69 + bool exist; 70 71 struct list_head mixdev_node; 72 int mixdev_open; ··· 765 { 766 struct mousedev_client *client = file->private_data; 767 struct mousedev *mousedev = client->mousedev; 768 + unsigned int mask; 769 770 poll_wait(file, &mousedev->wait, wait); 771 + 772 + mask = mousedev->exist ? POLLOUT | POLLWRNORM : POLLHUP | POLLERR; 773 + if (client->ready || client->buffer) 774 + mask |= POLLIN | POLLRDNORM; 775 + 776 + return mask; 777 } 778 779 static const struct file_operations mousedev_fops = { ··· 802 static void mousedev_mark_dead(struct mousedev *mousedev) 803 { 804 mutex_lock(&mousedev->mutex); 805 + mousedev->exist = false; 806 mutex_unlock(&mousedev->mutex); 807 } 808 ··· 862 dev_set_name(&mousedev->dev, "mouse%d", minor); 863 864 mousedev->minor = minor; 865 + mousedev->exist = true; 866 mousedev->handle.dev = input_get_device(dev); 867 mousedev->handle.name = dev_name(&mousedev->dev); 868 mousedev->handle.handler = handler;
-75
drivers/input/serio/i8042-ppcio.h
··· 52 { 53 } 54 55 - #elif defined(CONFIG_SPRUCE) 56 - 57 - #define I8042_KBD_IRQ 22 58 - #define I8042_AUX_IRQ 21 59 - 60 - #define I8042_KBD_PHYS_DESC "spruceps2/serio0" 61 - #define I8042_AUX_PHYS_DESC "spruceps2/serio1" 62 - #define I8042_MUX_PHYS_DESC "spruceps2/serio%d" 63 - 64 - #define I8042_COMMAND_REG 0xff810000 65 - #define I8042_DATA_REG 0xff810001 66 - 67 - static inline int i8042_read_data(void) 68 - { 69 - unsigned long kbd_data; 70 - 71 - __raw_writel(0x00000088, 0xff500008); 72 - eieio(); 73 - 74 - __raw_writel(0x03000000, 0xff50000c); 75 - eieio(); 76 - 77 - asm volatile("lis 7,0xff88 \n\ 78 - lswi 6,7,0x8 \n\ 79 - mr %0,6" 80 - : "=r" (kbd_data) :: "6", "7"); 81 - 82 - __raw_writel(0x00000000, 0xff50000c); 83 - eieio(); 84 - 85 - return (unsigned char)(kbd_data >> 24); 86 - } 87 - 88 - static inline int i8042_read_status(void) 89 - { 90 - unsigned long kbd_status; 91 - 92 - __raw_writel(0x00000088, 0xff500008); 93 - eieio(); 94 - 95 - __raw_writel(0x03000000, 0xff50000c); 96 - eieio(); 97 - 98 - asm volatile("lis 7,0xff88 \n\ 99 - ori 7,7,0x8 \n\ 100 - lswi 6,7,0x8 \n\ 101 - mr %0,6" 102 - : "=r" (kbd_status) :: "6", "7"); 103 - 104 - __raw_writel(0x00000000, 0xff50000c); 105 - eieio(); 106 - 107 - return (unsigned char)(kbd_status >> 24); 108 - } 109 - 110 - static inline void i8042_write_data(int val) 111 - { 112 - *((unsigned char *)0xff810000) = (char)val; 113 - } 114 - 115 - static inline void i8042_write_command(int val) 116 - { 117 - *((unsigned char *)0xff810001) = (char)val; 118 - } 119 - 120 - static inline int i8042_platform_init(void) 121 - { 122 - i8042_reset = 1; 123 - return 0; 124 - } 125 - 126 - static inline void i8042_platform_exit(void) 127 - { 128 - } 129 - 130 #else 131 132 #include "i8042-io.h"
··· 52 { 53 } 54 55 #else 56 57 #include "i8042-io.h"
+41 -24
drivers/input/serio/i8042.c
··· 861 unsigned char param; 862 int i = 0; 863 864 - if (!i8042_reset) 865 - return 0; 866 - 867 /* 868 * We try this 5 times; on some really fragile systems this does not 869 * take the first time... ··· 1017 * Reset the controller if requested. 1018 */ 1019 1020 - i8042_controller_selftest(); 1021 1022 /* 1023 * Restore the original control register setting. ··· 1092 #ifdef CONFIG_PM 1093 1094 /* 1095 - * Here we try to restore the original BIOS settings to avoid 1096 - * upsetting it. 1097 - */ 1098 - 1099 - static int i8042_pm_reset(struct device *dev) 1100 - { 1101 - i8042_controller_reset(); 1102 - 1103 - return 0; 1104 - } 1105 - 1106 - /* 1107 * Here we try to reset everything back to a state we had 1108 * before suspending. 1109 */ 1110 1111 - static int i8042_pm_restore(struct device *dev) 1112 { 1113 int error; 1114 ··· 1104 if (error) 1105 return error; 1106 1107 - error = i8042_controller_selftest(); 1108 - if (error) 1109 - return error; 1110 1111 /* 1112 * Restore original CTR value and disable all ports ··· 1150 return 0; 1151 } 1152 1153 static int i8042_pm_thaw(struct device *dev) 1154 { 1155 i8042_interrupt(0, NULL); ··· 1179 return 0; 1180 } 1181 1182 static const struct dev_pm_ops i8042_pm_ops = { 1183 .suspend = i8042_pm_reset, 1184 - .resume = i8042_pm_restore, 1185 .thaw = i8042_pm_thaw, 1186 .poweroff = i8042_pm_reset, 1187 .restore = i8042_pm_restore, ··· 1404 1405 i8042_platform_device = dev; 1406 1407 - error = i8042_controller_selftest(); 1408 - if (error) 1409 - return error; 1410 1411 error = i8042_controller_init(); 1412 if (error)
··· 861 unsigned char param; 862 int i = 0; 863 864 /* 865 * We try this 5 times; on some really fragile systems this does not 866 * take the first time... ··· 1020 * Reset the controller if requested. 1021 */ 1022 1023 + if (i8042_reset) 1024 + i8042_controller_selftest(); 1025 1026 /* 1027 * Restore the original control register setting. ··· 1094 #ifdef CONFIG_PM 1095 1096 /* 1097 * Here we try to reset everything back to a state we had 1098 * before suspending. 1099 */ 1100 1101 + static int i8042_controller_resume(bool force_reset) 1102 { 1103 int error; 1104 ··· 1118 if (error) 1119 return error; 1120 1121 + if (i8042_reset || force_reset) { 1122 + error = i8042_controller_selftest(); 1123 + if (error) 1124 + return error; 1125 + } 1126 1127 /* 1128 * Restore original CTR value and disable all ports ··· 1162 return 0; 1163 } 1164 1165 + /* 1166 + * Here we try to restore the original BIOS settings to avoid 1167 + * upsetting it. 1168 + */ 1169 + 1170 + static int i8042_pm_reset(struct device *dev) 1171 + { 1172 + i8042_controller_reset(); 1173 + 1174 + return 0; 1175 + } 1176 + 1177 + static int i8042_pm_resume(struct device *dev) 1178 + { 1179 + /* 1180 + * On resume from S2R we always try to reset the controller 1181 + * to bring it in a sane state. (In case of S2D we expect 1182 + * BIOS to reset the controller for us.) 1183 + */ 1184 + return i8042_controller_resume(true); 1185 + } 1186 + 1187 static int i8042_pm_thaw(struct device *dev) 1188 { 1189 i8042_interrupt(0, NULL); ··· 1169 return 0; 1170 } 1171 1172 + static int i8042_pm_restore(struct device *dev) 1173 + { 1174 + return i8042_controller_resume(false); 1175 + } 1176 + 1177 static const struct dev_pm_ops i8042_pm_ops = { 1178 .suspend = i8042_pm_reset, 1179 + .resume = i8042_pm_resume, 1180 .thaw = i8042_pm_thaw, 1181 .poweroff = i8042_pm_reset, 1182 .restore = i8042_pm_restore, ··· 1389 1390 i8042_platform_device = dev; 1391 1392 + if (i8042_reset) { 1393 + error = i8042_controller_selftest(); 1394 + if (error) 1395 + return error; 1396 + } 1397 1398 error = i8042_controller_init(); 1399 if (error)
+44
drivers/input/tablet/wacom_wac.c
··· 158 return 1; 159 } 160 161 static int wacom_graphire_irq(struct wacom_wac *wacom) 162 { 163 struct wacom_features *features = &wacom->features; ··· 878 sync = wacom_ptu_irq(wacom_wac); 879 break; 880 881 case INTUOS: 882 case INTUOS3S: 883 case INTUOS3: ··· 1067 1068 case PL: 1069 case PTU: 1070 __set_bit(BTN_TOOL_PEN, input_dev->keybit); 1071 __set_bit(BTN_STYLUS, input_dev->keybit); 1072 __set_bit(BTN_STYLUS2, input_dev->keybit); ··· 1193 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE }; 1194 static const struct wacom_features wacom_features_0xC7 = 1195 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL }; 1196 static const struct wacom_features wacom_features_0xCC = 1197 { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047, 63, WACOM_21UX2 }; 1198 static const struct wacom_features wacom_features_0x90 = ··· 1276 { USB_DEVICE_WACOM(0xC5) }, 1277 { USB_DEVICE_WACOM(0xC6) }, 1278 { USB_DEVICE_WACOM(0xC7) }, 1279 { USB_DEVICE_WACOM(0xCC) }, 1280 { USB_DEVICE_WACOM(0x90) }, 1281 { USB_DEVICE_WACOM(0x93) },
··· 158 return 1; 159 } 160 161 + static int wacom_dtu_irq(struct wacom_wac *wacom) 162 + { 163 + struct wacom_features *features = &wacom->features; 164 + char *data = wacom->data; 165 + struct input_dev *input = wacom->input; 166 + int prox = data[1] & 0x20, pressure; 167 + 168 + dbg("wacom_dtu_irq: received report #%d", data[0]); 169 + 170 + if (prox) { 171 + /* Going into proximity select tool */ 172 + wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; 173 + if (wacom->tool[0] == BTN_TOOL_PEN) 174 + wacom->id[0] = STYLUS_DEVICE_ID; 175 + else 176 + wacom->id[0] = ERASER_DEVICE_ID; 177 + } 178 + input_report_key(input, BTN_STYLUS, data[1] & 0x02); 179 + input_report_key(input, BTN_STYLUS2, data[1] & 0x10); 180 + input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); 181 + input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); 182 + pressure = ((data[7] & 0x01) << 8) | data[6]; 183 + if (pressure < 0) 184 + pressure = features->pressure_max + pressure + 1; 185 + input_report_abs(input, ABS_PRESSURE, pressure); 186 + input_report_key(input, BTN_TOUCH, data[1] & 0x05); 187 + if (!prox) /* out-prox */ 188 + wacom->id[0] = 0; 189 + input_report_key(input, wacom->tool[0], prox); 190 + input_report_abs(input, ABS_MISC, wacom->id[0]); 191 + return 1; 192 + } 193 + 194 static int wacom_graphire_irq(struct wacom_wac *wacom) 195 { 196 struct wacom_features *features = &wacom->features; ··· 845 sync = wacom_ptu_irq(wacom_wac); 846 break; 847 848 + case DTU: 849 + sync = wacom_dtu_irq(wacom_wac); 850 + break; 851 + 852 case INTUOS: 853 case INTUOS3S: 854 case INTUOS3: ··· 1030 1031 case PL: 1032 case PTU: 1033 + case DTU: 1034 __set_bit(BTN_TOOL_PEN, input_dev->keybit); 1035 __set_bit(BTN_STYLUS, input_dev->keybit); 1036 __set_bit(BTN_STYLUS2, input_dev->keybit); ··· 1155 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE }; 1156 static const struct wacom_features wacom_features_0xC7 = 1157 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL }; 1158 + static const struct wacom_features wacom_features_0xCE = 1159 + { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511, 0, DTU }; 1160 + static const struct wacom_features wacom_features_0xF0 = 1161 + { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511, 0, DTU }; 1162 static const struct wacom_features wacom_features_0xCC = 1163 { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047, 63, WACOM_21UX2 }; 1164 static const struct wacom_features wacom_features_0x90 = ··· 1234 { USB_DEVICE_WACOM(0xC5) }, 1235 { USB_DEVICE_WACOM(0xC6) }, 1236 { USB_DEVICE_WACOM(0xC7) }, 1237 + { USB_DEVICE_WACOM(0xCE) }, 1238 + { USB_DEVICE_WACOM(0xF0) }, 1239 { USB_DEVICE_WACOM(0xCC) }, 1240 { USB_DEVICE_WACOM(0x90) }, 1241 { USB_DEVICE_WACOM(0x93) },
+1
drivers/input/tablet/wacom_wac.h
··· 43 WACOM_G4, 44 PTU, 45 PL, 46 INTUOS, 47 INTUOS3S, 48 INTUOS3,
··· 43 WACOM_G4, 44 PTU, 45 PL, 46 + DTU, 47 INTUOS, 48 INTUOS3S, 49 INTUOS3,
+46 -21
drivers/input/touchscreen/Kconfig
··· 55 To compile this driver as a module, choose M here: the 56 module will be called ad7877. 57 58 - config TOUCHSCREEN_AD7879_I2C 59 - tristate "AD7879 based touchscreens: AD7879-1 I2C Interface" 60 - depends on I2C 61 - select TOUCHSCREEN_AD7879 62 help 63 - Say Y here if you have a touchscreen interface using the 64 - AD7879-1/AD7889-1 controller, and your board-specific 65 - initialization code includes that in its table of I2C devices. 66 67 - If unsure, say N (but it's safe to say "Y"). 68 69 To compile this driver as a module, choose M here: the 70 module will be called ad7879. 71 72 config TOUCHSCREEN_AD7879_SPI 73 - tristate "AD7879 based touchscreens: AD7879 SPI Interface" 74 - depends on SPI_MASTER && TOUCHSCREEN_AD7879_I2C = n 75 - select TOUCHSCREEN_AD7879 76 help 77 - Say Y here if you have a touchscreen interface using the 78 - AD7879/AD7889 controller, and your board-specific initialization 79 - code includes that in its table of SPI devices. 80 81 If unsure, say N (but it's safe to say "Y"). 82 83 To compile this driver as a module, choose M here: the 84 - module will be called ad7879. 85 - 86 - config TOUCHSCREEN_AD7879 87 - tristate 88 - default n 89 90 config TOUCHSCREEN_BITSY 91 tristate "Compaq iPAQ H3600 (Bitsy) touchscreen" ··· 97 98 To compile this driver as a module, choose M here: the 99 module will be called h3600_ts_input. 100 101 config TOUCHSCREEN_DA9034 102 tristate "Touchscreen support for Dialog Semiconductor DA9034" ··· 304 305 To compile this driver as a module, choose M here: the 306 module will be called penmount. 307 308 config TOUCHSCREEN_MIGOR 309 tristate "Renesas MIGO-R touchscreen" ··· 565 bool "Zytronic controller" if EMBEDDED 566 depends on TOUCHSCREEN_USB_COMPOSITE 567 568 - config TOUCHSCREEN_USB_ETT_TC5UH 569 default y 570 - bool "ET&T TC5UH touchscreen controler support" if EMBEDDED 571 depends on TOUCHSCREEN_USB_COMPOSITE 572 573 config TOUCHSCREEN_USB_NEXIO
··· 55 To compile this driver as a module, choose M here: the 56 module will be called ad7877. 57 58 + config TOUCHSCREEN_AD7879 59 + tristate "Analog Devices AD7879-1/AD7889-1 touchscreen interface" 60 help 61 + Say Y here if you want to support a touchscreen interface using 62 + the AD7879-1/AD7889-1 controller. 63 64 + You should select a bus connection too. 65 66 To compile this driver as a module, choose M here: the 67 module will be called ad7879. 68 + 69 + config TOUCHSCREEN_AD7879_I2C 70 + tristate "support I2C bus connection" 71 + depends on TOUCHSCREEN_AD7879 && I2C 72 + help 73 + Say Y here if you have AD7879-1/AD7889-1 hooked to an I2C bus. 74 + 75 + To compile this driver as a module, choose M here: the 76 + module will be called ad7879-i2c. 77 78 config TOUCHSCREEN_AD7879_SPI 79 + tristate "support SPI bus connection" 80 + depends on TOUCHSCREEN_AD7879 && SPI_MASTER 81 help 82 + Say Y here if you have AD7879-1/AD7889-1 hooked to a SPI bus. 83 84 If unsure, say N (but it's safe to say "Y"). 85 86 To compile this driver as a module, choose M here: the 87 + module will be called ad7879-spi. 88 89 config TOUCHSCREEN_BITSY 90 tristate "Compaq iPAQ H3600 (Bitsy) touchscreen" ··· 98 99 To compile this driver as a module, choose M here: the 100 module will be called h3600_ts_input. 101 + 102 + config TOUCHSCREEN_CY8CTMG110 103 + tristate "cy8ctmg110 touchscreen" 104 + depends on I2C 105 + depends on GPIOLIB 106 + 107 + help 108 + Say Y here if you have a cy8ctmg110 capacitive touchscreen on 109 + an AAVA device. 110 + 111 + If unsure, say N. 112 + 113 + To compile this driver as a module, choose M here: the 114 + module will be called cy8ctmg110_ts. 115 116 config TOUCHSCREEN_DA9034 117 tristate "Touchscreen support for Dialog Semiconductor DA9034" ··· 291 292 To compile this driver as a module, choose M here: the 293 module will be called penmount. 294 + 295 + config TOUCHSCREEN_QT602240 296 + tristate "QT602240 I2C Touchscreen" 297 + depends on I2C 298 + help 299 + Say Y here if you have the AT42QT602240/ATMXT224 I2C touchscreen 300 + connected to your system. 301 + 302 + If unsure, say N. 303 + 304 + To compile this driver as a module, choose M here: the 305 + module will be called qt602240_ts. 306 307 config TOUCHSCREEN_MIGOR 308 tristate "Renesas MIGO-R touchscreen" ··· 540 bool "Zytronic controller" if EMBEDDED 541 depends on TOUCHSCREEN_USB_COMPOSITE 542 543 + config TOUCHSCREEN_USB_ETT_TC45USB 544 default y 545 + bool "ET&T USB series TC4UM/TC5UH touchscreen controler support" if EMBEDDED 546 depends on TOUCHSCREEN_USB_COMPOSITE 547 548 config TOUCHSCREEN_USB_NEXIO
+5 -1
drivers/input/touchscreen/Makefile
··· 9 obj-$(CONFIG_TOUCHSCREEN_88PM860X) += 88pm860x-ts.o 10 obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o 11 obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o 12 obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o 13 obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o 14 obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o 15 obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o 16 obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE) += hampshire.o 17 obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o ··· 34 obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o 35 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o 36 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o 37 obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o 38 obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o 39 obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o ··· 43 obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o 44 obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o 45 obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o 46 - obj-$(CONFIG_TOUCHSCREEN_DA9034) += da9034-ts.o 47 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o 48 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o 49 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o
··· 9 obj-$(CONFIG_TOUCHSCREEN_88PM860X) += 88pm860x-ts.o 10 obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o 11 obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o 12 + obj-$(CONFIG_TOUCHSCREEN_AD7879_I2C) += ad7879-i2c.o 13 + obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o 14 obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o 15 obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o 16 obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o 17 + obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o 18 + obj-$(CONFIG_TOUCHSCREEN_DA9034) += da9034-ts.o 19 obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o 20 obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE) += hampshire.o 21 obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o ··· 30 obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o 31 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o 32 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o 33 + obj-$(CONFIG_TOUCHSCREEN_QT602240) += qt602240_ts.o 34 obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o 35 obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o 36 obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o ··· 38 obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o 39 obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o 40 obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o 41 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o 42 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o 43 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o
+143
drivers/input/touchscreen/ad7879-i2c.c
···
··· 1 + /* 2 + * AD7879-1/AD7889-1 touchscreen (I2C bus) 3 + * 4 + * Copyright (C) 2008-2010 Michael Hennerich, Analog Devices Inc. 5 + * 6 + * Licensed under the GPL-2 or later. 7 + */ 8 + 9 + #include <linux/input.h> /* BUS_I2C */ 10 + #include <linux/i2c.h> 11 + #include <linux/module.h> 12 + #include <linux/types.h> 13 + 14 + #include "ad7879.h" 15 + 16 + #define AD7879_DEVID 0x79 /* AD7879-1/AD7889-1 */ 17 + 18 + #ifdef CONFIG_PM 19 + static int ad7879_i2c_suspend(struct i2c_client *client, pm_message_t message) 20 + { 21 + struct ad7879 *ts = i2c_get_clientdata(client); 22 + 23 + ad7879_suspend(ts); 24 + 25 + return 0; 26 + } 27 + 28 + static int ad7879_i2c_resume(struct i2c_client *client) 29 + { 30 + struct ad7879 *ts = i2c_get_clientdata(client); 31 + 32 + ad7879_resume(ts); 33 + 34 + return 0; 35 + } 36 + #else 37 + # define ad7879_i2c_suspend NULL 38 + # define ad7879_i2c_resume NULL 39 + #endif 40 + 41 + /* All registers are word-sized. 42 + * AD7879 uses a high-byte first convention. 43 + */ 44 + static int ad7879_i2c_read(struct device *dev, u8 reg) 45 + { 46 + struct i2c_client *client = to_i2c_client(dev); 47 + 48 + return swab16(i2c_smbus_read_word_data(client, reg)); 49 + } 50 + 51 + static int ad7879_i2c_multi_read(struct device *dev, 52 + u8 first_reg, u8 count, u16 *buf) 53 + { 54 + struct i2c_client *client = to_i2c_client(dev); 55 + u8 idx; 56 + 57 + i2c_smbus_read_i2c_block_data(client, first_reg, count * 2, (u8 *)buf); 58 + 59 + for (idx = 0; idx < count; ++idx) 60 + buf[idx] = swab16(buf[idx]); 61 + 62 + return 0; 63 + } 64 + 65 + static int ad7879_i2c_write(struct device *dev, u8 reg, u16 val) 66 + { 67 + struct i2c_client *client = to_i2c_client(dev); 68 + 69 + return i2c_smbus_write_word_data(client, reg, swab16(val)); 70 + } 71 + 72 + static const struct ad7879_bus_ops ad7879_i2c_bus_ops = { 73 + .bustype = BUS_I2C, 74 + .read = ad7879_i2c_read, 75 + .multi_read = ad7879_i2c_multi_read, 76 + .write = ad7879_i2c_write, 77 + }; 78 + 79 + static int __devinit ad7879_i2c_probe(struct i2c_client *client, 80 + const struct i2c_device_id *id) 81 + { 82 + struct ad7879 *ts; 83 + 84 + if (!i2c_check_functionality(client->adapter, 85 + I2C_FUNC_SMBUS_WORD_DATA)) { 86 + dev_err(&client->dev, "SMBUS Word Data not Supported\n"); 87 + return -EIO; 88 + } 89 + 90 + ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq, 91 + &ad7879_i2c_bus_ops); 92 + if (IS_ERR(ts)) 93 + return PTR_ERR(ts); 94 + 95 + i2c_set_clientdata(client, ts); 96 + 97 + return 0; 98 + } 99 + 100 + static int __devexit ad7879_i2c_remove(struct i2c_client *client) 101 + { 102 + struct ad7879 *ts = i2c_get_clientdata(client); 103 + 104 + ad7879_remove(ts); 105 + 106 + return 0; 107 + } 108 + 109 + static const struct i2c_device_id ad7879_id[] = { 110 + { "ad7879", 0 }, 111 + { "ad7889", 0 }, 112 + { } 113 + }; 114 + MODULE_DEVICE_TABLE(i2c, ad7879_id); 115 + 116 + static struct i2c_driver ad7879_i2c_driver = { 117 + .driver = { 118 + .name = "ad7879", 119 + .owner = THIS_MODULE, 120 + }, 121 + .probe = ad7879_i2c_probe, 122 + .remove = __devexit_p(ad7879_i2c_remove), 123 + .suspend = ad7879_i2c_suspend, 124 + .resume = ad7879_i2c_resume, 125 + .id_table = ad7879_id, 126 + }; 127 + 128 + static int __init ad7879_i2c_init(void) 129 + { 130 + return i2c_add_driver(&ad7879_i2c_driver); 131 + } 132 + module_init(ad7879_i2c_init); 133 + 134 + static void __exit ad7879_i2c_exit(void) 135 + { 136 + i2c_del_driver(&ad7879_i2c_driver); 137 + } 138 + module_exit(ad7879_i2c_exit); 139 + 140 + MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 141 + MODULE_DESCRIPTION("AD7879(-1) touchscreen I2C bus driver"); 142 + MODULE_LICENSE("GPL"); 143 + MODULE_ALIAS("i2c:ad7879");
+198
drivers/input/touchscreen/ad7879-spi.c
···
··· 1 + /* 2 + * AD7879/AD7889 touchscreen (SPI bus) 3 + * 4 + * Copyright (C) 2008-2010 Michael Hennerich, Analog Devices Inc. 5 + * 6 + * Licensed under the GPL-2 or later. 7 + */ 8 + 9 + #include <linux/input.h> /* BUS_SPI */ 10 + #include <linux/spi/spi.h> 11 + 12 + #include "ad7879.h" 13 + 14 + #define AD7879_DEVID 0x7A /* AD7879/AD7889 */ 15 + 16 + #define MAX_SPI_FREQ_HZ 5000000 17 + #define AD7879_CMD_MAGIC 0xE000 18 + #define AD7879_CMD_READ (1 << 10) 19 + #define AD7879_CMD(reg) (AD7879_CMD_MAGIC | ((reg) & 0xF)) 20 + #define AD7879_WRITECMD(reg) (AD7879_CMD(reg)) 21 + #define AD7879_READCMD(reg) (AD7879_CMD(reg) | AD7879_CMD_READ) 22 + 23 + #ifdef CONFIG_PM 24 + static int ad7879_spi_suspend(struct spi_device *spi, pm_message_t message) 25 + { 26 + struct ad7879 *ts = spi_get_drvdata(spi); 27 + 28 + ad7879_suspend(ts); 29 + 30 + return 0; 31 + } 32 + 33 + static int ad7879_spi_resume(struct spi_device *spi) 34 + { 35 + struct ad7879 *ts = spi_get_drvdata(spi); 36 + 37 + ad7879_resume(ts); 38 + 39 + return 0; 40 + } 41 + #else 42 + # define ad7879_spi_suspend NULL 43 + # define ad7879_spi_resume NULL 44 + #endif 45 + 46 + /* 47 + * ad7879_read/write are only used for initial setup and for sysfs controls. 48 + * The main traffic is done in ad7879_collect(). 49 + */ 50 + 51 + static int ad7879_spi_xfer(struct spi_device *spi, 52 + u16 cmd, u8 count, u16 *tx_buf, u16 *rx_buf) 53 + { 54 + struct spi_message msg; 55 + struct spi_transfer *xfers; 56 + void *spi_data; 57 + u16 *command; 58 + u16 *_rx_buf = _rx_buf; /* shut gcc up */ 59 + u8 idx; 60 + int ret; 61 + 62 + xfers = spi_data = kzalloc(sizeof(*xfers) * (count + 2), GFP_KERNEL); 63 + if (!spi_data) 64 + return -ENOMEM; 65 + 66 + spi_message_init(&msg); 67 + 68 + command = spi_data; 69 + command[0] = cmd; 70 + if (count == 1) { 71 + /* ad7879_spi_{read,write} gave us buf on stack */ 72 + command[1] = *tx_buf; 73 + tx_buf = &command[1]; 74 + _rx_buf = rx_buf; 75 + rx_buf = &command[2]; 76 + } 77 + 78 + ++xfers; 79 + xfers[0].tx_buf = command; 80 + xfers[0].len = 2; 81 + spi_message_add_tail(&xfers[0], &msg); 82 + ++xfers; 83 + 84 + for (idx = 0; idx < count; ++idx) { 85 + if (rx_buf) 86 + xfers[idx].rx_buf = &rx_buf[idx]; 87 + if (tx_buf) 88 + xfers[idx].tx_buf = &tx_buf[idx]; 89 + xfers[idx].len = 2; 90 + spi_message_add_tail(&xfers[idx], &msg); 91 + } 92 + 93 + ret = spi_sync(spi, &msg); 94 + 95 + if (count == 1) 96 + _rx_buf[0] = command[2]; 97 + 98 + kfree(spi_data); 99 + 100 + return ret; 101 + } 102 + 103 + static int ad7879_spi_multi_read(struct device *dev, 104 + u8 first_reg, u8 count, u16 *buf) 105 + { 106 + struct spi_device *spi = to_spi_device(dev); 107 + 108 + return ad7879_spi_xfer(spi, AD7879_READCMD(first_reg), count, NULL, buf); 109 + } 110 + 111 + static int ad7879_spi_read(struct device *dev, u8 reg) 112 + { 113 + struct spi_device *spi = to_spi_device(dev); 114 + u16 ret, dummy; 115 + 116 + return ad7879_spi_xfer(spi, AD7879_READCMD(reg), 1, &dummy, &ret) ? : ret; 117 + } 118 + 119 + static int ad7879_spi_write(struct device *dev, u8 reg, u16 val) 120 + { 121 + struct spi_device *spi = to_spi_device(dev); 122 + u16 dummy; 123 + 124 + return ad7879_spi_xfer(spi, AD7879_WRITECMD(reg), 1, &val, &dummy); 125 + } 126 + 127 + static const struct ad7879_bus_ops ad7879_spi_bus_ops = { 128 + .bustype = BUS_SPI, 129 + .read = ad7879_spi_read, 130 + .multi_read = ad7879_spi_multi_read, 131 + .write = ad7879_spi_write, 132 + }; 133 + 134 + static int __devinit ad7879_spi_probe(struct spi_device *spi) 135 + { 136 + struct ad7879 *ts; 137 + int err; 138 + 139 + /* don't exceed max specified SPI CLK frequency */ 140 + if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) { 141 + dev_err(&spi->dev, "SPI CLK %d Hz?\n", spi->max_speed_hz); 142 + return -EINVAL; 143 + } 144 + 145 + spi->bits_per_word = 16; 146 + err = spi_setup(spi); 147 + if (err) { 148 + dev_dbg(&spi->dev, "spi master doesn't support 16 bits/word\n"); 149 + return err; 150 + } 151 + 152 + ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, &ad7879_spi_bus_ops); 153 + if (IS_ERR(ts)) 154 + return PTR_ERR(ts); 155 + 156 + spi_set_drvdata(spi, ts); 157 + 158 + return 0; 159 + } 160 + 161 + static int __devexit ad7879_spi_remove(struct spi_device *spi) 162 + { 163 + struct ad7879 *ts = spi_get_drvdata(spi); 164 + 165 + ad7879_remove(ts); 166 + spi_set_drvdata(spi, NULL); 167 + 168 + return 0; 169 + } 170 + 171 + static struct spi_driver ad7879_spi_driver = { 172 + .driver = { 173 + .name = "ad7879", 174 + .bus = &spi_bus_type, 175 + .owner = THIS_MODULE, 176 + }, 177 + .probe = ad7879_spi_probe, 178 + .remove = __devexit_p(ad7879_spi_remove), 179 + .suspend = ad7879_spi_suspend, 180 + .resume = ad7879_spi_resume, 181 + }; 182 + 183 + static int __init ad7879_spi_init(void) 184 + { 185 + return spi_register_driver(&ad7879_spi_driver); 186 + } 187 + module_init(ad7879_spi_init); 188 + 189 + static void __exit ad7879_spi_exit(void) 190 + { 191 + spi_unregister_driver(&ad7879_spi_driver); 192 + } 193 + module_exit(ad7879_spi_exit); 194 + 195 + MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 196 + MODULE_DESCRIPTION("AD7879(-1) touchscreen SPI bus driver"); 197 + MODULE_LICENSE("GPL"); 198 + MODULE_ALIAS("spi:ad7879");
+191 -444
drivers/input/touchscreen/ad7879.c
··· 1 /* 2 - * Copyright (C) 2008-2009 Michael Hennerich, Analog Devices Inc. 3 * 4 - * Description: AD7879/AD7889 based touchscreen, and GPIO driver 5 - * (I2C/SPI Interface) 6 * 7 - * Bugs: Enter bugs at http://blackfin.uclinux.org/ 8 - * 9 - * This program is free software; you can redistribute it and/or modify 10 - * it under the terms of the GNU General Public License as published by 11 - * the Free Software Foundation; either version 2 of the License, or 12 - * (at your option) any later version. 13 - * 14 - * This program is distributed in the hope that it will be useful, 15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 - * GNU General Public License for more details. 18 - * 19 - * You should have received a copy of the GNU General Public License 20 - * along with this program; if not, see the file COPYING, or write 21 - * to the Free Software Foundation, Inc., 22 - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 * 24 * History: 25 * Copyright (c) 2005 David Brownell ··· 28 #include <linux/interrupt.h> 29 #include <linux/irq.h> 30 #include <linux/slab.h> 31 - #include <linux/workqueue.h> 32 #include <linux/spi/spi.h> 33 #include <linux/i2c.h> 34 #include <linux/gpio.h> 35 36 #include <linux/spi/ad7879.h> 37 38 #define AD7879_REG_ZEROS 0 39 #define AD7879_REG_CTRL1 1 ··· 104 #define MAX_12BIT ((1<<12)-1) 105 #define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50) 106 107 - #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE) 108 - #define AD7879_DEVID 0x7A 109 - typedef struct spi_device bus_device; 110 - #elif defined(CONFIG_TOUCHSCREEN_AD7879_I2C) || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE) 111 - #define AD7879_DEVID 0x79 112 - typedef struct i2c_client bus_device; 113 - #endif 114 - 115 struct ad7879 { 116 - bus_device *bus; 117 struct input_dev *input; 118 - struct work_struct work; 119 struct timer_list timer; 120 #ifdef CONFIG_GPIOLIB 121 struct gpio_chip gc; 122 - #endif 123 struct mutex mutex; 124 - unsigned disabled:1; /* P: mutex */ 125 - 126 - #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE) 127 - struct spi_message msg; 128 - struct spi_transfer xfer[AD7879_NR_SENSE + 1]; 129 - u16 cmd; 130 #endif 131 u16 conversion_data[AD7879_NR_SENSE]; 132 char phys[32]; 133 u8 first_conversion_delay; ··· 131 u16 cmd_crtl3; 132 }; 133 134 - static int ad7879_read(bus_device *, u8); 135 - static int ad7879_write(bus_device *, u8, u16); 136 - static void ad7879_collect(struct ad7879 *); 137 138 - static void ad7879_report(struct ad7879 *ts) 139 { 140 struct input_dev *input_dev = ts->input; 141 unsigned Rt; ··· 159 160 /* 161 * The samples processed here are already preprocessed by the AD7879. 162 - * The preprocessing function consists of a median and an averaging filter. 163 - * The combination of these two techniques provides a robust solution, 164 - * discarding the spurious noise in the signal and keeping only the data of interest. 165 - * The size of both filters is programmable. (dev.platform_data, see linux/spi/ad7879.h) 166 - * Other user-programmable conversion controls include variable acquisition time, 167 - * and first conversion delay. Up to 16 averages can be taken per conversion. 168 */ 169 170 if (likely(x && z1)) { ··· 175 Rt /= z1; 176 Rt = (Rt + 2047) >> 12; 177 178 input_report_abs(input_dev, ABS_X, x); 179 input_report_abs(input_dev, ABS_Y, y); 180 input_report_abs(input_dev, ABS_PRESSURE, Rt); 181 input_sync(input_dev); 182 } 183 - } 184 185 - static void ad7879_work(struct work_struct *work) 186 - { 187 - struct ad7879 *ts = container_of(work, struct ad7879, work); 188 - 189 - /* use keventd context to read the result registers */ 190 - ad7879_collect(ts); 191 - ad7879_report(ts); 192 - mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); 193 } 194 195 static void ad7879_ts_event_release(struct ad7879 *ts) ··· 193 struct input_dev *input_dev = ts->input; 194 195 input_report_abs(input_dev, ABS_PRESSURE, 0); 196 input_sync(input_dev); 197 } 198 ··· 208 { 209 struct ad7879 *ts = handle; 210 211 - /* The repeated conversion sequencer controlled by TMR kicked off too fast. 212 - * We ignore the last and process the sample sequence currently in the queue. 213 - * It can't be older than 9.4ms 214 - */ 215 216 - if (!work_pending(&ts->work)) 217 - schedule_work(&ts->work); 218 219 return IRQ_HANDLED; 220 } 221 222 - static void ad7879_setup(struct ad7879 *ts) 223 { 224 - ad7879_write(ts->bus, AD7879_REG_CTRL2, ts->cmd_crtl2); 225 - ad7879_write(ts->bus, AD7879_REG_CTRL3, ts->cmd_crtl3); 226 - ad7879_write(ts->bus, AD7879_REG_CTRL1, ts->cmd_crtl1); 227 } 228 229 - static void ad7879_disable(struct ad7879 *ts) 230 { 231 - mutex_lock(&ts->mutex); 232 233 - if (!ts->disabled) { 234 235 - ts->disabled = 1; 236 - disable_irq(ts->bus->irq); 237 - 238 - cancel_work_sync(&ts->work); 239 - 240 - if (del_timer_sync(&ts->timer)) 241 - ad7879_ts_event_release(ts); 242 - 243 - ad7879_write(ts->bus, AD7879_REG_CTRL2, 244 - AD7879_PM(AD7879_PM_SHUTDOWN)); 245 - } 246 - 247 - mutex_unlock(&ts->mutex); 248 } 249 250 - static void ad7879_enable(struct ad7879 *ts) 251 - { 252 - mutex_lock(&ts->mutex); 253 254 - if (ts->disabled) { 255 - ad7879_setup(ts); 256 - ts->disabled = 0; 257 - enable_irq(ts->bus->irq); 258 } 259 260 - mutex_unlock(&ts->mutex); 261 } 262 263 static ssize_t ad7879_disable_show(struct device *dev, ··· 322 if (error) 323 return error; 324 325 - if (val) 326 - ad7879_disable(ts); 327 - else 328 - ad7879_enable(ts); 329 330 return count; 331 } ··· 347 348 mutex_lock(&ts->mutex); 349 ts->cmd_crtl2 |= AD7879_GPIO_EN | AD7879_GPIODIR | AD7879_GPIOPOL; 350 - err = ad7879_write(ts->bus, AD7879_REG_CTRL2, ts->cmd_crtl2); 351 mutex_unlock(&ts->mutex); 352 353 return err; ··· 367 else 368 ts->cmd_crtl2 &= ~AD7879_GPIO_DATA; 369 370 - err = ad7879_write(ts->bus, AD7879_REG_CTRL2, ts->cmd_crtl2); 371 mutex_unlock(&ts->mutex); 372 373 return err; ··· 379 u16 val; 380 381 mutex_lock(&ts->mutex); 382 - val = ad7879_read(ts->bus, AD7879_REG_CTRL2); 383 mutex_unlock(&ts->mutex); 384 385 return !!(val & AD7879_GPIO_DATA); ··· 396 else 397 ts->cmd_crtl2 &= ~AD7879_GPIO_DATA; 398 399 - ad7879_write(ts->bus, AD7879_REG_CTRL2, ts->cmd_crtl2); 400 mutex_unlock(&ts->mutex); 401 } 402 403 - static int __devinit ad7879_gpio_add(struct device *dev) 404 { 405 - struct ad7879 *ts = dev_get_drvdata(dev); 406 - struct ad7879_platform_data *pdata = dev->platform_data; 407 int ret = 0; 408 409 if (pdata->gpio_export) { 410 ts->gc.direction_input = ad7879_gpio_direction_input; ··· 417 ts->gc.ngpio = 1; 418 ts->gc.label = "AD7879-GPIO"; 419 ts->gc.owner = THIS_MODULE; 420 - ts->gc.dev = dev; 421 422 ret = gpiochip_add(&ts->gc); 423 if (ret) 424 - dev_err(dev, "failed to register gpio %d\n", 425 ts->gc.base); 426 } 427 428 return ret; 429 } 430 431 - /* 432 - * We mark ad7879_gpio_remove inline so there is a chance the code 433 - * gets discarded when not needed. We can't do __devinit/__devexit 434 - * markup since it is used in both probe and remove methods. 435 - */ 436 - static inline void ad7879_gpio_remove(struct device *dev) 437 { 438 - struct ad7879 *ts = dev_get_drvdata(dev); 439 - struct ad7879_platform_data *pdata = dev->platform_data; 440 int ret; 441 442 if (pdata->gpio_export) { 443 ret = gpiochip_remove(&ts->gc); 444 if (ret) 445 - dev_err(dev, "failed to remove gpio %d\n", 446 ts->gc.base); 447 } 448 } 449 #else 450 - static inline int ad7879_gpio_add(struct device *dev) 451 { 452 return 0; 453 } 454 455 - static inline void ad7879_gpio_remove(struct device *dev) 456 { 457 } 458 #endif 459 460 - static int __devinit ad7879_construct(bus_device *bus, struct ad7879 *ts) 461 { 462 struct input_dev *input_dev; 463 - struct ad7879_platform_data *pdata = bus->dev.platform_data; 464 int err; 465 u16 revid; 466 467 - if (!bus->irq) { 468 - dev_err(&bus->dev, "no IRQ?\n"); 469 - return -ENODEV; 470 } 471 472 if (!pdata) { 473 - dev_err(&bus->dev, "no platform data?\n"); 474 - return -ENODEV; 475 } 476 477 input_dev = input_allocate_device(); 478 - if (!input_dev) 479 - return -ENOMEM; 480 481 ts->input = input_dev; 482 483 setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts); 484 - INIT_WORK(&ts->work, ad7879_work); 485 - mutex_init(&ts->mutex); 486 487 ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; 488 ts->pressure_max = pdata->pressure_max ? : ~0; ··· 496 ts->pen_down_acc_interval = pdata->pen_down_acc_interval; 497 ts->median = pdata->median; 498 499 - snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&bus->dev)); 500 501 input_dev->name = "AD7879 Touchscreen"; 502 input_dev->phys = ts->phys; 503 - input_dev->dev.parent = &bus->dev; 504 505 __set_bit(EV_ABS, input_dev->evbit); 506 __set_bit(ABS_X, input_dev->absbit); 507 __set_bit(ABS_Y, input_dev->absbit); 508 __set_bit(ABS_PRESSURE, input_dev->absbit); 509 510 input_set_abs_params(input_dev, ABS_X, 511 pdata->x_min ? : 0, ··· 527 input_set_abs_params(input_dev, ABS_PRESSURE, 528 pdata->pressure_min, pdata->pressure_max, 0, 0); 529 530 - err = ad7879_write(bus, AD7879_REG_CTRL2, AD7879_RESET); 531 - 532 if (err < 0) { 533 - dev_err(&bus->dev, "Failed to write %s\n", input_dev->name); 534 goto err_free_mem; 535 } 536 537 - revid = ad7879_read(bus, AD7879_REG_REVID); 538 - 539 - if ((revid & 0xFF) != AD7879_DEVID) { 540 - dev_err(&bus->dev, "Failed to probe %s\n", input_dev->name); 541 err = -ENODEV; 542 goto err_free_mem; 543 } ··· 560 AD7879_ACQ(ts->acquisition_time) | 561 AD7879_TMR(ts->pen_down_acc_interval); 562 563 - ad7879_setup(ts); 564 - 565 - err = request_irq(bus->irq, ad7879_irq, 566 - IRQF_TRIGGER_FALLING, bus->dev.driver->name, ts); 567 - 568 if (err) { 569 - dev_err(&bus->dev, "irq %d busy?\n", bus->irq); 570 goto err_free_mem; 571 } 572 573 - err = sysfs_create_group(&bus->dev.kobj, &ad7879_attr_group); 574 if (err) 575 goto err_free_irq; 576 577 - err = ad7879_gpio_add(&bus->dev); 578 if (err) 579 goto err_remove_attr; 580 ··· 582 if (err) 583 goto err_remove_gpio; 584 585 - dev_info(&bus->dev, "Rev.%d touchscreen, irq %d\n", 586 - revid >> 8, bus->irq); 587 - 588 - return 0; 589 590 err_remove_gpio: 591 - ad7879_gpio_remove(&bus->dev); 592 err_remove_attr: 593 - sysfs_remove_group(&bus->dev.kobj, &ad7879_attr_group); 594 err_free_irq: 595 - free_irq(bus->irq, ts); 596 err_free_mem: 597 input_free_device(input_dev); 598 - 599 - return err; 600 } 601 602 - static int __devexit ad7879_destroy(bus_device *bus, struct ad7879 *ts) 603 { 604 - ad7879_gpio_remove(&bus->dev); 605 - ad7879_disable(ts); 606 - sysfs_remove_group(&ts->bus->dev.kobj, &ad7879_attr_group); 607 - free_irq(ts->bus->irq, ts); 608 input_unregister_device(ts->input); 609 - dev_dbg(&bus->dev, "unregistered touchscreen\n"); 610 - 611 - return 0; 612 - } 613 - 614 - #ifdef CONFIG_PM 615 - static int ad7879_suspend(bus_device *bus, pm_message_t message) 616 - { 617 - struct ad7879 *ts = dev_get_drvdata(&bus->dev); 618 - 619 - ad7879_disable(ts); 620 - 621 - return 0; 622 - } 623 - 624 - static int ad7879_resume(bus_device *bus) 625 - { 626 - struct ad7879 *ts = dev_get_drvdata(&bus->dev); 627 - 628 - ad7879_enable(ts); 629 - 630 - return 0; 631 - } 632 - #else 633 - #define ad7879_suspend NULL 634 - #define ad7879_resume NULL 635 - #endif 636 - 637 - #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE) 638 - #define MAX_SPI_FREQ_HZ 5000000 639 - #define AD7879_CMD_MAGIC 0xE000 640 - #define AD7879_CMD_READ (1 << 10) 641 - #define AD7879_WRITECMD(reg) (AD7879_CMD_MAGIC | (reg & 0xF)) 642 - #define AD7879_READCMD(reg) (AD7879_CMD_MAGIC | AD7879_CMD_READ | (reg & 0xF)) 643 - 644 - struct ser_req { 645 - u16 command; 646 - u16 data; 647 - struct spi_message msg; 648 - struct spi_transfer xfer[2]; 649 - }; 650 - 651 - /* 652 - * ad7879_read/write are only used for initial setup and for sysfs controls. 653 - * The main traffic is done in ad7879_collect(). 654 - */ 655 - 656 - static int ad7879_read(struct spi_device *spi, u8 reg) 657 - { 658 - struct ser_req *req; 659 - int status, ret; 660 - 661 - req = kzalloc(sizeof *req, GFP_KERNEL); 662 - if (!req) 663 - return -ENOMEM; 664 - 665 - spi_message_init(&req->msg); 666 - 667 - req->command = (u16) AD7879_READCMD(reg); 668 - req->xfer[0].tx_buf = &req->command; 669 - req->xfer[0].len = 2; 670 - 671 - req->xfer[1].rx_buf = &req->data; 672 - req->xfer[1].len = 2; 673 - 674 - spi_message_add_tail(&req->xfer[0], &req->msg); 675 - spi_message_add_tail(&req->xfer[1], &req->msg); 676 - 677 - status = spi_sync(spi, &req->msg); 678 - ret = status ? : req->data; 679 - 680 - kfree(req); 681 - 682 - return ret; 683 - } 684 - 685 - static int ad7879_write(struct spi_device *spi, u8 reg, u16 val) 686 - { 687 - struct ser_req *req; 688 - int status; 689 - 690 - req = kzalloc(sizeof *req, GFP_KERNEL); 691 - if (!req) 692 - return -ENOMEM; 693 - 694 - spi_message_init(&req->msg); 695 - 696 - req->command = (u16) AD7879_WRITECMD(reg); 697 - req->xfer[0].tx_buf = &req->command; 698 - req->xfer[0].len = 2; 699 - 700 - req->data = val; 701 - req->xfer[1].tx_buf = &req->data; 702 - req->xfer[1].len = 2; 703 - 704 - spi_message_add_tail(&req->xfer[0], &req->msg); 705 - spi_message_add_tail(&req->xfer[1], &req->msg); 706 - 707 - status = spi_sync(spi, &req->msg); 708 - 709 - kfree(req); 710 - 711 - return status; 712 - } 713 - 714 - static void ad7879_collect(struct ad7879 *ts) 715 - { 716 - int status = spi_sync(ts->bus, &ts->msg); 717 - 718 - if (status) 719 - dev_err(&ts->bus->dev, "spi_sync --> %d\n", status); 720 - } 721 - 722 - static void ad7879_setup_ts_def_msg(struct ad7879 *ts) 723 - { 724 - struct spi_message *m; 725 - int i; 726 - 727 - ts->cmd = (u16) AD7879_READCMD(AD7879_REG_XPLUS); 728 - 729 - m = &ts->msg; 730 - spi_message_init(m); 731 - ts->xfer[0].tx_buf = &ts->cmd; 732 - ts->xfer[0].len = 2; 733 - 734 - spi_message_add_tail(&ts->xfer[0], m); 735 - 736 - for (i = 0; i < AD7879_NR_SENSE; i++) { 737 - ts->xfer[i + 1].rx_buf = &ts->conversion_data[i]; 738 - ts->xfer[i + 1].len = 2; 739 - spi_message_add_tail(&ts->xfer[i + 1], m); 740 - } 741 - } 742 - 743 - static int __devinit ad7879_probe(struct spi_device *spi) 744 - { 745 - struct ad7879 *ts; 746 - int error; 747 - 748 - /* don't exceed max specified SPI CLK frequency */ 749 - if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) { 750 - dev_err(&spi->dev, "SPI CLK %d Hz?\n", spi->max_speed_hz); 751 - return -EINVAL; 752 - } 753 - 754 - ts = kzalloc(sizeof(struct ad7879), GFP_KERNEL); 755 - if (!ts) 756 - return -ENOMEM; 757 - 758 - dev_set_drvdata(&spi->dev, ts); 759 - ts->bus = spi; 760 - 761 - ad7879_setup_ts_def_msg(ts); 762 - 763 - error = ad7879_construct(spi, ts); 764 - if (error) { 765 - dev_set_drvdata(&spi->dev, NULL); 766 - kfree(ts); 767 - } 768 - 769 - return error; 770 - } 771 - 772 - static int __devexit ad7879_remove(struct spi_device *spi) 773 - { 774 - struct ad7879 *ts = dev_get_drvdata(&spi->dev); 775 - 776 - ad7879_destroy(spi, ts); 777 - dev_set_drvdata(&spi->dev, NULL); 778 kfree(ts); 779 - 780 - return 0; 781 } 782 - 783 - static struct spi_driver ad7879_driver = { 784 - .driver = { 785 - .name = "ad7879", 786 - .bus = &spi_bus_type, 787 - .owner = THIS_MODULE, 788 - }, 789 - .probe = ad7879_probe, 790 - .remove = __devexit_p(ad7879_remove), 791 - .suspend = ad7879_suspend, 792 - .resume = ad7879_resume, 793 - }; 794 - 795 - static int __init ad7879_init(void) 796 - { 797 - return spi_register_driver(&ad7879_driver); 798 - } 799 - module_init(ad7879_init); 800 - 801 - static void __exit ad7879_exit(void) 802 - { 803 - spi_unregister_driver(&ad7879_driver); 804 - } 805 - module_exit(ad7879_exit); 806 - 807 - #elif defined(CONFIG_TOUCHSCREEN_AD7879_I2C) || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE) 808 - 809 - /* All registers are word-sized. 810 - * AD7879 uses a high-byte first convention. 811 - */ 812 - static int ad7879_read(struct i2c_client *client, u8 reg) 813 - { 814 - return swab16(i2c_smbus_read_word_data(client, reg)); 815 - } 816 - 817 - static int ad7879_write(struct i2c_client *client, u8 reg, u16 val) 818 - { 819 - return i2c_smbus_write_word_data(client, reg, swab16(val)); 820 - } 821 - 822 - static void ad7879_collect(struct ad7879 *ts) 823 - { 824 - int i; 825 - 826 - for (i = 0; i < AD7879_NR_SENSE; i++) 827 - ts->conversion_data[i] = ad7879_read(ts->bus, 828 - AD7879_REG_XPLUS + i); 829 - } 830 - 831 - static int __devinit ad7879_probe(struct i2c_client *client, 832 - const struct i2c_device_id *id) 833 - { 834 - struct ad7879 *ts; 835 - int error; 836 - 837 - if (!i2c_check_functionality(client->adapter, 838 - I2C_FUNC_SMBUS_WORD_DATA)) { 839 - dev_err(&client->dev, "SMBUS Word Data not Supported\n"); 840 - return -EIO; 841 - } 842 - 843 - ts = kzalloc(sizeof(struct ad7879), GFP_KERNEL); 844 - if (!ts) 845 - return -ENOMEM; 846 - 847 - i2c_set_clientdata(client, ts); 848 - ts->bus = client; 849 - 850 - error = ad7879_construct(client, ts); 851 - if (error) 852 - kfree(ts); 853 - 854 - return error; 855 - } 856 - 857 - static int __devexit ad7879_remove(struct i2c_client *client) 858 - { 859 - struct ad7879 *ts = dev_get_drvdata(&client->dev); 860 - 861 - ad7879_destroy(client, ts); 862 - kfree(ts); 863 - 864 - return 0; 865 - } 866 - 867 - static const struct i2c_device_id ad7879_id[] = { 868 - { "ad7879", 0 }, 869 - { "ad7889", 0 }, 870 - { } 871 - }; 872 - MODULE_DEVICE_TABLE(i2c, ad7879_id); 873 - 874 - static struct i2c_driver ad7879_driver = { 875 - .driver = { 876 - .name = "ad7879", 877 - .owner = THIS_MODULE, 878 - }, 879 - .probe = ad7879_probe, 880 - .remove = __devexit_p(ad7879_remove), 881 - .suspend = ad7879_suspend, 882 - .resume = ad7879_resume, 883 - .id_table = ad7879_id, 884 - }; 885 - 886 - static int __init ad7879_init(void) 887 - { 888 - return i2c_add_driver(&ad7879_driver); 889 - } 890 - module_init(ad7879_init); 891 - 892 - static void __exit ad7879_exit(void) 893 - { 894 - i2c_del_driver(&ad7879_driver); 895 - } 896 - module_exit(ad7879_exit); 897 - #endif 898 899 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 900 MODULE_DESCRIPTION("AD7879(-1) touchscreen Driver"); 901 MODULE_LICENSE("GPL"); 902 - MODULE_ALIAS("spi:ad7879");
··· 1 /* 2 + * AD7879/AD7889 based touchscreen and GPIO driver 3 * 4 + * Copyright (C) 2008-2010 Michael Hennerich, Analog Devices Inc. 5 * 6 + * Licensed under the GPL-2 or later. 7 * 8 * History: 9 * Copyright (c) 2005 David Brownell ··· 44 #include <linux/interrupt.h> 45 #include <linux/irq.h> 46 #include <linux/slab.h> 47 #include <linux/spi/spi.h> 48 #include <linux/i2c.h> 49 #include <linux/gpio.h> 50 51 #include <linux/spi/ad7879.h> 52 + #include "ad7879.h" 53 54 #define AD7879_REG_ZEROS 0 55 #define AD7879_REG_CTRL1 1 ··· 120 #define MAX_12BIT ((1<<12)-1) 121 #define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50) 122 123 struct ad7879 { 124 + const struct ad7879_bus_ops *bops; 125 + 126 + struct device *dev; 127 struct input_dev *input; 128 struct timer_list timer; 129 #ifdef CONFIG_GPIOLIB 130 struct gpio_chip gc; 131 struct mutex mutex; 132 #endif 133 + unsigned int irq; 134 + bool disabled; /* P: input->mutex */ 135 + bool suspended; /* P: input->mutex */ 136 u16 conversion_data[AD7879_NR_SENSE]; 137 char phys[32]; 138 u8 first_conversion_delay; ··· 158 u16 cmd_crtl3; 159 }; 160 161 + static int ad7879_read(struct ad7879 *ts, u8 reg) 162 + { 163 + return ts->bops->read(ts->dev, reg); 164 + } 165 166 + static int ad7879_multi_read(struct ad7879 *ts, u8 first_reg, u8 count, u16 *buf) 167 + { 168 + return ts->bops->multi_read(ts->dev, first_reg, count, buf); 169 + } 170 + 171 + static int ad7879_write(struct ad7879 *ts, u8 reg, u16 val) 172 + { 173 + return ts->bops->write(ts->dev, reg, val); 174 + } 175 + 176 + static int ad7879_report(struct ad7879 *ts) 177 { 178 struct input_dev *input_dev = ts->input; 179 unsigned Rt; ··· 175 176 /* 177 * The samples processed here are already preprocessed by the AD7879. 178 + * The preprocessing function consists of a median and an averaging 179 + * filter. The combination of these two techniques provides a robust 180 + * solution, discarding the spurious noise in the signal and keeping 181 + * only the data of interest. The size of both filters is 182 + * programmable. (dev.platform_data, see linux/spi/ad7879.h) Other 183 + * user-programmable conversion controls include variable acquisition 184 + * time, and first conversion delay. Up to 16 averages can be taken 185 + * per conversion. 186 */ 187 188 if (likely(x && z1)) { ··· 189 Rt /= z1; 190 Rt = (Rt + 2047) >> 12; 191 192 + if (!timer_pending(&ts->timer)) 193 + input_report_key(input_dev, BTN_TOUCH, 1); 194 + 195 input_report_abs(input_dev, ABS_X, x); 196 input_report_abs(input_dev, ABS_Y, y); 197 input_report_abs(input_dev, ABS_PRESSURE, Rt); 198 input_sync(input_dev); 199 + return 0; 200 } 201 202 + return -EINVAL; 203 } 204 205 static void ad7879_ts_event_release(struct ad7879 *ts) ··· 211 struct input_dev *input_dev = ts->input; 212 213 input_report_abs(input_dev, ABS_PRESSURE, 0); 214 + input_report_key(input_dev, BTN_TOUCH, 0); 215 input_sync(input_dev); 216 } 217 ··· 225 { 226 struct ad7879 *ts = handle; 227 228 + ad7879_multi_read(ts, AD7879_REG_XPLUS, AD7879_NR_SENSE, ts->conversion_data); 229 230 + if (!ad7879_report(ts)) 231 + mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); 232 233 return IRQ_HANDLED; 234 } 235 236 + static void __ad7879_enable(struct ad7879 *ts) 237 { 238 + ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2); 239 + ad7879_write(ts, AD7879_REG_CTRL3, ts->cmd_crtl3); 240 + ad7879_write(ts, AD7879_REG_CTRL1, ts->cmd_crtl1); 241 + 242 + enable_irq(ts->irq); 243 } 244 245 + static void __ad7879_disable(struct ad7879 *ts) 246 { 247 + disable_irq(ts->irq); 248 249 + if (del_timer_sync(&ts->timer)) 250 + ad7879_ts_event_release(ts); 251 252 + ad7879_write(ts, AD7879_REG_CTRL2, AD7879_PM(AD7879_PM_SHUTDOWN)); 253 } 254 255 256 + static int ad7879_open(struct input_dev *input) 257 + { 258 + struct ad7879 *ts = input_get_drvdata(input); 259 + 260 + /* protected by input->mutex */ 261 + if (!ts->disabled && !ts->suspended) 262 + __ad7879_enable(ts); 263 + 264 + return 0; 265 + } 266 + 267 + static void ad7879_close(struct input_dev* input) 268 + { 269 + struct ad7879 *ts = input_get_drvdata(input); 270 + 271 + /* protected by input->mutex */ 272 + if (!ts->disabled && !ts->suspended) 273 + __ad7879_disable(ts); 274 + } 275 + 276 + void ad7879_suspend(struct ad7879 *ts) 277 + { 278 + mutex_lock(&ts->input->mutex); 279 + 280 + if (!ts->suspended && !ts->disabled && ts->input->users) 281 + __ad7879_disable(ts); 282 + 283 + ts->suspended = true; 284 + 285 + mutex_unlock(&ts->input->mutex); 286 + } 287 + EXPORT_SYMBOL(ad7879_suspend); 288 + 289 + void ad7879_resume(struct ad7879 *ts) 290 + { 291 + mutex_lock(&ts->input->mutex); 292 + 293 + if (ts->suspended && !ts->disabled && ts->input->users) 294 + __ad7879_enable(ts); 295 + 296 + ts->suspended = false; 297 + 298 + mutex_unlock(&ts->input->mutex); 299 + } 300 + EXPORT_SYMBOL(ad7879_resume); 301 + 302 + static void ad7879_toggle(struct ad7879 *ts, bool disable) 303 + { 304 + mutex_lock(&ts->input->mutex); 305 + 306 + if (!ts->suspended && ts->input->users != 0) { 307 + 308 + if (disable) { 309 + if (ts->disabled) 310 + __ad7879_enable(ts); 311 + } else { 312 + if (!ts->disabled) 313 + __ad7879_disable(ts); 314 + } 315 } 316 317 + ts->disabled = disable; 318 + 319 + mutex_unlock(&ts->input->mutex); 320 } 321 322 static ssize_t ad7879_disable_show(struct device *dev, ··· 297 if (error) 298 return error; 299 300 + ad7879_toggle(ts, val); 301 302 return count; 303 } ··· 325 326 mutex_lock(&ts->mutex); 327 ts->cmd_crtl2 |= AD7879_GPIO_EN | AD7879_GPIODIR | AD7879_GPIOPOL; 328 + err = ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2); 329 mutex_unlock(&ts->mutex); 330 331 return err; ··· 345 else 346 ts->cmd_crtl2 &= ~AD7879_GPIO_DATA; 347 348 + err = ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2); 349 mutex_unlock(&ts->mutex); 350 351 return err; ··· 357 u16 val; 358 359 mutex_lock(&ts->mutex); 360 + val = ad7879_read(ts, AD7879_REG_CTRL2); 361 mutex_unlock(&ts->mutex); 362 363 return !!(val & AD7879_GPIO_DATA); ··· 374 else 375 ts->cmd_crtl2 &= ~AD7879_GPIO_DATA; 376 377 + ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2); 378 mutex_unlock(&ts->mutex); 379 } 380 381 + static int ad7879_gpio_add(struct ad7879 *ts, 382 + const struct ad7879_platform_data *pdata) 383 { 384 int ret = 0; 385 + 386 + mutex_init(&ts->mutex); 387 388 if (pdata->gpio_export) { 389 ts->gc.direction_input = ad7879_gpio_direction_input; ··· 394 ts->gc.ngpio = 1; 395 ts->gc.label = "AD7879-GPIO"; 396 ts->gc.owner = THIS_MODULE; 397 + ts->gc.dev = ts->dev; 398 399 ret = gpiochip_add(&ts->gc); 400 if (ret) 401 + dev_err(ts->dev, "failed to register gpio %d\n", 402 ts->gc.base); 403 } 404 405 return ret; 406 } 407 408 + static void ad7879_gpio_remove(struct ad7879 *ts) 409 { 410 + const struct ad7879_platform_data *pdata = ts->dev->platform_data; 411 int ret; 412 413 if (pdata->gpio_export) { 414 ret = gpiochip_remove(&ts->gc); 415 if (ret) 416 + dev_err(ts->dev, "failed to remove gpio %d\n", 417 ts->gc.base); 418 } 419 } 420 #else 421 + static inline int ad7879_gpio_add(struct ad7879 *ts, 422 + const struct ad7879_platform_data *pdata) 423 { 424 return 0; 425 } 426 427 + static inline void ad7879_gpio_remove(struct ad7879 *ts) 428 { 429 } 430 #endif 431 432 + struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq, 433 + const struct ad7879_bus_ops *bops) 434 { 435 + struct ad7879_platform_data *pdata = dev->platform_data; 436 + struct ad7879 *ts; 437 struct input_dev *input_dev; 438 int err; 439 u16 revid; 440 441 + if (!irq) { 442 + dev_err(dev, "no IRQ?\n"); 443 + err = -EINVAL; 444 + goto err_out; 445 } 446 447 if (!pdata) { 448 + dev_err(dev, "no platform data?\n"); 449 + err = -EINVAL; 450 + goto err_out; 451 } 452 453 + ts = kzalloc(sizeof(*ts), GFP_KERNEL); 454 input_dev = input_allocate_device(); 455 + if (!ts || !input_dev) { 456 + err = -ENOMEM; 457 + goto err_free_mem; 458 + } 459 460 + ts->bops = bops; 461 + ts->dev = dev; 462 ts->input = input_dev; 463 + ts->irq = irq; 464 465 setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts); 466 467 ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; 468 ts->pressure_max = pdata->pressure_max ? : ~0; ··· 470 ts->pen_down_acc_interval = pdata->pen_down_acc_interval; 471 ts->median = pdata->median; 472 473 + snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev)); 474 475 input_dev->name = "AD7879 Touchscreen"; 476 input_dev->phys = ts->phys; 477 + input_dev->dev.parent = dev; 478 + input_dev->id.bustype = bops->bustype; 479 + 480 + input_dev->open = ad7879_open; 481 + input_dev->close = ad7879_close; 482 + 483 + input_set_drvdata(input_dev, ts); 484 485 __set_bit(EV_ABS, input_dev->evbit); 486 __set_bit(ABS_X, input_dev->absbit); 487 __set_bit(ABS_Y, input_dev->absbit); 488 __set_bit(ABS_PRESSURE, input_dev->absbit); 489 + 490 + __set_bit(EV_KEY, input_dev->evbit); 491 + __set_bit(BTN_TOUCH, input_dev->keybit); 492 493 input_set_abs_params(input_dev, ABS_X, 494 pdata->x_min ? : 0, ··· 492 input_set_abs_params(input_dev, ABS_PRESSURE, 493 pdata->pressure_min, pdata->pressure_max, 0, 0); 494 495 + err = ad7879_write(ts, AD7879_REG_CTRL2, AD7879_RESET); 496 if (err < 0) { 497 + dev_err(dev, "Failed to write %s\n", input_dev->name); 498 goto err_free_mem; 499 } 500 501 + revid = ad7879_read(ts, AD7879_REG_REVID); 502 + input_dev->id.product = (revid & 0xff); 503 + input_dev->id.version = revid >> 8; 504 + if (input_dev->id.product != devid) { 505 + dev_err(dev, "Failed to probe %s (%x vs %x)\n", 506 + input_dev->name, devid, revid); 507 err = -ENODEV; 508 goto err_free_mem; 509 } ··· 524 AD7879_ACQ(ts->acquisition_time) | 525 AD7879_TMR(ts->pen_down_acc_interval); 526 527 + err = request_threaded_irq(ts->irq, NULL, ad7879_irq, 528 + IRQF_TRIGGER_FALLING, 529 + dev_name(dev), ts); 530 if (err) { 531 + dev_err(dev, "irq %d busy?\n", ts->irq); 532 goto err_free_mem; 533 } 534 535 + __ad7879_disable(ts); 536 + 537 + err = sysfs_create_group(&dev->kobj, &ad7879_attr_group); 538 if (err) 539 goto err_free_irq; 540 541 + err = ad7879_gpio_add(ts, pdata); 542 if (err) 543 goto err_remove_attr; 544 ··· 546 if (err) 547 goto err_remove_gpio; 548 549 + return ts; 550 551 err_remove_gpio: 552 + ad7879_gpio_remove(ts); 553 err_remove_attr: 554 + sysfs_remove_group(&dev->kobj, &ad7879_attr_group); 555 err_free_irq: 556 + free_irq(ts->irq, ts); 557 err_free_mem: 558 input_free_device(input_dev); 559 + kfree(ts); 560 + err_out: 561 + return ERR_PTR(err); 562 } 563 + EXPORT_SYMBOL(ad7879_probe); 564 565 + void ad7879_remove(struct ad7879 *ts) 566 { 567 + ad7879_gpio_remove(ts); 568 + sysfs_remove_group(&ts->dev->kobj, &ad7879_attr_group); 569 + free_irq(ts->irq, ts); 570 input_unregister_device(ts->input); 571 kfree(ts); 572 } 573 + EXPORT_SYMBOL(ad7879_remove); 574 575 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 576 MODULE_DESCRIPTION("AD7879(-1) touchscreen Driver"); 577 MODULE_LICENSE("GPL");
+30
drivers/input/touchscreen/ad7879.h
···
··· 1 + /* 2 + * AD7879/AD7889 touchscreen (bus interfaces) 3 + * 4 + * Copyright (C) 2008-2010 Michael Hennerich, Analog Devices Inc. 5 + * 6 + * Licensed under the GPL-2 or later. 7 + */ 8 + 9 + #ifndef _AD7879_H_ 10 + #define _AD7879_H_ 11 + 12 + #include <linux/types.h> 13 + 14 + struct ad7879; 15 + struct device; 16 + 17 + struct ad7879_bus_ops { 18 + u16 bustype; 19 + int (*read)(struct device *dev, u8 reg); 20 + int (*multi_read)(struct device *dev, u8 first_reg, u8 count, u16 *buf); 21 + int (*write)(struct device *dev, u8 reg, u16 val); 22 + }; 23 + 24 + void ad7879_suspend(struct ad7879 *); 25 + void ad7879_resume(struct ad7879 *); 26 + struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned irq, 27 + const struct ad7879_bus_ops *bops); 28 + void ad7879_remove(struct ad7879 *); 29 + 30 + #endif
+155 -51
drivers/input/touchscreen/ads7846.c
··· 68 u16 y; 69 u16 z1, z2; 70 int ignore; 71 }; 72 73 /* ··· 81 u8 read_x, read_y, read_z1, read_z2, pwrdown; 82 u16 dummy; /* for the pwrdown read */ 83 struct ts_event tc; 84 }; 85 86 struct ads7846 { ··· 211 struct spi_transfer xfer[6]; 212 }; 213 214 static void ads7846_enable(struct ads7846 *ts); 215 static void ads7846_disable(struct ads7846 *ts); 216 ··· 291 if (status == 0) { 292 /* on-wire is a must-ignore bit, a BE12 value, then padding */ 293 status = be16_to_cpu(req->sample); 294 status = status >> 3; 295 status &= 0x0fff; 296 } ··· 587 /* ads7846_rx_val() did in-place conversion (including byteswap) from 588 * on-the-wire format as part of debouncing to get stable readings. 589 */ 590 - x = packet->tc.x; 591 - y = packet->tc.y; 592 - z1 = packet->tc.z1; 593 - z2 = packet->tc.z2; 594 595 /* range filtering */ 596 if (x == MAX_12BIT) ··· 605 606 if (ts->model == 7843) { 607 Rt = ts->pressure_max / 2; 608 } else if (likely(x && z1)) { 609 /* compute touch pressure resistance using equation #2 */ 610 Rt = z2; ··· 731 m = &ts->msg[ts->msg_idx]; 732 t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list); 733 734 - /* adjust: on-wire is a must-ignore bit, a BE12 value, then padding; 735 - * built from two 8 bit values written msb-first. 736 - */ 737 - val = be16_to_cpup((__be16 *)t->rx_buf) >> 3; 738 739 action = ts->filter(ts->filter_data, ts->msg_idx, &val); 740 switch (action) { ··· 942 943 static int __devinit ads7846_probe(struct spi_device *spi) 944 { 945 - struct ads7846 *ts; 946 - struct ads7846_packet *packet; 947 - struct input_dev *input_dev; 948 - struct ads7846_platform_data *pdata = spi->dev.platform_data; 949 - struct spi_message *m; 950 - struct spi_transfer *x; 951 - int vref; 952 - int err; 953 954 if (!spi->irq) { 955 dev_dbg(&spi->dev, "no IRQ?\n"); ··· 1073 1074 spi_message_init(m); 1075 1076 - /* y- still on; turn on only y+ (and ADC) */ 1077 - packet->read_y = READ_Y(vref); 1078 - x->tx_buf = &packet->read_y; 1079 - x->len = 1; 1080 - spi_message_add_tail(x, m); 1081 1082 - x++; 1083 - x->rx_buf = &packet->tc.y; 1084 - x->len = 2; 1085 - spi_message_add_tail(x, m); 1086 1087 /* the first sample after switching drivers can be low quality; 1088 * optionally discard it, using a second one after the signals ··· 1118 m++; 1119 spi_message_init(m); 1120 1121 - /* turn y- off, x+ on, then leave in lowpower */ 1122 - x++; 1123 - packet->read_x = READ_X(vref); 1124 - x->tx_buf = &packet->read_x; 1125 - x->len = 1; 1126 - spi_message_add_tail(x, m); 1127 1128 - x++; 1129 - x->rx_buf = &packet->tc.x; 1130 - x->len = 2; 1131 - spi_message_add_tail(x, m); 1132 1133 /* ... maybe discard first sample ... */ 1134 if (pdata->settle_delay_usecs) { ··· 1230 m++; 1231 spi_message_init(m); 1232 1233 - x++; 1234 - packet->pwrdown = PWRDOWN; 1235 - x->tx_buf = &packet->pwrdown; 1236 - x->len = 1; 1237 - spi_message_add_tail(x, m); 1238 1239 - x++; 1240 - x->rx_buf = &packet->dummy; 1241 - x->len = 2; 1242 CS_CHANGE(*x); 1243 spi_message_add_tail(x, m); 1244 ··· 1270 goto err_put_regulator; 1271 } 1272 1273 - if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING, 1274 - spi->dev.driver->name, ts)) { 1275 dev_info(&spi->dev, 1276 "trying pin change workaround on irq %d\n", spi->irq); 1277 err = request_irq(spi->irq, ads7846_irq, 1278 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, 1279 spi->dev.driver->name, ts); 1280 - if (err) { 1281 - dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 1282 - goto err_disable_regulator; 1283 - } 1284 } 1285 1286 err = ads784x_hwmon_register(spi, ts); ··· 1297 /* take a first sample, leaving nPENIRQ active and vREF off; avoid 1298 * the touchscreen, in case it's not connected. 1299 */ 1300 - (void) ads7846_read12_ser(&spi->dev, 1301 - READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON); 1302 1303 err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group); 1304 if (err)
··· 68 u16 y; 69 u16 z1, z2; 70 int ignore; 71 + u8 x_buf[3]; 72 + u8 y_buf[3]; 73 }; 74 75 /* ··· 79 u8 read_x, read_y, read_z1, read_z2, pwrdown; 80 u16 dummy; /* for the pwrdown read */ 81 struct ts_event tc; 82 + /* for ads7845 with mpc5121 psc spi we use 3-byte buffers */ 83 + u8 read_x_cmd[3], read_y_cmd[3], pwrdown_cmd[3]; 84 }; 85 86 struct ads7846 { ··· 207 struct spi_transfer xfer[6]; 208 }; 209 210 + struct ads7845_ser_req { 211 + u8 command[3]; 212 + u8 pwrdown[3]; 213 + u8 sample[3]; 214 + struct spi_message msg; 215 + struct spi_transfer xfer[2]; 216 + }; 217 + 218 static void ads7846_enable(struct ads7846 *ts); 219 static void ads7846_disable(struct ads7846 *ts); 220 ··· 279 if (status == 0) { 280 /* on-wire is a must-ignore bit, a BE12 value, then padding */ 281 status = be16_to_cpu(req->sample); 282 + status = status >> 3; 283 + status &= 0x0fff; 284 + } 285 + 286 + kfree(req); 287 + return status; 288 + } 289 + 290 + static int ads7845_read12_ser(struct device *dev, unsigned command) 291 + { 292 + struct spi_device *spi = to_spi_device(dev); 293 + struct ads7846 *ts = dev_get_drvdata(dev); 294 + struct ads7845_ser_req *req = kzalloc(sizeof *req, GFP_KERNEL); 295 + int status; 296 + 297 + if (!req) 298 + return -ENOMEM; 299 + 300 + spi_message_init(&req->msg); 301 + 302 + req->command[0] = (u8) command; 303 + req->xfer[0].tx_buf = req->command; 304 + req->xfer[0].rx_buf = req->sample; 305 + req->xfer[0].len = 3; 306 + spi_message_add_tail(&req->xfer[0], &req->msg); 307 + 308 + ts->irq_disabled = 1; 309 + disable_irq(spi->irq); 310 + status = spi_sync(spi, &req->msg); 311 + ts->irq_disabled = 0; 312 + enable_irq(spi->irq); 313 + 314 + if (status == 0) { 315 + /* BE12 value, then padding */ 316 + status = be16_to_cpu(*((u16 *)&req->sample[1])); 317 status = status >> 3; 318 status &= 0x0fff; 319 } ··· 540 /* ads7846_rx_val() did in-place conversion (including byteswap) from 541 * on-the-wire format as part of debouncing to get stable readings. 542 */ 543 + if (ts->model == 7845) { 544 + x = *(u16 *)packet->tc.x_buf; 545 + y = *(u16 *)packet->tc.y_buf; 546 + z1 = 0; 547 + z2 = 0; 548 + } else { 549 + x = packet->tc.x; 550 + y = packet->tc.y; 551 + z1 = packet->tc.z1; 552 + z2 = packet->tc.z2; 553 + } 554 555 /* range filtering */ 556 if (x == MAX_12BIT) ··· 551 552 if (ts->model == 7843) { 553 Rt = ts->pressure_max / 2; 554 + } else if (ts->model == 7845) { 555 + if (get_pendown_state(ts)) 556 + Rt = ts->pressure_max / 2; 557 + else 558 + Rt = 0; 559 + dev_vdbg(&ts->spi->dev, "x/y: %d/%d, PD %d\n", x, y, Rt); 560 } else if (likely(x && z1)) { 561 /* compute touch pressure resistance using equation #2 */ 562 Rt = z2; ··· 671 m = &ts->msg[ts->msg_idx]; 672 t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list); 673 674 + if (ts->model == 7845) { 675 + val = be16_to_cpup((__be16 *)&(((char*)t->rx_buf)[1])) >> 3; 676 + } else { 677 + /* adjust: on-wire is a must-ignore bit, a BE12 value, then 678 + * padding; built from two 8 bit values written msb-first. 679 + */ 680 + val = be16_to_cpup((__be16 *)t->rx_buf) >> 3; 681 + } 682 683 action = ts->filter(ts->filter_data, ts->msg_idx, &val); 684 switch (action) { ··· 878 879 static int __devinit ads7846_probe(struct spi_device *spi) 880 { 881 + struct ads7846 *ts; 882 + struct ads7846_packet *packet; 883 + struct input_dev *input_dev; 884 + const struct ads7846_platform_data *pdata = spi->dev.platform_data; 885 + struct spi_message *m; 886 + struct spi_transfer *x; 887 + unsigned long irq_flags; 888 + int vref; 889 + int err; 890 891 if (!spi->irq) { 892 dev_dbg(&spi->dev, "no IRQ?\n"); ··· 1008 1009 spi_message_init(m); 1010 1011 + if (ts->model == 7845) { 1012 + packet->read_y_cmd[0] = READ_Y(vref); 1013 + packet->read_y_cmd[1] = 0; 1014 + packet->read_y_cmd[2] = 0; 1015 + x->tx_buf = &packet->read_y_cmd[0]; 1016 + x->rx_buf = &packet->tc.y_buf[0]; 1017 + x->len = 3; 1018 + spi_message_add_tail(x, m); 1019 + } else { 1020 + /* y- still on; turn on only y+ (and ADC) */ 1021 + packet->read_y = READ_Y(vref); 1022 + x->tx_buf = &packet->read_y; 1023 + x->len = 1; 1024 + spi_message_add_tail(x, m); 1025 1026 + x++; 1027 + x->rx_buf = &packet->tc.y; 1028 + x->len = 2; 1029 + spi_message_add_tail(x, m); 1030 + } 1031 1032 /* the first sample after switching drivers can be low quality; 1033 * optionally discard it, using a second one after the signals ··· 1043 m++; 1044 spi_message_init(m); 1045 1046 + if (ts->model == 7845) { 1047 + x++; 1048 + packet->read_x_cmd[0] = READ_X(vref); 1049 + packet->read_x_cmd[1] = 0; 1050 + packet->read_x_cmd[2] = 0; 1051 + x->tx_buf = &packet->read_x_cmd[0]; 1052 + x->rx_buf = &packet->tc.x_buf[0]; 1053 + x->len = 3; 1054 + spi_message_add_tail(x, m); 1055 + } else { 1056 + /* turn y- off, x+ on, then leave in lowpower */ 1057 + x++; 1058 + packet->read_x = READ_X(vref); 1059 + x->tx_buf = &packet->read_x; 1060 + x->len = 1; 1061 + spi_message_add_tail(x, m); 1062 1063 + x++; 1064 + x->rx_buf = &packet->tc.x; 1065 + x->len = 2; 1066 + spi_message_add_tail(x, m); 1067 + } 1068 1069 /* ... maybe discard first sample ... */ 1070 if (pdata->settle_delay_usecs) { ··· 1144 m++; 1145 spi_message_init(m); 1146 1147 + if (ts->model == 7845) { 1148 + x++; 1149 + packet->pwrdown_cmd[0] = PWRDOWN; 1150 + packet->pwrdown_cmd[1] = 0; 1151 + packet->pwrdown_cmd[2] = 0; 1152 + x->tx_buf = &packet->pwrdown_cmd[0]; 1153 + x->len = 3; 1154 + } else { 1155 + x++; 1156 + packet->pwrdown = PWRDOWN; 1157 + x->tx_buf = &packet->pwrdown; 1158 + x->len = 1; 1159 + spi_message_add_tail(x, m); 1160 1161 + x++; 1162 + x->rx_buf = &packet->dummy; 1163 + x->len = 2; 1164 + } 1165 + 1166 CS_CHANGE(*x); 1167 spi_message_add_tail(x, m); 1168 ··· 1174 goto err_put_regulator; 1175 } 1176 1177 + irq_flags = pdata->irq_flags ? : IRQF_TRIGGER_FALLING; 1178 + 1179 + err = request_irq(spi->irq, ads7846_irq, irq_flags, 1180 + spi->dev.driver->name, ts); 1181 + 1182 + if (err && !pdata->irq_flags) { 1183 dev_info(&spi->dev, 1184 "trying pin change workaround on irq %d\n", spi->irq); 1185 err = request_irq(spi->irq, ads7846_irq, 1186 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, 1187 spi->dev.driver->name, ts); 1188 + } 1189 + 1190 + if (err) { 1191 + dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 1192 + goto err_disable_regulator; 1193 } 1194 1195 err = ads784x_hwmon_register(spi, ts); ··· 1196 /* take a first sample, leaving nPENIRQ active and vREF off; avoid 1197 * the touchscreen, in case it's not connected. 1198 */ 1199 + if (ts->model == 7845) 1200 + ads7845_read12_ser(&spi->dev, PWRDOWN); 1201 + else 1202 + (void) ads7846_read12_ser(&spi->dev, 1203 + READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON); 1204 1205 err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group); 1206 if (err)
+363
drivers/input/touchscreen/cy8ctmg110_ts.c
···
··· 1 + /* 2 + * Driver for cypress touch screen controller 3 + * 4 + * Copyright (c) 2009 Aava Mobile 5 + * 6 + * Some cleanups by Alan Cox <alan@linux.intel.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 + */ 21 + 22 + #include <linux/module.h> 23 + #include <linux/kernel.h> 24 + #include <linux/input.h> 25 + #include <linux/slab.h> 26 + #include <linux/interrupt.h> 27 + #include <linux/io.h> 28 + #include <linux/i2c.h> 29 + #include <linux/gpio.h> 30 + #include <linux/input/cy8ctmg110_pdata.h> 31 + 32 + #define CY8CTMG110_DRIVER_NAME "cy8ctmg110" 33 + 34 + /* Touch coordinates */ 35 + #define CY8CTMG110_X_MIN 0 36 + #define CY8CTMG110_Y_MIN 0 37 + #define CY8CTMG110_X_MAX 759 38 + #define CY8CTMG110_Y_MAX 465 39 + 40 + 41 + /* cy8ctmg110 register definitions */ 42 + #define CY8CTMG110_TOUCH_WAKEUP_TIME 0 43 + #define CY8CTMG110_TOUCH_SLEEP_TIME 2 44 + #define CY8CTMG110_TOUCH_X1 3 45 + #define CY8CTMG110_TOUCH_Y1 5 46 + #define CY8CTMG110_TOUCH_X2 7 47 + #define CY8CTMG110_TOUCH_Y2 9 48 + #define CY8CTMG110_FINGERS 11 49 + #define CY8CTMG110_GESTURE 12 50 + #define CY8CTMG110_REG_MAX 13 51 + 52 + 53 + /* 54 + * The touch driver structure. 55 + */ 56 + struct cy8ctmg110 { 57 + struct input_dev *input; 58 + char phys[32]; 59 + struct i2c_client *client; 60 + int reset_pin; 61 + int irq_pin; 62 + }; 63 + 64 + /* 65 + * cy8ctmg110_power is the routine that is called when touch hardware 66 + * will powered off or on. 67 + */ 68 + static void cy8ctmg110_power(struct cy8ctmg110 *ts, bool poweron) 69 + { 70 + if (ts->reset_pin) 71 + gpio_direction_output(ts->reset_pin, 1 - poweron); 72 + } 73 + 74 + static int cy8ctmg110_write_regs(struct cy8ctmg110 *tsc, unsigned char reg, 75 + unsigned char len, unsigned char *value) 76 + { 77 + struct i2c_client *client = tsc->client; 78 + unsigned int ret; 79 + unsigned char i2c_data[6]; 80 + 81 + BUG_ON(len > 5); 82 + 83 + i2c_data[0] = reg; 84 + memcpy(i2c_data + 1, value, len); 85 + 86 + ret = i2c_master_send(client, i2c_data, len + 1); 87 + if (ret != 1) { 88 + dev_err(&client->dev, "i2c write data cmd failed\n"); 89 + return ret; 90 + } 91 + 92 + return 0; 93 + } 94 + 95 + static int cy8ctmg110_read_regs(struct cy8ctmg110 *tsc, 96 + unsigned char *data, unsigned char len, unsigned char cmd) 97 + { 98 + struct i2c_client *client = tsc->client; 99 + unsigned int ret; 100 + struct i2c_msg msg[2] = { 101 + /* first write slave position to i2c devices */ 102 + { client->addr, 0, 1, &cmd }, 103 + /* Second read data from position */ 104 + { client->addr, I2C_M_RD, len, data } 105 + }; 106 + 107 + ret = i2c_transfer(client->adapter, msg, 2); 108 + if (ret < 0) 109 + return ret; 110 + 111 + return 0; 112 + } 113 + 114 + static int cy8ctmg110_touch_pos(struct cy8ctmg110 *tsc) 115 + { 116 + struct input_dev *input = tsc->input; 117 + unsigned char reg_p[CY8CTMG110_REG_MAX]; 118 + int x, y; 119 + 120 + memset(reg_p, 0, CY8CTMG110_REG_MAX); 121 + 122 + /* Reading coordinates */ 123 + if (cy8ctmg110_read_regs(tsc, reg_p, 9, CY8CTMG110_TOUCH_X1) != 0) 124 + return -EIO; 125 + 126 + y = reg_p[2] << 8 | reg_p[3]; 127 + x = reg_p[0] << 8 | reg_p[1]; 128 + 129 + /* Number of touch */ 130 + if (reg_p[8] == 0) { 131 + input_report_key(input, BTN_TOUCH, 0); 132 + } else { 133 + input_report_key(input, BTN_TOUCH, 1); 134 + input_report_abs(input, ABS_X, x); 135 + input_report_abs(input, ABS_Y, y); 136 + } 137 + 138 + input_sync(input); 139 + 140 + return 0; 141 + } 142 + 143 + static int cy8ctmg110_set_sleepmode(struct cy8ctmg110 *ts, bool sleep) 144 + { 145 + unsigned char reg_p[3]; 146 + 147 + if (sleep) { 148 + reg_p[0] = 0x00; 149 + reg_p[1] = 0xff; 150 + reg_p[2] = 5; 151 + } else { 152 + reg_p[0] = 0x10; 153 + reg_p[1] = 0xff; 154 + reg_p[2] = 0; 155 + } 156 + 157 + return cy8ctmg110_write_regs(ts, CY8CTMG110_TOUCH_WAKEUP_TIME, 3, reg_p); 158 + } 159 + 160 + static irqreturn_t cy8ctmg110_irq_thread(int irq, void *dev_id) 161 + { 162 + struct cy8ctmg110 *tsc = dev_id; 163 + 164 + cy8ctmg110_touch_pos(tsc); 165 + 166 + return IRQ_HANDLED; 167 + } 168 + 169 + static int __devinit cy8ctmg110_probe(struct i2c_client *client, 170 + const struct i2c_device_id *id) 171 + { 172 + const struct cy8ctmg110_pdata *pdata = client->dev.platform_data; 173 + struct cy8ctmg110 *ts; 174 + struct input_dev *input_dev; 175 + int err; 176 + 177 + /* No pdata no way forward */ 178 + if (pdata == NULL) { 179 + dev_err(&client->dev, "no pdata\n"); 180 + return -ENODEV; 181 + } 182 + 183 + if (!i2c_check_functionality(client->adapter, 184 + I2C_FUNC_SMBUS_READ_WORD_DATA)) 185 + return -EIO; 186 + 187 + ts = kzalloc(sizeof(struct cy8ctmg110), GFP_KERNEL); 188 + input_dev = input_allocate_device(); 189 + if (!ts || !input_dev) { 190 + err = -ENOMEM; 191 + goto err_free_mem; 192 + } 193 + 194 + ts->client = client; 195 + ts->input = input_dev; 196 + 197 + snprintf(ts->phys, sizeof(ts->phys), 198 + "%s/input0", dev_name(&client->dev)); 199 + 200 + input_dev->name = CY8CTMG110_DRIVER_NAME " Touchscreen"; 201 + input_dev->phys = ts->phys; 202 + input_dev->id.bustype = BUS_I2C; 203 + input_dev->dev.parent = &client->dev; 204 + 205 + input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 206 + input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 207 + 208 + input_set_abs_params(input_dev, ABS_X, 209 + CY8CTMG110_X_MIN, CY8CTMG110_X_MAX, 0, 0); 210 + input_set_abs_params(input_dev, ABS_Y, 211 + CY8CTMG110_Y_MIN, CY8CTMG110_Y_MAX, 0, 0); 212 + 213 + if (ts->reset_pin) { 214 + err = gpio_request(ts->reset_pin, NULL); 215 + if (err) { 216 + dev_err(&client->dev, 217 + "Unable to request GPIO pin %d.\n", 218 + ts->reset_pin); 219 + goto err_free_mem; 220 + } 221 + } 222 + 223 + cy8ctmg110_power(ts, true); 224 + cy8ctmg110_set_sleepmode(ts, false); 225 + 226 + err = gpio_request(ts->irq_pin, "touch_irq_key"); 227 + if (err < 0) { 228 + dev_err(&client->dev, 229 + "Failed to request GPIO %d, error %d\n", 230 + ts->irq_pin, err); 231 + goto err_shutoff_device; 232 + } 233 + 234 + err = gpio_direction_input(ts->irq_pin); 235 + if (err < 0) { 236 + dev_err(&client->dev, 237 + "Failed to configure input direction for GPIO %d, error %d\n", 238 + ts->irq_pin, err); 239 + goto err_free_irq_gpio; 240 + } 241 + 242 + client->irq = gpio_to_irq(ts->irq_pin); 243 + if (client->irq < 0) { 244 + err = client->irq; 245 + dev_err(&client->dev, 246 + "Unable to get irq number for GPIO %d, error %d\n", 247 + ts->irq_pin, err); 248 + goto err_free_irq_gpio; 249 + } 250 + 251 + err = request_threaded_irq(client->irq, NULL, cy8ctmg110_irq_thread, 252 + IRQF_TRIGGER_RISING, "touch_reset_key", ts); 253 + if (err < 0) { 254 + dev_err(&client->dev, 255 + "irq %d busy? error %d\n", client->irq, err); 256 + goto err_free_irq_gpio; 257 + } 258 + 259 + err = input_register_device(input_dev); 260 + if (err) 261 + goto err_free_irq; 262 + 263 + i2c_set_clientdata(client, ts); 264 + device_init_wakeup(&client->dev, 1); 265 + return 0; 266 + 267 + err_free_irq: 268 + free_irq(client->irq, ts); 269 + err_free_irq_gpio: 270 + gpio_free(ts->irq_pin); 271 + err_shutoff_device: 272 + cy8ctmg110_set_sleepmode(ts, true); 273 + cy8ctmg110_power(ts, false); 274 + if (ts->reset_pin) 275 + gpio_free(ts->reset_pin); 276 + err_free_mem: 277 + input_free_device(input_dev); 278 + kfree(ts); 279 + return err; 280 + } 281 + 282 + #ifdef CONFIG_PM 283 + static int cy8ctmg110_suspend(struct i2c_client *client, pm_message_t mesg) 284 + { 285 + struct cy8ctmg110 *ts = i2c_get_clientdata(client); 286 + 287 + if (device_may_wakeup(&client->dev)) 288 + enable_irq_wake(client->irq); 289 + else { 290 + cy8ctmg110_set_sleepmode(ts, true); 291 + cy8ctmg110_power(ts, false); 292 + } 293 + return 0; 294 + } 295 + 296 + static int cy8ctmg110_resume(struct i2c_client *client) 297 + { 298 + struct cy8ctmg110 *ts = i2c_get_clientdata(client); 299 + 300 + if (device_may_wakeup(&client->dev)) 301 + disable_irq_wake(client->irq); 302 + else { 303 + cy8ctmg110_power(ts, true); 304 + cy8ctmg110_set_sleepmode(ts, false); 305 + } 306 + return 0; 307 + } 308 + #endif 309 + 310 + static int __devexit cy8ctmg110_remove(struct i2c_client *client) 311 + { 312 + struct cy8ctmg110 *ts = i2c_get_clientdata(client); 313 + 314 + cy8ctmg110_set_sleepmode(ts, true); 315 + cy8ctmg110_power(ts, false); 316 + 317 + free_irq(client->irq, ts); 318 + input_unregister_device(ts->input); 319 + gpio_free(ts->irq_pin); 320 + if (ts->reset_pin) 321 + gpio_free(ts->reset_pin); 322 + kfree(ts); 323 + 324 + return 0; 325 + } 326 + 327 + static struct i2c_device_id cy8ctmg110_idtable[] = { 328 + { CY8CTMG110_DRIVER_NAME, 1 }, 329 + { } 330 + }; 331 + 332 + MODULE_DEVICE_TABLE(i2c, cy8ctmg110_idtable); 333 + 334 + static struct i2c_driver cy8ctmg110_driver = { 335 + .driver = { 336 + .owner = THIS_MODULE, 337 + .name = CY8CTMG110_DRIVER_NAME, 338 + }, 339 + .id_table = cy8ctmg110_idtable, 340 + .probe = cy8ctmg110_probe, 341 + .remove = __devexit_p(cy8ctmg110_remove), 342 + #ifdef CONFIG_PM 343 + .suspend = cy8ctmg110_suspend, 344 + .resume = cy8ctmg110_resume, 345 + #endif 346 + }; 347 + 348 + static int __init cy8ctmg110_init(void) 349 + { 350 + return i2c_add_driver(&cy8ctmg110_driver); 351 + } 352 + 353 + static void __exit cy8ctmg110_exit(void) 354 + { 355 + i2c_del_driver(&cy8ctmg110_driver); 356 + } 357 + 358 + module_init(cy8ctmg110_init); 359 + module_exit(cy8ctmg110_exit); 360 + 361 + MODULE_AUTHOR("Samuli Konttila <samuli.konttila@aavamobile.com>"); 362 + MODULE_DESCRIPTION("cy8ctmg110 TouchScreen Driver"); 363 + MODULE_LICENSE("GPL v2");
+3 -3
drivers/input/touchscreen/mcs5000_ts.c
··· 16 #include <linux/module.h> 17 #include <linux/init.h> 18 #include <linux/i2c.h> 19 - #include <linux/i2c/mcs5000_ts.h> 20 #include <linux/interrupt.h> 21 #include <linux/input.h> 22 #include <linux/irq.h> ··· 105 struct mcs5000_ts_data { 106 struct i2c_client *client; 107 struct input_dev *input_dev; 108 - const struct mcs5000_ts_platform_data *platform_data; 109 }; 110 111 static irqreturn_t mcs5000_ts_interrupt(int irq, void *dev_id) ··· 164 165 static void mcs5000_ts_phys_init(struct mcs5000_ts_data *data) 166 { 167 - const struct mcs5000_ts_platform_data *platform_data = 168 data->platform_data; 169 struct i2c_client *client = data->client; 170
··· 16 #include <linux/module.h> 17 #include <linux/init.h> 18 #include <linux/i2c.h> 19 + #include <linux/i2c/mcs.h> 20 #include <linux/interrupt.h> 21 #include <linux/input.h> 22 #include <linux/irq.h> ··· 105 struct mcs5000_ts_data { 106 struct i2c_client *client; 107 struct input_dev *input_dev; 108 + const struct mcs_platform_data *platform_data; 109 }; 110 111 static irqreturn_t mcs5000_ts_interrupt(int irq, void *dev_id) ··· 164 165 static void mcs5000_ts_phys_init(struct mcs5000_ts_data *data) 166 { 167 + const struct mcs_platform_data *platform_data = 168 data->platform_data; 169 struct i2c_client *client = data->client; 170
+1401
drivers/input/touchscreen/qt602240_ts.c
···
··· 1 + /* 2 + * AT42QT602240/ATMXT224 Touchscreen driver 3 + * 4 + * Copyright (C) 2010 Samsung Electronics Co.Ltd 5 + * Author: Joonyoung Shim <jy0922.shim@samsung.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; either version 2 of the License, or (at your 10 + * option) any later version. 11 + * 12 + */ 13 + 14 + #include <linux/module.h> 15 + #include <linux/init.h> 16 + #include <linux/delay.h> 17 + #include <linux/firmware.h> 18 + #include <linux/i2c.h> 19 + #include <linux/i2c/qt602240_ts.h> 20 + #include <linux/input.h> 21 + #include <linux/interrupt.h> 22 + #include <linux/slab.h> 23 + 24 + /* Version */ 25 + #define QT602240_VER_20 20 26 + #define QT602240_VER_21 21 27 + #define QT602240_VER_22 22 28 + 29 + /* Slave addresses */ 30 + #define QT602240_APP_LOW 0x4a 31 + #define QT602240_APP_HIGH 0x4b 32 + #define QT602240_BOOT_LOW 0x24 33 + #define QT602240_BOOT_HIGH 0x25 34 + 35 + /* Firmware */ 36 + #define QT602240_FW_NAME "qt602240.fw" 37 + 38 + /* Registers */ 39 + #define QT602240_FAMILY_ID 0x00 40 + #define QT602240_VARIANT_ID 0x01 41 + #define QT602240_VERSION 0x02 42 + #define QT602240_BUILD 0x03 43 + #define QT602240_MATRIX_X_SIZE 0x04 44 + #define QT602240_MATRIX_Y_SIZE 0x05 45 + #define QT602240_OBJECT_NUM 0x06 46 + #define QT602240_OBJECT_START 0x07 47 + 48 + #define QT602240_OBJECT_SIZE 6 49 + 50 + /* Object types */ 51 + #define QT602240_DEBUG_DIAGNOSTIC 37 52 + #define QT602240_GEN_MESSAGE 5 53 + #define QT602240_GEN_COMMAND 6 54 + #define QT602240_GEN_POWER 7 55 + #define QT602240_GEN_ACQUIRE 8 56 + #define QT602240_TOUCH_MULTI 9 57 + #define QT602240_TOUCH_KEYARRAY 15 58 + #define QT602240_TOUCH_PROXIMITY 23 59 + #define QT602240_PROCI_GRIPFACE 20 60 + #define QT602240_PROCG_NOISE 22 61 + #define QT602240_PROCI_ONETOUCH 24 62 + #define QT602240_PROCI_TWOTOUCH 27 63 + #define QT602240_SPT_COMMSCONFIG 18 /* firmware ver 21 over */ 64 + #define QT602240_SPT_GPIOPWM 19 65 + #define QT602240_SPT_SELFTEST 25 66 + #define QT602240_SPT_CTECONFIG 28 67 + #define QT602240_SPT_USERDATA 38 /* firmware ver 21 over */ 68 + 69 + /* QT602240_GEN_COMMAND field */ 70 + #define QT602240_COMMAND_RESET 0 71 + #define QT602240_COMMAND_BACKUPNV 1 72 + #define QT602240_COMMAND_CALIBRATE 2 73 + #define QT602240_COMMAND_REPORTALL 3 74 + #define QT602240_COMMAND_DIAGNOSTIC 5 75 + 76 + /* QT602240_GEN_POWER field */ 77 + #define QT602240_POWER_IDLEACQINT 0 78 + #define QT602240_POWER_ACTVACQINT 1 79 + #define QT602240_POWER_ACTV2IDLETO 2 80 + 81 + /* QT602240_GEN_ACQUIRE field */ 82 + #define QT602240_ACQUIRE_CHRGTIME 0 83 + #define QT602240_ACQUIRE_TCHDRIFT 2 84 + #define QT602240_ACQUIRE_DRIFTST 3 85 + #define QT602240_ACQUIRE_TCHAUTOCAL 4 86 + #define QT602240_ACQUIRE_SYNC 5 87 + #define QT602240_ACQUIRE_ATCHCALST 6 88 + #define QT602240_ACQUIRE_ATCHCALSTHR 7 89 + 90 + /* QT602240_TOUCH_MULTI field */ 91 + #define QT602240_TOUCH_CTRL 0 92 + #define QT602240_TOUCH_XORIGIN 1 93 + #define QT602240_TOUCH_YORIGIN 2 94 + #define QT602240_TOUCH_XSIZE 3 95 + #define QT602240_TOUCH_YSIZE 4 96 + #define QT602240_TOUCH_BLEN 6 97 + #define QT602240_TOUCH_TCHTHR 7 98 + #define QT602240_TOUCH_TCHDI 8 99 + #define QT602240_TOUCH_ORIENT 9 100 + #define QT602240_TOUCH_MOVHYSTI 11 101 + #define QT602240_TOUCH_MOVHYSTN 12 102 + #define QT602240_TOUCH_NUMTOUCH 14 103 + #define QT602240_TOUCH_MRGHYST 15 104 + #define QT602240_TOUCH_MRGTHR 16 105 + #define QT602240_TOUCH_AMPHYST 17 106 + #define QT602240_TOUCH_XRANGE_LSB 18 107 + #define QT602240_TOUCH_XRANGE_MSB 19 108 + #define QT602240_TOUCH_YRANGE_LSB 20 109 + #define QT602240_TOUCH_YRANGE_MSB 21 110 + #define QT602240_TOUCH_XLOCLIP 22 111 + #define QT602240_TOUCH_XHICLIP 23 112 + #define QT602240_TOUCH_YLOCLIP 24 113 + #define QT602240_TOUCH_YHICLIP 25 114 + #define QT602240_TOUCH_XEDGECTRL 26 115 + #define QT602240_TOUCH_XEDGEDIST 27 116 + #define QT602240_TOUCH_YEDGECTRL 28 117 + #define QT602240_TOUCH_YEDGEDIST 29 118 + #define QT602240_TOUCH_JUMPLIMIT 30 /* firmware ver 22 over */ 119 + 120 + /* QT602240_PROCI_GRIPFACE field */ 121 + #define QT602240_GRIPFACE_CTRL 0 122 + #define QT602240_GRIPFACE_XLOGRIP 1 123 + #define QT602240_GRIPFACE_XHIGRIP 2 124 + #define QT602240_GRIPFACE_YLOGRIP 3 125 + #define QT602240_GRIPFACE_YHIGRIP 4 126 + #define QT602240_GRIPFACE_MAXTCHS 5 127 + #define QT602240_GRIPFACE_SZTHR1 7 128 + #define QT602240_GRIPFACE_SZTHR2 8 129 + #define QT602240_GRIPFACE_SHPTHR1 9 130 + #define QT602240_GRIPFACE_SHPTHR2 10 131 + #define QT602240_GRIPFACE_SUPEXTTO 11 132 + 133 + /* QT602240_PROCI_NOISE field */ 134 + #define QT602240_NOISE_CTRL 0 135 + #define QT602240_NOISE_OUTFLEN 1 136 + #define QT602240_NOISE_GCAFUL_LSB 3 137 + #define QT602240_NOISE_GCAFUL_MSB 4 138 + #define QT602240_NOISE_GCAFLL_LSB 5 139 + #define QT602240_NOISE_GCAFLL_MSB 6 140 + #define QT602240_NOISE_ACTVGCAFVALID 7 141 + #define QT602240_NOISE_NOISETHR 8 142 + #define QT602240_NOISE_FREQHOPSCALE 10 143 + #define QT602240_NOISE_FREQ0 11 144 + #define QT602240_NOISE_FREQ1 12 145 + #define QT602240_NOISE_FREQ2 13 146 + #define QT602240_NOISE_FREQ3 14 147 + #define QT602240_NOISE_FREQ4 15 148 + #define QT602240_NOISE_IDLEGCAFVALID 16 149 + 150 + /* QT602240_SPT_COMMSCONFIG */ 151 + #define QT602240_COMMS_CTRL 0 152 + #define QT602240_COMMS_CMD 1 153 + 154 + /* QT602240_SPT_CTECONFIG field */ 155 + #define QT602240_CTE_CTRL 0 156 + #define QT602240_CTE_CMD 1 157 + #define QT602240_CTE_MODE 2 158 + #define QT602240_CTE_IDLEGCAFDEPTH 3 159 + #define QT602240_CTE_ACTVGCAFDEPTH 4 160 + #define QT602240_CTE_VOLTAGE 5 /* firmware ver 21 over */ 161 + 162 + #define QT602240_VOLTAGE_DEFAULT 2700000 163 + #define QT602240_VOLTAGE_STEP 10000 164 + 165 + /* Define for QT602240_GEN_COMMAND */ 166 + #define QT602240_BOOT_VALUE 0xa5 167 + #define QT602240_BACKUP_VALUE 0x55 168 + #define QT602240_BACKUP_TIME 25 /* msec */ 169 + #define QT602240_RESET_TIME 65 /* msec */ 170 + 171 + #define QT602240_FWRESET_TIME 175 /* msec */ 172 + 173 + /* Command to unlock bootloader */ 174 + #define QT602240_UNLOCK_CMD_MSB 0xaa 175 + #define QT602240_UNLOCK_CMD_LSB 0xdc 176 + 177 + /* Bootloader mode status */ 178 + #define QT602240_WAITING_BOOTLOAD_CMD 0xc0 /* valid 7 6 bit only */ 179 + #define QT602240_WAITING_FRAME_DATA 0x80 /* valid 7 6 bit only */ 180 + #define QT602240_FRAME_CRC_CHECK 0x02 181 + #define QT602240_FRAME_CRC_FAIL 0x03 182 + #define QT602240_FRAME_CRC_PASS 0x04 183 + #define QT602240_APP_CRC_FAIL 0x40 /* valid 7 8 bit only */ 184 + #define QT602240_BOOT_STATUS_MASK 0x3f 185 + 186 + /* Touch status */ 187 + #define QT602240_SUPPRESS (1 << 1) 188 + #define QT602240_AMP (1 << 2) 189 + #define QT602240_VECTOR (1 << 3) 190 + #define QT602240_MOVE (1 << 4) 191 + #define QT602240_RELEASE (1 << 5) 192 + #define QT602240_PRESS (1 << 6) 193 + #define QT602240_DETECT (1 << 7) 194 + 195 + /* Touchscreen absolute values */ 196 + #define QT602240_MAX_XC 0x3ff 197 + #define QT602240_MAX_YC 0x3ff 198 + #define QT602240_MAX_AREA 0xff 199 + 200 + #define QT602240_MAX_FINGER 10 201 + 202 + /* Initial register values recommended from chip vendor */ 203 + static const u8 init_vals_ver_20[] = { 204 + /* QT602240_GEN_COMMAND(6) */ 205 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 206 + /* QT602240_GEN_POWER(7) */ 207 + 0x20, 0xff, 0x32, 208 + /* QT602240_GEN_ACQUIRE(8) */ 209 + 0x08, 0x05, 0x05, 0x00, 0x00, 0x00, 0x05, 0x14, 210 + /* QT602240_TOUCH_MULTI(9) */ 211 + 0x00, 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 212 + 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 213 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x64, 214 + /* QT602240_TOUCH_KEYARRAY(15) */ 215 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 216 + 0x00, 217 + /* QT602240_SPT_GPIOPWM(19) */ 218 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 219 + 0x00, 0x00, 220 + /* QT602240_PROCI_GRIPFACE(20) */ 221 + 0x00, 0x64, 0x64, 0x64, 0x64, 0x00, 0x00, 0x1e, 0x14, 0x04, 222 + 0x1e, 0x00, 223 + /* QT602240_PROCG_NOISE(22) */ 224 + 0x05, 0x00, 0x00, 0x19, 0x00, 0xe7, 0xff, 0x04, 0x32, 0x00, 225 + 0x01, 0x0a, 0x0f, 0x14, 0x00, 0x00, 0xe8, 226 + /* QT602240_TOUCH_PROXIMITY(23) */ 227 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 228 + 0x00, 0x00, 0x00, 229 + /* QT602240_PROCI_ONETOUCH(24) */ 230 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 231 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 232 + /* QT602240_SPT_SELFTEST(25) */ 233 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 234 + 0x00, 0x00, 0x00, 0x00, 235 + /* QT602240_PROCI_TWOTOUCH(27) */ 236 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 237 + /* QT602240_SPT_CTECONFIG(28) */ 238 + 0x00, 0x00, 0x00, 0x04, 0x08, 239 + }; 240 + 241 + static const u8 init_vals_ver_21[] = { 242 + /* QT602240_GEN_COMMAND(6) */ 243 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 244 + /* QT602240_GEN_POWER(7) */ 245 + 0x20, 0xff, 0x32, 246 + /* QT602240_GEN_ACQUIRE(8) */ 247 + 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23, 248 + /* QT602240_TOUCH_MULTI(9) */ 249 + 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 250 + 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 251 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 252 + /* QT602240_TOUCH_KEYARRAY(15) */ 253 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 254 + 0x00, 255 + /* QT602240_SPT_GPIOPWM(19) */ 256 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 257 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 258 + /* QT602240_PROCI_GRIPFACE(20) */ 259 + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04, 260 + 0x0f, 0x0a, 261 + /* QT602240_PROCG_NOISE(22) */ 262 + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00, 263 + 0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03, 264 + /* QT602240_TOUCH_PROXIMITY(23) */ 265 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 266 + 0x00, 0x00, 0x00, 267 + /* QT602240_PROCI_ONETOUCH(24) */ 268 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 269 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 270 + /* QT602240_SPT_SELFTEST(25) */ 271 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 272 + 0x00, 0x00, 0x00, 0x00, 273 + /* QT602240_PROCI_TWOTOUCH(27) */ 274 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 275 + /* QT602240_SPT_CTECONFIG(28) */ 276 + 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 277 + }; 278 + 279 + static const u8 init_vals_ver_22[] = { 280 + /* QT602240_GEN_COMMAND(6) */ 281 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 282 + /* QT602240_GEN_POWER(7) */ 283 + 0x20, 0xff, 0x32, 284 + /* QT602240_GEN_ACQUIRE(8) */ 285 + 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23, 286 + /* QT602240_TOUCH_MULTI(9) */ 287 + 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 288 + 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 289 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 290 + 0x00, 291 + /* QT602240_TOUCH_KEYARRAY(15) */ 292 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 293 + 0x00, 294 + /* QT602240_SPT_GPIOPWM(19) */ 295 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 296 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 297 + /* QT602240_PROCI_GRIPFACE(20) */ 298 + 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04, 299 + 0x0f, 0x0a, 300 + /* QT602240_PROCG_NOISE(22) */ 301 + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00, 302 + 0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03, 303 + /* QT602240_TOUCH_PROXIMITY(23) */ 304 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 305 + 0x00, 0x00, 0x00, 0x00, 0x00, 306 + /* QT602240_PROCI_ONETOUCH(24) */ 307 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 308 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 309 + /* QT602240_SPT_SELFTEST(25) */ 310 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 311 + 0x00, 0x00, 0x00, 0x00, 312 + /* QT602240_PROCI_TWOTOUCH(27) */ 313 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 314 + /* QT602240_SPT_CTECONFIG(28) */ 315 + 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 316 + }; 317 + 318 + struct qt602240_info { 319 + u8 family_id; 320 + u8 variant_id; 321 + u8 version; 322 + u8 build; 323 + u8 matrix_xsize; 324 + u8 matrix_ysize; 325 + u8 object_num; 326 + }; 327 + 328 + struct qt602240_object { 329 + u8 type; 330 + u16 start_address; 331 + u8 size; 332 + u8 instances; 333 + u8 num_report_ids; 334 + 335 + /* to map object and message */ 336 + u8 max_reportid; 337 + }; 338 + 339 + struct qt602240_message { 340 + u8 reportid; 341 + u8 message[7]; 342 + u8 checksum; 343 + }; 344 + 345 + struct qt602240_finger { 346 + int status; 347 + int x; 348 + int y; 349 + int area; 350 + }; 351 + 352 + /* Each client has this additional data */ 353 + struct qt602240_data { 354 + struct i2c_client *client; 355 + struct input_dev *input_dev; 356 + const struct qt602240_platform_data *pdata; 357 + struct qt602240_object *object_table; 358 + struct qt602240_info info; 359 + struct qt602240_finger finger[QT602240_MAX_FINGER]; 360 + unsigned int irq; 361 + }; 362 + 363 + static bool qt602240_object_readable(unsigned int type) 364 + { 365 + switch (type) { 366 + case QT602240_GEN_MESSAGE: 367 + case QT602240_GEN_COMMAND: 368 + case QT602240_GEN_POWER: 369 + case QT602240_GEN_ACQUIRE: 370 + case QT602240_TOUCH_MULTI: 371 + case QT602240_TOUCH_KEYARRAY: 372 + case QT602240_TOUCH_PROXIMITY: 373 + case QT602240_PROCI_GRIPFACE: 374 + case QT602240_PROCG_NOISE: 375 + case QT602240_PROCI_ONETOUCH: 376 + case QT602240_PROCI_TWOTOUCH: 377 + case QT602240_SPT_COMMSCONFIG: 378 + case QT602240_SPT_GPIOPWM: 379 + case QT602240_SPT_SELFTEST: 380 + case QT602240_SPT_CTECONFIG: 381 + case QT602240_SPT_USERDATA: 382 + return true; 383 + default: 384 + return false; 385 + } 386 + } 387 + 388 + static bool qt602240_object_writable(unsigned int type) 389 + { 390 + switch (type) { 391 + case QT602240_GEN_COMMAND: 392 + case QT602240_GEN_POWER: 393 + case QT602240_GEN_ACQUIRE: 394 + case QT602240_TOUCH_MULTI: 395 + case QT602240_TOUCH_KEYARRAY: 396 + case QT602240_TOUCH_PROXIMITY: 397 + case QT602240_PROCI_GRIPFACE: 398 + case QT602240_PROCG_NOISE: 399 + case QT602240_PROCI_ONETOUCH: 400 + case QT602240_PROCI_TWOTOUCH: 401 + case QT602240_SPT_GPIOPWM: 402 + case QT602240_SPT_SELFTEST: 403 + case QT602240_SPT_CTECONFIG: 404 + return true; 405 + default: 406 + return false; 407 + } 408 + } 409 + 410 + static void qt602240_dump_message(struct device *dev, 411 + struct qt602240_message *message) 412 + { 413 + dev_dbg(dev, "reportid:\t0x%x\n", message->reportid); 414 + dev_dbg(dev, "message1:\t0x%x\n", message->message[0]); 415 + dev_dbg(dev, "message2:\t0x%x\n", message->message[1]); 416 + dev_dbg(dev, "message3:\t0x%x\n", message->message[2]); 417 + dev_dbg(dev, "message4:\t0x%x\n", message->message[3]); 418 + dev_dbg(dev, "message5:\t0x%x\n", message->message[4]); 419 + dev_dbg(dev, "message6:\t0x%x\n", message->message[5]); 420 + dev_dbg(dev, "message7:\t0x%x\n", message->message[6]); 421 + dev_dbg(dev, "checksum:\t0x%x\n", message->checksum); 422 + } 423 + 424 + static int qt602240_check_bootloader(struct i2c_client *client, 425 + unsigned int state) 426 + { 427 + u8 val; 428 + 429 + recheck: 430 + if (i2c_master_recv(client, &val, 1) != 1) { 431 + dev_err(&client->dev, "%s: i2c recv failed\n", __func__); 432 + return -EIO; 433 + } 434 + 435 + switch (state) { 436 + case QT602240_WAITING_BOOTLOAD_CMD: 437 + case QT602240_WAITING_FRAME_DATA: 438 + val &= ~QT602240_BOOT_STATUS_MASK; 439 + break; 440 + case QT602240_FRAME_CRC_PASS: 441 + if (val == QT602240_FRAME_CRC_CHECK) 442 + goto recheck; 443 + break; 444 + default: 445 + return -EINVAL; 446 + } 447 + 448 + if (val != state) { 449 + dev_err(&client->dev, "Unvalid bootloader mode state\n"); 450 + return -EINVAL; 451 + } 452 + 453 + return 0; 454 + } 455 + 456 + static int qt602240_unlock_bootloader(struct i2c_client *client) 457 + { 458 + u8 buf[2]; 459 + 460 + buf[0] = QT602240_UNLOCK_CMD_LSB; 461 + buf[1] = QT602240_UNLOCK_CMD_MSB; 462 + 463 + if (i2c_master_send(client, buf, 2) != 2) { 464 + dev_err(&client->dev, "%s: i2c send failed\n", __func__); 465 + return -EIO; 466 + } 467 + 468 + return 0; 469 + } 470 + 471 + static int qt602240_fw_write(struct i2c_client *client, 472 + const u8 *data, unsigned int frame_size) 473 + { 474 + if (i2c_master_send(client, data, frame_size) != frame_size) { 475 + dev_err(&client->dev, "%s: i2c send failed\n", __func__); 476 + return -EIO; 477 + } 478 + 479 + return 0; 480 + } 481 + 482 + static int __qt602240_read_reg(struct i2c_client *client, 483 + u16 reg, u16 len, void *val) 484 + { 485 + struct i2c_msg xfer[2]; 486 + u8 buf[2]; 487 + 488 + buf[0] = reg & 0xff; 489 + buf[1] = (reg >> 8) & 0xff; 490 + 491 + /* Write register */ 492 + xfer[0].addr = client->addr; 493 + xfer[0].flags = 0; 494 + xfer[0].len = 2; 495 + xfer[0].buf = buf; 496 + 497 + /* Read data */ 498 + xfer[1].addr = client->addr; 499 + xfer[1].flags = I2C_M_RD; 500 + xfer[1].len = len; 501 + xfer[1].buf = val; 502 + 503 + if (i2c_transfer(client->adapter, xfer, 2) != 2) { 504 + dev_err(&client->dev, "%s: i2c transfer failed\n", __func__); 505 + return -EIO; 506 + } 507 + 508 + return 0; 509 + } 510 + 511 + static int qt602240_read_reg(struct i2c_client *client, u16 reg, u8 *val) 512 + { 513 + return __qt602240_read_reg(client, reg, 1, val); 514 + } 515 + 516 + static int qt602240_write_reg(struct i2c_client *client, u16 reg, u8 val) 517 + { 518 + u8 buf[3]; 519 + 520 + buf[0] = reg & 0xff; 521 + buf[1] = (reg >> 8) & 0xff; 522 + buf[2] = val; 523 + 524 + if (i2c_master_send(client, buf, 3) != 3) { 525 + dev_err(&client->dev, "%s: i2c send failed\n", __func__); 526 + return -EIO; 527 + } 528 + 529 + return 0; 530 + } 531 + 532 + static int qt602240_read_object_table(struct i2c_client *client, 533 + u16 reg, u8 *object_buf) 534 + { 535 + return __qt602240_read_reg(client, reg, QT602240_OBJECT_SIZE, 536 + object_buf); 537 + } 538 + 539 + static struct qt602240_object * 540 + qt602240_get_object(struct qt602240_data *data, u8 type) 541 + { 542 + struct qt602240_object *object; 543 + int i; 544 + 545 + for (i = 0; i < data->info.object_num; i++) { 546 + object = data->object_table + i; 547 + if (object->type == type) 548 + return object; 549 + } 550 + 551 + dev_err(&data->client->dev, "Invalid object type\n"); 552 + return NULL; 553 + } 554 + 555 + static int qt602240_read_message(struct qt602240_data *data, 556 + struct qt602240_message *message) 557 + { 558 + struct qt602240_object *object; 559 + u16 reg; 560 + 561 + object = qt602240_get_object(data, QT602240_GEN_MESSAGE); 562 + if (!object) 563 + return -EINVAL; 564 + 565 + reg = object->start_address; 566 + return __qt602240_read_reg(data->client, reg, 567 + sizeof(struct qt602240_message), message); 568 + } 569 + 570 + static int qt602240_read_object(struct qt602240_data *data, 571 + u8 type, u8 offset, u8 *val) 572 + { 573 + struct qt602240_object *object; 574 + u16 reg; 575 + 576 + object = qt602240_get_object(data, type); 577 + if (!object) 578 + return -EINVAL; 579 + 580 + reg = object->start_address; 581 + return __qt602240_read_reg(data->client, reg + offset, 1, val); 582 + } 583 + 584 + static int qt602240_write_object(struct qt602240_data *data, 585 + u8 type, u8 offset, u8 val) 586 + { 587 + struct qt602240_object *object; 588 + u16 reg; 589 + 590 + object = qt602240_get_object(data, type); 591 + if (!object) 592 + return -EINVAL; 593 + 594 + reg = object->start_address; 595 + return qt602240_write_reg(data->client, reg + offset, val); 596 + } 597 + 598 + static void qt602240_input_report(struct qt602240_data *data, int single_id) 599 + { 600 + struct qt602240_finger *finger = data->finger; 601 + struct input_dev *input_dev = data->input_dev; 602 + int status = finger[single_id].status; 603 + int finger_num = 0; 604 + int id; 605 + 606 + for (id = 0; id < QT602240_MAX_FINGER; id++) { 607 + if (!finger[id].status) 608 + continue; 609 + 610 + input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, 611 + finger[id].status != QT602240_RELEASE ? 612 + finger[id].area : 0); 613 + input_report_abs(input_dev, ABS_MT_POSITION_X, 614 + finger[id].x); 615 + input_report_abs(input_dev, ABS_MT_POSITION_Y, 616 + finger[id].y); 617 + input_mt_sync(input_dev); 618 + 619 + if (finger[id].status == QT602240_RELEASE) 620 + finger[id].status = 0; 621 + else 622 + finger_num++; 623 + } 624 + 625 + input_report_key(input_dev, BTN_TOUCH, finger_num > 0); 626 + 627 + if (status != QT602240_RELEASE) { 628 + input_report_abs(input_dev, ABS_X, finger[single_id].x); 629 + input_report_abs(input_dev, ABS_Y, finger[single_id].y); 630 + } 631 + 632 + input_sync(input_dev); 633 + } 634 + 635 + static void qt602240_input_touchevent(struct qt602240_data *data, 636 + struct qt602240_message *message, int id) 637 + { 638 + struct qt602240_finger *finger = data->finger; 639 + struct device *dev = &data->client->dev; 640 + u8 status = message->message[0]; 641 + int x; 642 + int y; 643 + int area; 644 + 645 + /* Check the touch is present on the screen */ 646 + if (!(status & QT602240_DETECT)) { 647 + if (status & QT602240_RELEASE) { 648 + dev_dbg(dev, "[%d] released\n", id); 649 + 650 + finger[id].status = QT602240_RELEASE; 651 + qt602240_input_report(data, id); 652 + } 653 + return; 654 + } 655 + 656 + /* Check only AMP detection */ 657 + if (!(status & (QT602240_PRESS | QT602240_MOVE))) 658 + return; 659 + 660 + x = (message->message[1] << 2) | ((message->message[3] & ~0x3f) >> 6); 661 + y = (message->message[2] << 2) | ((message->message[3] & ~0xf3) >> 2); 662 + area = message->message[4]; 663 + 664 + dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, 665 + status & QT602240_MOVE ? "moved" : "pressed", 666 + x, y, area); 667 + 668 + finger[id].status = status & QT602240_MOVE ? 669 + QT602240_MOVE : QT602240_PRESS; 670 + finger[id].x = x; 671 + finger[id].y = y; 672 + finger[id].area = area; 673 + 674 + qt602240_input_report(data, id); 675 + } 676 + 677 + static irqreturn_t qt602240_interrupt(int irq, void *dev_id) 678 + { 679 + struct qt602240_data *data = dev_id; 680 + struct qt602240_message message; 681 + struct qt602240_object *object; 682 + struct device *dev = &data->client->dev; 683 + int id; 684 + u8 reportid; 685 + u8 max_reportid; 686 + u8 min_reportid; 687 + 688 + do { 689 + if (qt602240_read_message(data, &message)) { 690 + dev_err(dev, "Failed to read message\n"); 691 + goto end; 692 + } 693 + 694 + reportid = message.reportid; 695 + 696 + /* whether reportid is thing of QT602240_TOUCH_MULTI */ 697 + object = qt602240_get_object(data, QT602240_TOUCH_MULTI); 698 + if (!object) 699 + goto end; 700 + 701 + max_reportid = object->max_reportid; 702 + min_reportid = max_reportid - object->num_report_ids + 1; 703 + id = reportid - min_reportid; 704 + 705 + if (reportid >= min_reportid && reportid <= max_reportid) 706 + qt602240_input_touchevent(data, &message, id); 707 + else 708 + qt602240_dump_message(dev, &message); 709 + } while (reportid != 0xff); 710 + 711 + end: 712 + return IRQ_HANDLED; 713 + } 714 + 715 + static int qt602240_check_reg_init(struct qt602240_data *data) 716 + { 717 + struct qt602240_object *object; 718 + struct device *dev = &data->client->dev; 719 + int index = 0; 720 + int i, j; 721 + u8 version = data->info.version; 722 + u8 *init_vals; 723 + 724 + switch (version) { 725 + case QT602240_VER_20: 726 + init_vals = (u8 *)init_vals_ver_20; 727 + break; 728 + case QT602240_VER_21: 729 + init_vals = (u8 *)init_vals_ver_21; 730 + break; 731 + case QT602240_VER_22: 732 + init_vals = (u8 *)init_vals_ver_22; 733 + break; 734 + default: 735 + dev_err(dev, "Firmware version %d doesn't support\n", version); 736 + return -EINVAL; 737 + } 738 + 739 + for (i = 0; i < data->info.object_num; i++) { 740 + object = data->object_table + i; 741 + 742 + if (!qt602240_object_writable(object->type)) 743 + continue; 744 + 745 + for (j = 0; j < object->size + 1; j++) 746 + qt602240_write_object(data, object->type, j, 747 + init_vals[index + j]); 748 + 749 + index += object->size + 1; 750 + } 751 + 752 + return 0; 753 + } 754 + 755 + static int qt602240_check_matrix_size(struct qt602240_data *data) 756 + { 757 + const struct qt602240_platform_data *pdata = data->pdata; 758 + struct device *dev = &data->client->dev; 759 + int mode = -1; 760 + int error; 761 + u8 val; 762 + 763 + dev_dbg(dev, "Number of X lines: %d\n", pdata->x_line); 764 + dev_dbg(dev, "Number of Y lines: %d\n", pdata->y_line); 765 + 766 + switch (pdata->x_line) { 767 + case 0 ... 15: 768 + if (pdata->y_line <= 14) 769 + mode = 0; 770 + break; 771 + case 16: 772 + if (pdata->y_line <= 12) 773 + mode = 1; 774 + if (pdata->y_line == 13 || pdata->y_line == 14) 775 + mode = 0; 776 + break; 777 + case 17: 778 + if (pdata->y_line <= 11) 779 + mode = 2; 780 + if (pdata->y_line == 12 || pdata->y_line == 13) 781 + mode = 1; 782 + break; 783 + case 18: 784 + if (pdata->y_line <= 10) 785 + mode = 3; 786 + if (pdata->y_line == 11 || pdata->y_line == 12) 787 + mode = 2; 788 + break; 789 + case 19: 790 + if (pdata->y_line <= 9) 791 + mode = 4; 792 + if (pdata->y_line == 10 || pdata->y_line == 11) 793 + mode = 3; 794 + break; 795 + case 20: 796 + mode = 4; 797 + } 798 + 799 + if (mode < 0) { 800 + dev_err(dev, "Invalid X/Y lines\n"); 801 + return -EINVAL; 802 + } 803 + 804 + error = qt602240_read_object(data, QT602240_SPT_CTECONFIG, 805 + QT602240_CTE_MODE, &val); 806 + if (error) 807 + return error; 808 + 809 + if (mode == val) 810 + return 0; 811 + 812 + /* Change the CTE configuration */ 813 + qt602240_write_object(data, QT602240_SPT_CTECONFIG, 814 + QT602240_CTE_CTRL, 1); 815 + qt602240_write_object(data, QT602240_SPT_CTECONFIG, 816 + QT602240_CTE_MODE, mode); 817 + qt602240_write_object(data, QT602240_SPT_CTECONFIG, 818 + QT602240_CTE_CTRL, 0); 819 + 820 + return 0; 821 + } 822 + 823 + static int qt602240_make_highchg(struct qt602240_data *data) 824 + { 825 + struct device *dev = &data->client->dev; 826 + int count = 10; 827 + int error; 828 + u8 val; 829 + 830 + /* Read dummy message to make high CHG pin */ 831 + do { 832 + error = qt602240_read_object(data, QT602240_GEN_MESSAGE, 0, &val); 833 + if (error) 834 + return error; 835 + } while ((val != 0xff) && --count); 836 + 837 + if (!count) { 838 + dev_err(dev, "CHG pin isn't cleared\n"); 839 + return -EBUSY; 840 + } 841 + 842 + return 0; 843 + } 844 + 845 + static void qt602240_handle_pdata(struct qt602240_data *data) 846 + { 847 + const struct qt602240_platform_data *pdata = data->pdata; 848 + u8 voltage; 849 + 850 + /* Set touchscreen lines */ 851 + qt602240_write_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_XSIZE, 852 + pdata->x_line); 853 + qt602240_write_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_YSIZE, 854 + pdata->y_line); 855 + 856 + /* Set touchscreen orient */ 857 + qt602240_write_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_ORIENT, 858 + pdata->orient); 859 + 860 + /* Set touchscreen burst length */ 861 + qt602240_write_object(data, QT602240_TOUCH_MULTI, 862 + QT602240_TOUCH_BLEN, pdata->blen); 863 + 864 + /* Set touchscreen threshold */ 865 + qt602240_write_object(data, QT602240_TOUCH_MULTI, 866 + QT602240_TOUCH_TCHTHR, pdata->threshold); 867 + 868 + /* Set touchscreen resolution */ 869 + qt602240_write_object(data, QT602240_TOUCH_MULTI, 870 + QT602240_TOUCH_XRANGE_LSB, (pdata->x_size - 1) & 0xff); 871 + qt602240_write_object(data, QT602240_TOUCH_MULTI, 872 + QT602240_TOUCH_XRANGE_MSB, (pdata->x_size - 1) >> 8); 873 + qt602240_write_object(data, QT602240_TOUCH_MULTI, 874 + QT602240_TOUCH_YRANGE_LSB, (pdata->y_size - 1) & 0xff); 875 + qt602240_write_object(data, QT602240_TOUCH_MULTI, 876 + QT602240_TOUCH_YRANGE_MSB, (pdata->y_size - 1) >> 8); 877 + 878 + /* Set touchscreen voltage */ 879 + if (data->info.version >= QT602240_VER_21 && pdata->voltage) { 880 + if (pdata->voltage < QT602240_VOLTAGE_DEFAULT) { 881 + voltage = (QT602240_VOLTAGE_DEFAULT - pdata->voltage) / 882 + QT602240_VOLTAGE_STEP; 883 + voltage = 0xff - voltage + 1; 884 + } else 885 + voltage = (pdata->voltage - QT602240_VOLTAGE_DEFAULT) / 886 + QT602240_VOLTAGE_STEP; 887 + 888 + qt602240_write_object(data, QT602240_SPT_CTECONFIG, 889 + QT602240_CTE_VOLTAGE, voltage); 890 + } 891 + } 892 + 893 + static int qt602240_get_info(struct qt602240_data *data) 894 + { 895 + struct i2c_client *client = data->client; 896 + struct qt602240_info *info = &data->info; 897 + int error; 898 + u8 val; 899 + 900 + error = qt602240_read_reg(client, QT602240_FAMILY_ID, &val); 901 + if (error) 902 + return error; 903 + info->family_id = val; 904 + 905 + error = qt602240_read_reg(client, QT602240_VARIANT_ID, &val); 906 + if (error) 907 + return error; 908 + info->variant_id = val; 909 + 910 + error = qt602240_read_reg(client, QT602240_VERSION, &val); 911 + if (error) 912 + return error; 913 + info->version = val; 914 + 915 + error = qt602240_read_reg(client, QT602240_BUILD, &val); 916 + if (error) 917 + return error; 918 + info->build = val; 919 + 920 + error = qt602240_read_reg(client, QT602240_OBJECT_NUM, &val); 921 + if (error) 922 + return error; 923 + info->object_num = val; 924 + 925 + return 0; 926 + } 927 + 928 + static int qt602240_get_object_table(struct qt602240_data *data) 929 + { 930 + int error; 931 + int i; 932 + u16 reg; 933 + u8 reportid = 0; 934 + u8 buf[QT602240_OBJECT_SIZE]; 935 + 936 + for (i = 0; i < data->info.object_num; i++) { 937 + struct qt602240_object *object = data->object_table + i; 938 + 939 + reg = QT602240_OBJECT_START + QT602240_OBJECT_SIZE * i; 940 + error = qt602240_read_object_table(data->client, reg, buf); 941 + if (error) 942 + return error; 943 + 944 + object->type = buf[0]; 945 + object->start_address = (buf[2] << 8) | buf[1]; 946 + object->size = buf[3]; 947 + object->instances = buf[4]; 948 + object->num_report_ids = buf[5]; 949 + 950 + if (object->num_report_ids) { 951 + reportid += object->num_report_ids * 952 + (object->instances + 1); 953 + object->max_reportid = reportid; 954 + } 955 + } 956 + 957 + return 0; 958 + } 959 + 960 + static int qt602240_initialize(struct qt602240_data *data) 961 + { 962 + struct i2c_client *client = data->client; 963 + struct qt602240_info *info = &data->info; 964 + int error; 965 + u8 val; 966 + 967 + error = qt602240_get_info(data); 968 + if (error) 969 + return error; 970 + 971 + data->object_table = kcalloc(info->object_num, 972 + sizeof(struct qt602240_data), 973 + GFP_KERNEL); 974 + if (!data->object_table) { 975 + dev_err(&client->dev, "Failed to allocate memory\n"); 976 + return -ENOMEM; 977 + } 978 + 979 + /* Get object table information */ 980 + error = qt602240_get_object_table(data); 981 + if (error) 982 + return error; 983 + 984 + /* Check register init values */ 985 + error = qt602240_check_reg_init(data); 986 + if (error) 987 + return error; 988 + 989 + /* Check X/Y matrix size */ 990 + error = qt602240_check_matrix_size(data); 991 + if (error) 992 + return error; 993 + 994 + error = qt602240_make_highchg(data); 995 + if (error) 996 + return error; 997 + 998 + qt602240_handle_pdata(data); 999 + 1000 + /* Backup to memory */ 1001 + qt602240_write_object(data, QT602240_GEN_COMMAND, 1002 + QT602240_COMMAND_BACKUPNV, 1003 + QT602240_BACKUP_VALUE); 1004 + msleep(QT602240_BACKUP_TIME); 1005 + 1006 + /* Soft reset */ 1007 + qt602240_write_object(data, QT602240_GEN_COMMAND, 1008 + QT602240_COMMAND_RESET, 1); 1009 + msleep(QT602240_RESET_TIME); 1010 + 1011 + /* Update matrix size at info struct */ 1012 + error = qt602240_read_reg(client, QT602240_MATRIX_X_SIZE, &val); 1013 + if (error) 1014 + return error; 1015 + info->matrix_xsize = val; 1016 + 1017 + error = qt602240_read_reg(client, QT602240_MATRIX_Y_SIZE, &val); 1018 + if (error) 1019 + return error; 1020 + info->matrix_ysize = val; 1021 + 1022 + dev_info(&client->dev, 1023 + "Family ID: %d Variant ID: %d Version: %d Build: %d\n", 1024 + info->family_id, info->variant_id, info->version, 1025 + info->build); 1026 + 1027 + dev_info(&client->dev, 1028 + "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n", 1029 + info->matrix_xsize, info->matrix_ysize, 1030 + info->object_num); 1031 + 1032 + return 0; 1033 + } 1034 + 1035 + static ssize_t qt602240_object_show(struct device *dev, 1036 + struct device_attribute *attr, char *buf) 1037 + { 1038 + struct qt602240_data *data = dev_get_drvdata(dev); 1039 + struct qt602240_object *object; 1040 + int count = 0; 1041 + int i, j; 1042 + int error; 1043 + u8 val; 1044 + 1045 + for (i = 0; i < data->info.object_num; i++) { 1046 + object = data->object_table + i; 1047 + 1048 + count += sprintf(buf + count, 1049 + "Object Table Element %d(Type %d)\n", 1050 + i + 1, object->type); 1051 + 1052 + if (!qt602240_object_readable(object->type)) { 1053 + count += sprintf(buf + count, "\n"); 1054 + continue; 1055 + } 1056 + 1057 + for (j = 0; j < object->size + 1; j++) { 1058 + error = qt602240_read_object(data, 1059 + object->type, j, &val); 1060 + if (error) 1061 + return error; 1062 + 1063 + count += sprintf(buf + count, 1064 + " Byte %d: 0x%x (%d)\n", j, val, val); 1065 + } 1066 + 1067 + count += sprintf(buf + count, "\n"); 1068 + } 1069 + 1070 + return count; 1071 + } 1072 + 1073 + static int qt602240_load_fw(struct device *dev, const char *fn) 1074 + { 1075 + struct qt602240_data *data = dev_get_drvdata(dev); 1076 + struct i2c_client *client = data->client; 1077 + const struct firmware *fw = NULL; 1078 + unsigned int frame_size; 1079 + unsigned int pos = 0; 1080 + int ret; 1081 + 1082 + ret = request_firmware(&fw, fn, dev); 1083 + if (ret) { 1084 + dev_err(dev, "Unable to open firmware %s\n", fn); 1085 + return ret; 1086 + } 1087 + 1088 + /* Change to the bootloader mode */ 1089 + qt602240_write_object(data, QT602240_GEN_COMMAND, 1090 + QT602240_COMMAND_RESET, QT602240_BOOT_VALUE); 1091 + msleep(QT602240_RESET_TIME); 1092 + 1093 + /* Change to slave address of bootloader */ 1094 + if (client->addr == QT602240_APP_LOW) 1095 + client->addr = QT602240_BOOT_LOW; 1096 + else 1097 + client->addr = QT602240_BOOT_HIGH; 1098 + 1099 + ret = qt602240_check_bootloader(client, QT602240_WAITING_BOOTLOAD_CMD); 1100 + if (ret) 1101 + goto out; 1102 + 1103 + /* Unlock bootloader */ 1104 + qt602240_unlock_bootloader(client); 1105 + 1106 + while (pos < fw->size) { 1107 + ret = qt602240_check_bootloader(client, 1108 + QT602240_WAITING_FRAME_DATA); 1109 + if (ret) 1110 + goto out; 1111 + 1112 + frame_size = ((*(fw->data + pos) << 8) | *(fw->data + pos + 1)); 1113 + 1114 + /* We should add 2 at frame size as the the firmware data is not 1115 + * included the CRC bytes. 1116 + */ 1117 + frame_size += 2; 1118 + 1119 + /* Write one frame to device */ 1120 + qt602240_fw_write(client, fw->data + pos, frame_size); 1121 + 1122 + ret = qt602240_check_bootloader(client, 1123 + QT602240_FRAME_CRC_PASS); 1124 + if (ret) 1125 + goto out; 1126 + 1127 + pos += frame_size; 1128 + 1129 + dev_dbg(dev, "Updated %d bytes / %zd bytes\n", pos, fw->size); 1130 + } 1131 + 1132 + out: 1133 + release_firmware(fw); 1134 + 1135 + /* Change to slave address of application */ 1136 + if (client->addr == QT602240_BOOT_LOW) 1137 + client->addr = QT602240_APP_LOW; 1138 + else 1139 + client->addr = QT602240_APP_HIGH; 1140 + 1141 + return ret; 1142 + } 1143 + 1144 + static ssize_t qt602240_update_fw_store(struct device *dev, 1145 + struct device_attribute *attr, 1146 + const char *buf, size_t count) 1147 + { 1148 + struct qt602240_data *data = dev_get_drvdata(dev); 1149 + unsigned int version; 1150 + int error; 1151 + 1152 + if (sscanf(buf, "%u", &version) != 1) { 1153 + dev_err(dev, "Invalid values\n"); 1154 + return -EINVAL; 1155 + } 1156 + 1157 + if (data->info.version < QT602240_VER_21 || version < QT602240_VER_21) { 1158 + dev_err(dev, "FW update supported starting with version 21\n"); 1159 + return -EINVAL; 1160 + } 1161 + 1162 + disable_irq(data->irq); 1163 + 1164 + error = qt602240_load_fw(dev, QT602240_FW_NAME); 1165 + if (error) { 1166 + dev_err(dev, "The firmware update failed(%d)\n", error); 1167 + count = error; 1168 + } else { 1169 + dev_dbg(dev, "The firmware update succeeded\n"); 1170 + 1171 + /* Wait for reset */ 1172 + msleep(QT602240_FWRESET_TIME); 1173 + 1174 + kfree(data->object_table); 1175 + data->object_table = NULL; 1176 + 1177 + qt602240_initialize(data); 1178 + } 1179 + 1180 + enable_irq(data->irq); 1181 + 1182 + return count; 1183 + } 1184 + 1185 + static DEVICE_ATTR(object, 0444, qt602240_object_show, NULL); 1186 + static DEVICE_ATTR(update_fw, 0664, NULL, qt602240_update_fw_store); 1187 + 1188 + static struct attribute *qt602240_attrs[] = { 1189 + &dev_attr_object.attr, 1190 + &dev_attr_update_fw.attr, 1191 + NULL 1192 + }; 1193 + 1194 + static const struct attribute_group qt602240_attr_group = { 1195 + .attrs = qt602240_attrs, 1196 + }; 1197 + 1198 + static void qt602240_start(struct qt602240_data *data) 1199 + { 1200 + /* Touch enable */ 1201 + qt602240_write_object(data, 1202 + QT602240_TOUCH_MULTI, QT602240_TOUCH_CTRL, 0x83); 1203 + } 1204 + 1205 + static void qt602240_stop(struct qt602240_data *data) 1206 + { 1207 + /* Touch disable */ 1208 + qt602240_write_object(data, 1209 + QT602240_TOUCH_MULTI, QT602240_TOUCH_CTRL, 0); 1210 + } 1211 + 1212 + static int qt602240_input_open(struct input_dev *dev) 1213 + { 1214 + struct qt602240_data *data = input_get_drvdata(dev); 1215 + 1216 + qt602240_start(data); 1217 + 1218 + return 0; 1219 + } 1220 + 1221 + static void qt602240_input_close(struct input_dev *dev) 1222 + { 1223 + struct qt602240_data *data = input_get_drvdata(dev); 1224 + 1225 + qt602240_stop(data); 1226 + } 1227 + 1228 + static int __devinit qt602240_probe(struct i2c_client *client, 1229 + const struct i2c_device_id *id) 1230 + { 1231 + struct qt602240_data *data; 1232 + struct input_dev *input_dev; 1233 + int error; 1234 + 1235 + if (!client->dev.platform_data) 1236 + return -EINVAL; 1237 + 1238 + data = kzalloc(sizeof(struct qt602240_data), GFP_KERNEL); 1239 + input_dev = input_allocate_device(); 1240 + if (!data || !input_dev) { 1241 + dev_err(&client->dev, "Failed to allocate memory\n"); 1242 + error = -ENOMEM; 1243 + goto err_free_mem; 1244 + } 1245 + 1246 + input_dev->name = "AT42QT602240/ATMXT224 Touchscreen"; 1247 + input_dev->id.bustype = BUS_I2C; 1248 + input_dev->dev.parent = &client->dev; 1249 + input_dev->open = qt602240_input_open; 1250 + input_dev->close = qt602240_input_close; 1251 + 1252 + __set_bit(EV_ABS, input_dev->evbit); 1253 + __set_bit(EV_KEY, input_dev->evbit); 1254 + __set_bit(BTN_TOUCH, input_dev->keybit); 1255 + 1256 + /* For single touch */ 1257 + input_set_abs_params(input_dev, ABS_X, 1258 + 0, QT602240_MAX_XC, 0, 0); 1259 + input_set_abs_params(input_dev, ABS_Y, 1260 + 0, QT602240_MAX_YC, 0, 0); 1261 + 1262 + /* For multi touch */ 1263 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 1264 + 0, QT602240_MAX_AREA, 0, 0); 1265 + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 1266 + 0, QT602240_MAX_XC, 0, 0); 1267 + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 1268 + 0, QT602240_MAX_YC, 0, 0); 1269 + 1270 + input_set_drvdata(input_dev, data); 1271 + 1272 + data->client = client; 1273 + data->input_dev = input_dev; 1274 + data->pdata = client->dev.platform_data; 1275 + data->irq = client->irq; 1276 + 1277 + i2c_set_clientdata(client, data); 1278 + 1279 + error = qt602240_initialize(data); 1280 + if (error) 1281 + goto err_free_object; 1282 + 1283 + error = request_threaded_irq(client->irq, NULL, qt602240_interrupt, 1284 + IRQF_TRIGGER_FALLING, client->dev.driver->name, data); 1285 + if (error) { 1286 + dev_err(&client->dev, "Failed to register interrupt\n"); 1287 + goto err_free_object; 1288 + } 1289 + 1290 + error = input_register_device(input_dev); 1291 + if (error) 1292 + goto err_free_irq; 1293 + 1294 + error = sysfs_create_group(&client->dev.kobj, &qt602240_attr_group); 1295 + if (error) 1296 + goto err_unregister_device; 1297 + 1298 + return 0; 1299 + 1300 + err_unregister_device: 1301 + input_unregister_device(input_dev); 1302 + input_dev = NULL; 1303 + err_free_irq: 1304 + free_irq(client->irq, data); 1305 + err_free_object: 1306 + kfree(data->object_table); 1307 + err_free_mem: 1308 + input_free_device(input_dev); 1309 + kfree(data); 1310 + return error; 1311 + } 1312 + 1313 + static int __devexit qt602240_remove(struct i2c_client *client) 1314 + { 1315 + struct qt602240_data *data = i2c_get_clientdata(client); 1316 + 1317 + sysfs_remove_group(&client->dev.kobj, &qt602240_attr_group); 1318 + free_irq(data->irq, data); 1319 + input_unregister_device(data->input_dev); 1320 + kfree(data->object_table); 1321 + kfree(data); 1322 + 1323 + return 0; 1324 + } 1325 + 1326 + #ifdef CONFIG_PM 1327 + static int qt602240_suspend(struct i2c_client *client, pm_message_t mesg) 1328 + { 1329 + struct qt602240_data *data = i2c_get_clientdata(client); 1330 + struct input_dev *input_dev = data->input_dev; 1331 + 1332 + mutex_lock(&input_dev->mutex); 1333 + 1334 + if (input_dev->users) 1335 + qt602240_stop(data); 1336 + 1337 + mutex_unlock(&input_dev->mutex); 1338 + 1339 + return 0; 1340 + } 1341 + 1342 + static int qt602240_resume(struct i2c_client *client) 1343 + { 1344 + struct qt602240_data *data = i2c_get_clientdata(client); 1345 + struct input_dev *input_dev = data->input_dev; 1346 + 1347 + /* Soft reset */ 1348 + qt602240_write_object(data, QT602240_GEN_COMMAND, 1349 + QT602240_COMMAND_RESET, 1); 1350 + 1351 + msleep(QT602240_RESET_TIME); 1352 + 1353 + mutex_lock(&input_dev->mutex); 1354 + 1355 + if (input_dev->users) 1356 + qt602240_start(data); 1357 + 1358 + mutex_unlock(&input_dev->mutex); 1359 + 1360 + return 0; 1361 + } 1362 + #else 1363 + #define qt602240_suspend NULL 1364 + #define qt602240_resume NULL 1365 + #endif 1366 + 1367 + static const struct i2c_device_id qt602240_id[] = { 1368 + { "qt602240_ts", 0 }, 1369 + { } 1370 + }; 1371 + MODULE_DEVICE_TABLE(i2c, qt602240_id); 1372 + 1373 + static struct i2c_driver qt602240_driver = { 1374 + .driver = { 1375 + .name = "qt602240_ts", 1376 + .owner = THIS_MODULE, 1377 + }, 1378 + .probe = qt602240_probe, 1379 + .remove = __devexit_p(qt602240_remove), 1380 + .suspend = qt602240_suspend, 1381 + .resume = qt602240_resume, 1382 + .id_table = qt602240_id, 1383 + }; 1384 + 1385 + static int __init qt602240_init(void) 1386 + { 1387 + return i2c_add_driver(&qt602240_driver); 1388 + } 1389 + 1390 + static void __exit qt602240_exit(void) 1391 + { 1392 + i2c_del_driver(&qt602240_driver); 1393 + } 1394 + 1395 + module_init(qt602240_init); 1396 + module_exit(qt602240_exit); 1397 + 1398 + /* Module information */ 1399 + MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); 1400 + MODULE_DESCRIPTION("AT42QT602240/ATMXT224 Touchscreen driver"); 1401 + MODULE_LICENSE("GPL");
-3
drivers/input/touchscreen/tps6507x-ts.c
··· 355 struct tps6507x_ts *tsc = tps6507x_dev->ts; 356 struct input_dev *input_dev = tsc->input_dev; 357 358 - if (!tsc) 359 - return 0; 360 - 361 cancel_delayed_work_sync(&tsc->work); 362 destroy_workqueue(tsc->wq); 363
··· 355 struct tps6507x_ts *tsc = tps6507x_dev->ts; 356 struct input_dev *input_dev = tsc->input_dev; 357 358 cancel_delayed_work_sync(&tsc->work); 359 destroy_workqueue(tsc->wq); 360
+155 -60
drivers/input/touchscreen/usbtouchscreen.c
··· 95 int (*get_pkt_len) (unsigned char *pkt, int len); 96 97 int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt); 98 int (*init) (struct usbtouch_usb *usbtouch); 99 void (*exit) (struct usbtouch_usb *usbtouch); 100 }; ··· 136 DEVTYPE_JASTEC, 137 DEVTYPE_E2I, 138 DEVTYPE_ZYTRONIC, 139 - DEVTYPE_TC5UH, 140 DEVTYPE_NEXIO, 141 }; 142 ··· 223 {USB_DEVICE(0x14c8, 0x0003), .driver_info = DEVTYPE_ZYTRONIC}, 224 #endif 225 226 - #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC5UH 227 - {USB_DEVICE(0x0664, 0x0309), .driver_info = DEVTYPE_TC5UH}, 228 #endif 229 230 #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO ··· 511 int ret = -ENOMEM; 512 unsigned char *buf; 513 514 - buf = kmalloc(2, GFP_KERNEL); 515 if (!buf) 516 goto err_nobuf; 517 /* reset */ ··· 578 #endif 579 580 /***************************************************************************** 581 - * ET&T TC5UH part 582 */ 583 - #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC5UH 584 - static int tc5uh_read_data(struct usbtouch_usb *dev, unsigned char *pkt) 585 { 586 dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1]; 587 dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3]; ··· 736 { 737 } 738 739 static int nexio_init(struct usbtouch_usb *usbtouch) 740 { 741 struct usb_device *dev = interface_to_usbdev(usbtouch->interface); 742 struct usb_host_interface *interface = usbtouch->interface->cur_altsetting; 743 - struct nexio_priv *priv; 744 int ret = -ENOMEM; 745 int actual_len, i; 746 unsigned char *buf; ··· 791 if (!input_ep || !output_ep) 792 return -ENXIO; 793 794 - buf = kmalloc(NEXIO_BUFSIZE, GFP_KERNEL); 795 if (!buf) 796 goto out_buf; 797 ··· 823 switch (buf[0]) { 824 case 0x83: /* firmware version */ 825 if (!firmware_ver) 826 - firmware_ver = kstrdup(&buf[2], GFP_KERNEL); 827 break; 828 case 0x84: /* device name */ 829 if (!device_name) 830 - device_name = kstrdup(&buf[2], GFP_KERNEL); 831 break; 832 } 833 } ··· 838 kfree(firmware_ver); 839 kfree(device_name); 840 841 - /* prepare ACK URB */ 842 - ret = -ENOMEM; 843 - 844 - usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL); 845 - if (!usbtouch->priv) 846 - goto out_buf; 847 - 848 - priv = usbtouch->priv; 849 - 850 - priv->ack_buf = kmemdup(nexio_ack_pkt, sizeof(nexio_ack_pkt), 851 - GFP_KERNEL); 852 - if (!priv->ack_buf) 853 - goto err_priv; 854 - 855 - priv->ack = usb_alloc_urb(0, GFP_KERNEL); 856 - if (!priv->ack) { 857 - dbg("%s - usb_alloc_urb failed: usbtouch->ack", __func__); 858 - goto err_ack_buf; 859 - } 860 - 861 usb_fill_bulk_urb(priv->ack, dev, usb_sndbulkpipe(dev, output_ep), 862 priv->ack_buf, sizeof(nexio_ack_pkt), 863 nexio_ack_complete, usbtouch); 864 ret = 0; 865 - goto out_buf; 866 867 - err_ack_buf: 868 - kfree(priv->ack_buf); 869 - err_priv: 870 - kfree(priv); 871 out_buf: 872 kfree(buf); 873 return ret; ··· 860 861 static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt) 862 { 863 - int x, y, begin_x, begin_y, end_x, end_y, w, h, ret; 864 struct nexio_touch_packet *packet = (void *) pkt; 865 struct nexio_priv *priv = usbtouch->priv; 866 867 /* got touch data? */ 868 if ((pkt[0] & 0xe0) != 0xe0) 869 return 0; 870 871 - if (be16_to_cpu(packet->data_len) > 0xff) 872 - packet->data_len = cpu_to_be16(be16_to_cpu(packet->data_len) - 0x100); 873 - if (be16_to_cpu(packet->x_len) > 0xff) 874 - packet->x_len = cpu_to_be16(be16_to_cpu(packet->x_len) - 0x80); 875 876 /* send ACK */ 877 ret = usb_submit_urb(priv->ack, GFP_ATOMIC); 878 879 if (!usbtouch->type->max_xc) { 880 - usbtouch->type->max_xc = 2 * be16_to_cpu(packet->x_len); 881 - input_set_abs_params(usbtouch->input, ABS_X, 0, 882 - 2 * be16_to_cpu(packet->x_len), 0, 0); 883 - usbtouch->type->max_yc = 2 * be16_to_cpu(packet->y_len); 884 - input_set_abs_params(usbtouch->input, ABS_Y, 0, 885 - 2 * be16_to_cpu(packet->y_len), 0, 0); 886 } 887 /* 888 * The device reports state of IR sensors on X and Y axes. ··· 895 * it's disabled (and untested) here as there's no X driver for that. 896 */ 897 begin_x = end_x = begin_y = end_y = -1; 898 - for (x = 0; x < be16_to_cpu(packet->x_len); x++) { 899 if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) { 900 begin_x = x; 901 continue; 902 } 903 if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) { 904 end_x = x - 1; 905 - for (y = be16_to_cpu(packet->x_len); 906 - y < be16_to_cpu(packet->data_len); y++) { 907 if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) { 908 - begin_y = y - be16_to_cpu(packet->x_len); 909 continue; 910 } 911 if (end_y == -1 && 912 begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) { 913 - end_y = y - 1 - be16_to_cpu(packet->x_len); 914 w = end_x - begin_x; 915 h = end_y - begin_y; 916 #if 0 ··· 1117 }, 1118 #endif 1119 1120 - #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC5UH 1121 - [DEVTYPE_TC5UH] = { 1122 .min_xc = 0x0, 1123 .max_xc = 0x0fff, 1124 .min_yc = 0x0, 1125 .max_yc = 0x0fff, 1126 .rept_size = 5, 1127 - .read_data = tc5uh_read_data, 1128 }, 1129 #endif 1130 ··· 1133 .rept_size = 1024, 1134 .irq_always = true, 1135 .read_data = nexio_read_data, 1136 .init = nexio_init, 1137 .exit = nexio_exit, 1138 }, ··· 1277 usbtouch->type->process_pkt(usbtouch, usbtouch->data, urb->actual_length); 1278 1279 exit: 1280 retval = usb_submit_urb(urb, GFP_ATOMIC); 1281 if (retval) 1282 err("%s - usb_submit_urb failed with result: %d", ··· 1287 static int usbtouch_open(struct input_dev *input) 1288 { 1289 struct usbtouch_usb *usbtouch = input_get_drvdata(input); 1290 1291 usbtouch->irq->dev = interface_to_usbdev(usbtouch->interface); 1292 1293 if (!usbtouch->type->irq_always) { 1294 - if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) 1295 - return -EIO; 1296 } 1297 1298 - return 0; 1299 } 1300 1301 static void usbtouch_close(struct input_dev *input) 1302 { 1303 struct usbtouch_usb *usbtouch = input_get_drvdata(input); 1304 1305 if (!usbtouch->type->irq_always) 1306 usb_kill_urb(usbtouch->irq); 1307 } 1308 1309 1310 static void usbtouch_free_buffers(struct usb_device *udev, 1311 struct usbtouch_usb *usbtouch) ··· 1490 usbtouch->irq->transfer_dma = usbtouch->data_dma; 1491 usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1492 1493 - /* device specific init */ 1494 if (type->init) { 1495 err = type->init(usbtouch); 1496 if (err) { 1497 dbg("%s - type->init() failed, err: %d", __func__, err); 1498 - goto out_free_urb; 1499 } 1500 } 1501 ··· 1517 usb_set_intfdata(intf, usbtouch); 1518 1519 if (usbtouch->type->irq_always) { 1520 err = usb_submit_urb(usbtouch->irq, GFP_KERNEL); 1521 if (err) { 1522 err("%s - usb_submit_urb failed with result: %d", 1523 __func__, err); 1524 goto out_unregister_input; ··· 1572 .name = "usbtouchscreen", 1573 .probe = usbtouch_probe, 1574 .disconnect = usbtouch_disconnect, 1575 .id_table = usbtouch_devices, 1576 }; 1577 1578 static int __init usbtouch_init(void)
··· 95 int (*get_pkt_len) (unsigned char *pkt, int len); 96 97 int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt); 98 + int (*alloc) (struct usbtouch_usb *usbtouch); 99 int (*init) (struct usbtouch_usb *usbtouch); 100 void (*exit) (struct usbtouch_usb *usbtouch); 101 }; ··· 135 DEVTYPE_JASTEC, 136 DEVTYPE_E2I, 137 DEVTYPE_ZYTRONIC, 138 + DEVTYPE_TC45USB, 139 DEVTYPE_NEXIO, 140 }; 141 ··· 222 {USB_DEVICE(0x14c8, 0x0003), .driver_info = DEVTYPE_ZYTRONIC}, 223 #endif 224 225 + #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB 226 + /* TC5UH */ 227 + {USB_DEVICE(0x0664, 0x0309), .driver_info = DEVTYPE_TC45USB}, 228 + /* TC4UM */ 229 + {USB_DEVICE(0x0664, 0x0306), .driver_info = DEVTYPE_TC45USB}, 230 #endif 231 232 #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO ··· 507 int ret = -ENOMEM; 508 unsigned char *buf; 509 510 + buf = kmalloc(2, GFP_NOIO); 511 if (!buf) 512 goto err_nobuf; 513 /* reset */ ··· 574 #endif 575 576 /***************************************************************************** 577 + * ET&T TC5UH/TC4UM part 578 */ 579 + #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB 580 + static int tc45usb_read_data(struct usbtouch_usb *dev, unsigned char *pkt) 581 { 582 dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1]; 583 dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3]; ··· 732 { 733 } 734 735 + static int nexio_alloc(struct usbtouch_usb *usbtouch) 736 + { 737 + struct nexio_priv *priv; 738 + int ret = -ENOMEM; 739 + 740 + usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL); 741 + if (!usbtouch->priv) 742 + goto out_buf; 743 + 744 + priv = usbtouch->priv; 745 + 746 + priv->ack_buf = kmemdup(nexio_ack_pkt, sizeof(nexio_ack_pkt), 747 + GFP_KERNEL); 748 + if (!priv->ack_buf) 749 + goto err_priv; 750 + 751 + priv->ack = usb_alloc_urb(0, GFP_KERNEL); 752 + if (!priv->ack) { 753 + dbg("%s - usb_alloc_urb failed: usbtouch->ack", __func__); 754 + goto err_ack_buf; 755 + } 756 + 757 + return 0; 758 + 759 + err_ack_buf: 760 + kfree(priv->ack_buf); 761 + err_priv: 762 + kfree(priv); 763 + out_buf: 764 + return ret; 765 + } 766 + 767 static int nexio_init(struct usbtouch_usb *usbtouch) 768 { 769 struct usb_device *dev = interface_to_usbdev(usbtouch->interface); 770 struct usb_host_interface *interface = usbtouch->interface->cur_altsetting; 771 + struct nexio_priv *priv = usbtouch->priv; 772 int ret = -ENOMEM; 773 int actual_len, i; 774 unsigned char *buf; ··· 755 if (!input_ep || !output_ep) 756 return -ENXIO; 757 758 + buf = kmalloc(NEXIO_BUFSIZE, GFP_NOIO); 759 if (!buf) 760 goto out_buf; 761 ··· 787 switch (buf[0]) { 788 case 0x83: /* firmware version */ 789 if (!firmware_ver) 790 + firmware_ver = kstrdup(&buf[2], GFP_NOIO); 791 break; 792 case 0x84: /* device name */ 793 if (!device_name) 794 + device_name = kstrdup(&buf[2], GFP_NOIO); 795 break; 796 } 797 } ··· 802 kfree(firmware_ver); 803 kfree(device_name); 804 805 usb_fill_bulk_urb(priv->ack, dev, usb_sndbulkpipe(dev, output_ep), 806 priv->ack_buf, sizeof(nexio_ack_pkt), 807 nexio_ack_complete, usbtouch); 808 ret = 0; 809 810 out_buf: 811 kfree(buf); 812 return ret; ··· 849 850 static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt) 851 { 852 struct nexio_touch_packet *packet = (void *) pkt; 853 struct nexio_priv *priv = usbtouch->priv; 854 + unsigned int data_len = be16_to_cpu(packet->data_len); 855 + unsigned int x_len = be16_to_cpu(packet->x_len); 856 + unsigned int y_len = be16_to_cpu(packet->y_len); 857 + int x, y, begin_x, begin_y, end_x, end_y, w, h, ret; 858 859 /* got touch data? */ 860 if ((pkt[0] & 0xe0) != 0xe0) 861 return 0; 862 863 + if (data_len > 0xff) 864 + data_len -= 0x100; 865 + if (x_len > 0xff) 866 + x_len -= 0x80; 867 868 /* send ACK */ 869 ret = usb_submit_urb(priv->ack, GFP_ATOMIC); 870 871 if (!usbtouch->type->max_xc) { 872 + usbtouch->type->max_xc = 2 * x_len; 873 + input_set_abs_params(usbtouch->input, ABS_X, 874 + 0, usbtouch->type->max_xc, 0, 0); 875 + usbtouch->type->max_yc = 2 * y_len; 876 + input_set_abs_params(usbtouch->input, ABS_Y, 877 + 0, usbtouch->type->max_yc, 0, 0); 878 } 879 /* 880 * The device reports state of IR sensors on X and Y axes. ··· 881 * it's disabled (and untested) here as there's no X driver for that. 882 */ 883 begin_x = end_x = begin_y = end_y = -1; 884 + for (x = 0; x < x_len; x++) { 885 if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) { 886 begin_x = x; 887 continue; 888 } 889 if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) { 890 end_x = x - 1; 891 + for (y = x_len; y < data_len; y++) { 892 if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) { 893 + begin_y = y - x_len; 894 continue; 895 } 896 if (end_y == -1 && 897 begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) { 898 + end_y = y - 1 - x_len; 899 w = end_x - begin_x; 900 h = end_y - begin_y; 901 #if 0 ··· 1104 }, 1105 #endif 1106 1107 + #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB 1108 + [DEVTYPE_TC45USB] = { 1109 .min_xc = 0x0, 1110 .max_xc = 0x0fff, 1111 .min_yc = 0x0, 1112 .max_yc = 0x0fff, 1113 .rept_size = 5, 1114 + .read_data = tc45usb_read_data, 1115 }, 1116 #endif 1117 ··· 1120 .rept_size = 1024, 1121 .irq_always = true, 1122 .read_data = nexio_read_data, 1123 + .alloc = nexio_alloc, 1124 .init = nexio_init, 1125 .exit = nexio_exit, 1126 }, ··· 1263 usbtouch->type->process_pkt(usbtouch, usbtouch->data, urb->actual_length); 1264 1265 exit: 1266 + usb_mark_last_busy(interface_to_usbdev(usbtouch->interface)); 1267 retval = usb_submit_urb(urb, GFP_ATOMIC); 1268 if (retval) 1269 err("%s - usb_submit_urb failed with result: %d", ··· 1272 static int usbtouch_open(struct input_dev *input) 1273 { 1274 struct usbtouch_usb *usbtouch = input_get_drvdata(input); 1275 + int r; 1276 1277 usbtouch->irq->dev = interface_to_usbdev(usbtouch->interface); 1278 1279 + r = usb_autopm_get_interface(usbtouch->interface) ? -EIO : 0; 1280 + if (r < 0) 1281 + goto out; 1282 + 1283 if (!usbtouch->type->irq_always) { 1284 + if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) { 1285 + r = -EIO; 1286 + goto out_put; 1287 + } 1288 } 1289 1290 + usbtouch->interface->needs_remote_wakeup = 1; 1291 + out_put: 1292 + usb_autopm_put_interface(usbtouch->interface); 1293 + out: 1294 + return r; 1295 } 1296 1297 static void usbtouch_close(struct input_dev *input) 1298 { 1299 struct usbtouch_usb *usbtouch = input_get_drvdata(input); 1300 + int r; 1301 1302 if (!usbtouch->type->irq_always) 1303 usb_kill_urb(usbtouch->irq); 1304 + r = usb_autopm_get_interface(usbtouch->interface); 1305 + usbtouch->interface->needs_remote_wakeup = 0; 1306 + if (!r) 1307 + usb_autopm_put_interface(usbtouch->interface); 1308 } 1309 1310 + static int usbtouch_suspend 1311 + (struct usb_interface *intf, pm_message_t message) 1312 + { 1313 + struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); 1314 + 1315 + usb_kill_urb(usbtouch->irq); 1316 + 1317 + return 0; 1318 + } 1319 + 1320 + static int usbtouch_resume(struct usb_interface *intf) 1321 + { 1322 + struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); 1323 + struct input_dev *input = usbtouch->input; 1324 + int result = 0; 1325 + 1326 + mutex_lock(&input->mutex); 1327 + if (input->users || usbtouch->type->irq_always) 1328 + result = usb_submit_urb(usbtouch->irq, GFP_NOIO); 1329 + mutex_unlock(&input->mutex); 1330 + 1331 + return result; 1332 + } 1333 + 1334 + static int usbtouch_reset_resume(struct usb_interface *intf) 1335 + { 1336 + struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); 1337 + struct input_dev *input = usbtouch->input; 1338 + int err = 0; 1339 + 1340 + /* reinit the device */ 1341 + if (usbtouch->type->init) { 1342 + err = usbtouch->type->init(usbtouch); 1343 + if (err) { 1344 + dbg("%s - type->init() failed, err: %d", 1345 + __func__, err); 1346 + return err; 1347 + } 1348 + } 1349 + 1350 + /* restart IO if needed */ 1351 + mutex_lock(&input->mutex); 1352 + if (input->users) 1353 + err = usb_submit_urb(usbtouch->irq, GFP_NOIO); 1354 + mutex_unlock(&input->mutex); 1355 + 1356 + return err; 1357 + } 1358 1359 static void usbtouch_free_buffers(struct usb_device *udev, 1360 struct usbtouch_usb *usbtouch) ··· 1411 usbtouch->irq->transfer_dma = usbtouch->data_dma; 1412 usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1413 1414 + /* device specific allocations */ 1415 + if (type->alloc) { 1416 + err = type->alloc(usbtouch); 1417 + if (err) { 1418 + dbg("%s - type->alloc() failed, err: %d", __func__, err); 1419 + goto out_free_urb; 1420 + } 1421 + } 1422 + 1423 + /* device specific initialisation*/ 1424 if (type->init) { 1425 err = type->init(usbtouch); 1426 if (err) { 1427 dbg("%s - type->init() failed, err: %d", __func__, err); 1428 + goto out_do_exit; 1429 } 1430 } 1431 ··· 1429 usb_set_intfdata(intf, usbtouch); 1430 1431 if (usbtouch->type->irq_always) { 1432 + /* this can't fail */ 1433 + usb_autopm_get_interface(intf); 1434 err = usb_submit_urb(usbtouch->irq, GFP_KERNEL); 1435 if (err) { 1436 + usb_autopm_put_interface(intf); 1437 err("%s - usb_submit_urb failed with result: %d", 1438 __func__, err); 1439 goto out_unregister_input; ··· 1481 .name = "usbtouchscreen", 1482 .probe = usbtouch_probe, 1483 .disconnect = usbtouch_disconnect, 1484 + .suspend = usbtouch_suspend, 1485 + .resume = usbtouch_resume, 1486 + .reset_resume = usbtouch_reset_resume, 1487 .id_table = usbtouch_devices, 1488 + .supports_autosuspend = 1, 1489 }; 1490 1491 static int __init usbtouch_init(void)
+37
include/linux/i2c/adp5588.h
··· 78 79 #define ADP5588_KEYMAPSIZE 80 80 81 struct adp5588_kpad_platform_data { 82 int rows; /* Number of rows */ 83 int cols; /* Number of columns */ ··· 121 unsigned en_keylock:1; /* Enable Key Lock feature */ 122 unsigned short unlock_key1; /* Unlock Key 1 */ 123 unsigned short unlock_key2; /* Unlock Key 2 */ 124 }; 125 126 struct adp5588_gpio_platform_data {
··· 78 79 #define ADP5588_KEYMAPSIZE 80 80 81 + #define GPI_PIN_ROW0 97 82 + #define GPI_PIN_ROW1 98 83 + #define GPI_PIN_ROW2 99 84 + #define GPI_PIN_ROW3 100 85 + #define GPI_PIN_ROW4 101 86 + #define GPI_PIN_ROW5 102 87 + #define GPI_PIN_ROW6 103 88 + #define GPI_PIN_ROW7 104 89 + #define GPI_PIN_COL0 105 90 + #define GPI_PIN_COL1 106 91 + #define GPI_PIN_COL2 107 92 + #define GPI_PIN_COL3 108 93 + #define GPI_PIN_COL4 109 94 + #define GPI_PIN_COL5 110 95 + #define GPI_PIN_COL6 111 96 + #define GPI_PIN_COL7 112 97 + #define GPI_PIN_COL8 113 98 + #define GPI_PIN_COL9 114 99 + 100 + #define GPI_PIN_ROW_BASE GPI_PIN_ROW0 101 + #define GPI_PIN_ROW_END GPI_PIN_ROW7 102 + #define GPI_PIN_COL_BASE GPI_PIN_COL0 103 + #define GPI_PIN_COL_END GPI_PIN_COL9 104 + 105 + #define GPI_PIN_BASE GPI_PIN_ROW_BASE 106 + #define GPI_PIN_END GPI_PIN_COL_END 107 + 108 + #define ADP5588_GPIMAPSIZE_MAX (GPI_PIN_END - GPI_PIN_BASE + 1) 109 + 110 + struct adp5588_gpi_map { 111 + unsigned short pin; 112 + unsigned short sw_evt; 113 + }; 114 + 115 struct adp5588_kpad_platform_data { 116 int rows; /* Number of rows */ 117 int cols; /* Number of columns */ ··· 87 unsigned en_keylock:1; /* Enable Key Lock feature */ 88 unsigned short unlock_key1; /* Unlock Key 1 */ 89 unsigned short unlock_key2; /* Unlock Key 2 */ 90 + const struct adp5588_gpi_map *gpimap; 91 + unsigned short gpimapsize; 92 + const struct adp5588_gpio_platform_data *gpio_data; 93 }; 94 95 struct adp5588_gpio_platform_data {
+34
include/linux/i2c/mcs.h
···
··· 1 + /* 2 + * Copyright (C) 2009 - 2010 Samsung Electronics Co.Ltd 3 + * Author: Joonyoung Shim <jy0922.shim@samsung.com> 4 + * Author: HeungJun Kim <riverful.kim@samsung.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU General Public License as published by the 8 + * Free Software Foundation; either version 2 of the License, or (at your 9 + * option) any later version. 10 + * 11 + */ 12 + 13 + #ifndef __LINUX_MCS_H 14 + #define __LINUX_MCS_H 15 + 16 + #define MCS_KEY_MAP(v, c) ((((v) & 0xff) << 16) | ((c) & 0xffff)) 17 + #define MCS_KEY_VAL(v) (((v) >> 16) & 0xff) 18 + #define MCS_KEY_CODE(v) ((v) & 0xffff) 19 + 20 + struct mcs_platform_data { 21 + void (*cfg_pin)(void); 22 + 23 + /* touchscreen */ 24 + unsigned int x_size; 25 + unsigned int y_size; 26 + 27 + /* touchkey */ 28 + const u32 *keymap; 29 + unsigned int keymap_size; 30 + unsigned int key_maxval; 31 + bool no_autorepeat; 32 + }; 33 + 34 + #endif /* __LINUX_MCS_H */
-24
include/linux/i2c/mcs5000_ts.h
··· 1 - /* 2 - * mcs5000_ts.h 3 - * 4 - * Copyright (C) 2009 Samsung Electronics Co.Ltd 5 - * Author: Joonyoung Shim <jy0922.shim@samsung.com> 6 - * 7 - * This program is free software; you can redistribute it and/or modify it 8 - * under the terms of the GNU General Public License as published by the 9 - * Free Software Foundation; either version 2 of the License, or (at your 10 - * option) any later version. 11 - * 12 - */ 13 - 14 - #ifndef __LINUX_MCS5000_TS_H 15 - #define __LINUX_MCS5000_TS_H 16 - 17 - /* platform data for the MELFAS MCS-5000 touchscreen driver */ 18 - struct mcs5000_ts_platform_data { 19 - void (*cfg_pin)(void); 20 - int x_size; 21 - int y_size; 22 - }; 23 - 24 - #endif /* __LINUX_MCS5000_TS_H */
···
+38
include/linux/i2c/qt602240_ts.h
···
··· 1 + /* 2 + * AT42QT602240/ATMXT224 Touchscreen driver 3 + * 4 + * Copyright (C) 2010 Samsung Electronics Co.Ltd 5 + * Author: Joonyoung Shim <jy0922.shim@samsung.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; either version 2 of the License, or (at your 10 + * option) any later version. 11 + */ 12 + 13 + #ifndef __LINUX_QT602240_TS_H 14 + #define __LINUX_QT602240_TS_H 15 + 16 + /* Orient */ 17 + #define QT602240_NORMAL 0x0 18 + #define QT602240_DIAGONAL 0x1 19 + #define QT602240_HORIZONTAL_FLIP 0x2 20 + #define QT602240_ROTATED_90_COUNTER 0x3 21 + #define QT602240_VERTICAL_FLIP 0x4 22 + #define QT602240_ROTATED_90 0x5 23 + #define QT602240_ROTATED_180 0x6 24 + #define QT602240_DIAGONAL_COUNTER 0x7 25 + 26 + /* The platform data for the AT42QT602240/ATMXT224 touchscreen driver */ 27 + struct qt602240_platform_data { 28 + unsigned int x_line; 29 + unsigned int y_line; 30 + unsigned int x_size; 31 + unsigned int y_size; 32 + unsigned int blen; 33 + unsigned int threshold; 34 + unsigned int voltage; 35 + unsigned char orient; 36 + }; 37 + 38 + #endif /* __LINUX_QT602240_TS_H */
+57 -3
include/linux/input.h
··· 691 #define ABS_TILT_X 0x1a 692 #define ABS_TILT_Y 0x1b 693 #define ABS_TOOL_WIDTH 0x1c 694 #define ABS_VOLUME 0x20 695 #define ABS_MISC 0x28 696 697 #define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ 698 #define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ 699 #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ ··· 708 #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ 709 #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ 710 #define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ 711 712 #define ABS_MAX 0x3f 713 #define ABS_CNT (ABS_MAX+1) ··· 1057 #include <linux/mod_devicetable.h> 1058 1059 /** 1060 * struct input_dev - represents an input device 1061 * @name: name of the device 1062 * @phys: physical path to the device in the system hierarchy ··· 1080 * @sndbit: bitmap of sound effects supported by the device 1081 * @ffbit: bitmap of force feedback effects supported by the device 1082 * @swbit: bitmap of switches present on the device 1083 * @keycodemax: size of keycode table 1084 * @keycodesize: size of elements in keycode table 1085 * @keycode: map of scancodes to keycodes for this device ··· 1099 * @repeat_key: stores key code of the last key pressed; used to implement 1100 * software autorepeat 1101 * @timer: timer for software autorepeat 1102 - * @sync: set to 1 when there were no new events since last EV_SYNC 1103 * @abs: current values for reports from absolute axes 1104 * @rep: current values for autorepeat parameters (delay, rate) 1105 * @key: reflects current state of device's keys/buttons 1106 * @led: reflects current state of device's LEDs 1107 * @snd: reflects current state of sound effects ··· 1143 * last user closes the device 1144 * @going_away: marks devices that are in a middle of unregistering and 1145 * causes input_open_device*() fail with -ENODEV. 1146 * @dev: driver model's view of this device 1147 * @h_list: list of input handles associated with the device. When 1148 * accessing the list dev->mutex must be held ··· 1165 unsigned long ffbit[BITS_TO_LONGS(FF_CNT)]; 1166 unsigned long swbit[BITS_TO_LONGS(SW_CNT)]; 1167 1168 unsigned int keycodemax; 1169 unsigned int keycodesize; 1170 void *keycode; ··· 1180 unsigned int repeat_key; 1181 struct timer_list timer; 1182 1183 - int sync; 1184 - 1185 int abs[ABS_CNT]; 1186 int rep[REP_MAX + 1]; 1187 1188 unsigned long key[BITS_TO_LONGS(KEY_CNT)]; 1189 unsigned long led[BITS_TO_LONGS(LED_CNT)]; ··· 1210 1211 unsigned int users; 1212 bool going_away; 1213 1214 struct device dev; 1215 ··· 1437 input_event(dev, EV_SYN, SYN_MT_REPORT, 0); 1438 } 1439 1440 void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code); 1441 1442 static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat) 1443 { ··· 1535 1536 int input_ff_create_memless(struct input_dev *dev, void *data, 1537 int (*play_effect)(struct input_dev *, void *, struct ff_effect *)); 1538 1539 #endif 1540 #endif
··· 691 #define ABS_TILT_X 0x1a 692 #define ABS_TILT_Y 0x1b 693 #define ABS_TOOL_WIDTH 0x1c 694 + 695 #define ABS_VOLUME 0x20 696 + 697 #define ABS_MISC 0x28 698 699 + #define ABS_MT_SLOT 0x2f /* MT slot being modified */ 700 #define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ 701 #define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ 702 #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ ··· 705 #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ 706 #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ 707 #define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ 708 + 709 + #ifdef __KERNEL__ 710 + /* Implementation details, userspace should not care about these */ 711 + #define ABS_MT_FIRST ABS_MT_TOUCH_MAJOR 712 + #define ABS_MT_LAST ABS_MT_PRESSURE 713 + #endif 714 715 #define ABS_MAX 0x3f 716 #define ABS_CNT (ABS_MAX+1) ··· 1048 #include <linux/mod_devicetable.h> 1049 1050 /** 1051 + * struct input_mt_slot - represents the state of an input MT slot 1052 + * @abs: holds current values of ABS_MT axes for this slot 1053 + */ 1054 + struct input_mt_slot { 1055 + int abs[ABS_MT_LAST - ABS_MT_FIRST + 1]; 1056 + }; 1057 + 1058 + /** 1059 * struct input_dev - represents an input device 1060 * @name: name of the device 1061 * @phys: physical path to the device in the system hierarchy ··· 1063 * @sndbit: bitmap of sound effects supported by the device 1064 * @ffbit: bitmap of force feedback effects supported by the device 1065 * @swbit: bitmap of switches present on the device 1066 + * @hint_events_per_packet: average number of events generated by the 1067 + * device in a packet (between EV_SYN/SYN_REPORT events). Used by 1068 + * event handlers to estimate size of the buffer needed to hold 1069 + * events. 1070 * @keycodemax: size of keycode table 1071 * @keycodesize: size of elements in keycode table 1072 * @keycode: map of scancodes to keycodes for this device ··· 1078 * @repeat_key: stores key code of the last key pressed; used to implement 1079 * software autorepeat 1080 * @timer: timer for software autorepeat 1081 * @abs: current values for reports from absolute axes 1082 * @rep: current values for autorepeat parameters (delay, rate) 1083 + * @mt: pointer to array of struct input_mt_slot holding current values 1084 + * of tracked contacts 1085 + * @mtsize: number of MT slots the device uses 1086 + * @slot: MT slot currently being transmitted 1087 * @key: reflects current state of device's keys/buttons 1088 * @led: reflects current state of device's LEDs 1089 * @snd: reflects current state of sound effects ··· 1119 * last user closes the device 1120 * @going_away: marks devices that are in a middle of unregistering and 1121 * causes input_open_device*() fail with -ENODEV. 1122 + * @sync: set to %true when there were no new events since last EV_SYN 1123 * @dev: driver model's view of this device 1124 * @h_list: list of input handles associated with the device. When 1125 * accessing the list dev->mutex must be held ··· 1140 unsigned long ffbit[BITS_TO_LONGS(FF_CNT)]; 1141 unsigned long swbit[BITS_TO_LONGS(SW_CNT)]; 1142 1143 + unsigned int hint_events_per_packet; 1144 + 1145 unsigned int keycodemax; 1146 unsigned int keycodesize; 1147 void *keycode; ··· 1153 unsigned int repeat_key; 1154 struct timer_list timer; 1155 1156 int abs[ABS_CNT]; 1157 int rep[REP_MAX + 1]; 1158 + 1159 + struct input_mt_slot *mt; 1160 + int mtsize; 1161 + int slot; 1162 1163 unsigned long key[BITS_TO_LONGS(KEY_CNT)]; 1164 unsigned long led[BITS_TO_LONGS(LED_CNT)]; ··· 1181 1182 unsigned int users; 1183 bool going_away; 1184 + 1185 + bool sync; 1186 1187 struct device dev; 1188 ··· 1406 input_event(dev, EV_SYN, SYN_MT_REPORT, 0); 1407 } 1408 1409 + static inline void input_mt_slot(struct input_dev *dev, int slot) 1410 + { 1411 + input_event(dev, EV_ABS, ABS_MT_SLOT, slot); 1412 + } 1413 + 1414 void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code); 1415 + 1416 + /** 1417 + * input_set_events_per_packet - tell handlers about the driver event rate 1418 + * @dev: the input device used by the driver 1419 + * @n_events: the average number of events between calls to input_sync() 1420 + * 1421 + * If the event rate sent from a device is unusually large, use this 1422 + * function to set the expected event rate. This will allow handlers 1423 + * to set up an appropriate buffer size for the event stream, in order 1424 + * to minimize information loss. 1425 + */ 1426 + static inline void input_set_events_per_packet(struct input_dev *dev, int n_events) 1427 + { 1428 + dev->hint_events_per_packet = n_events; 1429 + } 1430 1431 static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat) 1432 { ··· 1484 1485 int input_ff_create_memless(struct input_dev *dev, void *data, 1486 int (*play_effect)(struct input_dev *, void *, struct ff_effect *)); 1487 + 1488 + int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots); 1489 + void input_mt_destroy_slots(struct input_dev *dev); 1490 1491 #endif 1492 #endif
+349
include/linux/input/adxl34x.h
···
··· 1 + /* 2 + * include/linux/input/adxl34x.h 3 + * 4 + * Digital Accelerometer characteristics are highly application specific 5 + * and may vary between boards and models. The platform_data for the 6 + * device's "struct device" holds this information. 7 + * 8 + * Copyright 2009 Analog Devices Inc. 9 + * 10 + * Licensed under the GPL-2 or later. 11 + */ 12 + 13 + #ifndef __LINUX_INPUT_ADXL34X_H__ 14 + #define __LINUX_INPUT_ADXL34X_H__ 15 + 16 + struct adxl34x_platform_data { 17 + 18 + /* 19 + * X,Y,Z Axis Offset: 20 + * offer user offset adjustments in twoscompliment 21 + * form with a scale factor of 15.6 mg/LSB (i.e. 0x7F = +2 g) 22 + */ 23 + 24 + s8 x_axis_offset; 25 + s8 y_axis_offset; 26 + s8 z_axis_offset; 27 + 28 + /* 29 + * TAP_X/Y/Z Enable: Setting TAP_X, Y, or Z Enable enables X, 30 + * Y, or Z participation in Tap detection. A '0' excludes the 31 + * selected axis from participation in Tap detection. 32 + * Setting the SUPPRESS bit suppresses Double Tap detection if 33 + * acceleration greater than tap_threshold is present between 34 + * taps. 35 + */ 36 + 37 + #define ADXL_SUPPRESS (1 << 3) 38 + #define ADXL_TAP_X_EN (1 << 2) 39 + #define ADXL_TAP_Y_EN (1 << 1) 40 + #define ADXL_TAP_Z_EN (1 << 0) 41 + 42 + u8 tap_axis_control; 43 + 44 + /* 45 + * tap_threshold: 46 + * holds the threshold value for tap detection/interrupts. 47 + * The data format is unsigned. The scale factor is 62.5 mg/LSB 48 + * (i.e. 0xFF = +16 g). A zero value may result in undesirable 49 + * behavior if Tap/Double Tap is enabled. 50 + */ 51 + 52 + u8 tap_threshold; 53 + 54 + /* 55 + * tap_duration: 56 + * is an unsigned time value representing the maximum 57 + * time that an event must be above the tap_threshold threshold 58 + * to qualify as a tap event. The scale factor is 625 us/LSB. A zero 59 + * value will prevent Tap/Double Tap functions from working. 60 + */ 61 + 62 + u8 tap_duration; 63 + 64 + /* 65 + * tap_latency: 66 + * is an unsigned time value representing the wait time 67 + * from the detection of a tap event to the opening of the time 68 + * window tap_window for a possible second tap event. The scale 69 + * factor is 1.25 ms/LSB. A zero value will disable the Double Tap 70 + * function. 71 + */ 72 + 73 + u8 tap_latency; 74 + 75 + /* 76 + * tap_window: 77 + * is an unsigned time value representing the amount 78 + * of time after the expiration of tap_latency during which a second 79 + * tap can begin. The scale factor is 1.25 ms/LSB. A zero value will 80 + * disable the Double Tap function. 81 + */ 82 + 83 + u8 tap_window; 84 + 85 + /* 86 + * act_axis_control: 87 + * X/Y/Z Enable: A '1' enables X, Y, or Z participation in activity 88 + * or inactivity detection. A '0' excludes the selected axis from 89 + * participation. If all of the axes are excluded, the function is 90 + * disabled. 91 + * AC/DC: A '0' = DC coupled operation and a '1' = AC coupled 92 + * operation. In DC coupled operation, the current acceleration is 93 + * compared with activity_threshold and inactivity_threshold directly 94 + * to determine whether activity or inactivity is detected. In AC 95 + * coupled operation for activity detection, the acceleration value 96 + * at the start of activity detection is taken as a reference value. 97 + * New samples of acceleration are then compared to this 98 + * reference value and if the magnitude of the difference exceeds 99 + * activity_threshold the device will trigger an activity interrupt. In 100 + * AC coupled operation for inactivity detection, a reference value 101 + * is used again for comparison and is updated whenever the 102 + * device exceeds the inactivity threshold. Once the reference 103 + * value is selected, the device compares the magnitude of the 104 + * difference between the reference value and the current 105 + * acceleration with inactivity_threshold. If the difference is below 106 + * inactivity_threshold for a total of inactivity_time, the device is 107 + * considered inactive and the inactivity interrupt is triggered. 108 + */ 109 + 110 + #define ADXL_ACT_ACDC (1 << 7) 111 + #define ADXL_ACT_X_EN (1 << 6) 112 + #define ADXL_ACT_Y_EN (1 << 5) 113 + #define ADXL_ACT_Z_EN (1 << 4) 114 + #define ADXL_INACT_ACDC (1 << 3) 115 + #define ADXL_INACT_X_EN (1 << 2) 116 + #define ADXL_INACT_Y_EN (1 << 1) 117 + #define ADXL_INACT_Z_EN (1 << 0) 118 + 119 + u8 act_axis_control; 120 + 121 + /* 122 + * activity_threshold: 123 + * holds the threshold value for activity detection. 124 + * The data format is unsigned. The scale factor is 125 + * 62.5 mg/LSB. A zero value may result in undesirable behavior if 126 + * Activity interrupt is enabled. 127 + */ 128 + 129 + u8 activity_threshold; 130 + 131 + /* 132 + * inactivity_threshold: 133 + * holds the threshold value for inactivity 134 + * detection. The data format is unsigned. The scale 135 + * factor is 62.5 mg/LSB. A zero value may result in undesirable 136 + * behavior if Inactivity interrupt is enabled. 137 + */ 138 + 139 + u8 inactivity_threshold; 140 + 141 + /* 142 + * inactivity_time: 143 + * is an unsigned time value representing the 144 + * amount of time that acceleration must be below the value in 145 + * inactivity_threshold for inactivity to be declared. The scale factor 146 + * is 1 second/LSB. Unlike the other interrupt functions, which 147 + * operate on unfiltered data, the inactivity function operates on the 148 + * filtered output data. At least one output sample must be 149 + * generated for the inactivity interrupt to be triggered. This will 150 + * result in the function appearing un-responsive if the 151 + * inactivity_time register is set with a value less than the time 152 + * constant of the Output Data Rate. A zero value will result in an 153 + * interrupt when the output data is below inactivity_threshold. 154 + */ 155 + 156 + u8 inactivity_time; 157 + 158 + /* 159 + * free_fall_threshold: 160 + * holds the threshold value for Free-Fall detection. 161 + * The data format is unsigned. The root-sum-square(RSS) value 162 + * of all axes is calculated and compared to the value in 163 + * free_fall_threshold to determine if a free fall event may be 164 + * occurring. The scale factor is 62.5 mg/LSB. A zero value may 165 + * result in undesirable behavior if Free-Fall interrupt is 166 + * enabled. Values between 300 and 600 mg (0x05 to 0x09) are 167 + * recommended. 168 + */ 169 + 170 + u8 free_fall_threshold; 171 + 172 + /* 173 + * free_fall_time: 174 + * is an unsigned time value representing the minimum 175 + * time that the RSS value of all axes must be less than 176 + * free_fall_threshold to generate a Free-Fall interrupt. The 177 + * scale factor is 5 ms/LSB. A zero value may result in 178 + * undesirable behavior if Free-Fall interrupt is enabled. 179 + * Values between 100 to 350 ms (0x14 to 0x46) are recommended. 180 + */ 181 + 182 + u8 free_fall_time; 183 + 184 + /* 185 + * data_rate: 186 + * Selects device bandwidth and output data rate. 187 + * RATE = 3200 Hz / (2^(15 - x)). Default value is 0x0A, or 100 Hz 188 + * Output Data Rate. An Output Data Rate should be selected that 189 + * is appropriate for the communication protocol and frequency 190 + * selected. Selecting too high of an Output Data Rate with a low 191 + * communication speed will result in samples being discarded. 192 + */ 193 + 194 + u8 data_rate; 195 + 196 + /* 197 + * data_range: 198 + * FULL_RES: When this bit is set with the device is 199 + * in Full-Resolution Mode, where the output resolution increases 200 + * with RANGE to maintain a 4 mg/LSB scale factor. When this 201 + * bit is cleared the device is in 10-bit Mode and RANGE determine the 202 + * maximum g-Range and scale factor. 203 + */ 204 + 205 + #define ADXL_FULL_RES (1 << 3) 206 + #define ADXL_RANGE_PM_2g 0 207 + #define ADXL_RANGE_PM_4g 1 208 + #define ADXL_RANGE_PM_8g 2 209 + #define ADXL_RANGE_PM_16g 3 210 + 211 + u8 data_range; 212 + 213 + /* 214 + * low_power_mode: 215 + * A '0' = Normal operation and a '1' = Reduced 216 + * power operation with somewhat higher noise. 217 + */ 218 + 219 + u8 low_power_mode; 220 + 221 + /* 222 + * power_mode: 223 + * LINK: A '1' with both the activity and inactivity functions 224 + * enabled will delay the start of the activity function until 225 + * inactivity is detected. Once activity is detected, inactivity 226 + * detection will begin and prevent the detection of activity. This 227 + * bit serially links the activity and inactivity functions. When '0' 228 + * the inactivity and activity functions are concurrent. Additional 229 + * information can be found in the Application section under Link 230 + * Mode. 231 + * AUTO_SLEEP: A '1' sets the ADXL34x to switch to Sleep Mode 232 + * when inactivity (acceleration has been below inactivity_threshold 233 + * for at least inactivity_time) is detected and the LINK bit is set. 234 + * A '0' disables automatic switching to Sleep Mode. See SLEEP 235 + * for further description. 236 + */ 237 + 238 + #define ADXL_LINK (1 << 5) 239 + #define ADXL_AUTO_SLEEP (1 << 4) 240 + 241 + u8 power_mode; 242 + 243 + /* 244 + * fifo_mode: 245 + * BYPASS The FIFO is bypassed 246 + * FIFO FIFO collects up to 32 values then stops collecting data 247 + * STREAM FIFO holds the last 32 data values. Once full, the FIFO's 248 + * oldest data is lost as it is replaced with newer data 249 + * 250 + * DEFAULT should be ADXL_FIFO_STREAM 251 + */ 252 + 253 + #define ADXL_FIFO_BYPASS 0 254 + #define ADXL_FIFO_FIFO 1 255 + #define ADXL_FIFO_STREAM 2 256 + 257 + u8 fifo_mode; 258 + 259 + /* 260 + * watermark: 261 + * The Watermark feature can be used to reduce the interrupt load 262 + * of the system. The FIFO fills up to the value stored in watermark 263 + * [1..32] and then generates an interrupt. 264 + * A '0' disables the watermark feature. 265 + */ 266 + 267 + u8 watermark; 268 + 269 + u32 ev_type; /* EV_ABS or EV_REL */ 270 + 271 + u32 ev_code_x; /* ABS_X,Y,Z or REL_X,Y,Z */ 272 + u32 ev_code_y; /* ABS_X,Y,Z or REL_X,Y,Z */ 273 + u32 ev_code_z; /* ABS_X,Y,Z or REL_X,Y,Z */ 274 + 275 + /* 276 + * A valid BTN or KEY Code; use tap_axis_control to disable 277 + * event reporting 278 + */ 279 + 280 + u32 ev_code_tap[3]; /* EV_KEY {X-Axis, Y-Axis, Z-Axis} */ 281 + 282 + /* 283 + * A valid BTN or KEY Code for Free-Fall or Activity enables 284 + * input event reporting. A '0' disables the Free-Fall or 285 + * Activity reporting. 286 + */ 287 + 288 + u32 ev_code_ff; /* EV_KEY */ 289 + u32 ev_code_act_inactivity; /* EV_KEY */ 290 + 291 + /* 292 + * Use ADXL34x INT2 instead of INT1 293 + */ 294 + u8 use_int2; 295 + 296 + /* 297 + * ADXL346 only ORIENTATION SENSING feature 298 + * The orientation function of the ADXL346 reports both 2-D and 299 + * 3-D orientation concurrently. 300 + */ 301 + 302 + #define ADXL_EN_ORIENTATION_2D 1 303 + #define ADXL_EN_ORIENTATION_3D 2 304 + #define ADXL_EN_ORIENTATION_2D_3D 3 305 + 306 + u8 orientation_enable; 307 + 308 + /* 309 + * The width of the deadzone region between two or more 310 + * orientation positions is determined by setting the Deadzone 311 + * value. The deadzone region size can be specified with a 312 + * resolution of 3.6deg. The deadzone angle represents the total 313 + * angle where the orientation is considered invalid. 314 + */ 315 + 316 + #define ADXL_DEADZONE_ANGLE_0p0 0 /* !!!0.0 [deg] */ 317 + #define ADXL_DEADZONE_ANGLE_3p6 1 /* 3.6 [deg] */ 318 + #define ADXL_DEADZONE_ANGLE_7p2 2 /* 7.2 [deg] */ 319 + #define ADXL_DEADZONE_ANGLE_10p8 3 /* 10.8 [deg] */ 320 + #define ADXL_DEADZONE_ANGLE_14p4 4 /* 14.4 [deg] */ 321 + #define ADXL_DEADZONE_ANGLE_18p0 5 /* 18.0 [deg] */ 322 + #define ADXL_DEADZONE_ANGLE_21p6 6 /* 21.6 [deg] */ 323 + #define ADXL_DEADZONE_ANGLE_25p2 7 /* 25.2 [deg] */ 324 + 325 + u8 deadzone_angle; 326 + 327 + /* 328 + * To eliminate most human motion such as walking or shaking, 329 + * a Divisor value should be selected to effectively limit the 330 + * orientation bandwidth. Set the depth of the filter used to 331 + * low-pass filter the measured acceleration for stable 332 + * orientation sensing 333 + */ 334 + 335 + #define ADXL_LP_FILTER_DIVISOR_2 0 336 + #define ADXL_LP_FILTER_DIVISOR_4 1 337 + #define ADXL_LP_FILTER_DIVISOR_8 2 338 + #define ADXL_LP_FILTER_DIVISOR_16 3 339 + #define ADXL_LP_FILTER_DIVISOR_32 4 340 + #define ADXL_LP_FILTER_DIVISOR_64 5 341 + #define ADXL_LP_FILTER_DIVISOR_128 6 342 + #define ADXL_LP_FILTER_DIVISOR_256 7 343 + 344 + u8 divisor_length; 345 + 346 + u32 ev_codes_orient_2d[4]; /* EV_KEY {+X, -X, +Y, -Y} */ 347 + u32 ev_codes_orient_3d[6]; /* EV_KEY {+Z, +Y, +X, -X, -Y, -Z} */ 348 + }; 349 + #endif
+10
include/linux/input/cy8ctmg110_pdata.h
···
··· 1 + #ifndef _LINUX_CY8CTMG110_PDATA_H 2 + #define _LINUX_CY8CTMG110_PDATA_H 3 + 4 + struct cy8ctmg110_pdata 5 + { 6 + int reset_pin; /* Reset pin is wired to this GPIO (optional) */ 7 + int irq_pin; /* IRQ pin is wired to this GPIO */ 8 + }; 9 + 10 + #endif
+6
include/linux/input/matrix_keypad.h
··· 41 * @col_scan_delay_us: delay, measured in microseconds, that is 42 * needed before we can keypad after activating column gpio 43 * @debounce_ms: debounce interval in milliseconds 44 * @active_low: gpio polarity 45 * @wakeup: controls whether the device should be set up as wakeup 46 * source ··· 65 66 /* key debounce interval in milli-second */ 67 unsigned int debounce_ms; 68 69 bool active_low; 70 bool wakeup;
··· 41 * @col_scan_delay_us: delay, measured in microseconds, that is 42 * needed before we can keypad after activating column gpio 43 * @debounce_ms: debounce interval in milliseconds 44 + * @clustered_irq: may be specified if interrupts of all row/column GPIOs 45 + * are bundled to one single irq 46 + * @clustered_irq_flags: flags that are needed for the clustered irq 47 * @active_low: gpio polarity 48 * @wakeup: controls whether the device should be set up as wakeup 49 * source ··· 62 63 /* key debounce interval in milli-second */ 64 unsigned int debounce_ms; 65 + 66 + unsigned int clustered_irq; 67 + unsigned int clustered_irq_flags; 68 69 bool active_low; 70 bool wakeup;
+2 -1
include/linux/spi/ads7846.h
··· 48 * state if get_pendown_state == NULL 49 */ 50 int (*get_pendown_state)(void); 51 - int (*filter_init) (struct ads7846_platform_data *pdata, 52 void **filter_data); 53 int (*filter) (void *filter_data, int data_idx, int *val); 54 void (*filter_cleanup)(void *filter_data); 55 void (*wait_for_sync)(void); 56 bool wakeup; 57 }; 58
··· 48 * state if get_pendown_state == NULL 49 */ 50 int (*get_pendown_state)(void); 51 + int (*filter_init) (const struct ads7846_platform_data *pdata, 52 void **filter_data); 53 int (*filter) (void *filter_data, int data_idx, int *val); 54 void (*filter_cleanup)(void *filter_data); 55 void (*wait_for_sync)(void); 56 bool wakeup; 57 + unsigned long irq_flags; 58 }; 59