aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/ads7846.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-25 15:38:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-25 15:38:14 -0400
commitce1d5b23a8d1e19866ab82bdec0dc41fde5273d8 (patch)
tree028c80655ee8853ebf607d435bc3d6ab223aef1f /drivers/input/touchscreen/ads7846.c
parentad5e1b0f5d913d2c8bddfba81049cc07228da1a6 (diff)
parent308f0a5898033691d050374a949bbfe173987a16 (diff)
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: (40 commits) Input: wacom - add support for Cintiq 20WSX Input: ucb1400_ts - IRQ probe fix Input: at32psif - update MODULE_AUTHOR with new email Input: mac_hid - add lockdep annotation to emumousebtn Input: i8042 - fix incorrect usage of strncpy and strncat Input: bf54x-keys - add infrastructure for keypad wakeups Input: add MODULE_ALIAS() to hotpluggable platform modules Input: drivers/char/keyboard.c - use time_after Input: fix ordering in joystick Makefile Input: wm97xx-core - support use as a wakeup source Input: wm97xx-core - use IRQF_SAMPLE_RANDOM Input: wm97xx-core - only schedule interrupt handler if not already scheduled Input: add Zhen Hua driver Input: aiptek - add support for Genius G-PEN 560 tablet Input: wacom - implement suspend and autosuspend Input: xpad - set proper buffer length for outgoing requests Input: omap-keypad - fix build warning Input: gpio_keys - irq handling cleanup Input: add PS/2 serio driver for AVR32 devices Input: put ledstate in the keyboard notifier ...
Diffstat (limited to 'drivers/input/touchscreen/ads7846.c')
-rw-r--r--drivers/input/touchscreen/ads7846.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 39573b91c8de..907a45fe9d40 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -80,6 +80,7 @@ struct ads7846 {
80#endif 80#endif
81 81
82 u16 model; 82 u16 model;
83 u16 vref_mv;
83 u16 vref_delay_usecs; 84 u16 vref_delay_usecs;
84 u16 x_plate_ohms; 85 u16 x_plate_ohms;
85 u16 pressure_max; 86 u16 pressure_max;
@@ -177,9 +178,6 @@ struct ads7846 {
177 * The range is GND..vREF. The ads7843 and ads7835 must use external vREF; 178 * The range is GND..vREF. The ads7843 and ads7835 must use external vREF;
178 * ads7846 lets that pin be unconnected, to use internal vREF. 179 * ads7846 lets that pin be unconnected, to use internal vREF.
179 */ 180 */
180static unsigned vREF_mV;
181module_param(vREF_mV, uint, 0);
182MODULE_PARM_DESC(vREF_mV, "external vREF voltage, in milliVolts");
183 181
184struct ser_req { 182struct ser_req {
185 u8 ref_on; 183 u8 ref_on;
@@ -206,7 +204,6 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
206 struct ads7846 *ts = dev_get_drvdata(dev); 204 struct ads7846 *ts = dev_get_drvdata(dev);
207 struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL); 205 struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL);
208 int status; 206 int status;
209 int uninitialized_var(sample);
210 int use_internal; 207 int use_internal;
211 208
212 if (!req) 209 if (!req)
@@ -263,13 +260,13 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
263 260
264 if (status == 0) { 261 if (status == 0) {
265 /* on-wire is a must-ignore bit, a BE12 value, then padding */ 262 /* on-wire is a must-ignore bit, a BE12 value, then padding */
266 sample = be16_to_cpu(req->sample); 263 status = be16_to_cpu(req->sample);
267 sample = sample >> 3; 264 status = status >> 3;
268 sample &= 0x0fff; 265 status &= 0x0fff;
269 } 266 }
270 267
271 kfree(req); 268 kfree(req);
272 return status ? status : sample; 269 return status;
273} 270}
274 271
275#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) 272#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
@@ -310,7 +307,7 @@ static inline unsigned vaux_adjust(struct ads7846 *ts, ssize_t v)
310 unsigned retval = v; 307 unsigned retval = v;
311 308
312 /* external resistors may scale vAUX into 0..vREF */ 309 /* external resistors may scale vAUX into 0..vREF */
313 retval *= vREF_mV; 310 retval *= ts->vref_mv;
314 retval = retval >> 12; 311 retval = retval >> 12;
315 return retval; 312 return retval;
316} 313}
@@ -368,14 +365,14 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
368 /* hwmon sensors need a reference voltage */ 365 /* hwmon sensors need a reference voltage */
369 switch (ts->model) { 366 switch (ts->model) {
370 case 7846: 367 case 7846:
371 if (!vREF_mV) { 368 if (!ts->vref_mv) {
372 dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n"); 369 dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n");
373 vREF_mV = 2500; 370 ts->vref_mv = 2500;
374 } 371 }
375 break; 372 break;
376 case 7845: 373 case 7845:
377 case 7843: 374 case 7843:
378 if (!vREF_mV) { 375 if (!ts->vref_mv) {
379 dev_warn(&spi->dev, 376 dev_warn(&spi->dev,
380 "external vREF for ADS%d not specified\n", 377 "external vREF for ADS%d not specified\n",
381 ts->model); 378 ts->model);
@@ -868,6 +865,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
868 865
869 ts->spi = spi; 866 ts->spi = spi;
870 ts->input = input_dev; 867 ts->input = input_dev;
868 ts->vref_mv = pdata->vref_mv;
871 869
872 hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 870 hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
873 ts->timer.function = ads7846_timer; 871 ts->timer.function = ads7846_timer;