2 * Copyright (C) 2013 LG Electironics, Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
16 #define MAX_NUM_OF_BUTTON 4
17 #define MAX_NUM_OF_FINGER 10
18 #define DESCRIPTION_TABLE_START 0xE9
19 #define PAGE_SELECT_REG 0xFF
20 #define PAGE_MAX_NUM 4
22 #define REG_X_POSITION 0
23 #define REG_Y_POSITION 1
24 #define REG_YX_POSITION 2
27 #define NUM_OF_EACH_FINGER_DATA_REG 5
29 /* Define for Area based key button */
30 #define BUTTON_MARGIN 50
31 #define TOUCH_BUTTON_PRESSED 2
33 /* Debug Mask setting */
34 #define SYNAPTICS_RMI4_I2C_DEBUG_PRINT 1
35 #define SYNAPTICS_RMI4_I2C_ERROR_PRINT 1
36 #define SYNAPTICS_RMI4_I2C_INFO_PRINT 1
38 #if defined(SYNAPTICS_RMI4_I2C_INFO_PRINT)
39 #define SYNAPTICS_INFO_MSG(fmt, args...) printk(KERN_ERR "[Touch] " fmt, ##args);
41 #define SYNAPTICS_INFO_MSG(fmt, args...) {};
44 #if defined(SYNAPTICS_RMI4_I2C_DEBUG_PRINT)
45 #define SYNAPTICS_DEBUG_MSG(fmt, args...) printk(KERN_ERR "[Touch D] [%s %d] " fmt, __FUNCTION__, __LINE__, ##args);
47 #define SYNAPTICS_DEBUG_MSG(fmt, args...) {};
50 #if defined(SYNAPTICS_RMI4_I2C_ERROR_PRINT)
51 #define SYNAPTICS_ERR_MSG(fmt, args...) printk(KERN_ERR "[Touch E] [%s %d] " fmt, __FUNCTION__, __LINE__, ##args);
53 #define SYNAPTICS_ERR_MSG(fmt, args...) {};
58 SYNAPTICS_RMI4_I2C_DEBUG_NONE
= 0,
59 SYNAPTICS_RMI4_I2C_DEBUG_FUNC_TRACE
= 1U << 0, /* 1 */
60 SYNAPTICS_RMI4_I2C_DEBUG_INT_STATUS
= 1U << 1, /* 2 */
61 SYNAPTICS_RMI4_I2C_DEBUG_FINGER_STATUS
= 1U << 2, /* 4 */
62 SYNAPTICS_RMI4_I2C_DEBUG_FINGER_POSITION
= 1U << 3, /* 8 */
63 SYNAPTICS_RMI4_I2C_DEBUG_FINGER_REG
= 1U << 4, /* 16 */
64 SYNAPTICS_RMI4_I2C_DEBUG_BUTTON_STATUS
= 1U << 5, /* 32 */
65 SYNAPTICS_RMI4_I2C_DEBUG_BUTTON_REG
= 1U << 6, /* 64 */
66 SYNAPTICS_RMI4_I2C_DEBUG_INT_INTERVAL
= 1U << 7, /* 128 */
67 SYNAPTICS_RMI4_I2C_DEBUG_INT_ISR_DELAY
= 1U << 8, /* 256 */
68 SYNAPTICS_RMI4_I2C_DEBUG_FINGER_HANDLE_TIME
= 1U << 9, /* 512 */
69 SYNAPTICS_RMI4_I2C_DEBUG_BUTTON_HANDLE_TIME
= 1U << 10, /* 1024 */
70 SYNAPTICS_RMI4_I2C_DEBUG_UPGRADE_DELAY
= 1U << 11, /* 2048 */
74 IC_CTRL_CODE_NONE
= 0,
90 TIME_EX_FIRST_INT_TIME
,
91 TIME_EX_PREV_PRESS_TIME
,
92 TIME_EX_CURR_PRESS_TIME
,
93 TIME_EX_BUTTON_PRESS_START_TIME
,
94 TIME_EX_BUTTON_PRESS_END_TIME
,
95 TIME_EX_FIRST_GHOST_DETECT_TIME
,
96 TIME_EX_SECOND_GHOST_DETECT_TIME
,
97 TIME_EX_CURR_INT_TIME
,
102 IGNORE_INTERRUPT
= 100,
108 struct synaptics_ts_platform_data
{
110 unsigned long irqflags
;
111 unsigned short irq_num
;
112 //jhee//unsigned short int_gpio;
113 unsigned int int_gpio
;
114 //jhee//unsigned short reset_gpio;
115 unsigned int reset_gpio
;
116 int (*power
)(int on
);
117 unsigned short ic_booting_delay
; /* ms */
118 unsigned long report_period
; /* ns */
119 unsigned char num_of_finger
;
120 unsigned char num_of_button
;
121 unsigned short button
[MAX_NUM_OF_BUTTON
];
124 unsigned char fw_ver
;
125 unsigned int palm_threshold
;
126 unsigned int delta_pos_threshold
;
127 int use_ghost_detection
;
138 } ts_function_descriptor
;
141 unsigned int pos_x
[MAX_NUM_OF_FINGER
];
142 unsigned int pos_y
[MAX_NUM_OF_FINGER
];
143 unsigned char pressure
[MAX_NUM_OF_FINGER
];
148 struct synaptics_ts_timestamp
{
156 /* Device data structure */
157 struct synaptics_ts_data
{
158 struct i2c_client
*client
;
159 struct input_dev
*input_dev
;
160 struct synaptics_ts_platform_data
*pdata
;
161 bool is_downloading
; /* avoid power off during F/W upgrade */
162 bool is_suspended
; /* avoid power off during F/W upgrade */
163 unsigned int button_width
;
164 char button_prestate
[MAX_NUM_OF_BUTTON
];
165 char finger_prestate
[MAX_NUM_OF_FINGER
];
168 atomic_t interrupt_handled
;
169 ts_function_descriptor common_dsc
;
170 ts_function_descriptor finger_dsc
;
171 ts_function_descriptor button_dsc
;
172 ts_function_descriptor analog_dsc
;
173 ts_function_descriptor flash_dsc
;
179 unsigned char int_status_reg_asb0_bit
;
180 unsigned char int_status_reg_button_bit
;
181 unsigned char curr_int_mask
;
182 struct hrtimer timer
;
183 struct delayed_work work
;
184 struct delayed_work button_lock_work
;
185 struct synaptics_ts_timestamp int_delay
;
186 ts_finger_data pre_ts_data
;
192 unsigned char *fw_start
;
193 unsigned long fw_size
;
194 char fw_config_id
[5];
195 char fw_product_id
[11];
196 bool fw_force_upgrade
;
200 unsigned char device_status_reg
;
201 unsigned char interrupt_status_reg
;
202 unsigned char button_data_reg
;
206 unsigned char finger_state_reg
[3];
207 unsigned char finger_data
[MAX_NUM_OF_FINGER
][NUM_OF_EACH_FINGER_DATA_REG
];