Merge tag 'pci-v5.1-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
[linux-2.6-block.git] / drivers / input / touchscreen / ad7879-i2c.c
CommitLineData
4397c98a
MF
1/*
2 * AD7879-1/AD7889-1 touchscreen (I2C bus)
3 *
4 * Copyright (C) 2008-2010 Michael Hennerich, Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/input.h> /* BUS_I2C */
10#include <linux/i2c.h>
11#include <linux/module.h>
12#include <linux/types.h>
fa6e3ca2 13#include <linux/of.h>
d5dc9ac3 14#include <linux/pm.h>
404a24c3 15#include <linux/regmap.h>
4397c98a
MF
16
17#include "ad7879.h"
18
19#define AD7879_DEVID 0x79 /* AD7879-1/AD7889-1 */
20
404a24c3
DT
21static const struct regmap_config ad7879_i2c_regmap_config = {
22 .reg_bits = 8,
23 .val_bits = 16,
24 .max_register = 15,
4397c98a
MF
25};
26
5298cc4c 27static int ad7879_i2c_probe(struct i2c_client *client,
4397c98a
MF
28 const struct i2c_device_id *id)
29{
404a24c3 30 struct regmap *regmap;
4397c98a
MF
31
32 if (!i2c_check_functionality(client->adapter,
33 I2C_FUNC_SMBUS_WORD_DATA)) {
34 dev_err(&client->dev, "SMBUS Word Data not Supported\n");
35 return -EIO;
36 }
37
404a24c3
DT
38 regmap = devm_regmap_init_i2c(client, &ad7879_i2c_regmap_config);
39 if (IS_ERR(regmap))
40 return PTR_ERR(regmap);
41
4e34025b
DT
42 return ad7879_probe(&client->dev, regmap, client->irq,
43 BUS_I2C, AD7879_DEVID);
4397c98a
MF
44}
45
46static const struct i2c_device_id ad7879_id[] = {
47 { "ad7879", 0 },
48 { "ad7889", 0 },
49 { }
50};
51MODULE_DEVICE_TABLE(i2c, ad7879_id);
52
fa6e3ca2
SA
53#ifdef CONFIG_OF
54static const struct of_device_id ad7879_i2c_dt_ids[] = {
55 { .compatible = "adi,ad7879-1", },
56 { }
57};
58MODULE_DEVICE_TABLE(of, ad7879_i2c_dt_ids);
59#endif
60
4397c98a
MF
61static struct i2c_driver ad7879_i2c_driver = {
62 .driver = {
63 .name = "ad7879",
8672bd93 64 .pm = &ad7879_pm_ops,
fa6e3ca2 65 .of_match_table = of_match_ptr(ad7879_i2c_dt_ids),
4397c98a
MF
66 },
67 .probe = ad7879_i2c_probe,
4397c98a
MF
68 .id_table = ad7879_id,
69};
70
1b92c1cf 71module_i2c_driver(ad7879_i2c_driver);
4397c98a 72
2581e5d1 73MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
4397c98a
MF
74MODULE_DESCRIPTION("AD7879(-1) touchscreen I2C bus driver");
75MODULE_LICENSE("GPL");