From 32973882220c7453ea676644bc44469c32de88a8 Mon Sep 17 00:00:00 2001 From: eddie Date: Wed, 24 Aug 2011 15:57:27 +0800 Subject: [PATCH] newton:add ft5406 and gt819 early suspend --- drivers/input/touchscreen/ft5406_ts.c | 31 +++++++++++++++------------ drivers/input/touchscreen/gt819.c | 26 +++++++++++++++++----- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/drivers/input/touchscreen/ft5406_ts.c b/drivers/input/touchscreen/ft5406_ts.c index 51317a5c769c..d36cfbceb55e 100755 --- a/drivers/input/touchscreen/ft5406_ts.c +++ b/drivers/input/touchscreen/ft5406_ts.c @@ -59,10 +59,8 @@ #include /* ddl@rock-chips.com : camera support */ #include #include -#ifdef CONFIG_HAS_EARLYSUSPEND #include -static struct early_suspend ft5406_early_suspend; -#endif +static struct early_suspend ft5406_power; @@ -676,6 +674,17 @@ static int ft5406_resume(struct i2c_client *client) return 0; } +static void ft5406_suspend_early(struct early_suspend *h) +{ + dev_info(&this_client->dev, "ft5406_suspend_early!\n"); + ft5406_suspend(this_client,PMSG_SUSPEND); +} + +static void ft5406_resume_early(struct early_suspend *h) +{ + dev_info(&this_client->dev, "ft5406_resume_early!\n"); + ft5406_resume(this_client); +} static int __devexit ft5406_remove(struct i2c_client *client) { struct ft5x0x_ts_data *ft5x0x_ts = i2c_get_clientdata(client); @@ -686,9 +695,7 @@ static int __devexit ft5406_remove(struct i2c_client *client) cancel_work_sync(&ft5x0x_ts->pen_event_work); destroy_workqueue(ft5x0x_ts->ts_workqueue); i2c_set_clientdata(client, NULL); -#ifdef CONFIG_HAS_EARLYSUSPEND - unregister_early_suspend(&ft5406_early_suspend); -#endif + unregister_early_suspend(&ft5406_power); this_client = NULL; return 0; } @@ -836,12 +843,10 @@ static int ft5406_probe(struct i2c_client *client ,const struct i2c_device_id * } i2c_set_clientdata(client, ft5x0x_ts); -#if 0//def CONFIG_HAS_EARLYSUSPEND - ft5406_early_suspend.suspend =ft5406_ts_suspend; - ft5406_early_suspend.resume =ft5406_ts_resume; - ft5406_early_suspend.level = 0x2; - register_early_suspend(&ft5406_early_suspend); -#endif + ft5406_power.suspend =ft5406_suspend_early; + ft5406_power.resume =ft5406_resume_early; + ft5406_power.level = 0x2; + register_early_suspend(&ft5406_power); buf_w[0] = 6; err = ft5406_set_regs(client,0x88,buf_w,1); @@ -884,8 +889,6 @@ static struct i2c_driver ft5406_driver = { }, .id_table = ft5406_idtable, .probe = ft5406_probe, - .suspend = ft5406_suspend, - .resume = ft5406_resume, .remove = __devexit_p(ft5406_remove), }; diff --git a/drivers/input/touchscreen/gt819.c b/drivers/input/touchscreen/gt819.c index e8d40f7b4f7d..0705c6c333a6 100755 --- a/drivers/input/touchscreen/gt819.c +++ b/drivers/input/touchscreen/gt819.c @@ -98,6 +98,7 @@ unsigned int crc32_table[256]; unsigned int oldcrc32 = 0xFFFFFFFF; unsigned int ulPolynomial = 0x04c11db7; struct i2c_client * i2c_connect_client = NULL; +static struct early_suspend gt819_power; static u8 gt819_fw[]= { #include "gt819_fw.i" @@ -555,6 +556,17 @@ static int gt819_resume(struct i2c_client *client) return 0; } +static void gt819_early_suspend(struct early_suspend *h) +{ + dev_info(&i2c_connect_client->dev, "gt819_early_suspend!\n"); + gt819_suspend(i2c_connect_client,PMSG_SUSPEND); +} + +static void gt819_early_resume(struct early_suspend *h) +{ + dev_info(&i2c_connect_client->dev, "gt819_resume_early!\n"); + gt819_resume(i2c_connect_client); +} /******************************************************* Description: @@ -573,14 +585,16 @@ static int gt819_remove(struct i2c_client *client) remove_proc_entry("goodix-update", NULL); #endif //goodix_debug_sysfs_deinit(); - gpio_direction_input(ts->irq_gpio); - gpio_free(ts->irq_gpio); - free_irq(client->irq, ts); + gpio_direction_input(ts->irq_gpio); + gpio_free(ts->irq_gpio); + free_irq(client->irq, ts); if(ts->goodix_wq) destroy_workqueue(ts->goodix_wq); dev_notice(&client->dev,"The driver is removing...\n"); i2c_set_clientdata(client, NULL); input_unregister_device(ts->input_dev); + unregister_early_suspend(>819_power); + i2c_connect_client = 0; kfree(ts); return 0; } @@ -726,6 +740,10 @@ static int gt819_probe(struct i2c_client *client, const struct i2c_device_id *id } i2c_set_clientdata(client, ts); + gt819_power.suspend = gt819_early_suspend; + gt819_power.resume = gt819_early_resume; + gt819_power.level = 0x2; + register_early_suspend(>819_power); return 0; i2c_set_clientdata(client, NULL); input_unregister_device(ts->input_dev); @@ -754,8 +772,6 @@ static const struct i2c_device_id gt819_id[] = { static struct i2c_driver gt819_driver = { .probe = gt819_probe, .remove = gt819_remove, - .suspend = gt819_suspend, - .resume = gt819_resume, .id_table = gt819_id, .driver = { .name = GOODIX_I2C_NAME, -- 2.34.1