aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel/gptimers.c
diff options
context:
space:
mode:
authorSteven Miao <realmz6@gmail.com>2012-05-16 06:11:10 -0400
committerBob Liu <lliubbo@gmail.com>2012-05-21 02:54:20 -0400
commit2879bb30d788bb3841e2f1675ea7af5204eb171c (patch)
treea5d5eaca8faa37c95fda955c11a5c9d902bff7a5 /arch/blackfin/kernel/gptimers.c
parente578bbdeb8db3656eff428f097d6c8ed2f3718a5 (diff)
blackfin: bf60x: enable gptimer clock source
Signed-off-by: Steven Miao <realmz6@gmail.com> Signed-off-by: Bob Liu <lliubbo@gmail.com>
Diffstat (limited to 'arch/blackfin/kernel/gptimers.c')
-rw-r--r--arch/blackfin/kernel/gptimers.c83
1 files changed, 82 insertions, 1 deletions
diff --git a/arch/blackfin/kernel/gptimers.c b/arch/blackfin/kernel/gptimers.c
index 06459f4bf43a..f7afe570f880 100644
--- a/arch/blackfin/kernel/gptimers.c
+++ b/arch/blackfin/kernel/gptimers.c
@@ -23,7 +23,11 @@
23 printk(KERN_DEBUG "%s:%s:%i: Assertion failed: " #expr "\n", __FILE__, __func__, __LINE__); 23 printk(KERN_DEBUG "%s:%s:%i: Assertion failed: " #expr "\n", __FILE__, __func__, __LINE__);
24#endif 24#endif
25 25
26#define BFIN_TIMER_NUM_GROUP (BFIN_TIMER_OCTET(MAX_BLACKFIN_GPTIMERS - 1) + 1) 26#ifndef CONFIG_BF60x
27# define BFIN_TIMER_NUM_GROUP (BFIN_TIMER_OCTET(MAX_BLACKFIN_GPTIMERS - 1) + 1)
28#else
29# define BFIN_TIMER_NUM_GROUP 1
30#endif
27 31
28static struct bfin_gptimer_regs * const timer_regs[MAX_BLACKFIN_GPTIMERS] = 32static struct bfin_gptimer_regs * const timer_regs[MAX_BLACKFIN_GPTIMERS] =
29{ 33{
@@ -158,6 +162,74 @@ uint32_t get_gptimer_count(unsigned int timer_id)
158} 162}
159EXPORT_SYMBOL(get_gptimer_count); 163EXPORT_SYMBOL(get_gptimer_count);
160 164
165#ifdef CONFIG_BF60x
166void set_gptimer_delay(unsigned int timer_id, uint32_t delay)
167{
168 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
169 bfin_write(&timer_regs[timer_id]->delay, delay);
170 SSYNC();
171}
172EXPORT_SYMBOL(set_gptimer_delay);
173
174uint32_t get_gptimer_delay(unsigned int timer_id)
175{
176 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
177 return bfin_read(&timer_regs[timer_id]->delay);
178}
179EXPORT_SYMBOL(get_gptimer_delay);
180#endif
181
182#ifdef CONFIG_BF60x
183int get_gptimer_intr(unsigned int timer_id)
184{
185 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
186 return !!(bfin_read(&group_regs[BFIN_TIMER_OCTET(timer_id)]->data_ilat) & timil_mask[timer_id]);
187}
188EXPORT_SYMBOL(get_gptimer_intr);
189
190void clear_gptimer_intr(unsigned int timer_id)
191{
192 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
193 bfin_write(&group_regs[BFIN_TIMER_OCTET(timer_id)]->data_ilat, timil_mask[timer_id]);
194}
195EXPORT_SYMBOL(clear_gptimer_intr);
196
197int get_gptimer_over(unsigned int timer_id)
198{
199 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
200 return !!(bfin_read(&group_regs[BFIN_TIMER_OCTET(timer_id)]->stat_ilat) & tovf_mask[timer_id]);
201}
202EXPORT_SYMBOL(get_gptimer_over);
203
204void clear_gptimer_over(unsigned int timer_id)
205{
206 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
207 bfin_write(&group_regs[BFIN_TIMER_OCTET(timer_id)]->stat_ilat, tovf_mask[timer_id]);
208}
209EXPORT_SYMBOL(clear_gptimer_over);
210
211int get_gptimer_run(unsigned int timer_id)
212{
213 tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
214 return !!(bfin_read(&group_regs[BFIN_TIMER_OCTET(timer_id)]->run) & trun_mask[timer_id]);
215}
216EXPORT_SYMBOL(get_gptimer_run);
217
218uint32_t get_gptimer_status(unsigned int group)
219{
220 tassert(group < BFIN_TIMER_NUM_GROUP);
221 return bfin_read(&group_regs[group]->data_ilat);
222}
223EXPORT_SYMBOL(get_gptimer_status);
224
225void set_gptimer_status(unsigned int group, uint32_t value)
226{
227 tassert(group < BFIN_TIMER_NUM_GROUP);
228 bfin_write(&group_regs[group]->data_ilat, value);
229 SSYNC();
230}
231EXPORT_SYMBOL(set_gptimer_status);
232#else
161uint32_t get_gptimer_status(unsigned int group) 233uint32_t get_gptimer_status(unsigned int group)
162{ 234{
163 tassert(group < BFIN_TIMER_NUM_GROUP); 235 tassert(group < BFIN_TIMER_NUM_GROUP);
@@ -212,6 +284,7 @@ int get_gptimer_run(unsigned int timer_id)
212 return !!(read_gptimer_status(timer_id) & trun_mask[timer_id]); 284 return !!(read_gptimer_status(timer_id) & trun_mask[timer_id]);
213} 285}
214EXPORT_SYMBOL(get_gptimer_run); 286EXPORT_SYMBOL(get_gptimer_run);
287#endif
215 288
216void set_gptimer_config(unsigned int timer_id, uint16_t config) 289void set_gptimer_config(unsigned int timer_id, uint16_t config)
217{ 290{
@@ -231,6 +304,12 @@ EXPORT_SYMBOL(get_gptimer_config);
231void enable_gptimers(uint16_t mask) 304void enable_gptimers(uint16_t mask)
232{ 305{
233 int i; 306 int i;
307#ifdef CONFIG_BF60x
308 uint16_t imask;
309 imask = bfin_read16(TIMER_DATA_IMSK);
310 imask &= ~mask;
311 bfin_write16(TIMER_DATA_IMSK, imask);
312#endif
234 tassert((mask & ~BLACKFIN_GPTIMER_IDMASK) == 0); 313 tassert((mask & ~BLACKFIN_GPTIMER_IDMASK) == 0);
235 for (i = 0; i < BFIN_TIMER_NUM_GROUP; ++i) { 314 for (i = 0; i < BFIN_TIMER_NUM_GROUP; ++i) {
236 bfin_write(&group_regs[i]->enable, mask & 0xFF); 315 bfin_write(&group_regs[i]->enable, mask & 0xFF);
@@ -255,10 +334,12 @@ void disable_gptimers(uint16_t mask)
255{ 334{
256 int i; 335 int i;
257 _disable_gptimers(mask); 336 _disable_gptimers(mask);
337#ifndef CONFIG_BF60x
258 for (i = 0; i < MAX_BLACKFIN_GPTIMERS; ++i) 338 for (i = 0; i < MAX_BLACKFIN_GPTIMERS; ++i)
259 if (mask & (1 << i)) 339 if (mask & (1 << i))
260 bfin_write(&group_regs[BFIN_TIMER_OCTET(i)]->status, trun_mask[i]); 340 bfin_write(&group_regs[BFIN_TIMER_OCTET(i)]->status, trun_mask[i]);
261 SSYNC(); 341 SSYNC();
342#endif
262} 343}
263EXPORT_SYMBOL(disable_gptimers); 344EXPORT_SYMBOL(disable_gptimers);
264 345