cyttsp: implement early_suspend for cypress controller
authorHong Liu <hong.liu@intel.com>
Tue, 12 Apr 2011 01:38:06 +0000 (09:38 +0800)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 20:37:46 +0000 (12:37 -0800)
Put the controller into deep sleep mode when display is off.
This gives a saving of ~5mW on the TMD panel during S0i3.

Change-Id: I69d1e182311c164ad9372a44f736f8a71826fa17
Signed-off-by: Hong Liu <hong.liu@intel.com>
drivers/input/touchscreen/cyttsp_core.c

index 157786e..e9fb703 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/bitops.h>
 #include <linux/cyttsp.h>
 #include <linux/ctype.h>
+#include <linux/earlysuspend.h>
 #include "cyttsp_core.h"
 
 /* rely on kernel input.h to define Multi-Touch capability */
@@ -257,6 +258,8 @@ struct cyttsp {
        struct cyttsp_bus_ops *bus_ops;
        unsigned fw_loader_mode:1;
        unsigned suspended:1;
+
+       struct early_suspend early_suspend;
 };
 
 struct cyttsp_track_data {
@@ -1400,6 +1403,22 @@ int cyttsp_suspend(void *handle)
 EXPORT_SYMBOL(cyttsp_suspend);
 #endif
 
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static void cyttsp_early_suspend(struct early_suspend *h)
+{
+       struct cyttsp *ts = container_of(h, struct cyttsp, early_suspend);
+
+       cyttsp_suspend(ts);
+}
+
+static void cyttsp_late_resume(struct early_suspend *h)
+{
+       struct cyttsp *ts = container_of(h, struct cyttsp, early_suspend);
+
+       cyttsp_resume(ts);
+}
+#endif
+
 static ssize_t firmware_write(struct file *file, struct kobject *kobj,
                struct bin_attribute *bin_attr,
                char *buf, loff_t pos, size_t size)
@@ -1533,6 +1552,13 @@ int cyttsp_core_init(void *bus_priv, struct cyttsp_bus_ops *bus_ops,
        ts->bus_ops = bus_ops;
        ts->bus_priv = bus_priv;
 
+#ifdef CONFIG_HAS_EARLYSUSPEND
+       ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
+       ts->early_suspend.suspend = cyttsp_early_suspend;
+       ts->early_suspend.resume = cyttsp_late_resume;
+       register_early_suspend(&ts->early_suspend);
+#endif
+
        if (ts->platform_data->init)
                retval = ts->platform_data->init(1);
        if (retval) {