tizen 2.4 release
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-tiger / gpio_drvapi.h
1 /******************************************************************************
2  ** File Name:      gpio_drvapi.h                                                *
3  ** Author:         Xueliang.Wang                                             *
4  ** DATE:           03/18/2003                                                *
5  ** Copyright:      2003 Spreatrum, Incoporated. All Rights Reserved.         *
6  ** Description:    This file defines the basic operation interfaces of       *
7  **                 GPIO device.                                              *
8  ******************************************************************************
9
10  ******************************************************************************
11  **                        Edit History                                       *
12  ** ------------------------------------------------------------------------- *
13  ** DATE           NAME             DESCRIPTION                               *
14  ** 03/18/2003     Xueliang.Wang     Create.                                  *
15  ** 09/05/2003     Zhemin.Lin       Added functions for SM5100B EVB1.0        *
16  ** 22/11/2004     Benjamin.Wang    Modified according CR16760              *
17  ** 08/01/2008     Yiyue.He         modified the code for more generic adptation
18  ******************************************************************************/
19
20 #ifndef _GPIO_DRVAPI_H_
21 #define _GPIO_DRVAPI_H_
22
23 /**---------------------------------------------------------------------------*
24  **                         Dependencies                                      *
25  **---------------------------------------------------------------------------*/
26 #ifdef __cplusplus
27 extern   "C"
28 {
29 #endif
30
31 typedef enum GPIO_INT_tag
32 {
33     GPIO_INT_DISABLE = 0,   // Disable the relative gpio interrupt.
34     GPIO_INT_LEVEL_HIGH,    // detect high level.
35     GPIO_INT_LEVEL_LOW,     // detect low level.
36     GPIO_INT_EDGES_BOTH,    // detect the rising edges and falling edges.
37     GPIO_INT_EDGES_RISING,  // detect the rising edges.
38     GPIO_INT_EDGES_FALLING  // detect the falling edges.
39 } GPIO_INT_TYPE;
40
41
42 #define GPIO_DEFAULT_SHAKING_TIME   50
43
44 // CallBack function pointer prototype.
45 typedef void (* GPIO_CALLBACK) (uint32 gpio_id, uint32 gpio_state);
46
47 /*****************************************************************************/
48 //  Description:    This function initialize GPIO function.
49 //  Author:         Xueliang.Wang
50 //  Note:
51 /*****************************************************************************/
52 PUBLIC uint32 GPIO_Init (void);
53
54 /*****************************************************************************/
55 //  Description:    This function used to get the direction of a gpio pin
56 //  Author:           Benjamin.Wang
57 // retread by:      Yiyue.He
58 //  Note:              0 - Input
59 //                        1 - Output
60 /*****************************************************************************/
61 PUBLIC BOOLEAN GPIO_GetDirection (uint32  gpio_id);
62
63 /*****************************************************************************/
64 //  Description:    This function used to set the direction of a gpio pin
65 //  Author:           Benjamin.Wang
66 // retread by:      Yiyue.He
67 //  Note:              0 - Input
68 //                        1 - Output
69 /*****************************************************************************/
70 PUBLIC void GPIO_SetDirection (uint32  gpio_id, BOOLEAN directions);
71
72 /*****************************************************************************/
73 //  Description:    This function used to enable data w/r mask the given gpio port.
74 //  Author:           Benjamin.Wang
75 // retread by :     Yiyue.He
76 //  Note:
77 /*****************************************************************************/
78 PUBLIC void GPIO_Enable (uint32 gpio_id);
79
80 /*****************************************************************************/
81 //  Description:    This function used to disable the given gpio port.
82 //  Author:           Benjamin.Wang
83 // retread by :     Yiyue.He
84 //  Note:
85 /*****************************************************************************/
86 PUBLIC void GPIO_Disable (uint32 gpio_id);
87
88
89 /*****************************************************************************/
90 //  Description:    This function used to get the value of a gpio pin
91 //  Author:           Lin.Liu
92 //  Note:
93 /*****************************************************************************/
94 PUBLIC BOOLEAN  GPIO_GetValue (uint32  gpio_id);
95
96 /*****************************************************************************/
97 //  Description:    This function used to set the value of a gpio pin
98 //  Author:           Lin.Liu
99 //  Note:
100 /*****************************************************************************/
101 PUBLIC void GPIO_SetValue (uint32 gpio_id, BOOLEAN b_on);
102
103 /*****************************************************************************/
104 //  Description:    This function used to Deshaking 0 interrupt
105 //  Author:         Younger
106 //  Note:
107 /*****************************************************************************/
108
109 void GPIO_ZeroIntDeShaking (uint32 state);
110
111 /*****************************************************************************/
112 //  Description:    This function use timer to fix 0 interrpt issue
113 //  Author:         Zhemin.Lin
114 //  Note:
115 /*****************************************************************************/
116
117 void GPIO_ZeroIntHandler (uint32 int_num);
118
119 /*****************************************************************************/
120 //  Description:    This function used to enable gpio IRQ Interrupt.
121 //  Author:           Benjamin.Wang
122 //  Note:
123 /*****************************************************************************/
124 PUBLIC void GPIO_EnableInt (void);
125
126 /*****************************************************************************/
127 //  Description:    This function used to disable gpio IRQ Interrupt.
128 //  Author:           Benjamin.Wang
129 //  Note:
130 /*****************************************************************************/
131 PUBLIC void GPIO_DisableInt (void);
132
133
134 /*****************************************************************************/
135 //  Description:    This function used to enable gpio IRQ Interrupt.
136 //  Author:           Benjamin.Wang
137 //  Note:
138 /*****************************************************************************/
139 PUBLIC void GPIO_EnableInt (void);
140
141 /*****************************************************************************/
142 //  Description:    This function used to disable gpio IRQ Interrupt.
143 //  Author:           Benjamin.Wang
144 //  Note:
145 /*****************************************************************************/
146 PUBLIC void GPIO_DisableInt (void);
147
148 /*****************************************************************************/
149 //  Description:    This function used to enable the given gpio port's interrupt.
150 //  Author:           Benjamin.Wang
151 // retread by:        Yiyue.He
152 //  Note:
153 /*****************************************************************************/
154 PUBLIC void GPIO_EnableIntCtl (uint32 gpio_id);
155
156 /*****************************************************************************/
157 //  Description:    This function used to disable the given gpio port's interrupt.
158 //  Author:           Benjamin.Wang
159 // retread by:        Yiyue.He
160 //  Note:
161 /*****************************************************************************/
162 PUBLIC void GPIO_DisableIntCtl (uint32 gpio_id);
163
164 /*****************************************************************************/
165 //  Description:    This function used to get the intr state of a gpio pin
166 //  Author:         Zhemin.Lin
167 //  retread by:    Yiyue.He
168 //  Note:
169 /*****************************************************************************/
170 PUBLIC BOOLEAN GPIO_GetIntState (uint32 gpio_id);
171
172 /*****************************************************************************/
173 //  Description:    This function used to clear the given interrupt status bit.
174 //  Author:           Benjamin.Wang
175 // retread by:        Yiyue.He
176 //  Note:
177 /*****************************************************************************/
178 PUBLIC void GPIO_ClearIntStatus (uint32 gpio_id);
179
180 /*****************************************************************************/
181 //  Description:    This function used to set gpio Interrupt sense type.
182 //  Author:           Benjamin.Wang
183 //  Note:
184 /*****************************************************************************/
185 PUBLIC void GPIO_SetInterruptSense (uint32 gpio_id, GPIO_INT_TYPE sensetype);
186
187 /*****************************************************************************/
188 //  Description:    This function GPIO input state
189 //  Author:         Zhemin.Lin
190 //  Retread by :  Yiyue.He
191 //  Note:
192 /*****************************************************************************/
193 PUBLIC BOOLEAN GPIO_GetGPIOState (uint32 gpio_id);
194
195 /*****************************************************************************/
196 //  Description:    This function add an callback function to gpio_int_table
197 //  Author:
198 //  Retread by: Yiyue.He
199 //  Note:            This function and GPIO_AddToIntTable() can't be called simultaneously.
200 /*****************************************************************************/
201 PUBLIC uint32 GPIO_AddCallbackToIntTable (
202     uint32      gpio_id,            // GPIO ID
203     BOOLEAN     de_shaking,         // if SCI_TRUE, need de shaking, else needn't
204     uint32  shaking_interval,   // interval for de shaking
205     GPIO_CALLBACK gpio_callback_fun         // Callback function
206 );
207
208 /*****************************************************************************/
209 //  Description:    This function deletes an int from gpio_int_table
210 //  Author:           Benjamin.Wang
211 //  Retread by: Yiyue.He
212 //  Note:           If the GPIO INT is triggered by LEVEL, you have to delete it from int table in
213 //                   interrupt callback functions. Otherwise, the interrupt will be triggered ceaselessly.
214 /*****************************************************************************/
215 PUBLIC uint32 GPIO_DeleteFromIntTable (uint32 gpio_id);
216
217 /*****************************************************************************/
218 //  Description:    This function used to know whether the gpio port is enabled.
219 //  Author:           Yiyue.He
220 //  notes:
221 /*****************************************************************************/
222 PUBLIC BOOLEAN GPIO_GetDataMask (uint32 gpio_id);
223
224 /*****************************************************************************/
225 //  Description:    This function used to set the gpio port to enabled or not
226 //  Author:           Yiyue.He
227 //  notes:
228 /*****************************************************************************/
229 PUBLIC void GPIO_SetDataMask (uint32 gpio_id, BOOLEAN b_on);
230
231 /*****************************************************************************/
232 //  Description:    This function retrun the max number of gpio
233 //  Author:         Zhemin.Lin
234 //  Note:
235 /*****************************************************************************/
236 PUBLIC uint32 GPIO_GetMaxNumber (void);
237
238 PUBLIC void GPIO_SetInitState (uint32  gpio_id, uint32 state);
239
240 PUBLIC uint32 GPIO_GetInitState (uint32  gpio_id);
241
242 PUBLIC uint32 GPIO_GetShakeInterval (uint32 gpio_id);
243
244 PUBLIC void GPIO_GetCallBack (uint32 gpio_id, uint32 gpio_state);
245
246
247 #ifdef __cplusplus
248 }
249 #endif
250
251 #endif  // _GPIO_DRVAPI_H_
252
253 // End of gpio_drvapi.h