Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: arch/arm/mach-tegra/nv/include/nvrm_gpio.h

Issue 3256004: [ARM] tegra: add nvos/nvrm/nvmap drivers (Closed) Base URL: ssh://git@gitrw.chromium.org/kernel.git
Patch Set: remove ap15 headers Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2009 NVIDIA Corporation.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * Neither the name of the NVIDIA Corporation nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33 #ifndef INCLUDED_nvrm_gpio_H
34 #define INCLUDED_nvrm_gpio_H
35
36
37 #if defined(__cplusplus)
38 extern "C"
39 {
40 #endif
41
42 #include "nvrm_init.h"
43
44
45 /** @file
46 * @brief <b>NVIDIA Driver Development Kit NvRm gpio APIs</b>
47 *
48 * @b Description: Declares Interface for NvRm gpio module.
49 */
50
51 /**
52 * @defgroup nvrm_gpio RM GPIO Services
53 *
54 * This is the Resource Manager interface to general-purpose input-output
55 * (GPIO) services. Fundamental abstraction of this API is a "pin handle", which
56 * of type NvRmGpioPinHandle. A Pin handle is acquired by making a call to
57 * NvRmGpioAcquirePinHandle API. This API returns a pin handle which is
58 * subsequently used by the rest of the GPIO APIs.
59 *
60 * @ingroup nvddk_rm
61 * @{
62 */
63
64 #include "nvcommon.h"
65 #include "nvos.h"
66
67 /**
68 * NvRmGpioHandle is an opaque handle to the GPIO device on the chip.
69 */
70
71 typedef struct NvRmGpioRec *NvRmGpioHandle;
72
73 /**
74 * @brief GPIO pin handle which describes the physical pin. This values should
75 * not be cached or hardcoded by the drivers. This can vary from chip to chip
76 * and board to board.
77 */
78
79 typedef NvU32 NvRmGpioPinHandle;
80
81 /**
82 * @brief Defines the possible gpio pin modes.
83 */
84
85 typedef enum
86 {
87
88 /**
89 * Specifies the gpio pin as not in use. When in this state, the RM or
90 * ODM Kit may park the pin in a board-specific state in order to
91 * minimize leakage current.
92 */
93 NvRmGpioPinMode_Inactive = 1,
94
95 /// Specifies the gpio pin mode as input and enable interrupt for level low.
96 NvRmGpioPinMode_InputInterruptLow,
97
98 /// Specifies the gpio pin mode as input and enable interrupt for level high .
99 NvRmGpioPinMode_InputInterruptHigh,
100
101 /// Specifies the gpio pin mode as input and no interrupt configured.
102 NvRmGpioPinMode_InputData,
103
104 /// Specifies the gpio pin mode as output.
105 NvRmGpioPinMode_Output,
106
107 /// Specifies the gpio pin mode as a special function.
108 NvRmGpioPinMode_Function,
109
110 /// Specifies the gpio pin as input and interrupt configured to any edge.
111 /// i.e seamphore will be signaled for both the rising and failling edges.
112 NvRmGpioPinMode_InputInterruptAny,
113
114 /// Sepciifed the gpio pin a input and interrupt configured to rising edge.
115 NvRmGpioPinMode_InputInterruptRisingEdge,
116
117 /// Sepciifed the gpio pin a input and interrupt configured to falling edge.
118 NvRmGpioPinMode_InputInterruptFallingEdge,
119 NvRmGpioPinMode_Num,
120 NvRmGpioPinMode_Force32 = 0x7FFFFFFF
121 } NvRmGpioPinMode;
122
123 /**
124 * @brief Defines the pin state
125 */
126
127 typedef enum
128 {
129
130 // Pin state high
131 NvRmGpioPinState_Low = 0,
132
133 // Pin is high
134 NvRmGpioPinState_High,
135
136 // Pin is in tri state
137 NvRmGpioPinState_TriState,
138 NvRmGpioPinState_Num,
139 NvRmGpioPinState_Force32 = 0x7FFFFFFF
140 } NvRmGpioPinState;
141
142 // Gnerates a contruct the pin handle till the NvRmGpioAcquirePinHandle
143 // API is implemented.
144 #define GPIO_MAKE_PIN_HANDLE(inst, port, pin) (0x80000000 | (((NvU32)(pin) & 0x FF)) | (((NvU32)(port) & 0xff) << 8) | (((NvU32)(inst) & 0xff )<< 16))
145 #define NVRM_GPIO_CAMERA_PORT (0xfe)
146 #define NVRM_GPIO_CAMERA_INST (0xfe)
147
148 /**
149 * Creates and opens a GPIO handle. The handle can then be used to
150 * access GPIO functions.
151 *
152 * @param hRmDevice The RM device handle.
153 * @param phGpio Specifies a pointer to the gpio handle where the
154 * allocated handle is stored. The memory for handle is allocated
155 * inside this API.
156 *
157 * @retval NvSuccess gpio initialization is successful.
158 */
159
160 NvError NvRmGpioOpen(
161 NvRmDeviceHandle hRmDevice,
162 NvRmGpioHandle * phGpio );
163
164 /**
165 * Closes the GPIO handle. Any pin settings made while this handle was
166 * open will remain. All events enabled by this handle will be
167 * disabled.
168 *
169 * @param hGpio A handle from NvRmGpioOpen(). If hGpio is NULL, this API does
170 * nothing.
171 */
172
173 void NvRmGpioClose(
174 NvRmGpioHandle hGpio );
175
176 /** Get NvRmGpioPinHandle from the physical port and pin number. If a driver
177 * acquires a pin handle another driver will not be able to use this until the
178 * pin is released.
179 *
180 * @param hGpio A handle from NvRmGpioOpen().
181 * @param port Physical gpio ports which are chip specific.
182 * @param pinNumber pin number in that port.
183 * @param phGpioPin Pointer to the GPIO pin handle.
184 */
185
186 NvError NvRmGpioAcquirePinHandle(
187 NvRmGpioHandle hGpio,
188 NvU32 port,
189 NvU32 pin,
190 NvRmGpioPinHandle * phPin );
191
192 /** Releases the pin handles acquired by NvRmGpioAcquirePinHandle API.
193 *
194 * @param hGpio A handle got from NvRmGpioOpen().
195 * @param hPin Array of pin handles got from NvRmGpioAcquirePinHandle().
196 * @param pinCount Size of pin handles array.
197 */
198
199 void NvRmGpioReleasePinHandles(
200 NvRmGpioHandle hGpio,
201 NvRmGpioPinHandle * hPin,
202 NvU32 pinCount );
203
204 /**
205 * Sets the state of array of pins.
206 *
207 * NOTE: When multiple pins are specified (pinCount is greater than
208 * one), ODMs should not make assumptions about the order in which
209 * pins are updated. The implementation will attempt to coalesce
210 * updates to occur atomically; however, this can not be guaranteed in
211 * all cases, and may not occur if the list of pins includes pins from
212 * multiple ports.
213 *
214 * @param hGpio Specifies the gpio handle.
215 * @param pin Array of pin handles.
216 * @param pinState Array of elements specifying the pin state (of type
217 * NvRmGpioPinState).
218 * @param pinCount Number of elements in the array.
219 */
220
221 void NvRmGpioWritePins(
222 NvRmGpioHandle hGpio,
223 NvRmGpioPinHandle * pin,
224 NvRmGpioPinState * pinState,
225 NvU32 pinCount );
226
227 /**
228 * Reads the state of array of pins.
229 *
230 * @param hGpio The gpio handle.
231 * @param pin Array of pin handles.
232 * @param pinState Array of elements specifying the pin state (of type
233 * NvRmGpioPinState).
234 * @param pinCount Number of elements in the array.
235 */
236
237 void NvRmGpioReadPins(
238 NvRmGpioHandle hGpio,
239 NvRmGpioPinHandle * pin,
240 NvRmGpioPinState * pPinState,
241 NvU32 pinCount );
242
243 /**
244 * Configures a set of GPIO pins to a specified mode. Don't use this API for
245 * the interrupt modes. For interrupt modes, use NvRmGpioInterruptRegister and
246 * NvRmGpioInterruptUnregister APIs.
247 *
248 * @param hGpio The gpio handle.
249 * @param pin Pin handle array returned by a calls to NvRmGpioAcquirePinHandle()
250 * @param pinCount Number elements in the pin handle array.
251 *
252 * @param Mode Pin mode of type NvRmGpioPinMode.
253 *
254 *
255 * @retval NvSuccess requested operation is successful.
256 */
257
258 NvError NvRmGpioConfigPins(
259 NvRmGpioHandle hGpio,
260 NvRmGpioPinHandle * pin,
261 NvU32 pinCount,
262 NvRmGpioPinMode Mode );
263
264 /*
265 * Get the IRQs associated with the pin handles. So that the client can
266 * register the interrupt callback for that using interrupt APIs
267 */
268
269 NvError NvRmGpioGetIrqs(
270 NvRmDeviceHandle hRmDevice,
271 NvRmGpioPinHandle * pin,
272 NvU32 * Irq,
273 NvU32 pinCount );
274
275 /**
276 * Opaque handle to the GPIO interrupt.
277 */
278
279 typedef struct NvRmGpioInterruptRec *NvRmGpioInterruptHandle;
280
281
282 /* NOTE: Use the 2 APIs below to configure the gpios to interrupt mode and to
283 * have callabck functions. For the test case of how to use this APIs refer to
284 * the nvrm_gpio_unit_test applicaiton.
285 *
286 * Since the ISR is written by the clients of the API, care should be taken to
287 * clear the interrupt before the ISR is returned. If one fails to do that,
288 * interrupt will be triggered soon after the ISR returns.
289 */
290
291 /**
292 * Registers an interrupt callback function and the mode of interrupt for the
293 * gpio pin specified.
294 *
295 * Callback will be using the interrupt thread an the interrupt stack on linux
296 * and IST on wince. So, care should be taken on what APIs can be used on the
297 * callback function. Not all the nvos functions are available in the interrupt
298 * context. Check the nvos.h header file for the list of the functions available .
299 * When the callback is called, the interrupt on the pin is disabled. As soon as
300 * the callback exists, the interrupt is re-enabled. So, external interrupts
301 * should be cleared and then only the callback should be returned.
302 *
303 * @param hGpio The gpio handle.
304 * @param hRm The RM device handle.
305 * @param hPin The handle to a GPIO pin.
306 * @param Callback Callback function which will be caused when the interrupt
307 * triggers.
308 * @param Mode Interrupt mode. See @NvRmGpioPinMode
309 * @param CallbackArg Argument used when the callback is called by the ISR.
310 * @param hGpioInterrupt Interrupt handle for this registered intterrupt. This
311 * handle should be used while calling NvRmGpioInterruptUnregister for
312 * unregistering the interrupt.
313 * @param DebounceTime The debounce time in milliseconds
314 * @retval NvSuccess requested operation is successful.
315 */
316 NvError
317 NvRmGpioInterruptRegister(
318 NvRmGpioHandle hGpio,
319 NvRmDeviceHandle hRm,
320 NvRmGpioPinHandle hPin,
321 NvOsInterruptHandler Callback,
322 NvRmGpioPinMode Mode,
323 void *CallbackArg,
324 NvRmGpioInterruptHandle *hGpioInterrupt,
325 NvU32 DebounceTime);
326
327 /**
328 * Unregister the GPIO interrupt handler.
329 *
330 * @param hGpio The gpio handle.
331 * @param hRm The RM device handle.
332 * @param handle The interrupt handle returned by a successfull call to the
333 * NvRmGpioInterruptRegister API.
334 *
335 */
336 void
337 NvRmGpioInterruptUnregister(
338 NvRmGpioHandle hGpio,
339 NvRmDeviceHandle hRm,
340 NvRmGpioInterruptHandle handle);
341
342 /**
343 * Enable the GPIO interrupt handler.
344 *
345 * @param handle The interrupt handle returned by a successfull call to the
346 * NvRmGpioInterruptRegister API.
347 *
348 * @retval "NvError_BadParameter" if handle is not valid
349 * @retval "NvError_InsufficientMemory" if interupt enable failed.
350 * @retval "NvSuccess" if registration is successfull.
351 */
352 NvError
353 NvRmGpioInterruptEnable(NvRmGpioInterruptHandle handle);
354
355 /*
356 * Callback used to re-enable the interrupts.
357 *
358 * @param handle The interrupt handle returned by a successfull call to the
359 * NvRmGpioInterruptRegister API.
360 */
361 void
362 NvRmGpioInterruptDone( NvRmGpioInterruptHandle handle );
363
364
365
366 /**
367 * Mask/Unmask a gpio interrupt.
368 *
369 * Drivers can use this API to fend off interrupts. Mask means interrupts are
370 * not forwarded to the CPU. Unmask means, interrupts are forwarded to the CPU.
371 * In case of SMP systems, this API masks the interrutps to all the CPU, not
372 * just the calling CPU.
373 *
374 *
375 * @param handle Interrupt handle returned by NvRmGpioInterruptRegister API.
376 * @param mask NV_FALSE to forrward the interrupt to CPU. NV_TRUE to
377 * mask the interupts to CPU.
378 */
379 void
380 NvRmGpioInterruptMask(NvRmGpioInterruptHandle hGpioInterrupt, NvBool mask);
381
382
383 /** @} */
384
385 #if defined(__cplusplus)
386 }
387 #endif
388
389 #endif
OLDNEW
« no previous file with comments | « arch/arm/mach-tegra/nv/include/nvrm_drf.h ('k') | arch/arm/mach-tegra/nv/include/nvrm_hardware_access.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698