1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * TSC2004 touchscreen driver
5 * Copyright (C) 2015 QWERTY Embedded Design
6 * Copyright (C) 2015 EMAC Inc.
9 #include <linux/module.h>
10 #include <linux/input.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
= {
21 static int tsc2004_cmd(struct device
*dev
, u8 cmd
)
23 u8 tx
= TSC200X_CMD
| TSC200X_CMD_12BIT
| cmd
;
25 struct i2c_client
*i2c
= to_i2c_client(dev
);
27 data
= i2c_smbus_write_byte(i2c
, tx
);
29 dev_err(dev
, "%s: failed, command: %x i2c error: %d\n",
37 static int tsc2004_probe(struct i2c_client
*i2c
)
40 return tsc200x_probe(&i2c
->dev
, i2c
->irq
, &tsc2004_input_id
,
41 devm_regmap_init_i2c(i2c
, &tsc200x_regmap_config
),
45 static const struct i2c_device_id tsc2004_idtable
[] = {
49 MODULE_DEVICE_TABLE(i2c
, tsc2004_idtable
);
52 static const struct of_device_id tsc2004_of_match
[] = {
53 { .compatible
= "ti,tsc2004" },
56 MODULE_DEVICE_TABLE(of
, tsc2004_of_match
);
59 static struct i2c_driver tsc2004_driver
= {
62 .dev_groups
= tsc200x_groups
,
63 .of_match_table
= of_match_ptr(tsc2004_of_match
),
64 .pm
= pm_sleep_ptr(&tsc200x_pm_ops
),
66 .id_table
= tsc2004_idtable
,
67 .probe
= tsc2004_probe
,
69 module_i2c_driver(tsc2004_driver
);
71 MODULE_AUTHOR("Michael Welling <mwelling@ieee.org>");
72 MODULE_DESCRIPTION("TSC2004 Touchscreen Driver");
73 MODULE_LICENSE("GPL");