Path: blob/master/arch/h8300/kernel/timer/timer8.c
15126 views
/*1* linux/arch/h8300/kernel/cpu/timer/timer8.c2*3* Yoshinori Sato <[email protected]>4*5* 8bit 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/profile.h>1819#include <asm/io.h>20#include <asm/irq.h>21#include <asm/timer.h>22#if defined(CONFIG_CPU_H8300H)23#include <asm/regs306x.h>24#endif25#if defined(CONFIG_CPU_H8S)26#include <asm/regs267x.h>27#endif2829/* 8bit timer x2 */30#define CMFA 63132#if defined(CONFIG_H8300_TIMER8_CH0)33#define _8BASE _8TCR034#ifdef CONFIG_CPU_H8300H35#define _8IRQ 3636#endif37#ifdef CONFIG_CPU_H8S38#define _8IRQ 7239#endif40#elif defined(CONFIG_H8300_TIMER8_CH2)41#ifdef CONFIG_CPU_H8300H42#define _8BASE _8TCR243#define _8IRQ 4044#endif45#endif4647#ifndef _8BASE48#error Unknown timer channel.49#endif5051#define _8TCR 052#define _8TCSR 253#define TCORA 454#define TCORB 655#define _8TCNT 85657#define CMIEA 0x4058#define CCLR_CMA 0x0859#define CKS2 0x046061/*62* timer_interrupt() needs to keep up the real-time clock,63* as well as call the "xtime_update()" routine every clocktick64*/6566static irqreturn_t timer_interrupt(int irq, void *dev_id)67{68h8300_timer_tick();69ctrl_bclr(CMFA, _8BASE + _8TCSR);70return IRQ_HANDLED;71}7273static struct irqaction timer8_irq = {74.name = "timer-8",75.handler = timer_interrupt,76.flags = IRQF_DISABLED | IRQF_TIMER,77};7879static const int __initdata divide_rate[] = {8, 64, 8192};8081void __init h8300_timer_setup(void)82{83unsigned int div;84unsigned int cnt;8586calc_param(cnt, div, divide_rate, 0x10000);87div++;8889setup_irq(_8IRQ, &timer8_irq);9091#if defined(CONFIG_CPU_H8S)92/* Timer module enable */93ctrl_bclr(0, MSTPCRL)94#endif9596/* initialize timer */97ctrl_outw(cnt, _8BASE + TCORA);98ctrl_outw(0x0000, _8BASE + _8TCSR);99ctrl_outw((CMIEA|CCLR_CMA|CKS2) << 8 | div,100_8BASE + _8TCR);101}102103104