]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/input/touchscreen/ads7846.c
Merge branches 'release', 'acpica', 'bugzilla-10224', 'bugzilla-9772', 'bugzilla...
[linux-2.6-omap-h63xx.git] / drivers / input / touchscreen / ads7846.c
index 58934a40f5ce5ff90abfbe071327370598d0e631..907a45fe9d40f5a828bd002ecd8d05d1562d353a 100644 (file)
 #include <linux/spi/ads7846.h>
 #include <asm/irq.h>
 
-#ifdef CONFIG_ARM
-#include <asm/mach-types.h>
-#ifdef CONFIG_ARCH_OMAP
-#include <asm/arch/gpio.h>
-#endif
-#endif
-
 
 /*
  * This code has been heavily tested on a Nokia 770, and lightly
@@ -87,6 +80,7 @@ struct ads7846 {
 #endif
 
        u16                     model;
+       u16                     vref_mv;
        u16                     vref_delay_usecs;
        u16                     x_plate_ohms;
        u16                     pressure_max;
@@ -184,9 +178,6 @@ struct ads7846 {
  * The range is GND..vREF. The ads7843 and ads7835 must use external vREF;
  * ads7846 lets that pin be unconnected, to use internal vREF.
  */
-static unsigned vREF_mV;
-module_param(vREF_mV, uint, 0);
-MODULE_PARM_DESC(vREF_mV, "external vREF voltage, in milliVolts");
 
 struct ser_req {
        u8                      ref_on;
@@ -213,7 +204,6 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
        struct ads7846          *ts = dev_get_drvdata(dev);
        struct ser_req          *req = kzalloc(sizeof *req, GFP_KERNEL);
        int                     status;
-       int                     sample;
        int                     use_internal;
 
        if (!req)
@@ -270,13 +260,13 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
 
        if (status == 0) {
                /* on-wire is a must-ignore bit, a BE12 value, then padding */
-               sample = be16_to_cpu(req->sample);
-               sample = sample >> 3;
-               sample &= 0x0fff;
+               status = be16_to_cpu(req->sample);
+               status = status >> 3;
+               status &= 0x0fff;
        }
 
        kfree(req);
-       return status ? status : sample;
+       return status;
 }
 
 #if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
@@ -317,7 +307,7 @@ static inline unsigned vaux_adjust(struct ads7846 *ts, ssize_t v)
        unsigned retval = v;
 
        /* external resistors may scale vAUX into 0..vREF */
-       retval *= vREF_mV;
+       retval *= ts->vref_mv;
        retval = retval >> 12;
        return retval;
 }
@@ -375,14 +365,14 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
        /* hwmon sensors need a reference voltage */
        switch (ts->model) {
        case 7846:
-               if (!vREF_mV) {
+               if (!ts->vref_mv) {
                        dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n");
-                       vREF_mV = 2500;
+                       ts->vref_mv = 2500;
                }
                break;
        case 7845:
        case 7843:
-               if (!vREF_mV) {
+               if (!ts->vref_mv) {
                        dev_warn(&spi->dev,
                                "external vREF for ADS%d not specified\n",
                                ts->model);
@@ -875,6 +865,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
 
        ts->spi = spi;
        ts->input = input_dev;
+       ts->vref_mv = pdata->vref_mv;
 
        hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
        ts->timer.function = ads7846_timer;
@@ -1174,31 +1165,6 @@ static struct spi_driver ads7846_driver = {
 
 static int __init ads7846_init(void)
 {
-       /* grr, board-specific init should stay out of drivers!! */
-
-#ifdef CONFIG_ARCH_OMAP
-       if (machine_is_omap_osk()) {
-               /* GPIO4 = PENIRQ; GPIO6 = BUSY */
-               omap_request_gpio(4);
-               omap_set_gpio_direction(4, 1);
-               omap_request_gpio(6);
-               omap_set_gpio_direction(6, 1);
-       }
-       // also TI 1510 Innovator, bitbanging through FPGA
-       // also Nokia 770
-       // also Palm Tungsten T2
-#endif
-
-       // PXA:
-       // also Dell Axim X50
-       // also HP iPaq H191x/H192x/H415x/H435x
-       // also Intel Lubbock (additional to UCB1400; as temperature sensor)
-       // also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky)
-
-       // Atmel at91sam9261-EK uses ads7843
-
-       // also various AMD Au1x00 devel boards
-
        return spi_register_driver(&ads7846_driver);
 }
 module_init(ads7846_init);
@@ -1206,14 +1172,6 @@ module_init(ads7846_init);
 static void __exit ads7846_exit(void)
 {
        spi_unregister_driver(&ads7846_driver);
-
-#ifdef CONFIG_ARCH_OMAP
-       if (machine_is_omap_osk()) {
-               omap_free_gpio(4);
-               omap_free_gpio(6);
-       }
-#endif
-
 }
 module_exit(ads7846_exit);