Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / input / touchscreen / ad7879-i2c.c
blob0f20a1fdcdba03f59405477bb59cf40588321da8
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * AD7879-1/AD7889-1 touchscreen (I2C bus)
5 * Copyright (C) 2008-2010 Michael Hennerich, Analog Devices Inc.
6 */
8 #include <linux/input.h> /* BUS_I2C */
9 #include <linux/i2c.h>
10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/of.h>
13 #include <linux/pm.h>
14 #include <linux/regmap.h>
16 #include "ad7879.h"
18 #define AD7879_DEVID 0x79 /* AD7879-1/AD7889-1 */
20 static const struct regmap_config ad7879_i2c_regmap_config = {
21 .reg_bits = 8,
22 .val_bits = 16,
23 .max_register = 15,
26 static int ad7879_i2c_probe(struct i2c_client *client,
27 const struct i2c_device_id *id)
29 struct regmap *regmap;
31 if (!i2c_check_functionality(client->adapter,
32 I2C_FUNC_SMBUS_WORD_DATA)) {
33 dev_err(&client->dev, "SMBUS Word Data not Supported\n");
34 return -EIO;
37 regmap = devm_regmap_init_i2c(client, &ad7879_i2c_regmap_config);
38 if (IS_ERR(regmap))
39 return PTR_ERR(regmap);
41 return ad7879_probe(&client->dev, regmap, client->irq,
42 BUS_I2C, AD7879_DEVID);
45 static const struct i2c_device_id ad7879_id[] = {
46 { "ad7879", 0 },
47 { "ad7889", 0 },
48 { }
50 MODULE_DEVICE_TABLE(i2c, ad7879_id);
52 #ifdef CONFIG_OF
53 static const struct of_device_id ad7879_i2c_dt_ids[] = {
54 { .compatible = "adi,ad7879-1", },
55 { }
57 MODULE_DEVICE_TABLE(of, ad7879_i2c_dt_ids);
58 #endif
60 static struct i2c_driver ad7879_i2c_driver = {
61 .driver = {
62 .name = "ad7879",
63 .pm = &ad7879_pm_ops,
64 .of_match_table = of_match_ptr(ad7879_i2c_dt_ids),
66 .probe = ad7879_i2c_probe,
67 .id_table = ad7879_id,
70 module_i2c_driver(ad7879_i2c_driver);
72 MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
73 MODULE_DESCRIPTION("AD7879(-1) touchscreen I2C bus driver");
74 MODULE_LICENSE("GPL");