diff options
author | Robert Collins <rcollins@nvidia.com> | 2011-06-06 15:06:45 -0700 |
---|---|---|
committer | Niket Sirsi <nsirsi@nvidia.com> | 2011-06-24 20:56:50 -0700 |
commit | 8d74c1431175e8d3766d242f6f157cbe52122800 (patch) | |
tree | 42b967068126d30f0212ca90eb90d72181f7b417 | |
parent | 3bcb22dec581875cc5497433019472c8ee915acc (diff) |
Input: atmel_mxt_ts: add early suspend/resume functionality
Add early suspend/resume functionality to Atmel touch driver.
0W suspend.
Early suspend/resume functions written and provided by
Atmel Corporation.
BUG 826854
Change-Id: I58d5abacff20df9d3027c960021e94298e31b8a6
Reviewed-on: http://git-master/r/35286
Reviewed-by: Robert R Collins <rcollins@nvidia.com>
Tested-by: Robert R Collins <rcollins@nvidia.com>
Reviewed-by: Scott Williams <scwilliams@nvidia.com>
Reviewed-by: Narendra Damahe <ndamahe@nvidia.com>
Reviewed-by: Daniel Willemsen <dwillemsen@nvidia.com>
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 62942573515a..33d49f8aacaf 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -22,6 +22,10 @@ #include <linux/input.h> #include <linux/interrupt.h> #include <linux/slab.h> +#if defined(CONFIG_HAS_EARLYSUSPEND) +#include <linux/earlysuspend.h> +#endif + /* Version */ #define MXT_VER_20 20 @@ -261,8 +265,15 @@ struct mxt_data { u8 idle_cycle_time; u8 is_stopped; struct mutex access_mutex; +#if defined(CONFIG_HAS_EARLYSUSPEND) + struct early_suspend early_suspend; +#endif }; +#if defined(CONFIG_HAS_EARLYSUSPEND) +static void mxt_early_suspend(struct early_suspend *es); +static void mxt_early_resume(struct early_suspend *es); +#endif static bool mxt_object_readable(unsigned int type) { @@ -1266,6 +1277,13 @@ static int __devinit mxt_probe(struct i2c_client *client, goto err_free_object; } +#if defined(CONFIG_HAS_EARLYSUSPEND) + data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; + data->early_suspend.suspend = mxt_early_suspend; + data->early_suspend.resume = mxt_early_resume; + register_early_suspend(&data->early_suspend); +#endif + error = mxt_make_highchg(data); if (error) goto err_free_irq; @@ -1345,6 +1363,34 @@ static int mxt_resume(struct device *dev) return 0; } +#if defined(CONFIG_HAS_EARLYSUSPEND) +static void mxt_early_suspend(struct early_suspend *es) +{ + struct mxt_data *mxt; + struct device *dev; + mxt = container_of(es, struct mxt_data, early_suspend); + dev = &mxt->client->dev; + dev_info(dev, "MXT Early Suspend entered\n"); + + if (mxt_suspend(&mxt->client->dev) != 0) + dev_err(&mxt->client->dev, "%s: failed\n", __func__); + dev_info(dev, "MXT Early Suspended\n"); +} + +static void mxt_early_resume(struct early_suspend *es) +{ + struct mxt_data *mxt; + struct device *dev; + mxt = container_of(es, struct mxt_data, early_suspend); + dev = &mxt->client->dev; + dev_info(dev, "MXT Early Resume entered\n"); + + if (mxt_resume(&mxt->client->dev) != 0) + dev_err(&mxt->client->dev, "%s: failed\n", __func__); + dev_info(dev, "MXT Early Resumed\n"); +} +#endif + static const struct dev_pm_ops mxt_pm_ops = { .suspend = mxt_suspend, .resume = mxt_resume, |