1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/m68k/hp300/time.c
5 * Copyright (C) 1998 Philip Blundell <philb@gnu.org>
7 * This file contains the HP300-specific time handling code.
10 #include <asm/ptrace.h>
11 #include <linux/types.h>
12 #include <linux/init.h>
13 #include <linux/sched.h>
14 #include <linux/kernel_stat.h>
15 #include <linux/interrupt.h>
16 #include <asm/machdep.h>
19 #include <asm/traps.h>
20 #include <asm/blinken.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
)
42 irq_handler_t vector
= dev_id
;
43 in_8(CLOCKBASE
+ CLKSR
);
44 asm volatile ("movpw %1@(5),%0" : "=d" (tmp
) : "a" (CLOCKBASE
));
45 /* Turn off the network and SCSI leds */
46 blinken_leds(0, 0xe0);
47 return vector(irq
, NULL
);
50 u32
hp300_gettimeoffset(void)
52 /* Read current timer 1 value */
53 unsigned char lsb
, msb1
, msb2
;
56 msb1
= in_8(CLOCKBASE
+ 5);
57 lsb
= in_8(CLOCKBASE
+ 7);
58 msb2
= in_8(CLOCKBASE
+ 5);
60 /* A carry happened while we were reading. Read it again */
61 lsb
= in_8(CLOCKBASE
+ 7);
62 ticks
= INTVAL
- ((msb2
<< 8) | lsb
);
63 return ((USECS_PER_JIFFY
* ticks
) / INTVAL
) * 1000;
66 void __init
hp300_sched_init(irq_handler_t vector
)
68 out_8(CLOCKBASE
+ CLKCR2
, 0x1); /* select CR1 */
69 out_8(CLOCKBASE
+ CLKCR1
, 0x1); /* reset */
71 asm volatile(" movpw %0,%1@(5)" : : "d" (INTVAL
), "a" (CLOCKBASE
));
73 if (request_irq(IRQ_AUTO_6
, hp300_tick
, 0, "timer tick", vector
))
74 pr_err("Couldn't register timer interrupt\n");
76 out_8(CLOCKBASE
+ CLKCR2
, 0x1); /* select CR1 */
77 out_8(CLOCKBASE
+ CLKCR1
, 0x40); /* enable irq */