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/traps.h>
19 #include <asm/blinken.h>
21 /* Clock hardware definitions */
23 #define CLOCKBASE 0xf05f8000
33 /* This is for machines which generate the exact clock. */
34 #define USECS_PER_JIFFY (1000000/HZ)
36 #define INTVAL ((10000 / 4) - 1)
38 static irqreturn_t hp300_tick(int irq, void *dev_id)
40 irq_handler_t timer_routine = dev_id;
44 local_irq_save(flags);
45 in_8(CLOCKBASE + CLKSR);
46 asm volatile ("movpw %1@(5),%0" : "=d" (tmp) : "a" (CLOCKBASE));
47 timer_routine(0, NULL);
48 local_irq_restore(flags);
50 /* Turn off the network and SCSI leds */
51 blinken_leds(0, 0xe0);
55 u32 hp300_gettimeoffset(void)
57 /* Read current timer 1 value */
58 unsigned char lsb, msb1, msb2;
61 msb1 = in_8(CLOCKBASE + 5);
62 lsb = in_8(CLOCKBASE + 7);
63 msb2 = in_8(CLOCKBASE + 5);
65 /* A carry happened while we were reading. Read it again */
66 lsb = in_8(CLOCKBASE + 7);
67 ticks = INTVAL - ((msb2 << 8) | lsb);
68 return ((USECS_PER_JIFFY * ticks) / INTVAL) * 1000;
71 void __init hp300_sched_init(irq_handler_t vector)
73 out_8(CLOCKBASE + CLKCR2, 0x1); /* select CR1 */
74 out_8(CLOCKBASE + CLKCR1, 0x1); /* reset */
76 asm volatile(" movpw %0,%1@(5)" : : "d" (INTVAL), "a" (CLOCKBASE));
78 if (request_irq(IRQ_AUTO_6, hp300_tick, 0, "timer tick", vector))
79 pr_err("Couldn't register timer interrupt\n");
81 out_8(CLOCKBASE + CLKCR2, 0x1); /* select CR1 */
82 out_8(CLOCKBASE + CLKCR1, 0x40); /* enable irq */