]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/input/touchscreen/omap/omap_ts.c
h63xx: touchscreen support
[linux-2.6-omap-h63xx.git] / drivers / input / touchscreen / omap / omap_ts.c
index bb594df461112f943e8bcccfd59718a376b36c1c..1063794deec0606d222b726a26b3b6a3257b5d09 100644 (file)
@@ -35,7 +35,7 @@
 #include <linux/wait.h>
 #include <linux/interrupt.h>
 #include <linux/suspend.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
 
 #include <asm/mach-types.h>
 
 #define OMAP_TS_NAME   "omap_ts"
 
 static struct ts_device *__initdata ts_devs[] = {
-#if defined(CONFIG_MACH_OMAP_H2) || defined(CONFIG_MACH_OMAP_H3)
+#if defined(CONFIG_MACH_OMAP_H2) || defined(CONFIG_MACH_OMAP_H3) || defined(CONFIG_MACH_OMAP_H6300)
        &hx_ts,
 #endif
 #ifdef CONFIG_MACH_OMAP_OSK
        &osk_ts,
 #endif
-#if defined(CONFIG_MACH_OMAP_INNOVATOR) && defined(CONFIG_ARCH_OMAP1510)
+#if defined(CONFIG_MACH_OMAP_INNOVATOR) && defined(CONFIG_ARCH_OMAP15XX)
        &innovator1510_ts,
 #endif
 };
@@ -65,10 +65,10 @@ static int omap_ts_read(void)
 
        ts_omap.dev->read(data);
 
-       input_report_abs(&(ts_omap.inputdevice), ABS_X, data[0]);
-       input_report_abs(&(ts_omap.inputdevice), ABS_Y, data[1]);
-       input_report_abs(&(ts_omap.inputdevice), ABS_PRESSURE, data[2]);
-       input_sync(&(ts_omap.inputdevice));
+       input_report_abs(ts_omap.inputdevice, ABS_X, data[0]);
+       input_report_abs(ts_omap.inputdevice, ABS_Y, data[1]);
+       input_report_abs(ts_omap.inputdevice, ABS_PRESSURE, data[2]);
+       input_sync(ts_omap.inputdevice);
 
        DEBUG_TS("omap_ts_read: read x=%d,y=%d,p=%d\n", data[0], data[1],
                 data[2]);
