| 1 | #include <linux/init.h> |
| 2 | #include <linux/module.h> |
| 3 | #include <linux/delay.h> |
| 4 | #include <linux/i2c.h> |
| 5 | #include <linux/input.h> |
| 6 | #include <linux/slab.h> |
| 7 | #include <linux/gpio.h> |
| 8 | #include <linux/sched.h> |
| 9 | #include <linux/kthread.h> |
| 10 | #include <linux/bitops.h> |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/delay.h> |
| 13 | #include <linux/byteorder/generic.h> |
| 14 | #ifdef CONFIG_HAS_EARLYSUSPEND |
| 15 | #include <linux/earlysuspend.h> |
| 16 | #endif |
| 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/time.h> |
| 19 | #include <linux/rtpm_prio.h> |
| 20 | |
| 21 | #include <linux/proc_fs.h> |
| 22 | #include <asm/uaccess.h> |
| 23 | |
| 24 | |
| 25 | |
| 26 | #include "tpd_custom_GT818B.h" |
| 27 | #include <mach/mt_pm_ldo.h> |
| 28 | #include <mach/mt_typedefs.h> |
| 29 | #include <mach/mt_boot.h> |
| 30 | |
| 31 | #include "tpd.h" |
| 32 | #include <cust_eint.h> |
| 33 | #include <linux/jiffies.h> |
| 34 | |
| 35 | #ifndef TPD_NO_GPIO |
| 36 | #include "cust_gpio_usage.h" |
| 37 | #endif |
| 38 | |
| 39 | #include "gt818_fw.h" |
| 40 | |
| 41 | extern struct tpd_device *tpd; |
| 42 | |
| 43 | static int tpd_flag = 0; |
| 44 | static int tpd_halt=0; |
| 45 | static struct task_struct *thread = NULL; |
| 46 | static DECLARE_WAIT_QUEUE_HEAD(waiter); |
| 47 | static DEFINE_MUTEX(esd_check); |
| 48 | |
| 49 | |
| 50 | #ifdef TPD_HAVE_BUTTON |
| 51 | static int tpd_keys_local[TPD_KEY_COUNT] = TPD_KEYS; |
| 52 | static int tpd_keys_dim_local[TPD_KEY_COUNT][4] = TPD_KEYS_DIM; |
| 53 | #endif |
| 54 | #if (defined(TPD_WARP_START) && defined(TPD_WARP_END)) |
| 55 | static int tpd_wb_start_local[TPD_WARP_CNT] = TPD_WARP_START; |
| 56 | static int tpd_wb_end_local[TPD_WARP_CNT] = TPD_WARP_END; |
| 57 | #endif |
| 58 | #if (defined(TPD_HAVE_CALIBRATION) && !defined(TPD_CUSTOM_CALIBRATION)) |
| 59 | //static int tpd_calmat_local[8] = TPD_CALIBRATION_MATRIX; |
| 60 | static int tpd_def_calmat_local[8] = TPD_CALIBRATION_MATRIX; |
| 61 | #endif |
| 62 | |
| 63 | static void tpd_eint_interrupt_handler(void); |
| 64 | static int touch_event_handler(void *unused); |
| 65 | static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id); |
| 66 | static int tpd_i2c_detect(struct i2c_client *client, struct i2c_board_info *info); |
| 67 | static int tpd_i2c_remove(struct i2c_client *client); |
| 68 | #if 0 |
| 69 | extern void mt65xx_eint_unmask(unsigned int line); |
| 70 | extern void mt65xx_eint_mask(unsigned int line); |
| 71 | extern void mt65xx_eint_set_hw_debounce(kal_uint8 eintno, kal_uint32 ms); |
| 72 | extern kal_uint32 mt65xx_eint_set_sens(kal_uint8 eintno, kal_bool sens); |
| 73 | extern void mt65xx_eint_registration(kal_uint8 eintno, kal_bool Dbounce_En, |
| 74 | kal_bool ACT_Polarity, void (EINT_FUNC_PTR)(void), |
| 75 | kal_bool auto_umask); |
| 76 | #endif |
| 77 | #ifdef CREATE_WR_NODE |
| 78 | extern s32 init_wr_node(struct i2c_client*); |
| 79 | extern void uninit_wr_node(void); |
| 80 | #endif |
| 81 | |
| 82 | extern int gt818_downloader( struct i2c_client *client, unsigned short ver, unsigned char * data ); |
| 83 | //#define TPD_DITO_SENSOR |
| 84 | //#define TPD_CONDITION_SWITCH |
| 85 | #define TPD_RESET_ISSUE_WORKAROUND |
| 86 | #define TPD_MAX_RESET_COUNT 3 |
| 87 | |
| 88 | #ifdef ESD_PROTECT |
| 89 | static struct delayed_work tpd_esd_check_work; |
| 90 | static struct workqueue_struct * tpd_esd_check_workqueue = NULL; |
| 91 | static void tpd_esd_check_func(struct work_struct *); |
| 92 | #define ESD_CHECK_CIRCLE 500 |
| 93 | #define ESD_CHECK_DATA_LEN 6 |
| 94 | #define ESD_CHECK_TIME 3 |
| 95 | unsigned char esd_check_data[ESD_CHECK_TIME*ESD_CHECK_DATA_LEN]; |
| 96 | int esd_checked_time = 0; |
| 97 | #endif |
| 98 | #define TPD_OK 0 |
| 99 | |
| 100 | #define TPD_CONFIG_REG_BASE 0x6A2 |
| 101 | #define TPD_FREQ_CAL_RESULT 0x70F |
| 102 | #define TPD_TOUCH_INFO_REG_BASE 0x712 |
| 103 | #define TPD_POINT_INFO_REG_BASE 0x722 |
| 104 | #define TPD_VERSION_INFO_REG 0x713 |
| 105 | #define TPD_VERSION_BASIC_REG 0x717 |
| 106 | #define TPD_KEY_INFO_REG_BASE 0x721 |
| 107 | #define TPD_POWER_MODE_REG 0x692 |
| 108 | #define TPD_HANDSHAKING_START_REG 0xFFF |
| 109 | #define TPD_HANDSHAKING_END_REG 0x8000 |
| 110 | #define TPD_FREQ_REG 0x1522 |
| 111 | #define TPD_SOFT_RESET_MODE 0x01 |
| 112 | #define TPD_POINT_INFO_LEN 8 |
| 113 | #define TPD_MAX_POINTS 5 |
| 114 | #define MAX_TRANSACTION_LENGTH 8 |
| 115 | #define I2C_DEVICE_ADDRESS_LEN 2 |
| 116 |