0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/module.h>
0010 #include <linux/input.h>
0011 #include <linux/of.h>
0012 #include <linux/i2c.h>
0013 #include <linux/regmap.h>
0014 #include "tsc200x-core.h"
0015
0016 static const struct input_id tsc2004_input_id = {
0017 .bustype = BUS_I2C,
0018 .product = 2004,
0019 };
0020
0021 static int tsc2004_cmd(struct device *dev, u8 cmd)
0022 {
0023 u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd;
0024 s32 data;
0025 struct i2c_client *i2c = to_i2c_client(dev);
0026
0027 data = i2c_smbus_write_byte(i2c, tx);
0028 if (data < 0) {
0029 dev_err(dev, "%s: failed, command: %x i2c error: %d\n",
0030 __func__, cmd, data);
0031 return data;
0032 }
0033
0034 return 0;
0035 }
0036
0037 static int tsc2004_probe(struct i2c_client *i2c,
0038 const struct i2c_device_id *id)
0039
0040 {
0041 return tsc200x_probe(&i2c->dev, i2c->irq, &tsc2004_input_id,
0042 devm_regmap_init_i2c(i2c, &tsc200x_regmap_config),
0043 tsc2004_cmd);
0044 }
0045
0046 static int tsc2004_remove(struct i2c_client *i2c)
0047 {
0048 tsc200x_remove(&i2c->dev);
0049
0050 return 0;
0051 }
0052
0053 static const struct i2c_device_id tsc2004_idtable[] = {
0054 { "tsc2004", 0 },
0055 { }
0056 };
0057 MODULE_DEVICE_TABLE(i2c, tsc2004_idtable);
0058
0059 #ifdef CONFIG_OF
0060 static const struct of_device_id tsc2004_of_match[] = {
0061 { .compatible = "ti,tsc2004" },
0062 { }
0063 };
0064 MODULE_DEVICE_TABLE(of, tsc2004_of_match);
0065 #endif
0066
0067 static struct i2c_driver tsc2004_driver = {
0068 .driver = {
0069 .name = "tsc2004",
0070 .of_match_table = of_match_ptr(tsc2004_of_match),
0071 .pm = &tsc200x_pm_ops,
0072 },
0073 .id_table = tsc2004_idtable,
0074 .probe = tsc2004_probe,
0075 .remove = tsc2004_remove,
0076 };
0077 module_i2c_driver(tsc2004_driver);
0078
0079 MODULE_AUTHOR("Michael Welling <mwelling@ieee.org>");
0080 MODULE_DESCRIPTION("TSC2004 Touchscreen Driver");
0081 MODULE_LICENSE("GPL");