Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[pandora-kernel.git] / drivers / staging / iio / adc / ad7745.c
1 /*
2  * AD774X capacitive sensor driver supporting AD7745/6/7
3  *
4  * Copyright 2010 Analog Devices Inc.
5  *
6  * Licensed under the GPL-2 or later.
7  */
8
9 #include <linux/interrupt.h>
10 #include <linux/gpio.h>
11 #include <linux/device.h>
12 #include <linux/kernel.h>
13 #include <linux/slab.h>
14 #include <linux/sysfs.h>
15 #include <linux/list.h>
16 #include <linux/i2c.h>
17
18 #include "../iio.h"
19 #include "../sysfs.h"
20
21 /*
22  * AD774X registers definition
23  */
24
25 #define AD774X_STATUS           0
26 #define AD774X_STATUS_RDY       (1 << 2)
27 #define AD774X_STATUS_RDYVT     (1 << 1)
28 #define AD774X_STATUS_RDYCAP    (1 << 0)
29 #define AD774X_CAP_DATA_HIGH    1
30 #define AD774X_CAP_DATA_MID     2
31 #define AD774X_CAP_DATA_LOW     3
32 #define AD774X_VT_DATA_HIGH     4
33 #define AD774X_VT_DATA_MID      5
34 #define AD774X_VT_DATA_LOW      6
35 #define AD774X_CAP_SETUP        7
36 #define AD774X_VT_SETUP         8
37 #define AD774X_EXEC_SETUP       9
38 #define AD774X_CFG              10
39 #define AD774X_CAPDACA          11
40 #define AD774X_CAPDACB          12
41 #define AD774X_CAPDAC_EN        (1 << 7)
42 #define AD774X_CAP_OFFH         13
43 #define AD774X_CAP_OFFL         14
44 #define AD774X_CAP_GAINH        15
45 #define AD774X_CAP_GAINL        16
46 #define AD774X_VOLT_GAINH       17
47 #define AD774X_VOLT_GAINL       18
48
49 #define AD774X_MAX_CONV_MODE    6
50
51 /*
52  * struct ad774x_chip_info - chip specifc information
53  */
54
55 struct ad774x_chip_info {
56         struct i2c_client *client;
57         struct iio_dev *indio_dev;
58         bool inter;
59         u16 cap_offs;                   /* Capacitive offset */
60         u16 cap_gain;                   /* Capacitive gain calibration */
61         u16 volt_gain;                  /* Voltage gain calibration */
62         u8  cap_setup;
63         u8  vt_setup;
64         u8  exec_setup;
65
66         char *conversion_mode;
67 };
68
69 struct ad774x_conversion_mode {
70         char *name;
71         u8 reg_cfg;
72 };
73
74 static struct ad774x_conversion_mode
75 ad774x_conv_mode_table[AD774X_MAX_CONV_MODE] = {
76         { "idle", 0 },
77         { "continuous-conversion", 1 },
78         { "single-conversion", 2 },
79         { "power-down", 3 },
80         { "offset-calibration", 5 },
81         { "gain-calibration", 6 },
82 };
83
84 /*
85  * ad774x register access by I2C
86  */
87
88 static int ad774x_i2c_read(struct ad774x_chip_info *chip, u8 reg, u8 *data, int len)
89 {
90         struct i2c_client *client = chip->client;
91         int ret;
92
93         ret = i2c_master_send(client, &reg, 1);
94         if (ret < 0) {
95                 dev_err(&client->dev, "I2C write error\n");
96                 return ret;
97         }
98
99         ret = i2c_master_recv(client, data, len);
100         if (ret < 0) {
101                 dev_err(&client->dev, "I2C read error\n");
102                 return ret;
103         }
104
105         return ret;
106 }
107
108 static int ad774x_i2c_write(struct ad774x_chip_info *chip, u8 reg, u8 data)
109 {
110         struct i2c_client *client = chip->client;
111         int ret;
112
113         u8 tx[2] = {
114                 reg,
115                 data,
116         };
117
118         ret = i2c_master_send(client, tx, 2);
119         if (ret < 0)
120                 dev_err(&client->dev, "I2C write error\n");
121
122         return ret;
123 }
124
125 /*
126  * sysfs nodes
127  */
128
129 #define IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(_show)                              \
130         IIO_DEVICE_ATTR(available_conversion_modes, S_IRUGO, _show, NULL, 0)
131 #define IIO_DEV_ATTR_CONVERSION_MODE(_mode, _show, _store)              \
132         IIO_DEVICE_ATTR(conversion_mode, _mode, _show, _store, 0)
133 #define IIO_DEV_ATTR_CAP_SETUP(_mode, _show, _store)            \
134         IIO_DEVICE_ATTR(cap_setup, _mode, _show, _store, 0)
135 #define IIO_DEV_ATTR_VT_SETUP(_mode, _show, _store)              \
136         IIO_DEVICE_ATTR(in0_setup, _mode, _show, _store, 0)
137 #define IIO_DEV_ATTR_EXEC_SETUP(_mode, _show, _store)              \
138         IIO_DEVICE_ATTR(exec_setup, _mode, _show, _store, 0)
139 #define IIO_DEV_ATTR_VOLT_GAIN(_mode, _show, _store)            \
140         IIO_DEVICE_ATTR(in0_gain, _mode, _show, _store, 0)
141 #define IIO_DEV_ATTR_CAP_OFFS(_mode, _show, _store)             \
142         IIO_DEVICE_ATTR(cap_offs, _mode, _show, _store, 0)
143 #define IIO_DEV_ATTR_CAP_GAIN(_mode, _show, _store)             \
144         IIO_DEVICE_ATTR(cap_gain, _mode, _show, _store, 0)
145 #define IIO_DEV_ATTR_CAP_DATA(_show)            \
146         IIO_DEVICE_ATTR(cap0_raw, S_IRUGO, _show, NULL, 0)
147 #define IIO_DEV_ATTR_VT_DATA(_show)             \
148         IIO_DEVICE_ATTR(in0_raw, S_IRUGO, _show, NULL, 0)
149
150 static ssize_t ad774x_show_conversion_modes(struct device *dev,
151                 struct device_attribute *attr,
152                 char *buf)
153 {
154         int i;
155         int len = 0;
156
157         for (i = 0; i < AD774X_MAX_CONV_MODE; i++)
158                 len += sprintf(buf + len, "%s ", ad774x_conv_mode_table[i].name);
159
160         len += sprintf(buf + len, "\n");
161
162         return len;
163 }
164
165 static IIO_DEV_ATTR_AVAIL_CONVERSION_MODES(ad774x_show_conversion_modes);
166
167 static ssize_t ad774x_show_conversion_mode(struct device *dev,
168                 struct device_attribute *attr,
169                 char *buf)
170 {
171         struct iio_dev *dev_info = dev_get_drvdata(dev);
172         struct ad774x_chip_info *chip = dev_info->dev_data;
173
174         return sprintf(buf, "%s\n", chip->conversion_mode);
175 }
176
177 static ssize_t ad774x_store_conversion_mode(struct device *dev,
178                 struct device_attribute *attr,
179                 const char *buf,
180                 size_t len)
181 {
182         struct iio_dev *dev_info = dev_get_drvdata(dev);
183         struct ad774x_chip_info *chip = dev_info->dev_data;
184         u8 cfg;
185         int i;
186
187         ad774x_i2c_read(chip, AD774X_CFG, &cfg, 1);
188
189         for (i = 0; i < AD774X_MAX_CONV_MODE; i++) {
190                 if (strncmp(buf, ad774x_conv_mode_table[i].name,
191                                 strlen(ad774x_conv_mode_table[i].name) - 1) == 0) {
192                         chip->conversion_mode = ad774x_conv_mode_table[i].name;
193                         cfg |= 0x18 | ad774x_conv_mode_table[i].reg_cfg;
194                         ad774x_i2c_write(chip, AD774X_CFG, cfg);
195                         return len;
196                 }
197         }
198
199         dev_err(dev, "not supported conversion mode\n");
200
201         return -EINVAL;
202 }
203
204 static IIO_DEV_ATTR_CONVERSION_MODE(S_IRUGO | S_IWUSR,
205                 ad774x_show_conversion_mode,
206                 ad774x_store_conversion_mode);
207
208 static ssize_t ad774x_show_dac_value(struct device *dev,
209                 struct device_attribute *attr,
210                 char *buf)
211 {
212         struct iio_dev *dev_info = dev_get_drvdata(dev);
213         struct ad774x_chip_info *chip = dev_info->dev_data;
214         struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
215         u8 data;
216
217         ad774x_i2c_read(chip, this_attr->address, &data, 1);
218
219         return sprintf(buf, "%02x\n", data & 0x7F);
220 }
221
222 static ssize_t ad774x_store_dac_value(struct device *dev,
223                 struct device_attribute *attr,
224                 const char *buf,
225                 size_t len)
226 {
227         struct iio_dev *dev_info = dev_get_drvdata(dev);
228         struct ad774x_chip_info *chip = dev_info->dev_data;
229         struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
230         unsigned long data;
231         int ret;
232
233         ret = strict_strtoul(buf, 10, &data);
234
235         if (!ret) {
236                 ad774x_i2c_write(chip, this_attr->address,
237                         (data ? AD774X_CAPDAC_EN : 0) | (data & 0x7F));
238                 return len;
239         }
240
241         return -EINVAL;
242 }
243
244 static IIO_DEVICE_ATTR(capdac0_raw, S_IRUGO | S_IWUSR,
245                         ad774x_show_dac_value,
246                         ad774x_store_dac_value,
247                         AD774X_CAPDACA);
248
249 static IIO_DEVICE_ATTR(capdac1_raw, S_IRUGO | S_IWUSR,
250                         ad774x_show_dac_value,
251                         ad774x_store_dac_value,
252                         AD774X_CAPDACB);
253
254 static ssize_t ad774x_show_cap_setup(struct device *dev,
255                 struct device_attribute *attr,
256                 char *buf)
257 {
258         struct iio_dev *dev_info = dev_get_drvdata(dev);
259         struct ad774x_chip_info *chip = dev_info->dev_data;
260
261         return sprintf(buf, "0x%02x\n", chip->cap_setup);
262 }
263
264 static ssize_t ad774x_store_cap_setup(struct device *dev,
265                 struct device_attribute *attr,
266                 const char *buf,
267                 size_t len)
268 {
269         struct iio_dev *dev_info = dev_get_drvdata(dev);
270         struct ad774x_chip_info *chip = dev_info->dev_data;
271         unsigned long data;
272         int ret;
273
274         ret = strict_strtoul(buf, 10, &data);
275
276         if ((!ret) && (data < 0x100)) {
277                 ad774x_i2c_write(chip, AD774X_CAP_SETUP, data);
278                 chip->cap_setup = data;
279                 return len;
280         }
281
282         return -EINVAL;
283 }
284
285 static IIO_DEV_ATTR_CAP_SETUP(S_IRUGO | S_IWUSR,
286                 ad774x_show_cap_setup,
287                 ad774x_store_cap_setup);
288
289 static ssize_t ad774x_show_vt_setup(struct device *dev,
290                 struct device_attribute *attr,
291                 char *buf)
292 {
293         struct iio_dev *dev_info = dev_get_drvdata(dev);
294         struct ad774x_chip_info *chip = dev_info->dev_data;
295
296         return sprintf(buf, "0x%02x\n", chip->vt_setup);
297 }
298
299 static ssize_t ad774x_store_vt_setup(struct device *dev,
300                 struct device_attribute *attr,
301                 const char *buf,
302                 size_t len)
303 {
304         struct iio_dev *dev_info = dev_get_drvdata(dev);
305         struct ad774x_chip_info *chip = dev_info->dev_data;
306         unsigned long data;
307         int ret;
308
309         ret = strict_strtoul(buf, 10, &data);
310
311         if ((!ret) && (data < 0x100)) {
312                 ad774x_i2c_write(chip, AD774X_VT_SETUP, data);
313                 chip->vt_setup = data;
314                 return len;
315         }
316
317         return -EINVAL;
318 }
319
320 static IIO_DEV_ATTR_VT_SETUP(S_IRUGO | S_IWUSR,
321                 ad774x_show_vt_setup,
322                 ad774x_store_vt_setup);
323
324 static ssize_t ad774x_show_exec_setup(struct device *dev,
325                 struct device_attribute *attr,
326                 char *buf)
327 {
328         struct iio_dev *dev_info = dev_get_drvdata(dev);
329         struct ad774x_chip_info *chip = dev_info->dev_data;
330
331         return sprintf(buf, "0x%02x\n", chip->exec_setup);
332 }
333
334 static ssize_t ad774x_store_exec_setup(struct device *dev,
335                 struct device_attribute *attr,
336                 const char *buf,
337                 size_t len)
338 {
339         struct iio_dev *dev_info = dev_get_drvdata(dev);
340         struct ad774x_chip_info *chip = dev_info->dev_data;
341         unsigned long data;
342         int ret;
343
344         ret = strict_strtoul(buf, 10, &data);
345
346         if ((!ret) && (data < 0x100)) {
347                 ad774x_i2c_write(chip, AD774X_EXEC_SETUP, data);
348                 chip->exec_setup = data;
349                 return len;
350         }
351
352         return -EINVAL;
353 }
354
355 static IIO_DEV_ATTR_EXEC_SETUP(S_IRUGO | S_IWUSR,
356                 ad774x_show_exec_setup,
357                 ad774x_store_exec_setup);
358
359 static ssize_t ad774x_show_volt_gain(struct device *dev,
360                 struct device_attribute *attr,
361                 char *buf)
362 {
363         struct iio_dev *dev_info = dev_get_drvdata(dev);
364         struct ad774x_chip_info *chip = dev_info->dev_data;
365
366         return sprintf(buf, "%d\n", chip->volt_gain);
367 }
368
369 static ssize_t ad774x_store_volt_gain(struct device *dev,
370                 struct device_attribute *attr,
371                 const char *buf,
372                 size_t len)
373 {
374         struct iio_dev *dev_info = dev_get_drvdata(dev);
375         struct ad774x_chip_info *chip = dev_info->dev_data;
376         unsigned long data;
377         int ret;
378
379         ret = strict_strtoul(buf, 10, &data);
380
381         if ((!ret) && (data < 0x10000)) {
382                 ad774x_i2c_write(chip, AD774X_VOLT_GAINH, data >> 8);
383                 ad774x_i2c_write(chip, AD774X_VOLT_GAINL, data);
384                 chip->volt_gain = data;
385                 return len;
386         }
387
388         return -EINVAL;
389 }
390
391 static IIO_DEV_ATTR_VOLT_GAIN(S_IRUGO | S_IWUSR,
392                 ad774x_show_volt_gain,
393                 ad774x_store_volt_gain);
394
395 static ssize_t ad774x_show_cap_data(struct device *dev,
396                 struct device_attribute *attr,
397                 char *buf)
398 {
399         struct iio_dev *dev_info = dev_get_drvdata(dev);
400         struct ad774x_chip_info *chip = dev_info->dev_data;
401         unsigned long data;
402         char tmp[3];
403
404         ad774x_i2c_read(chip, AD774X_CAP_DATA_HIGH, tmp, 3);
405         data = ((int)tmp[0] << 16) | ((int)tmp[1] << 8) | (int)tmp[2];
406
407         return sprintf(buf, "%ld\n", data);
408 }
409
410 static IIO_DEV_ATTR_CAP_DATA(ad774x_show_cap_data);
411
412 static ssize_t ad774x_show_vt_data(struct device *dev,
413                 struct device_attribute *attr,
414                 char *buf)
415 {
416         struct iio_dev *dev_info = dev_get_drvdata(dev);
417         struct ad774x_chip_info *chip = dev_info->dev_data;
418         unsigned long data;
419         char tmp[3];
420
421         ad774x_i2c_read(chip, AD774X_VT_DATA_HIGH, tmp, 3);
422         data = ((int)tmp[0] << 16) | ((int)tmp[1] << 8) | (int)tmp[2];
423
424         return sprintf(buf, "%ld\n", data);
425 }
426
427 static IIO_DEV_ATTR_VT_DATA(ad774x_show_vt_data);
428
429 static ssize_t ad774x_show_cap_offs(struct device *dev,
430                 struct device_attribute *attr,
431                 char *buf)
432 {
433         struct iio_dev *dev_info = dev_get_drvdata(dev);
434         struct ad774x_chip_info *chip = dev_info->dev_data;
435
436         return sprintf(buf, "%d\n", chip->cap_offs);
437 }
438
439 static ssize_t ad774x_store_cap_offs(struct device *dev,
440                 struct device_attribute *attr,
441                 const char *buf,
442                 size_t len)
443 {
444         struct iio_dev *dev_info = dev_get_drvdata(dev);
445         struct ad774x_chip_info *chip = dev_info->dev_data;
446         unsigned long data;
447         int ret;
448
449         ret = strict_strtoul(buf, 10, &data);
450
451         if ((!ret) && (data < 0x10000)) {
452                 ad774x_i2c_write(chip, AD774X_CAP_OFFH, data >> 8);
453                 ad774x_i2c_write(chip, AD774X_CAP_OFFL, data);
454                 chip->cap_offs = data;
455                 return len;
456         }
457
458         return -EINVAL;
459 }
460
461 static IIO_DEV_ATTR_CAP_OFFS(S_IRUGO | S_IWUSR,
462                 ad774x_show_cap_offs,
463                 ad774x_store_cap_offs);
464
465 static ssize_t ad774x_show_cap_gain(struct device *dev,
466                 struct device_attribute *attr,
467                 char *buf)
468 {
469         struct iio_dev *dev_info = dev_get_drvdata(dev);
470         struct ad774x_chip_info *chip = dev_info->dev_data;
471
472         return sprintf(buf, "%d\n", chip->cap_gain);
473 }
474
475 static ssize_t ad774x_store_cap_gain(struct device *dev,
476                 struct device_attribute *attr,
477                 const char *buf,
478                 size_t len)
479 {
480         struct iio_dev *dev_info = dev_get_drvdata(dev);
481         struct ad774x_chip_info *chip = dev_info->dev_data;
482         unsigned long data;
483         int ret;
484
485         ret = strict_strtoul(buf, 10, &data);
486
487         if ((!ret) && (data < 0x10000)) {
488                 ad774x_i2c_write(chip, AD774X_CAP_GAINH, data >> 8);
489                 ad774x_i2c_write(chip, AD774X_CAP_GAINL, data);
490                 chip->cap_gain = data;
491                 return len;
492         }
493
494         return -EINVAL;
495 }
496
497 static IIO_DEV_ATTR_CAP_GAIN(S_IRUGO | S_IWUSR,
498                 ad774x_show_cap_gain,
499                 ad774x_store_cap_gain);
500
501 static struct attribute *ad774x_attributes[] = {
502         &iio_dev_attr_available_conversion_modes.dev_attr.attr,
503         &iio_dev_attr_conversion_mode.dev_attr.attr,
504         &iio_dev_attr_cap_setup.dev_attr.attr,
505         &iio_dev_attr_in0_setup.dev_attr.attr,
506         &iio_dev_attr_exec_setup.dev_attr.attr,
507         &iio_dev_attr_cap_offs.dev_attr.attr,
508         &iio_dev_attr_cap_gain.dev_attr.attr,
509         &iio_dev_attr_in0_gain.dev_attr.attr,
510         &iio_dev_attr_in0_raw.dev_attr.attr,
511         &iio_dev_attr_cap0_raw.dev_attr.attr,
512         &iio_dev_attr_capdac0_raw.dev_attr.attr,
513         &iio_dev_attr_capdac1_raw.dev_attr.attr,
514         NULL,
515 };
516
517 static const struct attribute_group ad774x_attribute_group = {
518         .attrs = ad774x_attributes,
519 };
520
521 /*
522  * data ready events
523  */
524
525 #define IIO_EVENT_CODE_CAP_RDY     0
526 #define IIO_EVENT_CODE_VT_RDY      1
527
528 #define IIO_EVENT_ATTR_CAP_RDY_SH(_evlist, _show, _store, _mask)        \
529         IIO_EVENT_ATTR_SH(cap_rdy, _evlist, _show, _store, _mask)
530
531 #define IIO_EVENT_ATTR_VT_RDY_SH(_evlist, _show, _store, _mask) \
532         IIO_EVENT_ATTR_SH(vt_rdy, _evlist, _show, _store, _mask)
533
534 static irqreturn_t ad774x_event_handler(int irq, void *private)
535 {
536         struct iio_dev *indio_dev = private;
537         struct ad774x_chip_info *chip = iio_dev_get_devdata(indio_dev);
538         u8 int_status;
539
540         ad774x_i2c_read(chip, AD774X_STATUS, &int_status, 1);
541
542         if (int_status & AD774X_STATUS_RDYCAP)
543                 iio_push_event(indio_dev, 0,
544                                IIO_EVENT_CODE_CAP_RDY,
545                                iio_get_time_ns());
546
547         if (int_status & AD774X_STATUS_RDYVT)
548                 iio_push_event(indio_dev, 0,
549                                IIO_EVENT_CODE_VT_RDY,
550                                iio_get_time_ns());
551
552         return IRQ_HANDLED;
553 }
554
555 static IIO_CONST_ATTR(cap_rdy_en, "1");
556 static IIO_CONST_ATTR(vt_rdy_en, "1");
557
558 static struct attribute *ad774x_event_attributes[] = {
559         &iio_const_attr_cap_rdy_en.dev_attr.attr,
560         &iio_const_attr_vt_rdy_en.dev_attr.attr,
561         NULL,
562 };
563
564 static struct attribute_group ad774x_event_attribute_group = {
565         .attrs = ad774x_event_attributes,
566 };
567
568 static const struct iio_info ad774x_info = {
569         .attrs = &ad774x_event_attribute_group,
570         .event_attrs = &ad774x_event_attribute_group,
571         .num_interrupt_lines = 1,
572         .driver_module = THIS_MODULE,
573 };
574 /*
575  * device probe and remove
576  */
577
578 static int __devinit ad774x_probe(struct i2c_client *client,
579                 const struct i2c_device_id *id)
580 {
581         int ret = 0, regdone = 0;
582         struct ad774x_chip_info *chip = kzalloc(sizeof(*chip), GFP_KERNEL);
583         if (chip == NULL) {
584                 ret = -ENOMEM;
585                 goto error_ret;
586         }
587
588         /* this is only used for device removal purposes */
589         i2c_set_clientdata(client, chip);
590
591         chip->client = client;
592
593         chip->indio_dev = iio_allocate_device(0);
594         if (chip->indio_dev == NULL) {
595                 ret = -ENOMEM;
596                 goto error_free_chip;
597         }
598
599         /* Establish that the iio_dev is a child of the i2c device */
600         chip->indio_dev->name = id->name;
601         chip->indio_dev->dev.parent = &client->dev;
602         chip->indio_dev->info = &ad774x_info;
603         chip->indio_dev->dev_data = (void *)(chip);
604         chip->indio_dev->modes = INDIO_DIRECT_MODE;
605
606         ret = iio_device_register(chip->indio_dev);
607         if (ret)
608                 goto error_free_dev;
609         regdone = 1;
610
611         if (client->irq) {
612                 ret = request_threaded_irq(client->irq,
613                                            NULL,
614                                            &ad774x_event_handler,
615                                            IRQF_TRIGGER_FALLING,
616                                            "ad774x",
617                                            chip->indio_dev);
618                 if (ret)
619                         goto error_free_dev;
620         }
621
622         dev_err(&client->dev, "%s capacitive sensor registered, irq: %d\n", id->name, client->irq);
623
624         return 0;
625
626 error_free_dev:
627         if (regdone)
628                 free_irq(client->irq, chip->indio_dev);
629         else
630                 iio_free_device(chip->indio_dev);
631 error_free_chip:
632         kfree(chip);
633 error_ret:
634         return ret;
635 }
636
637 static int __devexit ad774x_remove(struct i2c_client *client)
638 {
639         struct ad774x_chip_info *chip = i2c_get_clientdata(client);
640         struct iio_dev *indio_dev = chip->indio_dev;
641
642         if (client->irq)
643                 free_irq(client->irq, indio_dev);
644         iio_device_unregister(indio_dev);
645         kfree(chip);
646
647         return 0;
648 }
649
650 static const struct i2c_device_id ad774x_id[] = {
651         { "ad7745", 0 },
652         { "ad7746", 0 },
653         { "ad7747", 0 },
654         {}
655 };
656
657 MODULE_DEVICE_TABLE(i2c, ad774x_id);
658
659 static struct i2c_driver ad774x_driver = {
660         .driver = {
661                 .name = "ad774x",
662         },
663         .probe = ad774x_probe,
664         .remove = __devexit_p(ad774x_remove),
665         .id_table = ad774x_id,
666 };
667
668 static __init int ad774x_init(void)
669 {
670         return i2c_add_driver(&ad774x_driver);
671 }
672
673 static __exit void ad774x_exit(void)
674 {
675         i2c_del_driver(&ad774x_driver);
676 }
677
678 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
679 MODULE_DESCRIPTION("Analog Devices ad7745/6/7 capacitive sensor driver");
680 MODULE_LICENSE("GPL v2");
681
682 module_init(ad774x_init);
683 module_exit(ad774x_exit);