/drivers/staging/iio/adc/ad7745.c

https://bitbucket.org/cyanogenmod/android_kernel_asus_tf300t · C · 674 lines · 520 code · 127 blank · 27 comment · 29 complexity · 117b6c4faa65523bfb7c8bdbfb680102 MD5 · raw file

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