2 * linux/arch/m68k/hp300/time.c
4 * Copyright (C) 1998 Philip Blundell <philb@gnu.org>
6 * This file contains the HP300-specific time handling code.
9 #include <asm/ptrace.h>
10 #include <linux/types.h>
11 #include <linux/init.h>
12 #include <linux/sched.h>
13 #include <linux/kernel_stat.h>
14 #include <linux/interrupt.h>
15 #include <asm/machdep.h>
18 #include <asm/system.h>
19 #include <asm/traps.h>
22 /* Clock hardware definitions */
24 #define CLOCKBASE 0xf05f8000
34 /* This is for machines which generate the exact clock. */
35 #define USECS_PER_JIFFY (1000000/HZ)
37 #define INTVAL ((10000 / 4) - 1)
39 static irqreturn_t hp300_tick(int irq, void *dev_id, struct pt_regs *regs)
42 irqreturn_t (*vector)(int, void *, struct pt_regs *) = dev_id;
43 in_8(CLOCKBASE + CLKSR);
44 asm volatile ("movpw %1@(5),%0" : "=d" (tmp) : "a" (CLOCKBASE));
45 return vector(irq, NULL, regs);
48 unsigned long hp300_gettimeoffset(void)
50 /* Read current timer 1 value */
51 unsigned char lsb, msb1, msb2;
54 msb1 = in_8(CLOCKBASE + 5);
55 lsb = in_8(CLOCKBASE + 7);
56 msb2 = in_8(CLOCKBASE + 5);
58 /* A carry happened while we were reading. Read it again */
59 lsb = in_8(CLOCKBASE + 7);
60 ticks = INTVAL - ((msb2 << 8) | lsb);
61 return (USECS_PER_JIFFY * ticks) / INTVAL;
64 void __init hp300_sched_init(irqreturn_t (*vector)(int, void *, struct pt_regs *))
66 out_8(CLOCKBASE + CLKCR2, 0x1); /* select CR1 */
67 out_8(CLOCKBASE + CLKCR1, 0x1); /* reset */
69 asm volatile(" movpw %0,%1@(5)" : : "d" (INTVAL), "a" (CLOCKBASE));
71 cpu_request_irq(6, hp300_tick, IRQ_FLG_STD, "timer tick", vector);
73 out_8(CLOCKBASE + CLKCR2, 0x1); /* select CR1 */
74 out_8(CLOCKBASE + CLKCR1, 0x40); /* enable irq */