Path: blob/master/arch/h8300/kernel/timer/timer16.c
15126 views
/*1* linux/arch/h8300/kernel/timer/timer16.c2*3* Yoshinori Sato <[email protected]>4*5* 16bit Timer Handler6*7*/89#include <linux/errno.h>10#include <linux/sched.h>11#include <linux/kernel.h>12#include <linux/param.h>13#include <linux/string.h>14#include <linux/mm.h>15#include <linux/interrupt.h>16#include <linux/init.h>17#include <linux/timex.h>1819#include <asm/segment.h>20#include <asm/io.h>21#include <asm/irq.h>22#include <asm/regs306x.h>2324/* 16bit timer */25#if CONFIG_H8300_TIMER16_CH == 026#define _16BASE 0xffff7827#define _16IRQ 2428#elif CONFIG_H8300_TIMER16_CH == 129#define _16BASE 0xffff8030#define _16IRQ 2831#elif CONFIG_H8300_TIMER16_CH == 232#define _16BASE 0xffff8833#define _16IRQ 3234#else35#error Unknown timer channel.36#endif3738#define TCR 039#define TIOR 140#define TCNT 241#define GRA 442#define GRB 64344#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*10000 /* Timer input freq. */4546static irqreturn_t timer_interrupt(int irq, void *dev_id)47{48h8300_timer_tick();49ctrl_bclr(CONFIG_H8300_TIMER16_CH, TISRA);50return IRQ_HANDLED;51}5253static struct irqaction timer16_irq = {54.name = "timer-16",55.handler = timer_interrupt,56.flags = IRQF_DISABLED | IRQF_TIMER,57};5859static const int __initdata divide_rate[] = {1, 2, 4, 8};6061void __init h8300_timer_setup(void)62{63unsigned int div;64unsigned int cnt;6566calc_param(cnt, div, divide_rate, 0x10000);6768setup_irq(_16IRQ, &timer16_irq);6970/* initialize timer */71ctrl_outb(0, TSTR);72ctrl_outb(CCLR0 | div, _16BASE + TCR);73ctrl_outw(cnt, _16BASE + GRA);74ctrl_bset(4 + CONFIG_H8300_TIMER16_CH, TISRA);75ctrl_bset(CONFIG_H8300_TIMER16_CH, TSTR);76}777879