]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/input/touchscreen/tsc2005.c
Merge current mainline tree into linux-omap tree
[linux-2.6-omap-h63xx.git] / drivers / input / touchscreen / tsc2005.c
index 035d2097a6bd95c2af45ef7bb3d4b4888a9544f5..ec4c9e7a736753a7070af69cbddcbd551d0a0f1d 100644 (file)
 #include <linux/input.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
+#include <linux/gpio.h>
 #include <linux/spi/spi.h>
 
-#ifdef CONFIG_ARCH_OMAP
-#include <asm/arch/gpio.h>
-#endif
-
 #include <linux/spi/tsc2005.h>
 
 /**
  *     during the last 20ms which means the pen has been lifted.
  */
 
-#define TSC2005_HZ     (14000000)
+#define TSC2005_VDD_LOWER_27
+
+#ifdef TSC2005_VDD_LOWER_27
+#define TSC2005_HZ     (10000000)
+#else
+#define TSC2005_HZ     (25000000)
+#endif
 
 #define TSC2005_CMD    (0x80)
 #define TSC2005_REG    (0x00)
@@ -226,13 +229,12 @@ static void tsc2005_cmd(struct tsc2005 *ts, u8 cmd)
        struct spi_message msg;
        struct spi_transfer xfer = { 0 };
 
-       spi_message_init(&msg);
-       msg.spi = ts->spi;
        xfer.tx_buf = &data;
        xfer.rx_buf = NULL;
-       xfer.len = 2;
+       xfer.len = 1;
        xfer.bits_per_word = 8;
 
+       spi_message_init(&msg);
        spi_message_add_tail(&xfer, &msg);
        spi_sync(ts->spi, &msg);
 }
@@ -244,16 +246,15 @@ static void tsc2005_write(struct tsc2005 *ts, u8 reg, u16 value)
        struct spi_transfer xfer = { 0 };
 
        tx = (TSC2005_REG | reg | TSC2005_REG_PND0 |
-              TSC2005_REG_WRITE) << (2 * 8);
+              TSC2005_REG_WRITE) << 16;
        tx |= value;
 
-       spi_message_init(&msg);
-       msg.spi = ts->spi;
        xfer.tx_buf = &tx;
        xfer.rx_buf = NULL;
        xfer.len = 4;
-       xfer.bits_per_word = 3 * 8;
+       xfer.bits_per_word = 24;
 
+       spi_message_init(&msg);
        spi_message_add_tail(&xfer, &msg);
        spi_sync(ts->spi, &msg);
 }
@@ -271,10 +272,10 @@ static void tsc2005_ts_update_pen_state(struct tsc2005 *ts,
                }
        } else {
                input_report_abs(ts->idev, ABS_PRESSURE, 0);
-               if (ts->pen_down)
+               if (ts->pen_down) {
                        input_report_key(ts->idev, BTN_TOUCH, 0);
-
-               ts->pen_down = 0;
+                       ts->pen_down = 0;
+               }
        }
 
        input_sync(ts->idev);
@@ -377,7 +378,7 @@ static void tsc2005_ts_penup_timer_handler(unsigned long data)
 
 /*
  * This interrupt is called when pen is down and coordinates are
- * available. That is indicated by a falling edge on DEV line.
+ * available. That is indicated by a falling edge on DAV line.
  */
 static irqreturn_t tsc2005_ts_irq_handler(int irq, void *dev_id)
 {
@@ -406,7 +407,6 @@ static void tsc2005_ts_setup_spi_xfer(struct tsc2005 *ts)
        int i;
 
        spi_message_init(m);
-       m->spi = ts->spi;
 
        for (i = 0; i < NUM_READ_REGS; i++, x++) {
                x->tx_buf = &tsc2005_read_reg[i];
@@ -531,16 +531,15 @@ static int __devinit tsc2005_ts_init(struct tsc2005 *ts,
        ts->dav_gpio = dav_gpio;
        dev_dbg(&ts->spi->dev, "TSC2005: DAV GPIO = %d\n", dav_gpio);
 
-#ifdef CONFIG_ARCH_OMAP
-       r = omap_request_gpio(dav_gpio);
+       r = gpio_request(dav_gpio, "TSC2005 dav");
        if (r < 0) {
                dev_err(&ts->spi->dev, "unable to get DAV GPIO");
                goto err1;
        }
-       omap_set_gpio_direction(dav_gpio, 1);
-       ts->irq = OMAP_GPIO_IRQ(dav_gpio);
+       gpio_direction_input(dav_gpio);
+       ts->irq = gpio_to_irq(dav_gpio);
        dev_dbg(&ts->spi->dev, "TSC2005: DAV IRQ = %d\n", ts->irq);
-#endif
+
        init_timer(&ts->penup_timer);
        setup_timer(&ts->penup_timer, tsc2005_ts_penup_timer_handler,
                        (unsigned long)ts);
@@ -565,13 +564,9 @@ static int __devinit tsc2005_ts_init(struct tsc2005 *ts,
                goto err2;
        }
 
-       /*
-        * TODO: should be "TSC2005 touchscreen", but X has hardcoded these
-        * strings and doesn't accept TSC2005 yet...
-        */
-       idev->name = "TSC2301 touchscreen";
+       idev->name = "TSC2005 touchscreen";
        snprintf(ts->phys, sizeof(ts->phys), "%s/input-ts",
-                ts->spi->dev.bus_id);
+                dev_name(&ts->spi->dev));
        idev->phys = ts->phys;
 
        idev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
@@ -613,9 +608,7 @@ err3:
        tsc2005_stop_scan(ts);
        input_free_device(idev);
 err2:
-#ifdef CONFIG_ARCH_OMAP
-       omap_free_gpio(dav_gpio);
-#endif
+       gpio_free(dav_gpio);
 err1:
        return r;
 }
@@ -662,11 +655,10 @@ err1:
 static int __devexit tsc2005_remove(struct spi_device *spi)
 {
        struct tsc2005 *ts = dev_get_drvdata(&spi->dev);
-       unsigned long flags;
 
-       spin_lock_irqsave(&ts->lock, flags);
+       mutex_lock(&ts->mutex);
        tsc2005_disable(ts);
-       spin_unlock_irqrestore(&ts->lock, flags);
+       mutex_unlock(&ts->mutex);
 
        device_remove_file(&ts->spi->dev, &dev_attr_disable_ts);
        device_remove_file(&ts->spi->dev, &dev_attr_pen_down);
@@ -674,9 +666,7 @@ static int __devexit tsc2005_remove(struct spi_device *spi)
        free_irq(ts->irq, ts);
        input_unregister_device(ts->idev);
 
-#ifdef CONFIG_ARCH_OMAP
-       omap_free_gpio(ts->dav_gpio);
-#endif
+       gpio_free(ts->dav_gpio);
        kfree(ts);
 
        return 0;
@@ -709,7 +699,6 @@ static int tsc2005_resume(struct spi_device *spi)
 static struct spi_driver tsc2005_driver = {
        .driver = {
                .name = "tsc2005",
-               .bus = &spi_bus_type,
                .owner = THIS_MODULE,
        },
 #ifdef CONFIG_PM
@@ -736,4 +725,4 @@ module_exit(tsc2005_exit);
 
 MODULE_AUTHOR("Lauri Leukkunen <lauri.leukkunen@nokia.com>");
 MODULE_LICENSE("GPL");
-
+MODULE_ALIAS("platform:tsc2005");