Linux Audio

Check our new training course

Loading...
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 * TSC2004 touchscreen driver
 4 *
 5 * Copyright (C) 2015 QWERTY Embedded Design
 6 * Copyright (C) 2015 EMAC Inc.
 
 
 
 
 
 
 
 
 
 
 7 */
 8
 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"
15
16static const struct input_id tsc2004_input_id = {
17	.bustype = BUS_I2C,
18	.product = 2004,
19};
20
21static int tsc2004_cmd(struct device *dev, u8 cmd)
22{
23	u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd;
24	s32 data;
25	struct i2c_client *i2c = to_i2c_client(dev);
26
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;
32	}
33
34	return 0;
35}
36
37static int tsc2004_probe(struct i2c_client *i2c)
 
38
39{
40	return tsc200x_probe(&i2c->dev, i2c->irq, &tsc2004_input_id,
41			     devm_regmap_init_i2c(i2c, &tsc200x_regmap_config),
42			     tsc2004_cmd);
43}
44
 
 
 
 
 
45static const struct i2c_device_id tsc2004_idtable[] = {
46	{ "tsc2004" },
47	{ }
48};
49MODULE_DEVICE_TABLE(i2c, tsc2004_idtable);
50
51#ifdef CONFIG_OF
52static const struct of_device_id tsc2004_of_match[] = {
53	{ .compatible = "ti,tsc2004" },
54	{ /* sentinel */ }
55};
56MODULE_DEVICE_TABLE(of, tsc2004_of_match);
57#endif
58
59static struct i2c_driver tsc2004_driver = {
60	.driver = {
61		.name		= "tsc2004",
62		.dev_groups	= tsc200x_groups,
63		.of_match_table	= of_match_ptr(tsc2004_of_match),
64		.pm		= pm_sleep_ptr(&tsc200x_pm_ops),
65	},
66	.id_table       = tsc2004_idtable,
67	.probe          = tsc2004_probe,
 
68};
69module_i2c_driver(tsc2004_driver);
70
71MODULE_AUTHOR("Michael Welling <mwelling@ieee.org>");
72MODULE_DESCRIPTION("TSC2004 Touchscreen Driver");
73MODULE_LICENSE("GPL");
v4.10.11
 
 1/*
 2 * TSC2004 touchscreen driver
 3 *
 4 * Copyright (C) 2015 QWERTY Embedded Design
 5 * Copyright (C) 2015 EMAC Inc.
 6 *
 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.
11 *
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.
16 */
17
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"
24
25static const struct input_id tsc2004_input_id = {
26	.bustype = BUS_I2C,
27	.product = 2004,
28};
29
30static int tsc2004_cmd(struct device *dev, u8 cmd)
31{
32	u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd;
33	s32 data;
34	struct i2c_client *i2c = to_i2c_client(dev);
35
36	data = i2c_smbus_write_byte(i2c, tx);
37	if (data < 0) {
38		dev_err(dev, "%s: failed, command: %x i2c error: %d\n",
39			__func__, cmd, data);
40		return data;
41	}
42
43	return 0;
44}
45
46static int tsc2004_probe(struct i2c_client *i2c,
47			 const struct i2c_device_id *id)
48
49{
50	return tsc200x_probe(&i2c->dev, i2c->irq, &tsc2004_input_id,
51			     devm_regmap_init_i2c(i2c, &tsc200x_regmap_config),
52			     tsc2004_cmd);
53}
54
55static int tsc2004_remove(struct i2c_client *i2c)
56{
57	return tsc200x_remove(&i2c->dev);
58}
59
60static const struct i2c_device_id tsc2004_idtable[] = {
61	{ "tsc2004", 0 },
62	{ }
63};
64MODULE_DEVICE_TABLE(i2c, tsc2004_idtable);
65
66#ifdef CONFIG_OF
67static const struct of_device_id tsc2004_of_match[] = {
68	{ .compatible = "ti,tsc2004" },
69	{ /* sentinel */ }
70};
71MODULE_DEVICE_TABLE(of, tsc2004_of_match);
72#endif
73
74static struct i2c_driver tsc2004_driver = {
75	.driver = {
76		.name   = "tsc2004",
77		.of_match_table = of_match_ptr(tsc2004_of_match),
78		.pm     = &tsc200x_pm_ops,
 
79	},
80	.id_table       = tsc2004_idtable,
81	.probe          = tsc2004_probe,
82	.remove         = tsc2004_remove,
83};
84module_i2c_driver(tsc2004_driver);
85
86MODULE_AUTHOR("Michael Welling <mwelling@ieee.org>");
87MODULE_DESCRIPTION("TSC2004 Touchscreen Driver");
88MODULE_LICENSE("GPL");