aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/input/touchscreen/ads7846.c22
-rw-r--r--include/linux/spi/ads7846.h3
2 files changed, 12 insertions, 13 deletions
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 57a1c28bf12..a571aa965da 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -87,6 +87,7 @@ struct ads7846 {
87#endif 87#endif
88 88
89 u16 model; 89 u16 model;
90 u16 vref_mv;
90 u16 vref_delay_usecs; 91 u16 vref_delay_usecs;
91 u16 x_plate_ohms; 92 u16 x_plate_ohms;
92 u16 pressure_max; 93 u16 pressure_max;
@@ -184,9 +185,6 @@ struct ads7846 {
184 * The range is GND..vREF. The ads7843 and ads7835 must use external vREF; 185 * The range is GND..vREF. The ads7843 and ads7835 must use external vREF;
185 * ads7846 lets that pin be unconnected, to use internal vREF. 186 * ads7846 lets that pin be unconnected, to use internal vREF.
186 */ 187 */
187static unsigned vREF_mV;
188module_param(vREF_mV, uint, 0);
189MODULE_PARM_DESC(vREF_mV, "external vREF voltage, in milliVolts");
190 188
191struct ser_req { 189struct ser_req {
192 u8 ref_on; 190 u8 ref_on;
@@ -213,7 +211,6 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
213 struct ads7846 *ts = dev_get_drvdata(dev); 211 struct ads7846 *ts = dev_get_drvdata(dev);
214 struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL); 212 struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL);
215 int status; 213 int status;
216 int uninitialized_var(sample);
217 int use_internal; 214 int use_internal;
218 215
219 if (!req) 216 if (!req)
@@ -270,13 +267,13 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
270 267
271 if (status == 0) { 268 if (status == 0) {
272 /* on-wire is a must-ignore bit, a BE12 value, then padding */ 269 /* on-wire is a must-ignore bit, a BE12 value, then padding */
273 sample = be16_to_cpu(req->sample); 270 status = be16_to_cpu(req->sample);
274 sample = sample >> 3; 271 status = status >> 3;
275 sample &= 0x0fff; 272 status &= 0x0fff;
276 } 273 }
277 274
278 kfree(req); 275 kfree(req);
279 return status ? status : sample; 276 return status;
280} 277}
281 278
282#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) 279#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
@@ -317,7 +314,7 @@ static inline unsigned vaux_adjust(struct ads7846 *ts, ssize_t v)
317 unsigned retval = v; 314 unsigned retval = v;
318 315
319 /* external resistors may scale vAUX into 0..vREF */ 316 /* external resistors may scale vAUX into 0..vREF */
320 retval *= vREF_mV; 317 retval *= ts->vref_mv;
321 retval = retval >> 12; 318 retval = retval >> 12;
322 return retval; 319 return retval;
323} 320}
@@ -375,14 +372,14 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
375 /* hwmon sensors need a reference voltage */ 372 /* hwmon sensors need a reference voltage */
376 switch (ts->model) { 373 switch (ts->model) {
377 case 7846: 374 case 7846:
378 if (!vREF_mV) { 375 if (!ts->vref_mv) {
379 dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n"); 376 dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n");
380 vREF_mV = 2500; 377 ts->vref_mv = 2500;
381 } 378 }
382 break; 379 break;
383 case 7845: 380 case 7845:
384 case 7843: 381 case 7843:
385 if (!vREF_mV) { 382 if (!ts->vref_mv) {
386 dev_warn(&spi->dev, 383 dev_warn(&spi->dev,
387 "external vREF for ADS%d not specified\n", 384 "external vREF for ADS%d not specified\n",
388 ts->model); 385 ts->model);
@@ -875,6 +872,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
875 872
876 ts->spi = spi; 873 ts->spi = spi;
877 ts->input = input_dev; 874 ts->input = input_dev;
875 ts->vref_mv = pdata->vref_mv;
878 876
879 hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 877 hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
880 ts->timer.function = ads7846_timer; 878 ts->timer.function = ads7846_timer;
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index 334d3141162..daf744017a3 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -14,7 +14,8 @@ enum ads7846_filter {
14struct ads7846_platform_data { 14struct ads7846_platform_data {
15 u16 model; /* 7843, 7845, 7846. */ 15 u16 model; /* 7843, 7845, 7846. */
16 u16 vref_delay_usecs; /* 0 for external vref; etc */ 16 u16 vref_delay_usecs; /* 0 for external vref; etc */
17 int keep_vref_on:1; /* set to keep vref on for differential 17 u16 vref_mv; /* external vref value, milliVolts */
18 bool keep_vref_on; /* set to keep vref on for differential
18 * measurements as well */ 19 * measurements as well */
19 20
20 /* Settling time of the analog signals; a function of Vcc and the 21 /* Settling time of the analog signals; a function of Vcc and the