[Nexus 4 Original Android Development] bponury:
[MENTION=3750240]stratosk[/MENTION]: I looked into that touchwake code and you are correct for some reason it's code is always handling suspend which is IMO wrong.

I just changed early suspend and late resume calls to work normally with touchwake disabled (file: lge_touch_core.c)

Here is modified patch (discard last one).

diff --git a/drivers/input/input.c b/drivers/input/input.c
index ad45927..ec79fee 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -247,7 +247,7 @@ static void input_handle_event(struct input_dev *dev,
if (is_event_supported(code, dev->keybit, KEY_MAX) &&
!!test_bit(code, dev->key) != value) {
#ifdef CONFIG_TOUCH_WAKE
-	if (code == KEY_POWER && !device_is_suspended()) {
+	if (touchwake_is_enabled() && code == KEY_POWER && !device_is_suspended()) {
if (value == 1)
powerkey_pressed();
else if (value == 0)
diff --git a/drivers/input/touchscreen/lge_touch_core.c b/drivers/input/touchscreen/lge_touch_core.c
index 900b23c..bb70cdb 100644
--- a/drivers/input/touchscreen/lge_touch_core.c
+++ b/drivers/input/touchscreen/lge_touch_core.c
@@ -2056,10 +2056,14 @@ static int touch_remove(struct i2c_client *client)
#if defined(CONFIG_HAS_EARLYSUSPEND)
static void touch_early_suspend(struct early_suspend *h)
{
-#ifndef CONFIG_TOUCH_WAKE
struct lge_touch_data *ts =
container_of(h, struct lge_touch_data, early_suspend);

+#ifdef CONFIG_TOUCH_WAKE
+	if (touchwake_is_enabled())
+	return;	/* touchwake will handle touchscreen suspend call */
+#endif
+	/* touchwake is not compiled or it's disabled - handle suspend */
if (unlikely(touch_debug_mask & DEBUG_TRACE))
TOUCH_DEBUG_MSG("\n");

@@ -2083,15 +2087,19 @@ static void touch_early_suspend(struct early_suspend *h)
release_all_ts_event(ts);

touch_power_cntl(ts, ts->pdata->role->suspend_pwr);
-#endif
}

static void touch_late_resume(struct early_suspend *h)
{
-#ifndef CONFIG_TOUCH_WAKE
struct lge_touch_data *ts =
container_of(h, struct lge_touch_data, early_suspend);

+#ifdef CONFIG_TOUCH_WAKE
+	if (touchwake_is_enabled())
+	return;
+#endif
+	/* touchwake is not compiled or it's disabled - handle wake */
+
if (unlikely(touch_debug_mask & DEBUG_TRACE))
TOUCH_DEBUG_MSG("\n");

@@ -2116,7 +2124,6 @@ static void touch_late_resume(struct early_suspend *h)
msecs_to_jiffies(ts->pdata->role->booting_delay));
else
queue_delayed_work(touch_wq, &ts->work_init, 0);
-#endif
}
#endif

diff --git a/drivers/misc/touch_wake.c b/drivers/misc/touch_wake.c
index 50645e7..9682fdb 100644
--- a/drivers/misc/touch_wake.c
+++ b/drivers/misc/touch_wake.c
@@ -66,8 +66,17 @@ static void touchwake_enable_touch(void)
return;
}

+bool touchwake_is_enabled(void)
+{
+	return touchwake_enabled;
+}
+EXPORT_SYMBOL(touchwake_is_enabled);
+
static void touchwake_early_suspend(struct early_suspend *h)
{
+	if (!touchwake_enabled)
+	return;
+
if (touchwake_enabled && timed_out) {
wake_lock(&touchwake_wake_lock);
led_trigger_event(&touchwake_led_trigger, LED_FULL);
@@ -93,6 +102,7 @@ static void touchwake_late_resume(struct early_suspend *h)
led_trigger_event(&touchwake_led_trigger, LED_OFF);
timed_out = true;
device_suspended = false;
+
return;
}

diff --git a/include/linux/touch_wake.h b/include/linux/touch_wake.h
index 0185ec7..00b2293 100644
--- a/include/linux/touch_wake.h
+++ b/include/linux/touch_wake.h
@@ -7,6 +7,7 @@

extern void touchscreen_enable(void);
extern void touchscreen_disable(void);
+bool touchwake_is_enabled(void);

void powerkey_pressed(void);
void powerkey_released(void);

There is just one thing I'm not sure about - in touch_wake.c i would also add this:

static void touchwake_late_resume(struct early_suspend *h)
{
if (!touchwake_enabled)
return;

cancel_delayed_work(&touchoff_work);

But it should not be necessary.