Blackfin arch: add support for checking/clearing overruns in generic purpose Timer API

Signed-off-by: Mike Frysinger <michael.frysinger@analog.com>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
This commit is contained in:
Mike Frysinger 2007-10-29 18:02:09 +08:00 committed by Bryan Wu
parent 226eb1ef52
commit 4ad1ec7154
2 changed files with 42 additions and 7 deletions

View File

@ -20,8 +20,7 @@
#else #else
# define tassert(expr) \ # define tassert(expr) \
if (!(expr)) \ if (!(expr)) \
printk(KERN_DEBUG "%s:%s:%i: Assertion failed: " #expr "\n", \ printk(KERN_DEBUG "%s:%s:%i: Assertion failed: " #expr "\n", __FILE__, __func__, __LINE__);
__FILE__, __func__, __LINE__);
#endif #endif
#define BFIN_TIMER_NUM_GROUP (BFIN_TIMER_OCTET(MAX_BLACKFIN_GPTIMERS - 1) + 1) #define BFIN_TIMER_NUM_GROUP (BFIN_TIMER_OCTET(MAX_BLACKFIN_GPTIMERS - 1) + 1)
@ -70,7 +69,7 @@ static volatile GPTIMER_group_regs *const group_regs[BFIN_TIMER_NUM_GROUP] =
#endif #endif
}; };
static uint32_t const dis_mask[MAX_BLACKFIN_GPTIMERS] = static uint32_t const trun_mask[MAX_BLACKFIN_GPTIMERS] =
{ {
TIMER_STATUS_TRUN0, TIMER_STATUS_TRUN0,
TIMER_STATUS_TRUN1, TIMER_STATUS_TRUN1,
@ -90,7 +89,27 @@ static uint32_t const dis_mask[MAX_BLACKFIN_GPTIMERS] =
#endif #endif
}; };
static uint32_t const irq_mask[MAX_BLACKFIN_GPTIMERS] = static uint32_t const tovf_mask[MAX_BLACKFIN_GPTIMERS] =
{
TIMER_STATUS_TOVF0,
TIMER_STATUS_TOVF1,
TIMER_STATUS_TOVF2,
#if (MAX_BLACKFIN_GPTIMERS > 3)
TIMER_STATUS_TOVF3,
TIMER_STATUS_TOVF4,
TIMER_STATUS_TOVF5,
TIMER_STATUS_TOVF6,
TIMER_STATUS_TOVF7,
#endif
#if (MAX_BLACKFIN_GPTIMERS > 8)
TIMER_STATUS_TOVF8,
TIMER_STATUS_TOVF9,
TIMER_STATUS_TOVF10,
TIMER_STATUS_TOVF11,
#endif
};
static uint32_t const timil_mask[MAX_BLACKFIN_GPTIMERS] =
{ {
TIMER_STATUS_TIMIL0, TIMER_STATUS_TIMIL0,
TIMER_STATUS_TIMIL1, TIMER_STATUS_TIMIL1,
@ -165,17 +184,31 @@ EXPORT_SYMBOL(set_gptimer_status);
uint16_t get_gptimer_intr(int timer_id) uint16_t get_gptimer_intr(int timer_id)
{ {
tassert(timer_id < MAX_BLACKFIN_GPTIMERS); tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
return (group_regs[BFIN_TIMER_OCTET(timer_id)]->status & irq_mask[timer_id]) ? 1 : 0; return (group_regs[BFIN_TIMER_OCTET(timer_id)]->status & timil_mask[timer_id]) ? 1 : 0;
} }
EXPORT_SYMBOL(get_gptimer_intr); EXPORT_SYMBOL(get_gptimer_intr);
void clear_gptimer_intr(int timer_id) void clear_gptimer_intr(int timer_id)
{ {
tassert(timer_id < MAX_BLACKFIN_GPTIMERS); tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
group_regs[BFIN_TIMER_OCTET(timer_id)]->status = irq_mask[timer_id]; group_regs[BFIN_TIMER_OCTET(timer_id)]->status = timil_mask[timer_id];
} }
EXPORT_SYMBOL(clear_gptimer_intr); EXPORT_SYMBOL(clear_gptimer_intr);
uint16_t get_gptimer_over(int timer_id)
{
tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
return (group_regs[BFIN_TIMER_OCTET(timer_id)]->status & tovf_mask[timer_id]) ? 1 : 0;
}
EXPORT_SYMBOL(get_gptimer_over);
void clear_gptimer_over(int timer_id)
{
tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
group_regs[BFIN_TIMER_OCTET(timer_id)]->status = tovf_mask[timer_id];
}
EXPORT_SYMBOL(clear_gptimer_over);
void set_gptimer_config(int timer_id, uint16_t config) void set_gptimer_config(int timer_id, uint16_t config)
{ {
tassert(timer_id < MAX_BLACKFIN_GPTIMERS); tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
@ -214,7 +247,7 @@ void disable_gptimers(uint16_t mask)
} }
for (i = 0; i < MAX_BLACKFIN_GPTIMERS; ++i) for (i = 0; i < MAX_BLACKFIN_GPTIMERS; ++i)
if (mask & (1 << i)) if (mask & (1 << i))
group_regs[BFIN_TIMER_OCTET(i)]->status |= dis_mask[i]; group_regs[BFIN_TIMER_OCTET(i)]->status |= trun_mask[i];
SSYNC(); SSYNC();
} }
EXPORT_SYMBOL(disable_gptimers); EXPORT_SYMBOL(disable_gptimers);

View File

@ -197,6 +197,8 @@ uint32_t get_gptimer_period (int timer_id);
uint32_t get_gptimer_count (int timer_id); uint32_t get_gptimer_count (int timer_id);
uint16_t get_gptimer_intr (int timer_id); uint16_t get_gptimer_intr (int timer_id);
void clear_gptimer_intr (int timer_id); void clear_gptimer_intr (int timer_id);
uint16_t get_gptimer_over (int timer_id);
void clear_gptimer_over (int timer_id);
void set_gptimer_config (int timer_id, uint16_t config); void set_gptimer_config (int timer_id, uint16_t config);
uint16_t get_gptimer_config (int timer_id); uint16_t get_gptimer_config (int timer_id);
void set_gptimer_pulse_hi (int timer_id); void set_gptimer_pulse_hi (int timer_id);