OMAP3: SR: Remove redundant defines
[linux-ginger.git] / arch / arm / mach-bcmring / include / csp / tmrHw.h
blobf1236d00cb976f88162c36b394c95ac836bebbf1
1 /*****************************************************************************
2 * Copyright 2004 - 2008 Broadcom Corporation. All rights reserved.
4 * Unless you and Broadcom execute a separate written software license
5 * agreement governing use of this software, this software is licensed to you
6 * under the terms of the GNU General Public License version 2, available at
7 * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
9 * Notwithstanding the above, under no circumstances may you combine this
10 * software in any way with any other Broadcom software provided under a
11 * license other than the GPL, without Broadcom's express prior written
12 * consent.
13 *****************************************************************************/
15 /****************************************************************************/
16 /**
17 * @file tmrHw.h
19 * @brief API definitions for low level Timer driver
22 /****************************************************************************/
23 #ifndef _TMRHW_H
24 #define _TMRHW_H
26 #include <csp/stdint.h>
28 typedef uint32_t tmrHw_ID_t; /* Timer ID */
29 typedef uint32_t tmrHw_COUNT_t; /* Timer count */
30 typedef uint32_t tmrHw_INTERVAL_t; /* Timer interval */
31 typedef uint32_t tmrHw_RATE_t; /* Timer event (count/interrupt) rate */
33 typedef enum {
34 tmrHw_INTERRUPT_STATUS_SET, /* Interrupted */
35 tmrHw_INTERRUPT_STATUS_UNSET /* No Interrupt */
36 } tmrHw_INTERRUPT_STATUS_e;
38 typedef enum {
39 tmrHw_CAPABILITY_CLOCK, /* Clock speed in HHz */
40 tmrHw_CAPABILITY_RESOLUTION /* Timer resolution in bits */
41 } tmrHw_CAPABILITY_e;
43 /****************************************************************************/
44 /**
45 * @brief Get timer capability
47 * This function returns various capabilities/attributes of a timer
49 * @return Numeric capability
52 /****************************************************************************/
53 uint32_t tmrHw_getTimerCapability(tmrHw_ID_t timerId, /* [ IN ] Timer Id */
54 tmrHw_CAPABILITY_e capability /* [ IN ] Timer capability */
57 /****************************************************************************/
58 /**
59 * @brief Configures a periodic timer in terms of timer interrupt rate
61 * This function initializes a periodic timer to generate specific number of
62 * timer interrupt per second
64 * @return On success: Effective timer frequency
65 * On failure: 0
68 /****************************************************************************/
69 tmrHw_RATE_t tmrHw_setPeriodicTimerRate(tmrHw_ID_t timerId, /* [ IN ] Timer Id */
70 tmrHw_RATE_t rate /* [ IN ] Number of timer interrupt per second */
73 /****************************************************************************/
74 /**
75 * @brief Configures a periodic timer to generate timer interrupt after
76 * certain time interval
78 * This function initializes a periodic timer to generate timer interrupt
79 * after every time interval in milisecond
81 * @return On success: Effective interval set in mili-second
82 * On failure: 0
85 /****************************************************************************/
86 tmrHw_INTERVAL_t tmrHw_setPeriodicTimerInterval(tmrHw_ID_t timerId, /* [ IN ] Timer Id */
87 tmrHw_INTERVAL_t msec /* [ IN ] Interval in mili-second */
90 /****************************************************************************/
91 /**
92 * @brief Configures a periodic timer to generate timer interrupt just once
93 * after certain time interval
95 * This function initializes a periodic timer to generate a single ticks after
96 * certain time interval in milisecond
98 * @return On success: Effective interval set in mili-second
99 * On failure: 0
102 /****************************************************************************/
103 tmrHw_INTERVAL_t tmrHw_setOneshotTimerInterval(tmrHw_ID_t timerId, /* [ IN ] Timer Id */
104 tmrHw_INTERVAL_t msec /* [ IN ] Interval in mili-second */
107 /****************************************************************************/
109 * @brief Configures a timer to run as a free running timer
111 * This function initializes a timer to run as a free running timer
113 * @return Timer resolution (count / sec)
116 /****************************************************************************/
117 tmrHw_RATE_t tmrHw_setFreeRunningTimer(tmrHw_ID_t timerId, /* [ IN ] Timer Id */
118 uint32_t divider /* [ IN ] Dividing the clock frequency */
119 ) __attribute__ ((section(".aramtext")));
121 /****************************************************************************/
123 * @brief Starts a timer
125 * This function starts a preconfigured timer
127 * @return -1 - On Failure
128 * 0 - On Success
130 /****************************************************************************/
131 int tmrHw_startTimer(tmrHw_ID_t timerId /* [ IN ] Timer id */
132 ) __attribute__ ((section(".aramtext")));
134 /****************************************************************************/
136 * @brief Stops a timer
138 * This function stops a running timer
140 * @return -1 - On Failure
141 * 0 - On Success
143 /****************************************************************************/
144 int tmrHw_stopTimer(tmrHw_ID_t timerId /* [ IN ] Timer id */
147 /****************************************************************************/
149 * @brief Gets current timer count
151 * This function returns the current timer value
153 * @return Current downcounting timer value
156 /****************************************************************************/
157 tmrHw_COUNT_t tmrHw_GetCurrentCount(tmrHw_ID_t timerId /* [ IN ] Timer id */
158 ) __attribute__ ((section(".aramtext")));
160 /****************************************************************************/
162 * @brief Gets timer count rate
164 * This function returns the number of counts per second
166 * @return Count rate
169 /****************************************************************************/
170 tmrHw_RATE_t tmrHw_getCountRate(tmrHw_ID_t timerId /* [ IN ] Timer id */
171 ) __attribute__ ((section(".aramtext")));
173 /****************************************************************************/
175 * @brief Enables timer interrupt
177 * This function enables the timer interrupt
179 * @return N/A
182 /****************************************************************************/
183 void tmrHw_enableInterrupt(tmrHw_ID_t timerId /* [ IN ] Timer id */
186 /****************************************************************************/
188 * @brief Disables timer interrupt
190 * This function disable the timer interrupt
192 * @return N/A
194 /****************************************************************************/
195 void tmrHw_disableInterrupt(tmrHw_ID_t timerId /* [ IN ] Timer id */
198 /****************************************************************************/
200 * @brief Clears the interrupt
202 * This function clears the timer interrupt
204 * @return N/A
206 * @note
207 * Must be called under the context of ISR
209 /****************************************************************************/
210 void tmrHw_clearInterrupt(tmrHw_ID_t timerId /* [ IN ] Timer id */
213 /****************************************************************************/
215 * @brief Gets the interrupt status
217 * This function returns timer interrupt status
219 * @return Interrupt status
221 /****************************************************************************/
222 tmrHw_INTERRUPT_STATUS_e tmrHw_getInterruptStatus(tmrHw_ID_t timerId /* [ IN ] Timer id */
225 /****************************************************************************/
227 * @brief Indentifies a timer causing interrupt
229 * This functions returns a timer causing interrupt
231 * @return 0xFFFFFFFF : No timer causing an interrupt
232 * ! 0xFFFFFFFF : timer causing an interrupt
233 * @note
234 * tmrHw_clearIntrrupt() must be called with a valid timer id after calling this function
236 /****************************************************************************/
237 tmrHw_ID_t tmrHw_getInterruptSource(void);
239 /****************************************************************************/
241 * @brief Displays specific timer registers
244 * @return void
247 /****************************************************************************/
248 void tmrHw_printDebugInfo(tmrHw_ID_t timerId, /* [ IN ] Timer id */
249 int (*fpPrint) (const char *, ...) /* [ IN ] Print callback function */
252 /****************************************************************************/
254 * @brief Use a timer to perform a busy wait delay for a number of usecs.
256 * @return N/A
258 /****************************************************************************/
259 void tmrHw_udelay(tmrHw_ID_t timerId, /* [ IN ] Timer id */
260 unsigned long usecs /* [ IN ] usec to delay */
261 ) __attribute__ ((section(".aramtext")));
263 #endif /* _TMRHW_H */