aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javier@dowhile0.org>2012-01-31 03:18:00 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-01-31 03:18:36 -0500
commit4065d1e7b2164cff4af57b58fac887df2fe75d2a (patch)
treecb54ecc552144ba47a91bd2fec6b624e244485be /drivers/input/touchscreen
parent31175a8348af76aea2f557857c90467d13632dc3 (diff)
Input: add Cypress TTSP capacitive multi-touch screen support
Cypress TrueTouch(tm) Standard Product controllers are found in a wide range of embedded devices. This driver add support for a variety of TTSP controllers. Since the hardware is capable of tracking identifiable contacts, multi-touch protocol type B (stateful) is used to report contact information. The driver is composed of a core driver that process the data sent by the contacts and a set of bus specific interface modules. This patch adds the base core TTSP driver. Signed-off-by: Javier Martinez Canillas <javier@dowhile0.org> Reviewed-by: Henrik Rydberg <rydberg@euromail.se> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/Kconfig32
-rw-r--r--drivers/input/touchscreen/Makefile5
-rw-r--r--drivers/input/touchscreen/cyttsp_core.c625
-rw-r--r--drivers/input/touchscreen/cyttsp_core.h149
-rw-r--r--drivers/input/touchscreen/cyttsp_i2c.c146
-rw-r--r--drivers/input/touchscreen/cyttsp_spi.c210
6 files changed, 1165 insertions, 2 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 4af2a18eb3ba..2b21a7066d36 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -139,7 +139,6 @@ config TOUCHSCREEN_CY8CTMG110
139 tristate "cy8ctmg110 touchscreen" 139 tristate "cy8ctmg110 touchscreen"
140 depends on I2C 140 depends on I2C
141 depends on GPIOLIB 141 depends on GPIOLIB
142
143 help 142 help
144 Say Y here if you have a cy8ctmg110 capacitive touchscreen on 143 Say Y here if you have a cy8ctmg110 capacitive touchscreen on
145 an AAVA device. 144 an AAVA device.
@@ -149,6 +148,37 @@ config TOUCHSCREEN_CY8CTMG110
149 To compile this driver as a module, choose M here: the 148 To compile this driver as a module, choose M here: the
150 module will be called cy8ctmg110_ts. 149 module will be called cy8ctmg110_ts.
151 150
151config TOUCHSCREEN_CYTTSP_CORE
152 tristate "Cypress TTSP touchscreen"
153 help
154 Say Y here if you have a touchscreen using controller from
155 the Cypress TrueTouch(tm) Standard Product family connected
156 to your system. You will also need to select appropriate
157 bus connection below.
158
159 If unsure, say N.
160
161 To compile this driver as a module, choose M here: the
162 module will be called cyttsp_core.
163
164config TOUCHSCREEN_CYTTSP_I2C
165 tristate "support I2C bus connection"
166 depends on TOUCHSCREEN_CYTTSP_CORE && I2C
167 help
168 Say Y here if the touchscreen is connected via I2C bus.
169
170 To compile this driver as a module, choose M here: the
171 module will be called cyttsp_i2c.
172
173config TOUCHSCREEN_CYTTSP_SPI
174 tristate "support SPI bus connection"
175 depends on TOUCHSCREEN_CYTTSP_CORE && SPI_MASTER
176 help
177 Say Y here if the touchscreen is connected via SPI bus.
178
179 To compile this driver as a module, choose M here: the
180 module will be called cyttsp_spi.
181
152config TOUCHSCREEN_DA9034 182config TOUCHSCREEN_DA9034
153 tristate "Touchscreen support for Dialog Semiconductor DA9034" 183 tristate "Touchscreen support for Dialog Semiconductor DA9034"
154 depends on PMIC_DA903X 184 depends on PMIC_DA903X
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 496091e88460..d9acbdcda3d9 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -16,8 +16,11 @@ obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o
16obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o 16obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o
17obj-$(CONFIG_TOUCHSCREEN_AUO_PIXCIR) += auo-pixcir-ts.o 17obj-$(CONFIG_TOUCHSCREEN_AUO_PIXCIR) += auo-pixcir-ts.o
18obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o 18obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o
19obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o 19obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o
20obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o 20obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o
21obj-$(CONFIG_TOUCHSCREEN_CYTTSP_CORE) += cyttsp_core.o
22obj-$(CONFIG_TOUCHSCREEN_CYTTSP_I2C) += cyttsp_i2c.o
23obj-$(CONFIG_TOUCHSCREEN_CYTTSP_SPI) += cyttsp_spi.o
21obj-$(CONFIG_TOUCHSCREEN_DA9034) += da9034-ts.o 24obj-$(CONFIG_TOUCHSCREEN_DA9034) += da9034-ts.o
22obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o 25obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o
23obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE) += hampshire.o 26obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE) += hampshire.o
diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
new file mode 100644
index 000000000000..8be22479b41c
--- /dev/null
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -0,0 +1,625 @@
1/*
2 * Core Source for:
3 * Cypress TrueTouch(TM) Standard Product (TTSP) touchscreen drivers.
4 * For use with Cypress Txx3xx parts.
5 * Supported parts include:
6 * CY8CTST341
7 * CY8CTMA340
8 *
9 * Copyright (C) 2009, 2010, 2011 Cypress Semiconductor, Inc.
10 * Copyright (C) 2012 Javier Martinez Canillas <javier@dowhile0.org>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * version 2, and only version 2, as published by the
15 * Free Software Foundation.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 *
26 * Contact Cypress Semiconductor at www.cypress.com <kev@cypress.com>
27 *
28 */
29
30#include <linux/delay.h>
31#include <linux/input.h>
32#include <linux/input/mt.h>
33#include <linux/gpio.h>
34#include <linux/interrupt.h>
35#include <linux/slab.h>
36
37#include "cyttsp_core.h"
38
39/* Bootloader number of command keys */
40#define CY_NUM_BL_KEYS 8
41
42/* helpers */
43#define GET_NUM_TOUCHES(x) ((x) & 0x0F)
44#define IS_LARGE_AREA(x) (((x) & 0x10) >> 4)
45#define IS_BAD_PKT(x) ((x) & 0x20)
46#define IS_VALID_APP(x) ((x) & 0x01)
47#define IS_OPERATIONAL_ERR(x) ((x) & 0x3F)
48#define GET_HSTMODE(reg) (((reg) & 0x70) >> 4)
49#define GET_BOOTLOADERMODE(reg) (((reg) & 0x10) >> 4)
50
51#define CY_REG_BASE 0x00
52#define CY_REG_ACT_DIST 0x1E
53#define CY_REG_ACT_INTRVL 0x1D
54#define CY_REG_TCH_TMOUT (CY_REG_ACT_INTRVL + 1)
55#define CY_REG_LP_INTRVL (CY_REG_TCH_TMOUT + 1)
56#define CY_MAXZ 255
57#define CY_DELAY_DFLT 20 /* ms */
58#define CY_DELAY_MAX 500
59#define CY_ACT_DIST_DFLT 0xF8
60#define CY_HNDSHK_BIT 0x80
61/* device mode bits */
62#define CY_OPERATE_MODE 0x00
63#define CY_SYSINFO_MODE 0x10
64/* power mode select bits */
65#define CY_SOFT_RESET_MODE 0x01 /* return to Bootloader mode */
66#define CY_DEEP_SLEEP_MODE 0x02
67#define CY_LOW_POWER_MODE 0x04
68
69/* Slots management */
70#define CY_MAX_FINGER 4
71#define CY_MAX_ID 16
72
73static const u8 bl_command[] = {
74 0x00, /* file offset */
75 0xFF, /* command */
76 0xA5, /* exit bootloader command */
77 0, 1, 2, 3, 4, 5, 6, 7 /* default keys */
78};
79
80static int ttsp_read_block_data(struct cyttsp *ts, u8 command,
81 u8 length, void *buf)
82{
83 int error;
84 int tries;
85
86 for (tries = 0; tries < CY_NUM_RETRY; tries++) {
87 error = ts->bus_ops->read(ts, command, length, buf);
88 if (!error)
89 return 0;
90
91 msleep(CY_DELAY_DFLT);
92 }
93
94 return -EIO;
95}
96
97static int ttsp_write_block_data(struct cyttsp *ts, u8 command,
98 u8 length, void *buf)
99{
100 int error;
101 int tries;
102