diff options
Diffstat (limited to 'drivers/input/touchscreen/ads7846.c')
-rw-r--r-- | drivers/input/touchscreen/ads7846.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 1de1c19dad30..5196861b86ef 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -109,6 +109,7 @@ struct ads7846 { | |||
109 | u16 pressure_max; | 109 | u16 pressure_max; |
110 | 110 | ||
111 | bool swap_xy; | 111 | bool swap_xy; |
112 | bool use_internal; | ||
112 | 113 | ||
113 | struct ads7846_packet *packet; | 114 | struct ads7846_packet *packet; |
114 | 115 | ||
@@ -307,7 +308,6 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
307 | struct ads7846 *ts = dev_get_drvdata(dev); | 308 | struct ads7846 *ts = dev_get_drvdata(dev); |
308 | struct ser_req *req; | 309 | struct ser_req *req; |
309 | int status; | 310 | int status; |
310 | int use_internal; | ||
311 | 311 | ||
312 | req = kzalloc(sizeof *req, GFP_KERNEL); | 312 | req = kzalloc(sizeof *req, GFP_KERNEL); |
313 | if (!req) | 313 | if (!req) |
@@ -315,11 +315,8 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
315 | 315 | ||
316 | spi_message_init(&req->msg); | 316 | spi_message_init(&req->msg); |
317 | 317 | ||
318 | /* FIXME boards with ads7846 might use external vref instead ... */ | ||
319 | use_internal = (ts->model == 7846); | ||
320 | |||
321 | /* maybe turn on internal vREF, and let it settle */ | 318 | /* maybe turn on internal vREF, and let it settle */ |
322 | if (use_internal) { | 319 | if (ts->use_internal) { |
323 | req->ref_on = REF_ON; | 320 | req->ref_on = REF_ON; |
324 | req->xfer[0].tx_buf = &req->ref_on; | 321 | req->xfer[0].tx_buf = &req->ref_on; |
325 | req->xfer[0].len = 1; | 322 | req->xfer[0].len = 1; |
@@ -331,8 +328,14 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
331 | /* for 1uF, settle for 800 usec; no cap, 100 usec. */ | 328 | /* for 1uF, settle for 800 usec; no cap, 100 usec. */ |
332 | req->xfer[1].delay_usecs = ts->vref_delay_usecs; | 329 | req->xfer[1].delay_usecs = ts->vref_delay_usecs; |
333 | spi_message_add_tail(&req->xfer[1], &req->msg); | 330 | spi_message_add_tail(&req->xfer[1], &req->msg); |
331 | |||
332 | /* Enable reference voltage */ | ||
333 | command |= ADS_PD10_REF_ON; | ||
334 | } | 334 | } |
335 | 335 | ||
336 | /* Enable ADC in every case */ | ||
337 | command |= ADS_PD10_ADC_ON; | ||
338 | |||
336 | /* take sample */ | 339 | /* take sample */ |
337 | req->command = (u8) command; | 340 | req->command = (u8) command; |
338 | req->xfer[2].tx_buf = &req->command; | 341 | req->xfer[2].tx_buf = &req->command; |
@@ -416,7 +419,7 @@ name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \ | |||
416 | { \ | 419 | { \ |
417 | struct ads7846 *ts = dev_get_drvdata(dev); \ | 420 | struct ads7846 *ts = dev_get_drvdata(dev); \ |
418 | ssize_t v = ads7846_read12_ser(dev, \ | 421 | ssize_t v = ads7846_read12_ser(dev, \ |
419 | READ_12BIT_SER(var) | ADS_PD10_ALL_ON); \ | 422 | READ_12BIT_SER(var)); \ |
420 | if (v < 0) \ | 423 | if (v < 0) \ |
421 | return v; \ | 424 | return v; \ |
422 | return sprintf(buf, "%u\n", adjust(ts, v)); \ | 425 | return sprintf(buf, "%u\n", adjust(ts, v)); \ |
@@ -509,6 +512,7 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts) | |||
509 | if (!ts->vref_mv) { | 512 | if (!ts->vref_mv) { |
510 | dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n"); | 513 | dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n"); |
511 | ts->vref_mv = 2500; | 514 | ts->vref_mv = 2500; |
515 | ts->use_internal = true; | ||
512 | } | 516 | } |
513 | break; | 517 | break; |
514 | case 7845: | 518 | case 7845: |
@@ -969,6 +973,13 @@ static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads784 | |||
969 | pdata->gpio_pendown); | 973 | pdata->gpio_pendown); |
970 | return err; | 974 | return err; |
971 | } | 975 | } |
976 | err = gpio_direction_input(pdata->gpio_pendown); | ||
977 | if (err) { | ||
978 | dev_err(&spi->dev, "failed to setup pendown GPIO%d\n", | ||
979 | pdata->gpio_pendown); | ||
980 | gpio_free(pdata->gpio_pendown); | ||
981 | return err; | ||
982 | } | ||
972 | 983 | ||
973 | ts->gpio_pendown = pdata->gpio_pendown; | 984 | ts->gpio_pendown = pdata->gpio_pendown; |
974 | 985 | ||
@@ -1340,8 +1351,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1340 | if (ts->model == 7845) | 1351 | if (ts->model == 7845) |
1341 | ads7845_read12_ser(&spi->dev, PWRDOWN); | 1352 | ads7845_read12_ser(&spi->dev, PWRDOWN); |
1342 | else | 1353 | else |
1343 | (void) ads7846_read12_ser(&spi->dev, | 1354 | (void) ads7846_read12_ser(&spi->dev, READ_12BIT_SER(vaux)); |
1344 | READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON); | ||
1345 | 1355 | ||
1346 | err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group); | 1356 | err = sysfs_create_group(&spi->dev.kobj, &ads784x_attr_group); |
1347 | if (err) | 1357 | if (err) |