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

Side by Side Diff: arch/arm/mach-tegra/nv/include/nvodm_services.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) 2007-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 /**
34 * @file
35 * <b>NVIDIA Tegra ODM Kit:
36 * ODM Services API</b>
37 *
38 * @b Description: Defines the abstraction to SOC resources used by
39 * external peripherals.
40 */
41
42 #ifndef INCLUDED_NVODM_SERVICES_H
43 #define INCLUDED_NVODM_SERVICES_H
44
45 // Using addtogroup when defgroup resides in another file
46 /**
47 * @addtogroup nvodm_services
48 * @{
49 */
50
51 #include "nvcommon.h"
52 #include "nvodm_modules.h"
53 #include "nvassert.h"
54 #include "nvcolor.h"
55 #include "nvodm_query_pinmux.h"
56 #include "nvodm_query.h"
57
58 #if defined(__cplusplus)
59 extern "C"
60 {
61 #endif
62
63 /*
64 * This header is split into two sections: OS abstraction APIs and basic I/O
65 * driver APIs.
66 */
67
68 /** @name OS Abstraction APIs
69 * The Operating System APIs are portable to any NVIDIA-supported operating
70 * system and will appear in all of the engineering sample code.
71 */
72 /*@{*/
73
74 /**
75 * Outputs a message to the console, if present. Do not use this for
76 * interacting with a user from an application.
77 *
78 * @param format A pointer to the format string. The format string and variable
79 * parameters exactly follow the posix printf standard.
80 */
81 void
82 NvOdmOsPrintf( const char *format, ...);
83
84 /**
85 * Outputs a message to the debugging console, if present. Do not use this for
86 * interacting with a user from an application.
87 *
88 * @param format A pointer to the format string. The format string and variable
89 * parameters exactly follow the posix printf standard.
90 */
91 void
92 NvOdmOsDebugPrintf( const char *format, ... );
93
94 /**
95 * Dynamically allocates memory. Alignment, if desired, must be done by the
96 * caller.
97 *
98 * @param size The size, in bytes, of the allocation request.
99 */
100 void *
101 NvOdmOsAlloc(size_t size);
102
103 /**
104 * Frees a dynamic memory allocation.
105 *
106 * Freeing a NULL value is supported.
107 *
108 * @param ptr A pointer to the memory to free, which should be from NvOdmOsAlloc ().
109 */
110 void
111 NvOdmOsFree(void *ptr);
112
113 typedef struct NvOdmOsMutexRec *NvOdmOsMutexHandle;
114 typedef struct NvOdmOsSemaphoreRec *NvOdmOsSemaphoreHandle;
115 typedef struct NvOdmOsThreadRec *NvOdmOsThreadHandle;
116
117 /**
118 * Copies a specified number of bytes from a source memory location to
119 * a destination memory location.
120 *
121 * @param dest A pointer to the destination of the copy.
122 * @param src A pointer to the source memory.
123 * @param size The length of the copy in bytes.
124 */
125 void
126 NvOdmOsMemcpy(void *dest, const void *src, size_t size);
127
128 /**
129 * Sets a region of memory to a value.
130 *
131 * @param s A pointer to the memory region.
132 * @param c The value to set.
133 * @param size The length of the region in bytes.
134 */
135 void
136 NvOdmOsMemset(void *s, NvU8 c, size_t size);
137
138 /**
139 * Create a new mutex.
140 *
141 * @note Mutexes can be locked recursively; if a thread owns the lock,
142 * it can lock it again as long as it unlocks it an equal number of times.
143 *
144 * @return NULL on failure.
145 */
146 NvOdmOsMutexHandle
147 NvOdmOsMutexCreate( void );
148
149 /**
150 * Locks the given unlocked mutex.
151 *
152 * @note This is a recursive lock.
153 *
154 * @param mutex The mutex to lock.
155 */
156 void
157 NvOdmOsMutexLock( NvOdmOsMutexHandle mutex );
158
159 /**
160 * Unlock a locked mutex.
161 *
162 * A mutex must be unlocked exactly as many times as it has been locked.
163 *
164 * @param mutex The mutex to unlock.
165 */
166 void
167 NvOdmOsMutexUnlock( NvOdmOsMutexHandle mutex );
168
169 /**
170 * Frees the resources held by a mutex.
171 *
172 * @param mutex The mutex to destroy. Passing a NULL mutex is supported.
173 */
174 void
175 NvOdmOsMutexDestroy( NvOdmOsMutexHandle mutex );
176
177 /**
178 * Creates a counting semaphore.
179 *
180 * @param value The initial semaphore value.
181 *
182 * @return NULL on failure.
183 */
184 NvOdmOsSemaphoreHandle
185 NvOdmOsSemaphoreCreate( NvU32 value );
186
187 /**
188 * Waits until the semaphore value becomes non-zero.
189 *
190 * @param semaphore The semaphore for which to wait.
191 */
192 void
193 NvOdmOsSemaphoreWait( NvOdmOsSemaphoreHandle semaphore );
194
195 /**
196 * Waits for the given semaphore value to become non-zero with timeout.
197 *
198 * @param semaphore The semaphore for which to wait.
199 * @param msec The timeout value in milliseconds. Use ::NV_WAIT_INFINITE
200 * to wait forever.
201 *
202 * @return NV_FALSE if the wait expires.
203 */
204 NvBool
205 NvOdmOsSemaphoreWaitTimeout( NvOdmOsSemaphoreHandle semaphore, NvU32 msec );
206
207 /**
208 * Increments the semaphore value.
209 *
210 * @param semaphore The semaphore to signal.
211 */
212 void
213 NvOdmOsSemaphoreSignal( NvOdmOsSemaphoreHandle semaphore );
214
215 /**
216 * Frees resources held by the semaphore.
217 *
218 * @param semaphore The semaphore to destroy. Passing in a NULL semaphore
219 * is supported (no op).
220 */
221 void
222 NvOdmOsSemaphoreDestroy( NvOdmOsSemaphoreHandle semaphore );
223
224 /**
225 * Entry point for a thread.
226 */
227 typedef void (*NvOdmOsThreadFunction)(void *args);
228
229 /**
230 * Creates a thread.
231 *
232 * @param function The thread entry point.
233 * @param args The thread arguments.
234 *
235 * @return The thread handle, or NULL on failure.
236 */
237 NvOdmOsThreadHandle
238 NvOdmOsThreadCreate(
239 NvOdmOsThreadFunction function,
240 void *args);
241
242 /**
243 * Waits for the given thread to exit.
244 *
245 * The joined thread will be destroyed automatically. All OS resources
246 * will be reclaimed. There is no method for terminating a thread
247 * before it exits naturally.
248 *
249 * Passing in a NULL thread ID is ok (no op).
250 *
251 * @param thread The thread to wait for.
252 */
253 void
254 NvOdmOsThreadJoin(NvOdmOsThreadHandle thread);
255
256 /**
257 * Unschedules the calling thread for at least the given
258 * number of milliseconds.
259 *
260 * Other threads may run during the sleep time.
261 *
262 * @param msec The number of milliseconds to sleep. This API should not be
263 * called from an ISR, can be called from the IST though!
264 */
265 void
266 NvOdmOsSleepMS(NvU32 msec);
267
268
269 /**
270 * Stalls the calling thread for at least the given number of
271 * microseconds. The actual time waited might be longer, so you cannot
272 * depend on this function for precise timing.
273 *
274 * @note It is safe to use this function at ISR time.
275 *
276 * @param usec The number of microseconds to wait.
277 */
278 void
279 NvOdmOsWaitUS(NvU32 usec);
280
281 /**
282 * Gets the system time in milliseconds.
283 * The returned values are guaranteed to be monotonically increasing,
284 * but may wrap back to zero (after about 50 days of runtime).
285 *
286 * @return The system time in milliseconds.
287 */
288 NvU32
289 NvOdmOsGetTimeMS(void);
290
291 /// Defines possible operating system types.
292 typedef enum
293 {
294 NvOdmOsOs_Unknown,
295 NvOdmOsOs_Windows,
296 NvOdmOsOs_Linux,
297 NvOdmOsOs_Aos,
298 NvOdmOsOs_Force32 = 0x7fffffffUL,
299 } NvOdmOsOs;
300
301 /// Defines possible operating system SKUs.
302 typedef enum
303 {
304 NvOdmOsSku_Unknown,
305 NvOdmOsSku_CeBase,
306 NvOdmOsSku_Mobile_SmartFon,
307 NvOdmOsSku_Mobile_PocketPC,
308 NvOdmOsSku_Android,
309 NvOdmOsSku_Force32 = 0x7fffffffUL,
310 } NvOdmOsSku;
311
312 /// Defines the OS information record.
313 typedef struct NvOdmOsOsInfoRec
314 {
315 NvOdmOsOs OsType;
316 NvOdmOsSku Sku;
317 NvU16 MajorVersion;
318 NvU16 MinorVersion;
319 NvU32 SubVersion;
320 NvU32 Caps;
321 } NvOdmOsOsInfo;
322
323 /**
324 * Gets the current OS version.
325 *
326 * @param pOsInfo A pointer to the OS version.
327 * @return NV_TRUE if successful, or NV_FALSE otherwise.
328 */
329 NvBool
330 NvOdmOsGetOsInformation( NvOdmOsOsInfo *pOsInfo );
331
332 /*@}*/
333 /** @name Basic I/O Driver APIs
334 * The basic I/O driver APIs are a set of common input/outputs
335 * that can be used to extend the functionality of the software stack
336 * for new devices that aren't explicity handled by the stack.
337 * GPIO, I2C, and SPI are currently supported.
338 */
339 /*@{*/
340
341 /**
342 * Defines an opaque handle to the ODM Services GPIO rec interface.
343 */
344 typedef struct NvOdmServicesGpioRec *NvOdmServicesGpioHandle;
345 /**
346 * Defines an opaque handle to the ODM Services GPIO intr interface.
347 */
348 typedef struct NvOdmServicesGpioIntrRec *NvOdmServicesGpioIntrHandle;
349 /**
350 * Defines an opaque handle to the ODM Services SPI interface.
351 */
352 typedef struct NvOdmServicesSpiRec *NvOdmServicesSpiHandle;
353 /**
354 * Defines an opaque handle to the ODM Services I2C interface.
355 */
356 typedef struct NvOdmServicesI2cRec *NvOdmServicesI2cHandle;
357 /**
358 * Defines an opaque handle to the ODM Services PMU interface.
359 */
360 typedef struct NvOdmServicesPmuRec *NvOdmServicesPmuHandle;
361 /**
362 * Defines an opaque handle to the ODM Services PWM interface.
363 */
364 typedef struct NvOdmServicesPwmRec *NvOdmServicesPwmHandle;
365 /**
366 * Defines an opaque handle to the ODM Services key list interface.
367 */
368 typedef struct NvOdmServicesKeyList *NvOdmServicesKeyListHandle;
369
370 /**
371 * Defines an interrupt handler.
372 */
373 typedef void (*NvOdmInterruptHandler)(void *args);
374
375 /**
376 * @brief Defines the possible GPIO pin modes.
377 */
378 typedef enum
379 {
380 /// Specifies that that the pin is tristated, which will consume less power.
381 NvOdmGpioPinMode_Tristate = 1,
382
383 /// Specifies input mode with active low interrupt.
384 NvOdmGpioPinMode_InputInterruptLow,
385
386 /// Specifies input mode with active high interrupt.
387 NvOdmGpioPinMode_InputInterruptHigh,
388
389 /// Specifies input mode with no events.
390 NvOdmGpioPinMode_InputData,
391
392 /// Specifies output mode.
393 NvOdmGpioPinMode_Output,
394
395 /// Specifies special function.
396 NvOdmGpioPinMode_Function,
397
398 /// Specifies input and interrupt on any edge.
399 NvOdmGpioPinMode_InputInterruptAny,
400
401 /// Specifies input and interrupt on rising edge.
402 NvOdmGpioPinMode_InputInterruptRisingEdge,
403
404 /// Specifies output and interrupt on falling edge.
405 NvOdmGpioPinMode_InputInterruptFallingEdge,
406
407 /// Ignore -- Forces compilers to make 32-bit enums.
408 NvOdmGpioPinMode_Force32 = 0x7fffffff
409
410 } NvOdmGpioPinMode;
411
412 /**
413 * Defines the opaque handle to the GPIO pin.
414 */
415 typedef struct NvOdmGpioPinRec *NvOdmGpioPinHandle;
416
417 /**
418 * Creates and opens a GPIO handle. The handle can then be used to
419 * access GPIO functions.
420 *
421 * @see NvOdmGpioClose
422 *
423 * @return The handle to the GPIO controller, or NULL if an error occurred.
424 */
425 NvOdmServicesGpioHandle NvOdmGpioOpen(void);
426
427 /**
428 * Closes the GPIO handle. Any pin settings made while this handle is
429 * open will remain. All events enabled by this handle are
430 * disabled.
431 *
432 * @see NvOdmGpioOpen
433 *
434 * @param hOdmGpio The GPIO handle.
435 */
436 void NvOdmGpioClose(NvOdmServicesGpioHandle hOdmGpio);
437
438 /**
439 * Acquires a pin handle to be used in subsequent calls to
440 * access the pin.
441 *
442 * @see NvOdmGpioClose
443 *
444 * @param hOdmGpio The GPIO handle.
445 * @param port The port.
446 * @param Pin The pin for which to return the handle.
447 *
448 * @return The pin handle, or NULL if an error occurred.
449 */
450 NvOdmGpioPinHandle
451 NvOdmGpioAcquirePinHandle(NvOdmServicesGpioHandle hOdmGpio,
452 NvU32 port, NvU32 Pin);
453
454 /**
455 * Releases the pin handle that was acquired by NvOdmGpioAcquirePinHandle()
456 * and used by the rest of the GPIO ODM APIs.
457 *
458 * @see NvOdmGpioAcquirePinHandle
459 *
460 * @param hOdmGpio The GPIO handle.
461 * @param hPin The pin handle to release.
462 */
463 void
464 NvOdmGpioReleasePinHandle(NvOdmServicesGpioHandle hOdmGpio,
465 NvOdmGpioPinHandle hPin);
466 /**
467 * Sets the output state of a set of GPIO pins.
468 *
469 * @see NvOdmGpioOpen, NvOdmGpioGetState
470 *
471 * @param hOdmGpio The GPIO handle.
472 * @param hGpioPin The pin handle.
473 * @param PinValue The pin state to set. 0 means drive low, 1 means drive high.
474 */
475 void
476 NvOdmGpioSetState(NvOdmServicesGpioHandle hOdmGpio,
477 NvOdmGpioPinHandle hGpioPin,
478 NvU32 PinValue);
479
480 /**
481 * Gets the output state of a specified set of GPIO pins in the port.
482 *
483 * @see NvOdmGpioOpen, NvOdmGpioSetState
484 *
485 * @param hOdmGpio The GPIO handle.
486 * @param hGpioPin The pin handle.
487 * @param pPinStateValue A pointer to the returned current state of the pin.
488 */
489 void
490 NvOdmGpioGetState(NvOdmServicesGpioHandle hOdmGpio,
491 NvOdmGpioPinHandle hGpioPin,
492 NvU32 *pPinStateValue);
493
494 /**
495 * Configures the GPIO to specific mode. Don't use this API to configure the pin
496 * as interrupt pin, instead use the NvOdmGpioInterruptRegister
497 * and NvOdmGpioInterruptUnregister APIs which internally call this function.
498 *
499 * @param hOdmGpio The GPIO handle.
500 * @param hGpioPin The pin handle.
501 * @param Mode The mode type to configure.
502 */
503 void
504 NvOdmGpioConfig(NvOdmServicesGpioHandle hOdmGpio,
505 NvOdmGpioPinHandle hGpioPin,
506 NvOdmGpioPinMode Mode);
507
508 /**
509 * Registers an interrupt callback function and the mode of interrupt for the
510 * GPIO pin specified.
511 *
512 * Callback uses the interrupt thread and the interrupt stack on Linux
513 * and IST on Windows CE; so, care should be taken on all the APIs used in
514 * the callback function.
515 *
516 * Interrupts are masked when they are triggered. It is up to the caller to
517 * re-enable the interrupts by calling NvOdmGpioInterruptDone().
518 *
519 * @param hOdmGpio The GPIO handle.
520 * @param hGpioIntr A pointer to the GPIO interrupt handle. Use this
521 * handle while unregistering the interrupt. On failure to hook
522 * up the interrupt, a NULL handle is returned.
523 * @param hGpioPin The pin handle.
524 * @param Mode The mode type to configure. Allowed mode values are:
525 * - NvOdmGpioPinMode_InputInterruptFallingEdge
526 * - NvOdmGpioPinMode_InputInterruptRisingEdge
527 * - NvOdmGpioPinMode_InputInterruptAny
528 * - NvOdmGpioPinMode_InputInterruptLow
529 * - NvOdmGpioPinMode_InputInterruptHigh
530 *
531 * @param Callback The callback function that is called when
532 * the interrupt triggers.
533 * @param arg The argument used when the callback is called by the ISR.
534 * @param DebounceTime The debounce time in milliseconds.
535 *
536 * @return NV_TRUE if successful, or NV_FALSE otherwise.
537 */
538 NvBool
539 NvOdmGpioInterruptRegister(NvOdmServicesGpioHandle hOdmGpio,
540 NvOdmServicesGpioIntrHandle *hGpioIntr,
541 NvOdmGpioPinHandle hGpioPin,
542 NvOdmGpioPinMode Mode,
543 NvOdmInterruptHandler Callback,
544 void *arg,
545 NvU32 DebounceTime);
546
547 /**
548 * Client of GPIO interrupt to re-enable the interrupt after
549 * the handling the interrupt.
550 *
551 * @param handle GPIO interrupt handle returned by a sucessfull call to
552 * NvOdmGpioInterruptRegister().
553 */
554 void NvOdmGpioInterruptDone( NvOdmServicesGpioIntrHandle handle );
555
556 /**
557 * Mask/Unmask a gpio interrupt.
558 *
559 * Drivers can use this API to fend off interrupts. Mask means interrupts are
560 * not forwarded to the CPU. Unmask means, interrupts are forwarded to the CPU.
561 * In case of SMP systems, this API masks the interrutps to all the CPU, not
562 * just the calling CPU.
563 *
564 *
565 * @param handle Interrupt handle returned by NvOdmGpioInterruptRegister API.
566 * @param mask NV_FALSE to forrward the interrupt to CPU. NV_TRUE to
567 * mask the interupts to CPU.
568 */
569 void
570 NvOdmGpioInterruptMask(NvOdmServicesGpioIntrHandle handle, NvBool mask);
571
572 /**
573 * Unregisters the GPIO interrupt handler.
574 *
575 * @param hOdmGpio The GPIO handle.
576 * @param hGpioPin The pin handle.
577 * @param handle The interrupt handle returned by a successfull call to
578 * NvOdmGpioInterruptRegister().
579 *
580 */
581 void
582 NvOdmGpioInterruptUnregister(NvOdmServicesGpioHandle hOdmGpio,
583 NvOdmGpioPinHandle hGpioPin,
584 NvOdmServicesGpioIntrHandle handle);
585
586 /**
587 * Obtains a handle that can be used to access one of the serial peripheral
588 * interface (SPI) controllers.
589 *
590 * There may be one or more instances of the SPI, depending upon the SOC,
591 * and these instances start from 0.
592 *
593 * @see NvOdmSpiClose
594 *
595 * @param OdmIoModule The ODM I/O module for the SFLASH, SPI, or SLINK.
596 * @param ControllerId The SPI controlled ID for which a handle is required.
597 * Valid SPI channel IDs start from 0.
598 *
599 *
600 * @return The handle to the SPI controller, or NULL if an error occurred.
601 */
602 NvOdmServicesSpiHandle NvOdmSpiOpen(NvOdmIoModule OdmIoModule, NvU32 ControllerI d);
603
604 /**
605 * Obtains a handle that can be used to access one of the serial peripheral
606 * interface (SPI) controllers, for SPI controllers which are multiplexed
607 * between multiple pin mux configurations. The SPI controller's pin mux
608 * will be reset to the specified value every transaction, so that two handles
609 * to the same controller may safely interleave across pin mux configurations.
610 *
611 * The ODM pin mux query for the specified controller must be
612 * NvOdmSpiPinMap_Multiplexed in order to create a handle using this function.
613 *
614 * There may be one or more instances of the SPI, depending upon the SOC,
615 * and these instances start from 0.
616 *
617 * Currently, this function is only supported for OdmIoModule_Spi, instance 2.
618 *
619 * @see NvOdmSpiClose
620 *
621 * @param OdmIoModule The ODM I/O module for the SFLASH, SPI, or SLINK.
622 * @param ControllerId The SPI controlled ID for which a handle is required.
623 * Valid SPI channel IDs start from 0.
624 * @param PinMap The pin mux configuration to use for every transaction.
625 *
626 * @return The handle to the SPI controller, or NULL if an error occurred.
627 */
628 NvOdmServicesSpiHandle
629 NvOdmSpiPinMuxOpen(NvOdmIoModule OdmIoModule,
630 NvU32 ControllerId,
631 NvOdmSpiPinMap PinMap);
632
633
634 /**
635 * Obtains a handle that can be used to access one of the serial peripheral
636 * interface (SPI) controllers in slave mode.
637 *
638 * There may be one or more instances of the SPI, depending upon the SOC,
639 * and these instances start from 0.
640 *
641 * @see NvOdmSpiClose
642 *
643 * @param OdmIoModule The ODM I/O module for the SFLASH, SPI, or SLINK.
644 * @param ControllerId The SPI controlled ID for which a handle is required.
645 * Valid SPI channel IDs start from 0.
646 *
647 *
648 * @return The handle to the SPI controller, or NULL if an error occurred.
649 */
650 NvOdmServicesSpiHandle NvOdmSpiSlaveOpen(NvOdmIoModule OdmIoModule, NvU32 Contro llerId);
651
652
653 /**
654 * Releases a handle to an SPI controller. This API must be called once per
655 * successful call to NvOdmSpiOpen().
656 *
657 * @param hOdmSpi A SPI handle allocated in a call to \c NvOdmSpiOpen. If \em h OdmSpi
658 * is NULL, this API has no effect.
659 */
660 void NvOdmSpiClose(NvOdmServicesSpiHandle hOdmSpi);
661
662 /**
663 * Performs an SPI controller transaction. Every SPI transaction is by
664 * definition a simultaneous read and write transaction, so there are no
665 * separate APIs for read versus write. However, if you only need to do a read o r
666 * write, this API allows you to declare that you are not interested in the read
667 * data, or that the write data is not of interest.
668 *
669 * This is a blocking API. When it returns, all of the data has been sent out
670 * over the pins of the SOC (the transaction). This is true even if the read dat a
671 * is being discarded, as it cannot merely have been queued up.
672 *
673 * Several SPI transactions may be performed in a single call to this API, but
674 * only if all of the transactions are to the same chip select and have the same
675 * packet size.
676 *
677 * Transaction sizes from 1 bit to 32 bits are supported. However, all
678 * of the buffers in memory are byte-aligned. To perform one transaction,
679 * the \em Size argument should be:
680 *
681 * <tt> <!-- typewriter font formats this nicely in the output document -->
682 * (PacketSize + 7)/8
683 * </tt>
684 *
685 * To perform n transactions, \em Size should be:
686 *
687 * <tt>
688 * n*((PacketSize + 7)/8)
689 * </tt>
690 *
691 * Within a given
692 * transaction with the packet size larger than 8 bits, the bytes are stored in
693 * order of the MSB (most significant byte) first.
694 * The Packet is formed with the first Byte will be in MSB and then next byte
695 * will be in the next MSB towards the LSB.
696 *
697 * For the example, if One packet need to be send and its size is the 20 bit
698 * then it will require the 3 bytes in the pWriteBuffer and arrangement of the
699 * data are as follows:
700 * The packet is 0x000ABCDE (Packet with length of 20 bit).
701 * pWriteBuff[0] = 0x0A
702 * pWriteBuff[1] = 0xBC
703 * pWtriteBuff[2] = 0xDE
704 *
705 * The most significant bit will be transmitted first i.e. bit20 is transmitted
706 * first and bit 0 will be transmitted last.
707 *
708 * If the transmitted packet (command + receive data) is more than 32 like 33 an d
709 * want to transfer in the single call (CS should be active) then it can be tran smitted
710 * in following way:
711 * The transfer is command(8 bit)+Dummy(1bit)+Read (24 bit) = 33 bit of transfer .
712 * - Send 33 bit as 33 byte and each byte have the 1 valid bit, So packet bit le ngth = 1 and
713 * bytes requested = 33.
714 * NvU8 pSendData[33], pRecData[33];
715 * pSendData[0] = (Comamnd >>7) & 0x1;
716 * pSendData[1] = (Command >> 6)& 0x1;
717 * ::::::::::::::
718 * pSendData[8] = DummyBit;
719 * pSendData[9] to pSendData[32] = 0;
720 * Call NvOdmSpiTransaction(hRmSpi,ChipSelect,ClockSpeedInKHz,pRecData, pSendDat a, 33,1);
721 * Now You will get the read data from pRecData[9] to pRecData[32] on bit 0 on e ach byte.
722 *
723 * - The 33 bit transfer can be also done as 11 byte and each byte have the 3 va lid bits.
724 * This need to rearrange the command in the pSendData in such a way that each b yte have the
725 * 3 valid bits.
726 * NvU8 pSendData[11], pRecData[11];
727 * pSendData[0] = (Comamnd >>4) & 0x7;
728 * pSendData[1] = (Command >> 1)& 0x7;
729 * pSendData[2] = (((Command)& 0x3) <<1) | DummyBit;
730 * pSendData[3] to pSendData[10] = 0;
731 *
732 * Call NvOdmSpiTransaction(hRmSpi, ChipSelect,ClockSpeedInKHz,pRecData, pSendDa ta, 11,3);
733 * Now You will get the read data from pRecData[4] to pRecData[10] on lower 3 bi ts on each byte.
734 *
735 * Similarly the 33 bit transfer can also be done as 6 byte and each 2 bytes con tain the 11 valid bits.
736 * Call NvOdmSpiTransaction(hRmSpi, ChipSelect,ClockSpeedInKHz,pRecData, pSendDa ta, 6,11);
737 *
738 *
739 * \em ReadBuf and \em WriteBuf may be the same pointer, in which case the write
740 * data is destroyed as we read in the read data. Unless they are identical poin ters,
741 * however, \em ReadBuf and \em WriteBuf must not overlap.
742 *
743 * @param hOdmSpi The SPI handle allocated in a call to NvOdmSpiOpen().
744 * @param ChipSelect Select with which of the several external devices (attached
745 * to a single controller) we are communicating. Chip select indices
746 * start at 0.
747 * @param ClockSpeedInKHz The speed in kHz on which the device can communicate.
748 * @param ReadBuf A pointer to buffer to be filled in with read data. If this
749 * pointer is NULL, the read data will be discarded.
750 * @param WriteBuf A pointer to a buffer from which to obtain write data. If thi s
751 * pointer is NULL, the write data will be all zeros.
752 * @param Size The size of \em ReadBuf and \em WriteBuf buffers in bytes.
753 * @param PacketSize The packet size in bits of each SPI transaction.
754 */
755 void
756 NvOdmSpiTransaction(
757 NvOdmServicesSpiHandle hOdmSpi,
758 NvU32 ChipSelect,
759 NvU32 ClockSpeedInKHz,
760 NvU8 *ReadBuf,
761 const NvU8 *WriteBuf,
762 NvU32 Size,
763 NvU32 PacketSize);
764
765
766 /**
767 * Starts an SPI controller read and write simultaneously in the slave mode.
768 *
769 * This is a nonblocking API, which starts the data transfer and returns
770 * to the caller without waiting for the data transfer completion.
771 *
772 * @note This API is only supported for the SPI handle, which is opened in
773 * slave mode using NvOdmSpiSlaveOpen(). This API asserts if the opened SPI
774 * handle is the master type.
775 *
776 * @see NvOdmSpiSlaveGetTransactionData
777 *
778 * @par Read or Write Transactions
779 *
780 * Every SPI transaction is by definition a simultaneous read and write
781 * transaction, so there are no separate APIs for read versus write.
782 * However, if you only need to start a read or write transaction, this API
783 * allows you to declare that you are not interested in the read data,
784 * or that the write data is not of interest. If only read
785 * is required to start, then the client can pass NV_TRUE to the \a IsReadTransf er
786 * parameter and a NULL pointer to \a pWriteBuffer. The state of the data out
787 * will be set by NvOdmQuerySpiIdleSignalState::IsIdleDataOutHigh
788 * in nvodm_query.h. Similarly, if the client wants to send data only
789 * then it can pass NV_FALSE to the \a IsReadTransfer parameter.
790 *
791 * @par Transaction Sizes
792 *
793 * Transaction sizes from 1 to 32 bits are supported. However, all of the
794 * packets are byte-aligned in memory. So, if \a packetBitLength is 12 bits
795 * then the client needs the 2nd byte for the 1 packet. New packets start from t he
796 * new bytes, e.g., byte0 and byte1 contain the first packet and byte2 and byte3
797 * will contain the second packets.
798 *
799 * To perform one transaction, the \a BytesRequested argument should be:
800 * <pre>
801 * (PacketSizeInBits + 7)/8
802 * </pre>
803 *
804 * To perform \a n transactions, \a BytesRequested should be:
805 * <pre>
806 * n*((PacketSizeInBits + 7)/8)
807 * </pre>
808 *
809 * Within a given transaction with the packet size larger than 8 bits,
810 * the bytes are stored in the order of the LSB (least significant byte) first.
811 * The packet is formed with the first byte will be in LSB and then next byte
812 * will be in the next LSB towards the MSB.
813 *
814 * For example, if one packet needs to be sent and its size is 20 bits,
815 * then it will require the 3 bytes in the \a pWriteBuffer and arrangement of
816 * the data are as follows:
817 * - The packet is 0x000ABCDE (Packet with length of 20 bit).
818 * - pWriteBuff[0] = 0xDE
819 * - pWriteBuff[1] = 0xBC
820 * - pWtriteBuff[2] = 0x0A
821 *
822 * The most significant bit will be transmitted first, i.e., bit20 is transmitte d
823 * first and bit0 will be transmitted last.
824 *
825 * @par Transfer Size Limitations
826 *
827 * The limitation on the maximum transfer size of SPI slave communication
828 * depends upon the hardware. The maximum size of byte transfer is 64 K bytes
829 * if the number of packets requested is a multiple of:
830 * - 4 for 8-bit packet length, or
831 * - 2 for 16-bit packet length, or
832 * - any number of packets for 32-bit packet length.
833 *
834 * For all other cases, the maximum transfer bytes size is limited to 16 K
835 * packets, that is:
836 * <pre>
837 * 16K*((PacketBitLength +7)/8))
838 * </pre>
839 *
840 * For the example:
841 * - Non-multiples of 4 for the 8-bit packet length
842 * - Non multiples of 2 for the 16-bit packet length
843 * - Any other bit length except for the 32-bit packet length
844 *
845 * This limitation comes from the:
846 * - Maximum HW DMA transfer of 64 KB
847 * - Maximum packet transfer for HW S-LINK controller of 64 K packets
848 * - The design of packed/unpacked format of the S-LINK controller
849 *
850 * @par CAIF Use Case
851 *
852 * The following describes a typical use case for the CAIF interface. The steps
853 * for doing the transfer are:
854 * -# ACPU calls the NvOdmSpiSlaveStartTransaction() to configure the SPI
855 * controller to set in the receive or transmit mode and make ready for the
856 * data transfer.
857 * -# ACPU then send the signal to the CCPU to send the SPICLK (by activating
858 * the SPI_INT) and start the transaction. CCPU get this signal and start sendin g
859 * SPICLK.
860 * -# ACPU will call the NvOdmSpiSlaveGetTransactionData() to get the
861 * data/information about the transaction.
862 * -# After completion of the transfer ACPU inactivate the SPI_INT.
863 *
864 * @param hOdmSpi The SPI handle allocated in a call to NvOdmSpiSlaveOpen().
865 * @param ChipSelectId The chip select ID on which device is connected.
866 * @param ClockSpeedInKHz The clock speed in kHz on which device can communicate .
867 * @param IsReadTransfer Tells that whether or not the read transfer is required .
868 * If it is NV_TRUE then read transfer is required and the read data will be
869 * available in the local buffer of the driver. The client will get the received
870 * data after calling the \c NvRmSpiGetTransactionData() function.
871 * @param pWriteBuffer A pointer to a buffer from which to obtain write data.
872 * If this pointer is NULL, the write data will be all zeros.
873 * @param BytesRequested The size of \a pReadBuffer and \a pWriteBuffer buffers
874 * in bytes.
875 * @param PacketSizeInBits The packet size in bits of each SPI transaction.
876 *
877 * @return NV_TRUE if successful, or NV_FALSE otherwise.
878 */
879 NvBool NvOdmSpiSlaveStartTransaction(
880 NvOdmServicesSpiHandle hOdmSpi,
881 NvU32 ChipSelectId,
882 NvU32 ClockSpeedInKHz,
883 NvBool IsReadTransfer,
884 NvU8 * pWriteBuffer,
885 NvU32 BytesRequested,
886 NvU32 PacketSizeInBits );
887
888 /**
889 * Gets the SPI transaction status that is started for the slave mode and waits,
890 * if required, until the transfer completes for a given timeout error.
891 * If a read transaction has been started, then it returns the receive data to
892 * the client.
893 *
894 * This is a blocking API and waits for the data transfer completion until the
895 * transfer completes or a timeout happens.
896 *
897 * @see NvOdmSpiSlaveStartTransaction
898 *
899 * @param hOdmSpi The SPI handle allocated in a call to NvOdmSpiSlaveOpen().
900 * @param pReadBuffer A pointer to a buffer to be filled in with read data. If t his
901 * pointer is NULL, the read data will be discarded.
902 * @param BytesRequested The size of \a pReadBuffer and \a pWriteBuffer buffers
903 * in bytes.
904 * @param pBytesTransfererd A pointer to the number of bytes transferred.
905 * @param WaitTimeout The timeout in millisecond to wait for the transaction to be
906 * completed.
907 *
908 * @return NV_TRUE if successful, or NV_FALSE otherwise.
909 *
910 */
911 NvBool NvOdmSpiSlaveGetTransactionData(
912 NvOdmServicesSpiHandle hOdmSpi,
913 NvU8 * pReadBuffer,
914 NvU32 BytesRequested,
915 NvU32 * pBytesTransfererd,
916 NvU32 WaitTimeout );
917
918 /**
919 * Sets the signal mode for the SPI communication for a given chip select.
920 * After calling this API, further communication happens with the newly
921 * configured signal modes.
922 * The default value of the signal mode is taken from ODM Query, and this
923 * API overrides the signal mode that is read from the query.
924 *
925 * @param hOdmSpi The SPI handle allocated in a call to NvOdmSpiOpen().
926 * @param ChipSelectId The chip select ID to which the device is connected.
927 * @param SpiSignalMode The ODM signal mode to be set.
928 *
929 */
930 void
931 NvOdmSpiSetSignalMode(
932 NvOdmServicesSpiHandle hOdmSpi,
933 NvU32 ChipSelectId,
934 NvOdmQuerySpiSignalMode SpiSignalMode);
935
936 /// Contains the error flags for the I2C transaction.
937 typedef enum
938 {
939 NvOdmI2cStatus_Success = 0,
940 NvOdmI2cStatus_Timeout,
941 NvOdmI2cStatus_SlaveNotFound,
942 NvOdmI2cStatus_InvalidTransferSize,
943 NvOdmI2cStatus_ReadFailed,
944 NvOdmI2cStatus_WriteFailed,
945 NvOdmI2cStatus_InternalError,
946 NvOdmI2cStatus_ArbitrationFailed,
947 NvOdmI2cStatus_Force32 = 0x7FFFFFFF
948 } NvOdmI2cStatus;
949
950 /// Flag to indicate the I2C write/read operation.
951 #define NVODM_I2C_IS_WRITE 0x00000001
952 /// Flag to indicate the I2C slave address type as 10-bit or 7-bit.
953 #define NVODM_I2C_IS_10_BIT_ADDRESS 0x00000002
954 /// Flag to indicate the I2C transaction with repeat start.
955 #define NVODM_I2C_USE_REPEATED_START 0x00000004
956 /// Flag to indicate that the I2C slave will not generate ACK.
957 #define NVODM_I2C_NO_ACK 0x00000008
958 /// Flag to indicate software I2C using GPIO.
959 #define NVODM_I2C_SOFTWARE_CONTROLLER 0x00000010
960
961
962 /// Contians the I2C transaction details.
963 typedef struct
964 {
965 /// Flags to indicate the transaction details, like write/read operation,
966 /// slave address type 10-bit or 7-bit and the transaction uses repeat
967 /// start or a normal transaction.
968 NvU32 Flags;
969 /// I2C slave device address.
970 NvU32 Address;
971 /// Number of bytes to be transferred.
972 NvU32 NumBytes;
973 /// Send/receive buffer. For I2C send operation this buffer should be
974 /// filled with the data to be sent to the slave device. For I2C receive
975 /// operation this buffer is filled with the data received from the slave de vice.
976 NvU8 *Buf;
977 } NvOdmI2cTransactionInfo;
978
979 /**
980 * Initializes and opens the I2C channel. This function allocates the
981 * handle for the I2C channel and provides it to the client.
982 *
983 * @see NvOdmI2cClose
984 *
985 * @param OdmIoModuleId The ODM I/O module for I2C.
986 * @param instance The instance of the I2C driver to be opened.
987 *
988 * @return The handle to the I2C controller, or NULL if an error occurred.
989 */
990 NvOdmServicesI2cHandle
991 NvOdmI2cOpen(
992 NvOdmIoModule OdmIoModuleId,
993 NvU32 instance);
994
995 /**
996 * Obtains a handle that can be used to access one of the I2C controllers,
997 * for I2C controllers which are multiplexed between multiple pin mux
998 * configurations. The I2C controller's pin mux will be reset to the specified
999 * value every transaction, so that two handles to the same controller may
1000 * safely interleave across pin mux configurations.
1001 *
1002 * The ODM pin mux query for the specified controller must be
1003 * NvOdmI2cPinMap_Multiplexed in order to create a handle using this function.
1004 *
1005 * There may be one or more instances of the I2C, depending upon the SOC,
1006 * and these instances start from 0.
1007 *
1008 * Currently, this function is only supported for OdmIoModule_I2C, instance 1.
1009 *
1010 * @see NvOdmI2cClose
1011 *
1012 * @param OdmIoModule The ODM I/O module for the I2C.
1013 * @param ControllerId The I2C controlled ID for which a handle is required.
1014 * Valid I2C controller IDs start from 0.
1015 * @param PinMap The pin mux configuration to use for every transaction.
1016 *
1017 * @return The handle to the I2C controller, or NULL if an error occurred.
1018 */
1019 NvOdmServicesI2cHandle
1020 NvOdmI2cPinMuxOpen(NvOdmIoModule OdmIoModule,
1021 NvU32 ControllerId,
1022 NvOdmI2cPinMap PinMap);
1023
1024 /**
1025 * Closes the I2C channel. This function frees the memory allocated for
1026 * the I2C handle and de-initializes the I2C ODM channel.
1027 *
1028 * @see NvOdmI2cOpen
1029 *
1030 * @param hOdmI2c The handle to the I2C channel.
1031 */
1032 void NvOdmI2cClose(NvOdmServicesI2cHandle hOdmI2c);
1033
1034 /**
1035 * Does the I2C send or receive transactions with the slave deivces. This is a
1036 * blocking call (with timeout). This API works for both the normal I2C transact ions
1037 * or I2C transactions in repeat start mode.
1038 *
1039 * For the I2C transactions with slave devices, a pointer to the list of require d
1040 * transactions must be passed and the corresponding number of transactions must
1041 * be passed.
1042 *
1043 * The transaction information structure contains the flags (to indicate the
1044 * transaction information, such as read or write transaction, transaction is wi th
1045 * repeat-start or normal transaction and the slave device address type is 7-bit or
1046 * 10-bit), slave deivce address, buffer to be transferred and number of bytes
1047 * to be transferred.
1048 *
1049 * @param hOdmI2c The handle to the I2C channel.
1050 * @param TransactionInfo A pointer to the array of I2C transaction structures.
1051 * @param NumberOfTransactions The number of I2C transactions.
1052 * @param ClockSpeedKHz Specifies the clock speed for the I2C transactions.
1053 * @param WaitTimeoutInMilliSeconds The timeout in milliseconds.
1054 * ::NV_WAIT_INFINITE specifies to wait forever.
1055 *
1056 * @retval NvOdmI2cStatus_Success If successful, or the appropriate error code.
1057 */
1058 NvOdmI2cStatus
1059 NvOdmI2cTransaction(
1060 NvOdmServicesI2cHandle hOdmI2c,
1061 NvOdmI2cTransactionInfo *TransactionInfo,
1062 NvU32 NumberOfTransactions,
1063 NvU32 ClockSpeedKHz,
1064 NvU32 WaitTimeoutInMilliSeconds);
1065
1066 /**
1067 * Defines the PMU VDD rail capabilities.
1068 */
1069 typedef struct NvOdmServicesPmuVddRailCapabilitiesRec
1070 {
1071 /// Specifies ODM protection attribute; if \c NV_TRUE PMU hardware
1072 /// or ODM Kit would protect this voltage from being changed by NvDdk clien t.
1073 NvBool RmProtected;
1074
1075 /// Specifies the minimum voltage level in mV.
1076 NvU32 MinMilliVolts;
1077
1078 /// Specifies the step voltage level in mV.
1079 NvU32 StepMilliVolts;
1080
1081 /// Specifies the maximum voltage level in mV.
1082 NvU32 MaxMilliVolts;
1083
1084 /// Specifies the request voltage level in mV.
1085 NvU32 requestMilliVolts;
1086
1087 } NvOdmServicesPmuVddRailCapabilities;
1088
1089 /// Special level to indicate voltage plane is disabled.
1090 #define NVODM_VOLTAGE_OFF (0UL)
1091
1092 /**
1093 * Initializes and opens the PMU driver. The handle that is returned by this
1094 * driver is used for all the other PMU operations.
1095 *
1096 * @see NvOdmPmuClose
1097 *
1098 * @return The handle to the PMU driver, or NULL if an error occurred.
1099 */
1100 NvOdmServicesPmuHandle NvOdmServicesPmuOpen(void);
1101
1102 /**
1103 * Closes the PMU handle.
1104 *
1105 * @see NvOdmServicesPmuOpen
1106 *
1107 * @param handle The handle to the PMU driver.
1108 */
1109 void NvOdmServicesPmuClose(NvOdmServicesPmuHandle handle);
1110
1111 /**
1112 * Gets capabilities for the specified PMU rail.
1113 *
1114 * @param handle The handle to the PMU driver.
1115 * @param vddId The ODM-defined PMU rail ID.
1116 * @param pCapabilities A pointer to the targeted
1117 * capabilities returned by the ODM.
1118 *
1119 */
1120 void NvOdmServicesPmuGetCapabilities(
1121 NvOdmServicesPmuHandle handle,
1122 NvU32 vddId,
1123 NvOdmServicesPmuVddRailCapabilities * pCapabilities );
1124
1125 /**
1126 * Gets current voltage level for the specified PMU rail.
1127 *
1128 * @param handle The handle to the PMU driver.
1129 * @param vddId The ODM-defined PMU rail ID.
1130 * @param pMilliVolts A pointer to the voltage level returned
1131 * by the ODM.
1132 */
1133 void NvOdmServicesPmuGetVoltage(
1134 NvOdmServicesPmuHandle handle,
1135 NvU32 vddId,
1136 NvU32 * pMilliVolts );
1137
1138 /**
1139 * Sets new voltage level for the specified PMU rail.
1140 *
1141 * @param handle The handle to the PMU driver.
1142 * @param vddId The ODM-defined PMU rail ID.
1143 * @param MilliVolts The new voltage level to be set in millivolts (mV).
1144 * Set to ::NVODM_VOLTAGE_OFF to turn off the target voltage.
1145 * @param pSettleMicroSeconds A pointer to the settling time in microseconds (uS ),
1146 * which is the time for supply voltage to settle after this function
1147 * returns; this may or may not include PMU control interface transaction time,
1148 * depending on the ODM implementation. If NULL this parameter is ignored.
1149 */
1150 void NvOdmServicesPmuSetVoltage(
1151 NvOdmServicesPmuHandle handle,
1152 NvU32 vddId,
1153 NvU32 MilliVolts,
1154 NvU32 * pSettleMicroSeconds );
1155
1156 /**
1157 * Configures SoC power rail controls for the upcoming PMU voltage transition.
1158 *
1159 * @note Should be called just before PMU rail On/Off, or Off/On transition.
1160 * Should not be called if rail voltage level is changing within On range.
1161 *
1162 * @param handle The handle to the PMU driver.
1163 * @param vddId The ODM-defined PMU rail ID.
1164 * @param Enable Set NV_TRUE if target voltage is about to be turned On, or
1165 * NV_FALSE if target voltage is about to be turned Off.
1166 */
1167 void NvOdmServicesPmuSetSocRailPowerState(
1168 NvOdmServicesPmuHandle handle,
1169 NvU32 vddId,
1170 NvBool Enable );
1171
1172 /**
1173 * Defines battery instances.
1174 */
1175 typedef enum
1176 {
1177 /// Specifies main battery.
1178 NvOdmServicesPmuBatteryInst_Main,
1179
1180 /// Specifies backup battery.
1181 NvOdmServicesPmuBatteryInst_Backup,
1182
1183 /// Ignore -- Forces compilers to make 32-bit enums.
1184 NvOdmServicesPmuBatteryInstance_Force32 = 0x7FFFFFFF
1185 } NvOdmServicesPmuBatteryInstance;
1186
1187 /**
1188 * Gets the battery status.
1189 *
1190 * @param handle The handle to the PMU driver.
1191 * @param batteryInst The battery type.
1192 * @param pStatus A pointer to the battery
1193 * status returned by the ODM.
1194 *
1195 * @return NV_TRUE if successful, or NV_FALSE otherwise.
1196 */
1197 NvBool
1198 NvOdmServicesPmuGetBatteryStatus(
1199 NvOdmServicesPmuHandle handle,
1200 NvOdmServicesPmuBatteryInstance batteryInst,
1201 NvU8 * pStatus);
1202
1203 /**
1204 * Defines battery data.
1205 */
1206 typedef struct NvOdmServicesPmuBatteryDataRec
1207 {
1208 /// Specifies battery life percent.
1209 NvU32 batteryLifePercent;
1210
1211 /// Specifies battery life time.
1212 NvU32 batteryLifeTime;
1213
1214 /// Specifies voltage.
1215 NvU32 batteryVoltage;
1216
1217 /// Specifies battery current.
1218 NvS32 batteryCurrent;
1219
1220 /// Specifies battery average current.
1221 NvS32 batteryAverageCurrent;
1222
1223 /// Specifies battery interval.
1224 NvU32 batteryAverageInterval;
1225
1226 /// Specifies the mAH consumed.
1227 NvU32 batteryMahConsumed;
1228
1229 /// Specifies battery temperature.
1230 NvU32 batteryTemperature;
1231 } NvOdmServicesPmuBatteryData;
1232
1233 /**
1234 * Gets the battery data.
1235 *
1236 * @param handle The handle to the PMU driver.
1237 * @param batteryInst The battery type.
1238 * @param pData A pointer to the battery
1239 * data returned by the ODM.
1240 *
1241 * @return NV_TRUE if successful, or NV_FALSE otherwise.
1242 */
1243 NvBool
1244 NvOdmServicesPmuGetBatteryData(
1245 NvOdmServicesPmuHandle handle,
1246 NvOdmServicesPmuBatteryInstance batteryInst,
1247 NvOdmServicesPmuBatteryData * pData);
1248
1249 /**
1250 * Gets the battery full lifetime.
1251 *
1252 * @param handle The handle to the PMU driver.
1253 * @param batteryInst The battery type.
1254 * @param pLifeTime A pointer to the battery
1255 * full lifetime returned by the ODM.
1256 */
1257 void
1258 NvOdmServicesPmuGetBatteryFullLifeTime(
1259 NvOdmServicesPmuHandle handle,
1260 NvOdmServicesPmuBatteryInstance batteryInst,
1261 NvU32 * pLifeTime);
1262
1263 /**
1264 * Defines battery chemistry.
1265 */
1266 typedef enum
1267 {
1268 /// Specifies an alkaline battery.
1269 NvOdmServicesPmuBatteryChemistry_Alkaline,
1270
1271 /// Specifies a nickel-cadmium (NiCd) battery.
1272 NvOdmServicesPmuBatteryChemistry_NICD,
1273
1274 /// Specifies a nickel-metal hydride (NiMH) battery.
1275 NvOdmServicesPmuBatteryChemistry_NIMH,
1276
1277 /// Specifies a lithium-ion (Li-ion) battery.
1278 NvOdmServicesPmuBatteryChemistry_LION,
1279
1280 /// Specifies a lithium-ion polymer (Li-poly) battery.
1281 NvOdmServicesPmuBatteryChemistry_LIPOLY,
1282
1283 /// Specifies a zinc-air battery.
1284 NvOdmServicesPmuBatteryChemistry_XINCAIR,
1285
1286 /// Ignore -- Forces compilers to make 32-bit enums.
1287 NvOdmServicesPmuBatteryChemistry_Force32 = 0x7FFFFFFF
1288 } NvOdmServicesPmuBatteryChemistry;
1289
1290 /**
1291 * Gets the battery chemistry.
1292 *
1293 * @param handle The handle to the PMU driver.
1294 * @param batteryInst The battery type.
1295 * @param pChemistry A pointer to the battery
1296 * chemistry returned by the ODM.
1297 */
1298 void
1299 NvOdmServicesPmuGetBatteryChemistry(
1300 NvOdmServicesPmuHandle handle,
1301 NvOdmServicesPmuBatteryInstance batteryInst,
1302 NvOdmServicesPmuBatteryChemistry * pChemistry);
1303
1304 /**
1305 * Defines the charging path.
1306 */
1307 typedef enum
1308 {
1309 /// Specifies external wall plug charger.
1310 NvOdmServicesPmuChargingPath_MainPlug,
1311
1312 /// Specifies external USB bus charger.
1313 NvOdmServicesPmuChargingPath_UsbBus,
1314
1315 /// Ignore -- Forces compilers to make 32-bit enums.
1316 NvOdmServicesPmuChargingPath_Force32 = 0x7FFFFFFF
1317 } NvOdmServicesPmuChargingPath;
1318
1319 /**
1320 * Sets the charging current limit.
1321 *
1322 * @param handle The Rm device handle.
1323 * @param ChargingPath The charging path.
1324 * @param ChargingCurrentLimitMa The charging current limit in mA.
1325 * @param ChargerType The charger type.
1326 */
1327 void
1328 NvOdmServicesPmuSetChargingCurrentLimit(
1329 NvOdmServicesPmuHandle handle,
1330 NvOdmServicesPmuChargingPath ChargingPath,
1331 NvU32 ChargingCurrentLimitMa,
1332 NvOdmUsbChargerType ChargerType);
1333
1334 /**
1335 * Obtains a handle to set or get state of keys, for example, the state of the
1336 * hold switch.
1337 *
1338 * @see NvOdmServicesKeyListClose()
1339 *
1340 * @return A handle to the key-list, or NULL if this open call fails.
1341 */
1342 NvOdmServicesKeyListHandle
1343 NvOdmServicesKeyListOpen(void);
1344
1345 /**
1346 * Releases the handle obtained during the NvOdmServicesKeyListOpen() call and
1347 * any other resources allocated.
1348 *
1349 * @param handle The handle returned from the \c NvOdmServicesKeyListOpen call.
1350 */
1351 void NvOdmServicesKeyListClose(NvOdmServicesKeyListHandle handle);
1352
1353 /**
1354 * Searches the list of keys present and returns the value of the appropriate
1355 * key.
1356 * @param handle The handle obtained from NvOdmServicesKeyListOpen().
1357 * @param KeyID The ID of the key whose value is required.
1358 *
1359 * @return The value of the corresponding key, or 0 if the key is not
1360 * present in the list.
1361 */
1362 NvU32
1363 NvOdmServicesGetKeyValue(
1364 NvOdmServicesKeyListHandle handle,
1365 NvU32 KeyID);
1366
1367 /**
1368 * Searches the list of keys present and sets the value of the key to the value
1369 * given. If the key is not present, it adds the key to the list and sets the
1370 * value.
1371 * @param handle The handle obtained from NvOdmServicesKeyListOpen().
1372 * @param Key The ID of the key whose value is to be set.
1373 * @param Value The value to be set for the corresponding key.
1374 *
1375 * @return NV_TRUE if successful, or NV_FALSE otherwise.
1376 */
1377 NvBool
1378 NvOdmServicesSetKeyValuePair(
1379 NvOdmServicesKeyListHandle handle,
1380 NvU32 Key,
1381 NvU32 Value);
1382
1383 /**
1384 * @brief Defines the possible PWM modes.
1385 */
1386
1387 typedef enum
1388 {
1389 /// Specifies Pwm disabled mode.
1390 NvOdmPwmMode_Disable = 1,
1391
1392 /// Specifies Pwm enabled mode.
1393 NvOdmPwmMode_Enable,
1394
1395 /// Specifies Blink LED enabled mode
1396 NvOdmPwmMode_Blink_LED,
1397
1398 /// Specifies Blink output 32KHz clock enable mode
1399 NvOdmPwmMode_Blink_32KHzClockOutput,
1400
1401 /// Specifies Blink disabled mode
1402 NvOdmPwmMode_Blink_Disable,
1403
1404 NvOdmPwmMode_Force32 = 0x7fffffffUL
1405
1406 } NvOdmPwmMode;
1407
1408 /**
1409 * @brief Defines the possible PWM output pin.
1410 */
1411
1412 typedef enum
1413 {
1414 /// Specifies PWM Output-0.
1415 NvOdmPwmOutputId_PWM0 = 1,
1416
1417 /// Specifies PWM Output-1.
1418 NvOdmPwmOutputId_PWM1,
1419
1420 /// Specifies PWM Output-2.
1421 NvOdmPwmOutputId_PWM2,
1422
1423 /// Specifies PWM Output-3.
1424 NvOdmPwmOutputId_PWM3,
1425
1426 /// Specifies PMC Blink LED.
1427 NvOdmPwmOutputId_Blink,
1428
1429 NvOdmPwmOutputId_Force32 = 0x7fffffffUL
1430
1431 } NvOdmPwmOutputId;
1432
1433 /**
1434 * Creates and opens a PWM handle. The handle can be used to
1435 * access PWM functions.
1436 *
1437 * @note Only the service client knows when the service can go idle,
1438 * like in the case of vibrator, so the client suspend entry code
1439 * must call NvOdmPwmClose() to close the PWM service.
1440 *
1441 * @return The handle to the PWM controller, or NULL if an error occurred.
1442 */
1443 NvOdmServicesPwmHandle NvOdmPwmOpen(void);
1444
1445 /**
1446 * Releases a handle to a PWM controller. This API must be called once per
1447 * successful call to NvOdmPwmOpen().
1448 *
1449 * @param hOdmPwm The handle to the PWM controller.
1450 */
1451 void NvOdmPwmClose(NvOdmServicesPwmHandle hOdmPwm);
1452
1453 /**
1454 * @brief Configures PWM module as disable/enable. This API is also
1455 * used to set the PWM duty cycle and frequency. Beside that, it is
1456 * used to configure PMC' blinking LED if OutputId is
1457 * NvOdmPwmOutputId_Blink
1458 *
1459 * @param hOdmPwm The PWM handle obtained from NvOdmPwmOpen().
1460 * @param OutputId The PWM output pin to configure. Allowed values are
1461 * defined in ::NvOdmPwmOutputId.
1462 * @param Mode The mode type to configure. Allowed values are
1463 * defined in ::NvOdmPwmMode.
1464 * @param DutyCycle The duty cycle is an unsigned 15.16 fixed point
1465 * value that represents the PWM duty cycle in percentage range from
1466 * 0.00 to 100.00. For example, 10.5 percentage duty cycle would be
1467 * represented as 0x000A8000. This parameter is ignored if NvOdmPwmMode
1468 * is NvOdmMode_Blink_32KHzClockOutput or NvOdmMode_Blink_Disable
1469 * @param pRequestedFreqHzOrPeriod A pointer to the request frequency in Hz
1470 * or period in second
1471 * A requested frequency value beyond the maximum supported value will be
1472 * clamped to the maximum supported value. If \em pRequestedFreqHzOrPeriod
1473 * is NULL, it returns the maximum supported frequency. This parameter is
1474 * ignored if NvOdmPwmMode is NvOdmMode_Blink_32KHzClockOutput or
1475 * NvOdmMode_Blink_Disable
1476 * @param pCurrentFreqHzOrPeriod A pointer to the returned frequency of
1477 * that mode. If PMC Blink LED is used then it is the pointer to the returns
1478 * period time. This parameter is ignored if NvOdmPwmMode is
1479 * NvOdmMode_Blink_32KHzClockOutput or NvOdmMode_Blink_Disable
1480 */
1481 void
1482 NvOdmPwmConfig(NvOdmServicesPwmHandle hOdmPwm,
1483 NvOdmPwmOutputId OutputId,
1484 NvOdmPwmMode Mode,
1485 NvU32 DutyCycle,
1486 NvU32 *pRequestedFreqHzOrPeriod,
1487 NvU32 *pCurrentFreqHzOrPeriod);
1488
1489 /**
1490 * Enables and disables external clock interfaces (e.g., CDEV and CSUS pins)
1491 * for the specified peripheral. External clock sources should be enabled
1492 * prior to programming peripherals reliant on them. If multiple peripherals use
1493 * the same external clock source, it is safe to call this API multiple times.
1494 *
1495 * @param Guid The ODM-defined GUID of the peripheral to be configured. The
1496 * peripheral should have an @see NvOdmIoAddress entry for the
1497 * NvOdmIoModule_ExternalClock device interface. If multiple
1498 * external clock interfaces are specified, all will be
1499 * enabled (disabled).
1500 *
1501 * @param EnableTristate NV_TRUE will tristate the specified clock sources,
1502 * NV_FALSE will drive them.
1503 *
1504 * @param pInstances Returns the list of clocks that were enabled.
1505 *
1506 * @param pFrequencies Returns the frequency, in kHz, that is
1507 * being output on each clock pin
1508 *
1509 * @param pNum Returns the number of clocks that were enabled.
1510 *
1511 * @return NV_TRUE if successful, or NV_FALSE otherwise.
1512 */
1513 NvBool
1514 NvOdmExternalClockConfig(
1515 NvU64 Guid,
1516 NvBool EnableTristate,
1517 NvU32 *pInstances,
1518 NvU32 *pFrequencies,
1519 NvU32 *pNum);
1520
1521 /**
1522 * Defines SoC strap groups.
1523 */
1524 typedef enum
1525 {
1526 /// Specifies the ram_code strap group.
1527 NvOdmStrapGroup_RamCode = 1,
1528
1529 NvOdmStrapGroup_Num,
1530 NvOdmStrapGroup_Force32 = 0x7FFFFFFF
1531 } NvOdmStrapGroup;
1532
1533 /**
1534 * Gets SoC strap value for the given strap group.
1535 *
1536 * @note The strap assignment on each platform must be consistent with SoC
1537 * bootrom specifications and platform-specific BCT contents. The strap
1538 * value usage in ODM queries, however, is not limited to bootrom defined
1539 * functionality. The mapping between strap values and platforms is the ODM's
1540 * responsibility. ODMs should also ensure that they are using strap groups
1541 * that match the SOC in their product.
1542 *
1543 * @param StrapGroup The strap group to be read.
1544 * @param pStrapValue A pointer to the returned strap group value.
1545 * This value can be used by ODM queries to identify ODM platforms and to
1546 * provide the respective configuration settings.
1547 *
1548 * @return NV_TRUE if successful, or NV_FALSE otherwise.
1549 */
1550 NvBool NvOdmGetStraps(NvOdmStrapGroup StrapGroup, NvU32* pStrapValue);
1551
1552 /**
1553 * File input/output.
1554 */
1555 typedef void* NvOdmOsFileHandle;
1556
1557 /**
1558 * Defines the OS file types.
1559 */
1560 typedef enum
1561 {
1562 NvOdmOsFileType_Unknown = 0,
1563 NvOdmOsFileType_File,
1564 NvOdmOsFileType_Directory,
1565 NvOdmOsFileType_Fifo,
1566
1567 NvOdmOsFileType_Force32 = 0x7FFFFFFF
1568 } NvOdmOsFileType;
1569
1570 /**
1571 * Defines the OS status type.
1572 */
1573 typedef struct NvOdmOsStatTypeRec
1574 {
1575 NvU64 size;
1576 NvOdmOsFileType type;
1577 } NvOdmOsStatType;
1578
1579 /** Open a file with read permissions. */
1580 #define NVODMOS_OPEN_READ 0x1
1581
1582 /** Open a file with write persmissions. */
1583 #define NVODMOS_OPEN_WRITE 0x2
1584
1585 /** Create a file if is not present on the file system. */
1586 #define NVODMOS_OPEN_CREATE 0x4
1587
1588 /**
1589 * Opens a file stream.
1590 *
1591 * If the ::NVODMOS_OPEN_CREATE flag is specified, ::NVODMOS_OPEN_WRITE must al so
1592 * be specified.
1593 *
1594 * If ::NVODMOS_OPEN_WRITE is specified the file will be opened for write and
1595 * will be truncated if it was previously existing.
1596 *
1597 * If ::NVODMOS_OPEN_WRITE and ::NVODMOS_OPEN_READ is specified the file will n ot
1598 * be truncated.
1599 *
1600 * @param path A pointer to the path to the file.
1601 * @param flags ORed flags for the open operation (NVODMOS_OPEN_*).
1602 * @param file [out] A pointer to the file that will be opened, if successful.
1603 *
1604 * @return NV_TRUE if successful, or NV_FALSE otherwise.
1605 */
1606 NvBool
1607 NvOdmOsFopen(const char *path, NvU32 flags, NvOdmOsFileHandle *file);
1608
1609 /**
1610 * Closes a file stream.
1611 * Passing in a NULL handle is okay.
1612 *
1613 * @param stream The file stream to close.
1614 */
1615 void NvOdmOsFclose(NvOdmOsFileHandle stream);
1616
1617 /**
1618 * Writes to a file stream.
1619 *
1620 * @param stream The file stream.
1621 * @param ptr A pointer to the data to write.
1622 * @param size The length of the write.
1623 *
1624 * @return NV_TRUE if successful, or NV_FALSE otherwise.
1625 */
1626 NvBool
1627 NvOdmOsFwrite(NvOdmOsFileHandle stream, const void *ptr, size_t size);
1628
1629 /**
1630 * Reads a file stream.
1631 *
1632 * To detect short reads (less that specified amount), pass in \a bytes
1633 * and check its value to the expected value. The \a bytes parameter may
1634 * be NULL.
1635 *
1636 * @param stream The file stream.
1637 * @param ptr A pointer to the buffer for the read data.
1638 * @param size The length of the read.
1639 * @param bytes [out] A pointer to the number of bytes read -- may be NULL.
1640 *
1641 * @return NV_TRUE if successful, or NV_FALSE otherwise.
1642 */
1643 NvBool
1644 NvOdmOsFread(NvOdmOsFileHandle stream, void *ptr, size_t size, size_t *bytes);
1645
1646 /**
1647 * Gets file information.
1648 *
1649 * @param filename A pointer to the file to get information about.
1650 * @param stat [out] A pointer to the information structure.
1651 *
1652 * @return NV_TRUE if successful, or NV_FALSE otherwise.
1653 */
1654 NvBool
1655 NvOdmOsStat(const char *filename, NvOdmOsStatType *stat);
1656
1657 /**
1658 * Enables or disables USB OTG circuitry.
1659 *
1660 * @param Enable NV_TRUE to enable, or NV_FALSE to disable.
1661 */
1662 void NvOdmEnableOtgCircuitry(NvBool Enable);
1663
1664 /**
1665 * Checks whether or not USB is connected.
1666 *
1667 * @pre The USB circuit is enabled by calling NvOdmEnableOtgCircuitry().
1668 * To reduce power consumption, disable the USB circuit when not connected
1669 * by calling \c NvOdmEnableOtgCircuitry(NV_FALSE).
1670 *
1671 * @return NV_TRUE if USB is successfully connected, otherwise NV_FALSE.
1672 */
1673 NvBool NvOdmUsbIsConnected(void);
1674
1675 /**
1676 * Checks the current charging type.
1677 *
1678 * @pre The USB circuit is enabled by calling NvOdmEnableOtgCircuitry().
1679 * To reduce power consumption, disable the USB circuit when not connected
1680 * by calling \c NvOdmEnableOtgCircuitry(NV_FALSE).
1681 *
1682 * @param Instance Set to 0 by default.
1683 * @return The current charging type.
1684 */
1685 NvOdmUsbChargerType NvOdmUsbChargingType(NvU32 Instance);
1686
1687 #if defined(__cplusplus)
1688 }
1689 #endif
1690
1691 /*@}*/
1692 /** @} */
1693
1694 #endif // INCLUDED_NVODM_SERVICES_H
OLDNEW
« no previous file with comments | « arch/arm/mach-tegra/nv/include/nvodm_sdio.h ('k') | arch/arm/mach-tegra/nv/include/nvodm_tmon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698