~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/input/keyboard/mcs_touchkey.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * mcs_touchkey.c - Touchkey driver for MELFAS MCS5000/5080 controller
 
2
 * Touchkey driver for MELFAS MCS5000/5080 controller
3
3
 *
4
4
 * Copyright (C) 2010 Samsung Electronics Co.Ltd
5
5
 * Author: HeungJun Kim <riverful.kim@samsung.com>
19
19
#include <linux/input.h>
20
20
#include <linux/irq.h>
21
21
#include <linux/slab.h>
 
22
#include <linux/pm.h>
22
23
 
23
24
/* MCS5000 Touchkey */
24
25
#define MCS5000_TOUCHKEY_STATUS         0x04
45
46
};
46
47
 
47
48
struct mcs_touchkey_data {
 
49
        void (*poweron)(bool);
 
50
 
48
51
        struct i2c_client *client;
49
52
        struct input_dev *input_dev;
50
53
        struct mcs_touchkey_chip chip;
169
172
        if (pdata->cfg_pin)
170
173
                pdata->cfg_pin();
171
174
 
 
175
        if (pdata->poweron) {
 
176
                data->poweron = pdata->poweron;
 
177
                data->poweron(true);
 
178
        }
 
179
 
172
180
        error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt,
173
181
                        IRQF_TRIGGER_FALLING, client->dev.driver->name, data);
174
182
        if (error) {
196
204
        struct mcs_touchkey_data *data = i2c_get_clientdata(client);
197
205
 
198
206
        free_irq(client->irq, data);
 
207
        if (data->poweron)
 
208
                data->poweron(false);
199
209
        input_unregister_device(data->input_dev);
200
210
        kfree(data);
201
211
 
202
212
        return 0;
203
213
}
204
214
 
 
215
static void mcs_touchkey_shutdown(struct i2c_client *client)
 
216
{
 
217
        struct mcs_touchkey_data *data = i2c_get_clientdata(client);
 
218
 
 
219
        if (data->poweron)
 
220
                data->poweron(false);
 
221
}
 
222
 
 
223
#ifdef CONFIG_PM_SLEEP
 
224
static int mcs_touchkey_suspend(struct device *dev)
 
225
{
 
226
        struct mcs_touchkey_data *data = dev_get_drvdata(dev);
 
227
        struct i2c_client *client = data->client;
 
228
 
 
229
        /* Disable the work */
 
230
        disable_irq(client->irq);
 
231
 
 
232
        /* Finally turn off the power */
 
233
        if (data->poweron)
 
234
                data->poweron(false);
 
235
 
 
236
        return 0;
 
237
}
 
238
 
 
239
static int mcs_touchkey_resume(struct device *dev)
 
240
{
 
241
        struct mcs_touchkey_data *data = dev_get_drvdata(dev);
 
242
        struct i2c_client *client = data->client;
 
243
 
 
244
        /* Enable the device first */
 
245
        if (data->poweron)
 
246
                data->poweron(true);
 
247
 
 
248
        /* Enable irq again */
 
249
        enable_irq(client->irq);
 
250
 
 
251
        return 0;
 
252
}
 
253
#endif
 
254
 
 
255
static SIMPLE_DEV_PM_OPS(mcs_touchkey_pm_ops,
 
256
                         mcs_touchkey_suspend, mcs_touchkey_resume);
 
257
 
205
258
static const struct i2c_device_id mcs_touchkey_id[] = {
206
259
        { "mcs5000_touchkey", MCS5000_TOUCHKEY },
207
260
        { "mcs5080_touchkey", MCS5080_TOUCHKEY },
213
266
        .driver = {
214
267
                .name   = "mcs_touchkey",
215
268
                .owner  = THIS_MODULE,
 
269
                .pm     = &mcs_touchkey_pm_ops,
216
270
        },
217
271
        .probe          = mcs_touchkey_probe,
218
272
        .remove         = __devexit_p(mcs_touchkey_remove),
 
273
        .shutdown       = mcs_touchkey_shutdown,
219
274
        .id_table       = mcs_touchkey_id,
220
275
};
221
276