Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / input / touchscreen / tsc2004.c
blob0272cedcc726175aab8c4a56ab9e2a7affe3d9ec
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * TSC2004 touchscreen driver
5 * Copyright (C) 2015 QWERTY Embedded Design
6 * Copyright (C) 2015 EMAC Inc.
7 */
9 #include <linux/module.h>
10 #include <linux/input.h>
11 #include <linux/of.h>
12 #include <linux/i2c.h>
13 #include <linux/regmap.h>
14 #include "tsc200x-core.h"
16 static const struct input_id tsc2004_input_id = {
17 .bustype = BUS_I2C,
18 .product = 2004,
21 static int tsc2004_cmd(struct device *dev, u8 cmd)
23 u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd;
24 s32 data;
25 struct i2c_client *i2c = to_i2c_client(dev);
27 data = i2c_smbus_write_byte(i2c, tx);
28 if (data < 0) {
29 dev_err(dev, "%s: failed, command: %x i2c error: %d\n",
30 __func__, cmd, data);
31 return data;
34 return 0;
37 static int tsc2004_probe(struct i2c_client *i2c,
38 const struct i2c_device_id *id)
41 return tsc200x_probe(&i2c->dev, i2c->irq, &tsc2004_input_id,
42 devm_regmap_init_i2c(i2c, &tsc200x_regmap_config),
43 tsc2004_cmd);
46 static int tsc2004_remove(struct i2c_client *i2c)
48 return tsc200x_remove(&i2c->dev);
51 static const struct i2c_device_id tsc2004_idtable[] = {
52 { "tsc2004", 0 },
53 { }
55 MODULE_DEVICE_TABLE(i2c, tsc2004_idtable);
57 #ifdef CONFIG_OF
58 static const struct of_device_id tsc2004_of_match[] = {
59 { .compatible = "ti,tsc2004" },
60 { /* sentinel */ }
62 MODULE_DEVICE_TABLE(of, tsc2004_of_match);
63 #endif
65 static struct i2c_driver tsc2004_driver = {
66 .driver = {
67 .name = "tsc2004",
68 .of_match_table = of_match_ptr(tsc2004_of_match),
69 .pm = &tsc200x_pm_ops,
71 .id_table = tsc2004_idtable,
72 .probe = tsc2004_probe,
73 .remove = tsc2004_remove,
75 module_i2c_driver(tsc2004_driver);
77 MODULE_AUTHOR("Michael Welling <mwelling@ieee.org>");
78 MODULE_DESCRIPTION("TSC2004 Touchscreen Driver");
79 MODULE_LICENSE("GPL");