aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/mms152_download_porting.h
blob: f12af3dbc0244faba5be29c3b6b24a1eeb8ba053 (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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/*--------------------------------------------------------
//
//
//	Melfas MCS7000 Series Download base v1.0 2010.04.05
//
//
//------------------------------------------------------*/

#ifndef __MELFAS_DOWNLOAD_PORTING_H_INCLUDED__
#define __MELFAS_DOWNLOAD_PORTING_H_INCLUDED__

/*============================================================
//
//	Porting order
//
//==========================================================*/
/*

1. melfas_download_porting.h
   - Check typedef	[melfas_download_porting.h]

   - Check download options	[melfas_download_porting.h]

   - Add Port control code  ( CE, RESETB, I2C,... )
	[melfas_download_porting.h]

   - Apply your delay function ( inside mcsdl_delaly())
	[melfas_download.c]
      Modify delay parameter constant ( ex. MCSDL_DELAY_5MS )
	to make it fit to your delay function.

   - Rename 'uart_printf()' to your console print function for debugging.
	[melfas_download_porting.h]
	or, define uart_printf() as different function properly.

   - Check Watchdog timer, Interrupt factor

   - Including Melfas binary .c file

   - Basenad dealy function
      fill up mcsdl_delay()

   - Implement processing external Melfas binary .bin file.

*/

/* ============================================================
//
//	Type define
//
//==========================================================*/

typedef char			INT8;
typedef unsigned char		UINT8;
/* typedef unsigned char		uint8_t; */
typedef short			INT16;
typedef unsigned short		UINT16;
/* typedef unsigned short	uint16_t; */
typedef int			INT32;
typedef unsigned int		UINT32;
typedef unsigned char		BOOLEAN;

#ifndef TRUE
#define TRUE			(1 == 1)
#endif

#ifndef FALSE
#define FALSE			(1 == 0)
#endif

#ifndef NULL
#define NULL			0
#endif

#ifndef GPIO_TOUCH_I2C_SDA
#define GPIO_TOUCH_I2C_SDA GPIO_I2C0_SDA
#define GPIO_TOUCH_I2C_SCL GPIO_I2C0_SCL
#endif

/* ============================================================
//
//	Porting Download Options
//
//========================================================== */

/*  For printing debug information. ( Please check 'printing function' ) */
#define MELFAS_ENABLE_DBG_PRINT				1
#define MELFAS_ENABLE_DBG_PROGRESS_PRINT		0

/*  For delay function test. ( Disable after Porting is finished ) */
#define MELFAS_ENABLE_DELAY_TEST			0


/* ============================================================
//
//	IO Control poting.
//
//	Fill 'Using signal' up only.
//	See MCSDL_USE_VDD_CONTROL,
//		MCSDL_USE_CE_CONTROL,
//
//========================================================== */

/* ----------------
// VDD
//-------------- */
#if MCSDL_USE_VDD_CONTROL

#ifdef CONFIG_MACH_P2LTE_REV00
#define MCSDL_VDD_SET_HIGH()    mcsdl_vdd_on()
#define MCSDL_VDD_SET_LOW()     mcsdl_vdd_off()
#else
#define MCSDL_VDD_SET_HIGH()    gpio_set_value(GPIO_TSP_RST, 1)
#define MCSDL_VDD_SET_LOW()     gpio_set_value(GPIO_TSP_RST, 0)
#endif

#else
#define MCSDL_VDD_SET_HIGH()
#define MCSDL_VDD_SET_LOW()
#endif

/* ----------------
// CE
//--------------*/
#if MCSDL_USE_CE_CONTROL

#ifdef CONFIG_MACH_P2LTE_REV00
#define MCSDL_CE_SET_HIGH()     mcsdl_vdd_on()
#define MCSDL_CE_SET_LOW()      mcsdl_vdd_off()
#else
#define MCSDL_CE_SET_HIGH()	gpio_set_value(GPIO_TSP_RST, 1)
#define MCSDL_CE_SET_LOW()	gpio_set_value(GPIO_TSP_RST, 0)
#endif

#define MCSDL_CE_SET_OUTPUT() gpio_tlmm_config(GPIO_CFG(TOUCH_EN, 0,\
	GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE)
#else
#define MCSDL_CE_SET_HIGH()
#define MCSDL_CE_SET_LOW()
#define MCSDL_CE_SET_OUTPUT()
#endif


