MAINTAINERS: add myself as co-maintainer of the iwlwifi driver
[linux/fpc-iii.git] / drivers / input / touchscreen / tsc2004.c
blob7295c198aa086be8630b3a77e202415649c6937b
1 /*
2 * TSC2004 touchscreen driver
4 * Copyright (C) 2015 QWERTY Embedded Design
5 * Copyright (C) 2015 EMAC Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/module.h>
19 #include <linux/input.h>
20 #include <linux/of.h>
21 #include <linux/i2c.h>
22 #include <linux/regmap.h>
23 #include "tsc200x-core.h"
25 static int tsc2004_cmd(struct device *dev, u8 cmd)
27 u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd;
28 s32 data;
29 struct i2c_client *i2c = to_i2c_client(dev);
31 data = i2c_smbus_write_byte(i2c, tx);
32 if (data < 0) {
33 dev_err(dev, "%s: failed, command: %x i2c error: %d\n",
34 __func__, cmd, data);
35 return data;
38 return 0;
41 static int tsc2004_probe(struct i2c_client *i2c,
42 const struct i2c_device_id *id)
45 return tsc200x_probe(&i2c->dev, i2c->irq, BUS_I2C,
46 devm_regmap_init_i2c(i2c, &tsc200x_regmap_config),
47 tsc2004_cmd);
50 static int tsc2004_remove(struct i2c_client *i2c)
52 return tsc200x_remove(&i2c->dev);
55 static const struct i2c_device_id tsc2004_idtable[] = {
56 { "tsc2004", 0 },
57 { }
59 MODULE_DEVICE_TABLE(i2c, tsc2004_idtable);
61 #ifdef CONFIG_OF
62 static const struct of_device_id tsc2004_of_match[] = {
63 { .compatible = "ti,tsc2004" },
64 { /* sentinel */ }
66 MODULE_DEVICE_TABLE(of, tsc2004_of_match);
67 #endif
69 static struct i2c_driver tsc2004_driver = {
70 .driver = {
71 .name = "tsc2004",
72 .of_match_table = of_match_ptr(tsc2004_of_match),
73 .pm = &tsc200x_pm_ops,
75 .id_table = tsc2004_idtable,
76 .probe = tsc2004_probe,
77 .remove = tsc2004_remove,
79 module_i2c_driver(tsc2004_driver);
81 MODULE_AUTHOR("Michael Welling <mwelling@ieee.org>");
82 MODULE_DESCRIPTION("TSC2004 Touchscreen Driver");
83 MODULE_LICENSE("GPL");