blob: efafabdd5bbffd8cb60f150c2101509da1a1c055 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * Galileo Technology chip interrupt handler
8 */
9#include <linux/interrupt.h>
10#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/sched.h>
12#include <linux/kernel_stat.h>
Ralf Baechle937a8012006-10-07 19:44:33 +010013#include <asm/irq_regs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/ptrace.h>
15#include <asm/gt64120.h>
16
17/*
18 * These are interrupt handlers for the GT on-chip interrupts. They all come
19 * in to the MIPS on a single interrupt line, and have to be handled and ack'ed
20 * differently than other MIPS interrupts.
21 */
22
Ralf Baechle65542072006-10-08 23:56:13 +010023static irqreturn_t gt64120_irq(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070024{
25 unsigned int irq_src, int_high_src, irq_src_mask, int_high_src_mask;
26 int handled = 0;
27
28 irq_src = GT_READ(GT_INTRCAUSE_OFS);
29 irq_src_mask = GT_READ(GT_INTRMASK_OFS);
30 int_high_src = GT_READ(GT_HINTRCAUSE_OFS);
31 int_high_src_mask = GT_READ(GT_HINTRMASK_OFS);
32 irq_src = irq_src & irq_src_mask;
33 int_high_src = int_high_src & int_high_src_mask;
34
35 if (irq_src & 0x00000800) { /* Check for timer interrupt */
36 handled = 1;
37 irq_src &= ~0x00000800;
Atsushi Nemoto3171a032006-09-29 02:00:32 -070038 do_timer(1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#ifndef CONFIG_SMP
Ralf Baechle937a8012006-10-07 19:44:33 +010040 update_process_times(user_mode(get_irq_regs()));
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#endif
42 }
43
44 GT_WRITE(GT_INTRCAUSE_OFS, 0);
45 GT_WRITE(GT_HINTRCAUSE_OFS, 0);
Ralf Baechle65542072006-10-08 23:56:13 +010046
47 return IRQ_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048}
49
50/*
51 * Initializes timer using galileo's built in timer.
52 */
53#ifdef CONFIG_SYSCLK_100
54#define Sys_clock (100 * 1000000) // 100 MHz
55#endif
56#ifdef CONFIG_SYSCLK_83
57#define Sys_clock (83.333 * 1000000) // 83.333 MHz
58#endif
59#ifdef CONFIG_SYSCLK_75
60#define Sys_clock (75 * 1000000) // 75 MHz
61#endif
62
63/*
64 * This will ignore the standard MIPS timer interrupt handler that is passed in
65 * as *irq (=irq0 in ../kernel/time.c). We will do our own timer interrupt
66 * handling.
67 */
68void gt64120_time_init(void)
69{
70 static struct irqaction timer;
71
72 /* Disable timer first */
73 GT_WRITE(GT_TC_CONTROL_OFS, 0);
74 /* Load timer value for 100 Hz */
75 GT_WRITE(GT_TC3_OFS, Sys_clock / 100);
76
77 /*
78 * Create the IRQ structure entry for the timer. Since we're too early
79 * in the boot process to use the "request_irq()" call, we'll hard-code
80 * the values to the correct interrupt line.
81 */
82 timer.handler = gt64120_irq;
Thomas Gleixnerf40298f2006-07-01 19:29:20 -070083 timer.flags = IRQF_SHARED | IRQF_DISABLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 timer.name = "timer";
85 timer.dev_id = NULL;
86 timer.next = NULL;
87 timer.mask = CPU_MASK_NONE;
88 irq_desc[GT_TIMER].action = &timer;
89
90 enable_irq(GT_TIMER);
91
92 /* Enable timer ints */
93 GT_WRITE(GT_TC_CONTROL_OFS, 0xc0);
94 /* clear Cause register first */
95 GT_WRITE(GT_INTRCAUSE_OFS, 0x0);
96 /* Unmask timer int */
97 GT_WRITE(GT_INTRMASK_OFS, 0x800);
98 /* Clear High int register */
99 GT_WRITE(GT_HINTRCAUSE_OFS, 0x0);
100 /* Mask All interrupts at High cause interrupt */
101 GT_WRITE(GT_HINTRMASK_OFS, 0x0);
102}