/* ----------------
// RESETB
//--------------*/
#if MCSDL_USE_RESETB_CONTROL
#define MCSDL_RESETB_SET_HIGH()		gpio_direction_output(GPIO_TSP_INT, 1)
#define MCSDL_RESETB_SET_LOW()		gpio_direction_output(GPIO_TSP_INT, 0)
#define MCSDL_RESETB_SET_OUTPUT()  /*gpio_direction_output(GPIO_TSP_INT, n) */
#define MCSDL_RESETB_SET_INPUT()	gpio_direction_input(GPIO_TSP_INT)
#else
#define MCSDL_RESETB_SET_HIGH()
#define MCSDL_RESETB_SET_LOW()
#define MCSDL_RESETB_SET_OUTPUT()
#define MCSDL_RESETB_SET_INPUT()
#endif


/* ------------------
// I2C SCL & SDA
//----------------*/

#define MCSDL_GPIO_SCL_SET_HIGH()	gpio_direction_output(GPIO_TSP_SCL, 1)
#define MCSDL_GPIO_SCL_SET_LOW()	gpio_direction_output(GPIO_TSP_SCL, 0)

#define MCSDL_GPIO_SDA_SET_HIGH()	gpio_direction_output(GPIO_TSP_SDA, 1)
#define MCSDL_GPIO_SDA_SET_LOW()	gpio_direction_output(GPIO_TSP_SDA, 0)

#define MCSDL_GPIO_SCL_SET_OUTPUT() /*gpio_direction_output(GPIO_TSP_SCL, n)*/
#define MCSDL_GPIO_SCL_SET_INPUT()	gpio_direction_input(GPIO_TSP_SCL)

#define MCSDL_GPIO_SDA_SET_OUTPUT() /*gpio_direction_output(GPIO_TSP_SDA, n)*/
#define MCSDL_GPIO_SDA_SET_INPUT()	gpio_direction_input(GPIO_TSP_SDA)

#define MCSDL_GPIO_SDA_IS_HIGH() ((gpio_get_value(GPIO_TSP_SDA) > 0) ? 1 : 0)

#define MCSDL_SET_GPIO_I2C()
#define MCSDL_SET_HW_I2C()


#define MCSDL_GPIO_SCL_SET_OUTPUT_ISC(n) gpio_direction_output(GPIO_TSP_SCL, n)
#define MCSDL_GPIO_SDA_SET_OUTPUT_ISC(n) gpio_direction_output(GPIO_TSP_SDA, n)
#define MCSDL_GPIO_SCL_IS_HIGH() ((gpio_get_value(GPIO_TSP_SCL) > 0) ? 1 : 0)

/* ============================================================
//
//	Delay parameter setting
//
//	These are used on 'mcsdl_delay()'
//
//==========================================================*/

#define MCSDL_DELAY_1US			1
#define MCSDL_DELAY_2US			2
#define MCSDL_DELAY_3US			3
#define MCSDL_DELAY_5US			5
#define MCSDL_DELAY_7US			7
#define MCSDL_DELAY_10US		10
#define MCSDL_DELAY_15US		15
#define MCSDL_DELAY_20US		20

#define MCSDL_DELAY_100US		100
#define MCSDL_DELAY_150US		150
#define MCSDL_DELAY_500US		500
#define MCSDL_DELAY_800US		800


#define MCSDL_DELAY_1MS			1000
#define MCSDL_DELAY_5MS			5000
#define MCSDL_DELAY_10MS		10000
#define MCSDL_DELAY_25MS		25000
#define MCSDL_DELAY_30MS		30000
#define MCSDL_DELAY_40MS		40000
#define MCSDL_DELAY_45MS		45000
#define MCSDL_DELAY_100MS		100000

/*start ADD DELAY */
#define MCSDL_DELAY_50MS		50000
#define MCSDL_DELAY_60MS		60000
#define MCSDL_DELAY_80MS		80000
#define MCSDL_DELAY_500MS		500000

#define MCSDL_DELAY_40US		40
#define MCSDL_DELAY_70US		70
#define MCSDL_DELAY_300US		300
/*end add delay */

/*============================================================
//
//	Defence External Effect
//
//==========================================================*/

#define MELFAS_DISABLE_BASEBAND_ISR()
#define MELFAS_DISABLE_WATCHDOG_TIMER_RESET()

#define MELFAS_ROLLBACK_BASEBAND_ISR()
#define MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET()

#endif