diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2009-05-04 05:11:37 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-06-12 06:11:47 -0400 |
commit | c8d5ea8ccb1ce586131c6c549899cb5073222da0 (patch) | |
tree | 8577a765ef1b9c5c4813ed9ceed5a03a885894f1 /arch/blackfin | |
parent | 9ba3c24f10c948dadac2ca91ed714dfbcedd61ca (diff) |
Blackfin: update gptimers API
First we fix the prototypes for functions that return boolean values by
using "int" rather than "uint16_t". Then we introduce a get_gptimer_run()
function for checking the current run status of a timer, and then we add a
disable_gptimers_sync() function which parallels disable_gptimers() with
corresponding normal "_sync" behavior.
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin')
-rw-r--r-- | arch/blackfin/include/asm/gptimers.h | 43 | ||||
-rw-r--r-- | arch/blackfin/kernel/gptimers.c | 30 |
2 files changed, 49 insertions, 24 deletions
diff --git a/arch/blackfin/include/asm/gptimers.h b/arch/blackfin/include/asm/gptimers.h index b0f847ae4bf4..89f08decb8e0 100644 --- a/arch/blackfin/include/asm/gptimers.h +++ b/arch/blackfin/include/asm/gptimers.h | |||
@@ -30,6 +30,7 @@ | |||
30 | # else | 30 | # else |
31 | # define MAX_BLACKFIN_GPTIMERS 11 | 31 | # define MAX_BLACKFIN_GPTIMERS 11 |
32 | # define TIMER8_GROUP_REG TIMER_ENABLE1 | 32 | # define TIMER8_GROUP_REG TIMER_ENABLE1 |
33 | # define TIMER_GROUP2 1 | ||
33 | # endif | 34 | # endif |
34 | # define TIMER0_GROUP_REG TIMER_ENABLE0 | 35 | # define TIMER0_GROUP_REG TIMER_ENABLE0 |
35 | #endif | 36 | #endif |
@@ -40,10 +41,12 @@ | |||
40 | # define MAX_BLACKFIN_GPTIMERS 12 | 41 | # define MAX_BLACKFIN_GPTIMERS 12 |
41 | # define TIMER0_GROUP_REG TMRS8_ENABLE | 42 | # define TIMER0_GROUP_REG TMRS8_ENABLE |
42 | # define TIMER8_GROUP_REG TMRS4_ENABLE | 43 | # define TIMER8_GROUP_REG TMRS4_ENABLE |
44 | # define TIMER_GROUP2 1 | ||
43 | #endif | 45 | #endif |
44 | /* | 46 | /* |
45 | * All others: 3 timers: | 47 | * All others: 3 timers: |
46 | */ | 48 | */ |
49 | #define TIMER_GROUP1 0 | ||
47 | #if !defined(MAX_BLACKFIN_GPTIMERS) | 50 | #if !defined(MAX_BLACKFIN_GPTIMERS) |
48 | # define MAX_BLACKFIN_GPTIMERS 3 | 51 | # define MAX_BLACKFIN_GPTIMERS 3 |
49 | # define TIMER0_GROUP_REG TIMER_ENABLE | 52 | # define TIMER0_GROUP_REG TIMER_ENABLE |
@@ -109,8 +112,8 @@ | |||
109 | #define TIMER_ERR_PROG_PER 0x8000 | 112 | #define TIMER_ERR_PROG_PER 0x8000 |
110 | #define TIMER_ERR_PROG_PW 0xC000 | 113 | #define TIMER_ERR_PROG_PW 0xC000 |
111 | #define TIMER_EMU_RUN 0x0200 | 114 | #define TIMER_EMU_RUN 0x0200 |
112 | #define TIMER_TOGGLE_HI 0x0100 | 115 | #define TIMER_TOGGLE_HI 0x0100 |
113 | #define TIMER_CLK_SEL 0x0080 | 116 | #define TIMER_CLK_SEL 0x0080 |
114 | #define TIMER_OUT_DIS 0x0040 | 117 | #define TIMER_OUT_DIS 0x0040 |
115 | #define TIMER_TIN_SEL 0x0020 | 118 | #define TIMER_TIN_SEL 0x0020 |
116 | #define TIMER_IRQ_ENA 0x0010 | 119 | #define TIMER_IRQ_ENA 0x0010 |
@@ -169,23 +172,25 @@ | |||
169 | 172 | ||
170 | /* The actual gptimer API */ | 173 | /* The actual gptimer API */ |
171 | 174 | ||
172 | void set_gptimer_pwidth (int timer_id, uint32_t width); | 175 | void set_gptimer_pwidth(int timer_id, uint32_t width); |
173 | uint32_t get_gptimer_pwidth (int timer_id); | 176 | uint32_t get_gptimer_pwidth(int timer_id); |
174 | void set_gptimer_period (int timer_id, uint32_t period); | 177 | void set_gptimer_period(int timer_id, uint32_t period); |
175 | uint32_t get_gptimer_period (int timer_id); | 178 | uint32_t get_gptimer_period(int timer_id); |
176 | uint32_t get_gptimer_count (int timer_id); | 179 | uint32_t get_gptimer_count(int timer_id); |
177 | uint16_t get_gptimer_intr (int timer_id); | 180 | int get_gptimer_intr(int timer_id); |
178 | void clear_gptimer_intr (int timer_id); | 181 | void clear_gptimer_intr(int timer_id); |
179 | uint16_t get_gptimer_over (int timer_id); | 182 | int get_gptimer_over(int timer_id); |
180 | void clear_gptimer_over (int timer_id); | 183 | void clear_gptimer_over(int timer_id); |
181 | void set_gptimer_config (int timer_id, uint16_t config); | 184 | void set_gptimer_config(int timer_id, uint16_t config); |
182 | uint16_t get_gptimer_config (int timer_id); | 185 | uint16_t get_gptimer_config(int timer_id); |
183 | void set_gptimer_pulse_hi (int timer_id); | 186 | int get_gptimer_run(int timer_id); |
187 | void set_gptimer_pulse_hi(int timer_id); | ||
184 | void clear_gptimer_pulse_hi(int timer_id); | 188 | void clear_gptimer_pulse_hi(int timer_id); |
185 | void enable_gptimers (uint16_t mask); | 189 | void enable_gptimers(uint16_t mask); |
186 | void disable_gptimers (uint16_t mask); | 190 | void disable_gptimers(uint16_t mask); |
187 | uint16_t get_enabled_gptimers (void); | 191 | void disable_gptimers_sync(uint16_t mask); |
188 | uint32_t get_gptimer_status (int group); | 192 | uint16_t get_enabled_gptimers(void); |
189 | void set_gptimer_status (int group, uint32_t value); | 193 | uint32_t get_gptimer_status(int group); |
194 | void set_gptimer_status(int group, uint32_t value); | ||
190 | 195 | ||
191 | #endif | 196 | #endif |
diff --git a/arch/blackfin/kernel/gptimers.c b/arch/blackfin/kernel/gptimers.c index 3a3e9615b002..7281a91d26b5 100644 --- a/arch/blackfin/kernel/gptimers.c +++ b/arch/blackfin/kernel/gptimers.c | |||
@@ -189,10 +189,10 @@ void set_gptimer_status(int group, uint32_t value) | |||
189 | } | 189 | } |
190 | EXPORT_SYMBOL(set_gptimer_status); | 190 | EXPORT_SYMBOL(set_gptimer_status); |
191 | 191 | ||
192 | uint16_t get_gptimer_intr(int timer_id) | 192 | int get_gptimer_intr(int timer_id) |
193 | { | 193 | { |
194 | tassert(timer_id < MAX_BLACKFIN_GPTIMERS); | 194 | tassert(timer_id < MAX_BLACKFIN_GPTIMERS); |
195 | return (group_regs[BFIN_TIMER_OCTET(timer_id)]->status & timil_mask[timer_id]) ? 1 : 0; | 195 | return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & timil_mask[timer_id]); |
196 | } | 196 | } |
197 | EXPORT_SYMBOL(get_gptimer_intr); | 197 | EXPORT_SYMBOL(get_gptimer_intr); |
198 | 198 | ||
@@ -203,10 +203,10 @@ void clear_gptimer_intr(int timer_id) | |||
203 | } | 203 | } |
204 | EXPORT_SYMBOL(clear_gptimer_intr); | 204 | EXPORT_SYMBOL(clear_gptimer_intr); |
205 | 205 | ||
206 | uint16_t get_gptimer_over(int timer_id) | 206 | int get_gptimer_over(int timer_id) |
207 | { | 207 | { |
208 | tassert(timer_id < MAX_BLACKFIN_GPTIMERS); | 208 | tassert(timer_id < MAX_BLACKFIN_GPTIMERS); |
209 | return (group_regs[BFIN_TIMER_OCTET(timer_id)]->status & tovf_mask[timer_id]) ? 1 : 0; | 209 | return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & tovf_mask[timer_id]); |
210 | } | 210 | } |
211 | EXPORT_SYMBOL(get_gptimer_over); | 211 | EXPORT_SYMBOL(get_gptimer_over); |
212 | 212 | ||
@@ -217,6 +217,13 @@ void clear_gptimer_over(int timer_id) | |||
217 | } | 217 | } |
218 | EXPORT_SYMBOL(clear_gptimer_over); | 218 | EXPORT_SYMBOL(clear_gptimer_over); |
219 | 219 | ||
220 | int get_gptimer_run(int timer_id) | ||
221 | { | ||
222 | tassert(timer_id < MAX_BLACKFIN_GPTIMERS); | ||
223 | return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & trun_mask[timer_id]); | ||
224 | } | ||
225 | EXPORT_SYMBOL(get_gptimer_run); | ||
226 | |||
220 | void set_gptimer_config(int timer_id, uint16_t config) | 227 | void set_gptimer_config(int timer_id, uint16_t config) |
221 | { | 228 | { |
222 | tassert(timer_id < MAX_BLACKFIN_GPTIMERS); | 229 | tassert(timer_id < MAX_BLACKFIN_GPTIMERS); |
@@ -244,7 +251,7 @@ void enable_gptimers(uint16_t mask) | |||
244 | } | 251 | } |
245 | EXPORT_SYMBOL(enable_gptimers); | 252 | EXPORT_SYMBOL(enable_gptimers); |
246 | 253 | ||
247 | void disable_gptimers(uint16_t mask) | 254 | static void _disable_gptimers(uint16_t mask) |
248 | { | 255 | { |
249 | int i; | 256 | int i; |
250 | uint16_t m = mask; | 257 | uint16_t m = mask; |
@@ -253,6 +260,12 @@ void disable_gptimers(uint16_t mask) | |||
253 | group_regs[i]->disable = m & 0xFF; | 260 | group_regs[i]->disable = m & 0xFF; |
254 | m >>= 8; | 261 | m >>= 8; |
255 | } | 262 | } |
263 | } | ||
264 | |||
265 | void disable_gptimers(uint16_t mask) | ||
266 | { | ||
267 | int i; | ||
268 | _disable_gptimers(mask); | ||
256 | for (i = 0; i < MAX_BLACKFIN_GPTIMERS; ++i) | 269 | for (i = 0; i < MAX_BLACKFIN_GPTIMERS; ++i) |
257 | if (mask & (1 << i)) | 270 | if (mask & (1 << i)) |
258 | group_regs[BFIN_TIMER_OCTET(i)]->status |= trun_mask[i]; | 271 | group_regs[BFIN_TIMER_OCTET(i)]->status |= trun_mask[i]; |
@@ -260,6 +273,13 @@ void disable_gptimers(uint16_t mask) | |||
260 | } | 273 | } |
261 | EXPORT_SYMBOL(disable_gptimers); | 274 | EXPORT_SYMBOL(disable_gptimers); |
262 | 275 | ||
276 | void disable_gptimers_sync(uint16_t mask) | ||
277 | { | ||
278 | _disable_gptimers(mask); | ||
279 | SSYNC(); | ||
280 | } | ||
281 | EXPORT_SYMBOL(disable_gptimers_sync); | ||
282 | |||
263 | void set_gptimer_pulse_hi(int timer_id) | 283 | void set_gptimer_pulse_hi(int timer_id) |
264 | { | 284 | { |
265 | tassert(timer_id < MAX_BLACKFIN_GPTIMERS); | 285 | tassert(timer_id < MAX_BLACKFIN_GPTIMERS); |