aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/i2c/touchkey_i2c.h
blob: 60002d2ac5e2210cf1c3d37385d48dfd04caa918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#ifndef _LINUX_CYPRESS_TOUCHKEY_I2C_H
#define _LINUX_CYPRESS_TOUCHKEY_I2C_H

#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/input.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/hrtimer.h>
#include <linux/gpio.h>
#include <linux/irq.h>
#include <linux/delay.h>

#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif

/* Touchkey Register */
#define KEYCODE_REG			0x00

#define TK_BIT_PRESS_EV		0x08
#define TK_BIT_KEYCODE		0x07

#define TK_BIT_AUTOCAL		0x80

#if defined(CONFIG_MACH_Q1_BD)\
	|| defined(CONFIG_TARGET_LOCALE_NA)\
	|| defined(CONFIG_MACH_M0)\
	|| defined(CONFIG_MACH_C1)\
	|| defined(CONFIG_MACH_M3)\
	|| defined(CONFIG_MACH_T0)
#define TK_CMD_LED_ON		0x10
#define TK_CMD_LED_OFF		0x20
#else
#define TK_CMD_LED_ON		1
#define TK_CMD_LED_OFF		2
#endif

#define I2C_M_WR 0		/* for i2c */

#define TK_UPDATE_DOWN		1
#define TK_UPDATE_FAIL		-1
#define TK_UPDATE_PASS		0

/* Firmware Version */
#if defined(CONFIG_MACH_Q1_BD)
#define TK_FIRMWARE_VER  0x12
#define TK_MODULE_VER    0x11
#elif defined(CONFIG_MACH_C1_NA_USCC_REV05)
#define TK_FIRMWARE_VER  0x0E
#define TK_MODULE_VER    0x08
#elif defined(CONFIG_MACH_M0)\
	|| defined(CONFIG_MACH_C1)\
	|| defined(CONFIG_MACH_M3)
#define TK_FIRMWARE_VER  0x06
#define TK_MODULE_VER    0x05
#elif defined(CONFIG_MACH_T0)
#define TK_FIRMWARE_VER	 0x11
#define TK_MODULE_VER    0x08
#else
#define TK_FIRMWARE_VER	 0x04
#define TK_MODULE_VER    0x00
#endif

/* LDO Regulator */
#if defined(CONFIG_MACH_M0)\
	|| defined(CONFIG_MACH_C1)\
	|| defined(CONFIG_MACH_M3)\
	|| defined(CONFIG_MACH_T0)
#define	TK_REGULATOR_NAME	"touchkey"
#else
#define	TK_REGULATOR_NAME	"touch"
#endif

/* LED LDO Type*/
#if defined(CONFIG_MACH_M0)\
	|| defined(CONFIG_MACH_C1_KOR_SKT)\
	|| defined(CONFIG_MACH_C1_KOR_KT)\
	|| defined(CONFIG_MACH_M3)\
	|| defined(CONFIG_MACH_C1)\
	|| defined(CONFIG_MACH_T0)
#define LED_LDO_WITH_EN_PIN
#else
#define LED_LDO_WITH_REGULATOR
#endif

/* Autocalibration */
#if defined(CONFIG_TARGET_LOCALE_NAATT)\
	|| defined(CONFIG_TARGET_LOCALE_NAATT_TEMP)\
	|| defined(CONFIG_TARGET_LOCALE_NA)\
	|| defined(CONFIG_MACH_Q1_BD)\
	|| defined(CONFIG_MACH_M0)\
	|| defined(CONFIG_MACH_C1)\
	|| defined(CONFIG_MACH_M3)\
	|| defined(CONFIG_MACH_T0)
#define TK_HAS_AUTOCAL
#endif

/* Generalized SMBus access */
#if defined(CONFIG_MACH_M0)\
	|| defined(CONFIG_MACH_M3)\
	|| defined(CONFIG_MACH_C1)\
	|| defined(CONFIG_MACH_T0)
#define TK_USE_GENERAL_SMBUS
#endif

/* Boot-up Firmware Update */
#if defined(CONFIG_MACH_Q1_BD) \
	|| defined(CONFIG_MACH_C1_NA_USCC_REV05) \
	|| defined(CONFIG_TARGET_LOCALE_NA)\
	|| defined(CONFIG_MACH_M0)\
	|| defined(CONFIG_MACH_C1)\
	|| defined(CONFIG_MACH_M3)\
	|| defined(CONFIG_MACH_T0)
#define TK_HAS_FIRMWARE_UPDATE
#endif

#if defined(CONFIG_TARGET_LOCALE_NAATT) \
	|| defined(CONFIG_TARGET_LOCALE_NAATT_TEMP)
#define TK_USE_4KEY_TYPE_ATT
#elif defined(CONFIG_MACH_LOCALE_NA) \
	|| defined(CONFIG_MACH_U1_NA_SPR) \
	|| defined(CONFIG_MACH_U1_NA_USCC)
#define TK_USE_4KEY_TYPE_NA
#elif defined(CONFIG_MACH_M0) \
	|| defined(CONFIG_MACH_C1) \
	|| defined(CONFIG_MACH_M3)\
	|| defined(CONFIG_MACH_T0)
#define TK_USE_2KEY_TYPE_M0
#else
#define TK_USE_2KEY_TYPE_U1
#endif

#if defined(TK_USE_4KEY_TYPE_ATT)\
	|| defined(TK_USE_4KEY_TYPE_NA)
#define TK_USE_4KEY
#elif defined(TK_USE_2KEY_TYPE_M0)\
	|| defined(TK_USE_2KEY_TYPE_U1)
#define TK_USE_2KEY
#endif

#if defined(CONFIG_MACH_M0_CHNOPEN)\
	|| defined(CONFIG_MACH_M0_HKTW)
#define  TOUCHKEY_FW_UPDATEABLE_HW_REV  10
#elif defined(CONFIG_MACH_M0)
#define  TOUCHKEY_FW_UPDATEABLE_HW_REV  11
#elif defined(CONFIG_MACH_C1)
#if defined(CONFIG_MACH_C1_KOR_SKT)\
	|| defined(CONFIG_MACH_C1_KOR_KT)
#define  TOUCHKEY_FW_UPDATEABLE_HW_REV  8
#elif defined(CONFIG_MACH_C1_KOR_LGT)
#define  TOUCHKEY_FW_UPDATEABLE_HW_REV  5
#else
#define  TOUCHKEY_FW_UPDATEABLE_HW_REV  7
#endif
#else
#define  TOUCHKEY_FW_UPDATEABLE_HW_REV  11
#endif

struct touchkey_platform_data {
	int gpio_sda;
	int gpio_scl;
	int gpio_int;
	void (*init_platform_hw)(void);
	int (*suspend) (void);
	int (*resume) (void);
	int (*power_on) (bool);
	int (*led_power_on) (bool);
	int (*reset_platform_hw)(void);
};

/*Parameters for i2c driver*/
struct touchkey_i2c {
	struct i2c_client *client;
	struct input_dev *input_dev;
	struct early_suspend early_suspend;
	struct mutex lock;
	struct device	*dev;
    struct work_struct	work;
    struct workqueue_struct *wq;
	int irq;
	int module_ver;
	int firmware_ver;
	struct touchkey_platform_data *pdata;
	char *name;
	int (*power)(int on);
	struct work_struct update_work;
	int update_status;
	atomic_t keypad_enable;
};

#endif /* _LINUX_CYPRESS_TOUCHKEY_I2C_H */