]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/input/touchscreen/ads7846.c
Merge current mainline tree into linux-omap tree
[linux-2.6-omap-h63xx.git] / drivers / input / touchscreen / ads7846.c
index 51ae4fb7d123b2882380f1ec78531949c70c59a9..48cc5b060122167838d10171bf07f998ca4c8f90 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
@@ -116,6 +109,7 @@ struct ads7846 {
 // FIXME remove "irq_disabled"
        unsigned                irq_disabled:1; /* P: lock */
        unsigned                disabled:1;
+       unsigned                is_suspended:1;
 
        int                     (*filter)(void *data, int data_idx, int *val);
        void                    *filter_data;
@@ -203,7 +197,7 @@ static void ads7846_disable(struct ads7846 *ts);
 static int device_suspended(struct device *dev)
 {
        struct ads7846 *ts = dev_get_drvdata(dev);
-       return dev->power.power_state.event != PM_EVENT_ON || ts->disabled;
+       return ts->is_suspended || ts->disabled;
 }
 
 static int ads7846_read12_ser(struct device *dev, unsigned command)
@@ -267,13 +261,12 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
        ts->irq_disabled = 0;
        enable_irq(spi->irq);
 
-       if (req->msg.status)
-               status = req->msg.status;
-
-       /* on-wire is a must-ignore bit, a BE12 value, then padding */
-       sample = be16_to_cpu(req->sample);
-       sample = sample >> 3;
-       sample &= 0x0fff;
+       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;
+       }
 
        kfree(req);
        return status ? status : sample;
@@ -795,7 +788,7 @@ static int ads7846_suspend(struct spi_device *spi, pm_message_t message)
 
        spin_lock_irq(&ts->lock);
 
-       spi->dev.power.power_state = message;
+       ts->is_suspended = 1;
        ads7846_disable(ts);
 
        spin_unlock_irq(&ts->lock);
@@ -810,7 +803,7 @@ static int ads7846_resume(struct spi_device *spi)
 
        spin_lock_irq(&ts->lock);
 
-       spi->dev.power.power_state = PMSG_ON;
+       ts->is_suspended = 0;
        ads7846_enable(ts);
 
        spin_unlock_irq(&ts->lock);
@@ -838,6 +831,15 @@ static int __devinit ads7846_probe(struct spi_device *spi)
                return -ENODEV;
        }
 
+       /* enable voltage */
+       if (pdata->vaux_control != NULL) {
+               err = pdata->vaux_control(VAUX_ENABLE);
+               if (err != 0) {
+                       dev_dbg(&spi->dev, "TS vaux enable failed\n");
+                       return err;
+               }
+       }
+
        /* don't exceed max specified sample rate */
        if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) {
                dev_dbg(&spi->dev, "f(sample) %d KHz?\n",
@@ -872,7 +874,6 @@ static int __devinit ads7846_probe(struct spi_device *spi)
        }
 
        dev_set_drvdata(&spi->dev, ts);
-       spi->dev.power.power_state = PMSG_ON;
 
        ts->spi = spi;
        ts->input = input_dev;
@@ -917,8 +918,8 @@ static int __devinit ads7846_probe(struct spi_device *spi)
        input_dev->phys = ts->phys;
        input_dev->dev.parent = &spi->dev;
 
-       input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
-       input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+       input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
+       input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
        input_set_abs_params(input_dev, ABS_X,
                        pdata->x_min ? : 0,
                        pdata->x_max ? : MAX_12BIT,
@@ -1175,31 +1176,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);
@@ -1207,14 +1183,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);