@@ -85,7 +85,7 @@ static void omap_ts_timer(unsigned long data)
        if (!ts_omap.dev->penup()) {
                if (!ts_omap.touched) {
                        DEBUG_TS("omap_ts_timer: pen down\n");
-                       input_report_key(&(ts_omap.inputdevice), BTN_TOUCH, 1);
+                       input_report_key(ts_omap.inputdevice, BTN_TOUCH, 1);
                }
                ts_omap.touched = 1;
                omap_ts_read();
@@ -95,12 +95,12 @@ static void omap_ts_timer(unsigned long data)
                if (ts_omap.touched) {
                        DEBUG_TS("omap_ts_timer: pen up\n");
                        ts_omap.touched = 0;
-                       input_report_abs(&(ts_omap.inputdevice), ABS_X, 0);
-                       input_report_abs(&(ts_omap.inputdevice), ABS_Y, 0);
-                       input_report_abs(&(ts_omap.inputdevice), ABS_PRESSURE,
+                       input_report_abs(ts_omap.inputdevice, ABS_X, 0);
+                       input_report_abs(ts_omap.inputdevice, ABS_Y, 0);
+                       input_report_abs(ts_omap.inputdevice, ABS_PRESSURE,
                                         0);
-                       input_sync(&(ts_omap.inputdevice));
-                       input_report_key(&(ts_omap.inputdevice), BTN_TOUCH, 0);
+                       input_sync(ts_omap.inputdevice);
+                       input_report_key(ts_omap.inputdevice, BTN_TOUCH, 0);
                }
                if (!ts_omap.irq_enabled) {
                        ts_omap.irq_enabled = 1;
@@ -120,20 +120,25 @@ static irqreturn_t omap_ts_handler(int irq, void *dev_id, struct pt_regs *regs)
                disable_irq(irq);
        }
        // restart acquire
-       ts_omap.ts_timer.expires = jiffies + HZ / 100;
-       add_timer(&(ts_omap.ts_timer));
+       mod_timer(&ts_omap.ts_timer, jiffies + HZ / 100);
 
        spin_unlock(&ts_omap.lock);
 
        return IRQ_HANDLED;
 }
 
-static int __init omap_ts_probe(struct device *dev)
+static int __init omap_ts_probe(struct platform_device *pdev)
 {
        int i;
        int status = -ENODEV;
 
        memset(&ts_omap, 0, sizeof(ts_omap));
+
+       ts_omap.inputdevice = input_allocate_device();
+       if (!ts_omap.inputdevice) {
+               return -ENOMEM;
+       }
+
        spin_lock_init(&ts_omap.lock);
 
        for (i = 0; i < ARRAY_SIZE(ts_devs); i++) {
@@ -146,8 +151,10 @@ static int __init omap_ts_probe(struct device *dev)
                }
        }
 
-       if (status != 0)
+       if (status != 0) {
+               input_free_device(ts_omap.inputdevice);
                return status;
+       }
 
        // Init acquisition timer function
        init_timer(&ts_omap.ts_timer);
@@ -155,26 +162,31 @@ static int __init omap_ts_probe(struct device *dev)
 
        /* request irq */
        if (ts_omap.irq != -1) {
-               if (request_irq(ts_omap.irq, omap_ts_handler, 0,
+               if (request_irq(ts_omap.irq, omap_ts_handler,
+                               SA_SAMPLE_RANDOM | ts_omap.irq_type,
                                OMAP_TS_NAME, &ts_omap)) {
                        printk(KERN_ERR
          "omap_ts.c: Could not allocate touchscreen IRQ!\n");
                        ts_omap.irq = -1;
+                       ts_omap.dev->remove();
+                       input_free_device(ts_omap.inputdevice);
                        return -EINVAL;
                }
                ts_omap.irq_enabled = 1;
        } else {
                printk(KERN_ERR "omap_ts.c: No touchscreen IRQ assigned!\n");
+               ts_omap.dev->remove();
+               input_free_device(ts_omap.inputdevice);
                return -EINVAL;
        }
 
-       init_input_dev(&(ts_omap.inputdevice));
-       ts_omap.inputdevice.name = OMAP_TS_NAME;
-       ts_omap.inputdevice.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
-       ts_omap.inputdevice.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
-       ts_omap.inputdevice.absbit[0] =
+       ts_omap.inputdevice->name = OMAP_TS_NAME;
+       ts_omap.inputdevice->dev = &pdev->dev;
+       ts_omap.inputdevice->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+       ts_omap.inputdevice->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+       ts_omap.inputdevice->absbit[0] =
            BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
-       input_register_device(&(ts_omap.inputdevice));
+       input_register_device(ts_omap.inputdevice);
 
        ts_omap.dev->enable();
 
@@ -183,10 +195,10 @@ static int __init omap_ts_probe(struct device *dev)
        return 0;
 }
 
-static int __exit omap_ts_remove(struct device *dev)
+static int omap_ts_remove(struct platform_device *pdev)
 {
        ts_omap.dev->disable();
-       input_unregister_device(&ts_omap.inputdevice);
+       input_unregister_device(ts_omap.inputdevice);
        if (ts_omap.irq != -1)
                free_irq(ts_omap.irq, &ts_omap);
 
@@ -195,22 +207,14 @@ static int __exit omap_ts_remove(struct device *dev)
        return 0;
 }
 
-static int omap_ts_suspend(struct device *dev, pm_message_t mesg, u32 level)
+static int omap_ts_suspend(struct platform_device *pdev, pm_message_t state)
 {
-       if (level != SUSPEND_POWER_DOWN) {
-               return 0;
-       }
-
        ts_omap.dev->disable();
        return 0;
 }
 
-static int omap_ts_resume(struct device *dev, u32 level)
+static int omap_ts_resume(struct platform_device *pdev)
 {
-       if (level != RESUME_POWER_ON) {
-               return 0;
-       }
-
        ts_omap.dev->enable();
        return 0;
 }
@@ -219,14 +223,14 @@ static void omap_ts_device_release(struct device *dev)
 {
        /* Nothing */
 }
-
-static struct device_driver omap_ts_driver = {
-       .name           = OMAP_TS_NAME,
-       .bus            = &platform_bus_type,
+static struct platform_driver omap_ts_driver = {
        .probe          = omap_ts_probe,
-       .remove         = __exit_p(omap_ts_remove),
+       .remove         = omap_ts_remove,
        .suspend        = omap_ts_suspend,
        .resume         = omap_ts_resume,
+       .driver = {
+               .name   = OMAP_TS_NAME,
+       },
 };
 
 static struct platform_device omap_ts_device = {
@@ -245,7 +249,7 @@ static int __init omap_ts_init(void)
        if (ret != 0)
                return -ENODEV;
 
-       ret = driver_register(&omap_ts_driver);
+       ret = platform_driver_register(&omap_ts_driver);
        if (ret != 0) {
                platform_device_unregister(&omap_ts_device);
                return -ENODEV;
@@ -256,7 +260,7 @@ static int __init omap_ts_init(void)
 
 static void __exit omap_ts_exit(void)
 {
-       driver_unregister(&omap_ts_driver);
+       platform_driver_unregister(&omap_ts_driver);
        platform_device_unregister(&omap_ts_device);
 }