From: Mike Frysinger Date: Mon, 29 Oct 2007 10:02:09 +0000 (+0800) Subject: Blackfin arch: add support for checking/clearing overruns in generic purpose Timer API X-Git-Tag: v2.6.24-rc2~78^2~11 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ad1ec7154d7e26c1bd82c03c44690ba2b566f2f;p=linux-2.6 Blackfin arch: add support for checking/clearing overruns in generic purpose Timer API Signed-off-by: Mike Frysinger Signed-off-by: Bryan Wu --- diff --git a/arch/blackfin/kernel/gptimers.c b/arch/blackfin/kernel/gptimers.c index cb7ba9bfc7..5cf4bdb1df 100644 --- a/arch/blackfin/kernel/gptimers.c +++ b/arch/blackfin/kernel/gptimers.c @@ -20,8 +20,7 @@ #else # define tassert(expr) \ if (!(expr)) \ - printk(KERN_DEBUG "%s:%s:%i: Assertion failed: " #expr "\n", \ - __FILE__, __func__, __LINE__); + printk(KERN_DEBUG "%s:%s:%i: Assertion failed: " #expr "\n", __FILE__, __func__, __LINE__); #endif #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 }; -static uint32_t const dis_mask[MAX_BLACKFIN_GPTIMERS] = +static uint32_t const trun_mask[MAX_BLACKFIN_GPTIMERS] = { TIMER_STATUS_TRUN0, TIMER_STATUS_TRUN1, @@ -90,7 +89,27 @@ static uint32_t const dis_mask[MAX_BLACKFIN_GPTIMERS] = #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_TIMIL1, @@ -165,17 +184,31 @@ EXPORT_SYMBOL(set_gptimer_status); uint16_t get_gptimer_intr(int timer_id) { 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); void clear_gptimer_intr(int timer_id) { 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); +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) { tassert(timer_id < MAX_BLACKFIN_GPTIMERS); @@ -214,7 +247,7 @@ void disable_gptimers(uint16_t mask) } for (i = 0; i < MAX_BLACKFIN_GPTIMERS; ++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(); } EXPORT_SYMBOL(disable_gptimers); diff --git a/include/asm-blackfin/gptimers.h b/include/asm-blackfin/gptimers.h index c97ab03e43..8265ea473d 100644 --- a/include/asm-blackfin/gptimers.h +++ b/include/asm-blackfin/gptimers.h @@ -197,6 +197,8 @@ uint32_t get_gptimer_period (int timer_id); uint32_t get_gptimer_count (int timer_id); uint16_t get_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); uint16_t get_gptimer_config (int timer_id); void set_gptimer_pulse_hi (int timer_id);