aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSangwon Jee <jeesw@melfas.com>2016-01-14 03:55:54 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2016-02-17 14:16:12 -0500
commit6ccb1d8f78bd349a8a5b2aa228d3c8b35ee704a8 (patch)
tree31ae6aa5f86fff50e291fdf86cf0029cbe0dc335 /drivers
parent1261d013daead425ee03c977a5b8dbe8016e25a6 (diff)
Input: add MELFAS MIP4 Touchscreen driver
This is an input driver for MELFAS MIP4 Touchscreen devices, such as MMS400, MMS500, MCS8000, MIT200, MIT300, MIT400, MFS10. All devices implementing MIP4 protocol (MELFAS Interface Protocol Version 4) should be supported by this driver. Signed-off-by: Sangwon Jee <jeesw@melfas.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/touchscreen/Kconfig11
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/melfas_mip4.c1499
3 files changed, 1511 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index f4e53b4a6062..309951da0970 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -491,6 +491,17 @@ config TOUCHSCREEN_MMS114
491 To compile this driver as a module, choose M here: the 491 To compile this driver as a module, choose M here: the
492 module will be called mms114. 492 module will be called mms114.
493 493
494config TOUCHSCREEN_MELFAS_MIP4
495 tristate "MELFAS MIP4 Touchscreen"
496 depends on I2C
497 help
498 Say Y here if you have a MELFAS MIP4 Touchscreen device.
499
500 If unsure, say N.
501
502 To compile this driver as a module, choose M here:
503 the module will be called melfas_mip4.
504
494config TOUCHSCREEN_MTOUCH 505config TOUCHSCREEN_MTOUCH
495 tristate "MicroTouch serial touchscreens" 506 tristate "MicroTouch serial touchscreens"
496 select SERIO 507 select SERIO
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 968ff12e3132..4b518c76e0d7 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_TOUCHSCREEN_LPC32XX) += lpc32xx_ts.o
48obj-$(CONFIG_TOUCHSCREEN_MAX11801) += max11801_ts.o 48obj-$(CONFIG_TOUCHSCREEN_MAX11801) += max11801_ts.o
49obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o 49obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o
50obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o 50obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o
51obj-$(CONFIG_TOUCHSCREEN_MELFAS_MIP4) += melfas_mip4.o
51obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o 52obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o
52obj-$(CONFIG_TOUCHSCREEN_MMS114) += mms114.o 53obj-$(CONFIG_TOUCHSCREEN_MMS114) += mms114.o
53obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o 54obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o
diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
new file mode 100644
index 000000000000..b8e9ead61ee2
--- /dev/null
+++ b/drivers/input/touchscreen/melfas_mip4.c
@@ -0,0 +1,1499 @@
1/*
2 * MELFAS MIP4 Touchscreen
3 *
4 * Copyright (C) 2016 MELFAS Inc.
5 *
6 * Author : Sangwon Jee <jeesw@melfas.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/acpi.h>
20#include <linux/delay.h>
21#include <linux/firmware.h>
22#include <linux/gpio/consumer.h>
23#include <linux/i2c.h>
24#include <linux/input.h>
25#include <linux/input/mt.h>
26#include <linux/interrupt.h>
27#include <linux/module.h>
28#include <linux/of.h>
29#include <linux/slab.h>
30#include <asm/unaligned.h>
31
32#define MIP4_DEVICE_NAME "mip4_ts"
33
34/*****************************************************************
35 * Protocol
36 * Version : MIP 4.0 Rev 4.4
37 *****************************************************************/
38
39/* Address */
40#define MIP4_R0_BOOT 0x00
41#define MIP4_R1_BOOT_MODE 0x01
42#define MIP4_R1_BOOT_BUF_ADDR 0x10
43#define MIP4_R1_BOOT_STATUS 0x20
44#define MIP4_R1_BOOT_CMD 0x30
45#define MIP4_R1_BOOT_TARGET_ADDR 0x40
46#define MIP4_R1_BOOT_SIZE 0x44
47
48#define MIP4_R0_INFO 0x01
49#define MIP4_R1_INFO_PRODUCT_NAME 0x00
50#define MIP4_R1_INFO_RESOLUTION_X 0x10
51#define MIP4_R1_INFO_RESOLUTION_Y 0x12
52#define MIP4_R1_INFO_NODE_NUM_X 0x14
53#define MIP4_R1_INFO_NODE_NUM_Y 0x15
54#define MIP4_R1_INFO_KEY_NUM 0x16
55#define MIP4_R1_INFO_VERSION_BOOT 0x20
56#define MIP4_R1_INFO_VERSION_CORE 0x22
57#define MIP4_R1_INFO_VERSION_APP 0x24
58#define MIP4_R1_INFO_VERSION_PARAM 0x26
59#define MIP4_R1_INFO_SECT_BOOT_START 0x30
60#define MIP4_R1_INFO_SECT_BOOT_END 0x31
61#define MIP4_R1_INFO_SECT_CORE_START 0x32
62#define MIP4_R1_INFO_SECT_CORE_END 0x33
63#define MIP4_R1_INFO_SECT_APP_START 0x34
64#define MIP4_R1_INFO_SECT_APP_END 0x35
65#define MIP4_R1_INFO_SECT_PARAM_START 0x36
66#define MIP4_R1_INFO_SECT_PARAM_END 0x37
67#define MIP4_R1_INFO_BUILD_DATE 0x40
68#define MIP4_R1_INFO_BUILD_TIME 0x44
69#define MIP4_R1_INFO_CHECKSUM_PRECALC 0x48
70#define MIP4_R1_INFO_CHECKSUM_REALTIME 0x4A
71#define MIP4_R1_INFO_PROTOCOL_NAME 0x50
72#define MIP4_R1_INFO_PROTOCOL_VERSION 0x58
73#define MIP4_R1_INFO_IC_ID 0x70
74#define MIP4_R1_INFO_IC_NAME 0x71
75#define MIP4_R1_INFO_IC_VENDOR_ID 0x75
76#define MIP4_R1_INFO_IC_HW_CATEGORY 0x77
77#define MIP4_R1_INFO_CONTACT_THD_SCR 0x78
78#define MIP4_R1_INFO_CONTACT_THD_KEY 0x7A
79
80#define MIP4_R0_EVENT 0x02
81#define MIP4_R1_EVENT_SUPPORTED_FUNC 0x00
82#define MIP4_R1_EVENT_FORMAT 0x04
83#define MIP4_R1_EVENT_SIZE 0x06
84#define MIP4_R1_EVENT_PACKET_INFO 0x10
85#define MIP4_R1_EVENT_PACKET_DATA 0x11
86
87#define MIP4_R0_CTRL 0x06
88#define MIP4_R1_CTRL_READY_STATUS 0x00
89#define MIP4_R1_CTRL_EVENT_READY 0x01
90#define MIP4_R1_CTRL_MODE 0x10
91#define MIP4_R1_CTRL_EVENT_TRIGGER_TYPE 0x11
92#define MIP4_R1_CTRL_RECALIBRATE 0x12
93#define MIP4_R1_CTRL_POWER_STATE 0x13
94#define MIP4_R1_CTRL_GESTURE_TYPE 0x14
95#define MIP4_R1_CTRL_DISABLE_ESD_ALERT 0x18
96#define MIP4_R1_CTRL_CHARGER_MODE 0x19
97#define MIP4_R1_CTRL_HIGH_SENS_MODE 0x1A
98#define MIP4_R1_CTRL_WINDOW_MODE 0x1B
99#define MIP4_R1_CTRL_PALM_REJECTION 0x1C
100#define MIP4_R1_CTRL_EDGE_CORRECTION 0x1D
101#define MIP4_R1_CTRL_ENTER_GLOVE_MODE 0x1E
102#define MIP4_R1_CTRL_I2C_ON_LPM 0x1F
103#define MIP4_R1_CTRL_GESTURE_DEBUG 0x20
104#define MIP4_R1_CTRL_PALM_EVENT 0x22
105#define MIP4_R1_CTRL_PROXIMITY_SENSING 0x23
106
107/* Value */
108#define MIP4_BOOT_MODE_BOOT 0x01
109#define MIP4_BOOT_MODE_APP 0x02
110
111#define MIP4_BOOT_STATUS_BUSY 0x05
112#define MIP4_BOOT_STATUS_ERROR 0x0E
113#define MIP4_BOOT_STATUS_DONE 0xA0
114
115#define MIP4_BOOT_CMD_MASS_ERASE 0x15
116#define MIP4_BOOT_CMD_PROGRAM 0x54
117#define MIP4_BOOT_CMD_ERASE 0x8F
118#define MIP4_BOOT_CMD_WRITE 0xA5
119#define MIP4_BOOT_CMD_READ 0xC2
120
121#define MIP4_EVENT_INPUT_TYPE_KEY 0
122#define MIP4_EVENT_INPUT_TYPE_SCREEN 1
123#define MIP4_EVENT_INPUT_TYPE_PROXIMITY 2
124
125#define I2C_RETRY_COUNT 3 /* 2~ */
126
127#define MIP4_BUF_SIZE 128
128#define MIP4_MAX_FINGERS 10
129#define MIP4_MAX_KEYS 4
130
131#define MIP4_TOUCH_MAJOR_MIN 0
132#define MIP4_TOUCH_MAJOR_MAX 255
133#define MIP4_TOUCH_MINOR_MIN 0
134#define MIP4_TOUCH_MINOR_MAX 255
135#define MIP4_PRESSURE_MIN 0
136#define MIP4_PRESSURE_MAX 255
137
138#define MIP4_FW_NAME "melfas_mip4.fw"
139#define MIP4_FW_UPDATE_DEBUG 0 /* 0 (default) or 1 */
140
141struct mip4_fw_version {
142 u16 boot;
143 u16 core;
144 u16 app;
145 u16 param;
146};
147
148struct mip4_ts {
149 struct i2c_client *client;
150 struct input_dev *input;
151 struct gpio_desc *gpio_ce;
152
153 char phys[32];
154 char product_name[16];
155
156 unsigned int max_x;
157 unsigned int max_y;
158 u8 node_x;
159 u8 node_y;
160