ARM: rockchip: rk3228: add grf definition
[firefly-linux-kernel-4.4.55.git] / include / linux / goodix_touch_82x.h
1 /*
2  * 
3  * Copyright (C) 2011 Goodix, Inc.
4  * 
5  * Author: Scott
6  * Date: 2012.01.05
7  */
8
9 #ifndef _LINUX_GOODIX_TOUCH_H
10 #define _LINUX_GOODIX_TOUCH_H
11
12 #include <linux/earlysuspend.h>
13 #include <linux/hrtimer.h>
14 #include <linux/i2c.h>
15 #include <linux/input.h>
16
17 #define fail    0
18 #define success 1
19
20 #define false   0
21 #define true    1
22
23 #define FLAG_UP                 0
24 #define FLAG_DOWN       1
25
26 #define RELEASE_DATE "2012-02-07"
27
28 #define GOODIX_I2C_NAME  "Goodix-TS-82X"
29 #define GOODIX_I2C_ADDR     0X5D
30
31 #if 1
32 #define GTDEBUG(fmt, arg...) printk("<--GT-DEBUG-->"fmt, ##arg)
33 #else
34 #define DEBUG(fmt, arg...)
35 #endif
36
37 #if 1
38 #define GTNOTICE(fmt, arg...) printk("<--GT-NOTICE-->"fmt, ##arg)
39 #else
40 #define NOTICE(fmt, arg...)
41 #endif
42
43 #if 1
44 #define GTWARNING(fmt, arg...) printk("<--GT-WARNING-->"fmt, ##arg)
45 #else
46 #define WARNING(fmt, arg...)
47 #endif
48
49 #if 1
50 #define GTDEBUG_MSG(fmt, arg...) printk("<--GT msg-->"fmt, ##arg)
51 #else
52 #define DEBUG_MSG(fmt, arg...)
53 #endif
54
55 #if 1
56 #define GTDEBUG_UPDATE(fmt, arg...) printk("<--GT update-->"fmt, ##arg)
57 #else
58 #define DEBUG_UPDATE(fmt, arg...)
59 #endif 
60
61 #if 0   //w++
62 #define GTDEBUG_COOR(fmt, arg...) printk(fmt, ##arg)
63 #define GTDEBUG_COORD
64 #else
65 #define GTDEBUG_COOR(fmt, arg...)
66 #define DEBUG_COOR(fmt, arg...)
67 #endif
68
69 #if 1
70 #define GTDEBUG_ARRAY(array, num)   do{\
71                                    int i;\
72                                    u8* a = array;\
73                                    for (i = 0; i < (num); i++)\
74                                    {\
75                                        printk("%02x   ", (a)[i]);\
76                                        if ((i + 1 ) %10 == 0)\
77                                        {\
78                                            printk("\n");\
79                                        }\
80                                    }\
81                                    printk("\n");\
82                                   }while(0)
83 #else
84 #define DEBUG_ARRAY(array, num) 
85 #endif 
86
87 #define ADDR_MAX_LENGTH     2
88 #define ADDR_LENGTH         ADDR_MAX_LENGTH
89
90 //#define CREATE_WR_NODE
91 //#define AUTO_UPDATE_GUITAR             //Èç¹û¶¨ÒåÁËÔòÉϵç»á×Ô¶¯ÅжÏÊÇ·ñÐèÒªÉý¼¶
92
93 //--------------------------For user redefine-----------------------------//
94 //-------------------------GPIO REDEFINE START----------------------------//
95 #define GPIO_DIRECTION_INPUT(port)          gpio_direction_input(port)
96 #define GPIO_DIRECTION_OUTPUT(port, val)    gpio_direction_output(port, val)
97 #define GPIO_SET_VALUE(port, val)           gpio_set_value(port, val)
98 #define GPIO_FREE(port)                     gpio_free(port)
99 #define GPIO_REQUEST(port, name)            gpio_request(port, name)
100 #define GPIO_PULL_UPDOWN(port, val)      gpio_pull_updown(port,val)  // s3c_gpio_setpull(port, val)
101 #define GPIO_CFG_PIN(port, cfg)                 //s3c_gpio_cfgpin(port, cfg)
102 //-------------------------GPIO REDEFINE END------------------------------//
103
104
105 //*************************TouchScreen Work Part Start**************************
106
107 #define RESET_PORT          S3C64XX_GPF(3)          //RESET¹Ü½ÅºÅ
108 #define INT_PORT            S3C64XX_GPL(10)         //Int IO port
109 #ifdef INT_PORT
110     #define TS_INT          gpio_to_irq(INT_PORT)      //Interrupt Number,EINT18(119)
111     #define INT_CFG         S3C_GPIO_SFN(3)            //IO configer as EINT
112 #else
113     #define TS_INT          0
114 #endif
115
116
117 #define GT_IRQ_RISING       IRQ_TYPE_EDGE_RISING
118 #define GT_IRQ_FALLING      IRQ_TYPE_EDGE_FALLING
119 #define INT_TRIGGER         GT_IRQ_FALLING
120 #define POLL_TIME           10        //actual query spacing interval:POLL_TIME+6
121
122 #define GOODIX_MULTI_TOUCH
123 #ifdef GOODIX_MULTI_TOUCH
124     #define MAX_FINGER_NUM    5
125 #else
126     #define MAX_FINGER_NUM    1
127 #endif
128
129 #define gtswap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
130
131 struct goodix_i2c_rmi_platform_data {
132  /*   u8 bad_data;      
133     u8 irq_is_disable;
134     u16 addr;
135     s32 use_reset;        //use RESET flag
136     s32 use_irq;          //use EINT flag
137     u32 version;
138     s32 (*power)(struct goodix_ts_data * ts, s32 on);
139     struct i2c_client *client;
140     struct input_dev *input_dev;
141     struct hrtimer timer;
142     struct work_struct work;
143     struct early_suspend early_suspend;
144     s8 phys[32];
145 */      
146     uint32_t version;   /* Use this entry for panels with */
147     unsigned gpio_shutdown;
148     unsigned gpio_irq;
149     unsigned gpio_reset;
150     bool irq_edge; /* 0:rising edge, 1:falling edge */
151     bool swap_xy;
152     bool xpol;
153     bool ypol;
154     int xmax;
155     int ymax;
156     int config_info_len;
157     u8 *config_info;
158     int (*init_platform_hw)(void);
159
160 };
161 //*************************TouchScreen Work Part End****************************
162
163 #endif /* _LINUX_GOODIX_TOUCH_H */