irq.c 4.7 KB
Newer Older
L
Linus Torvalds 已提交
1 2
/* irq.c: FRV IRQ handling
 *
3
 * Copyright (C) 2003, 2004, 2006 Red Hat, Inc. All Rights Reserved.
L
Linus Torvalds 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * Written by David Howells (dhowells@redhat.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */

#include <linux/ptrace.h>
#include <linux/errno.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/timex.h>
#include <linux/random.h>
#include <linux/init.h>
#include <linux/kernel_stat.h>
#include <linux/irq.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
25
#include <linux/module.h>
J
Jiri Slaby 已提交
26
#include <linux/bitops.h>
L
Linus Torvalds 已提交
27 28 29 30 31 32 33 34 35 36 37 38

#include <asm/atomic.h>
#include <asm/io.h>
#include <asm/smp.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <asm/pgalloc.h>
#include <asm/delay.h>
#include <asm/irq.h>
#include <asm/irc-regs.h>
#include <asm/gdb-stub.h>

39
#define set_IRR(N,A,B,C,D) __set_IRR(N, (A << 28) | (B << 24) | (C << 20) | (D << 16))
L
Linus Torvalds 已提交
40

41 42 43 44
extern void __init fpga_init(void);
#ifdef CONFIG_FUJITSU_MB93493
extern void __init mb93493_init(void);
#endif
L
Linus Torvalds 已提交
45

46
#define __reg16(ADDR) (*(volatile unsigned short *)(ADDR))
L
Linus Torvalds 已提交
47 48 49 50 51 52 53 54

atomic_t irq_err_count;

/*
 * Generic, controller-independent functions:
 */
int show_interrupts(struct seq_file *p, void *v)
{
55 56
	int i = *(loff_t *) v, cpu;
	struct irqaction * action;
L
Linus Torvalds 已提交
57 58
	unsigned long flags;

59 60
	if (i == 0) {
		char cpuname[12];
L
Linus Torvalds 已提交
61

62 63 64 65 66
		seq_printf(p, "    ");
		for_each_present_cpu(cpu) {
			sprintf(cpuname, "CPU%d", cpu);
			seq_printf(p, " %10s", cpuname);
		}
L
Linus Torvalds 已提交
67
		seq_putc(p, '\n');
68
	}
L
Linus Torvalds 已提交
69

70
	if (i < NR_IRQS) {
71
		raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
72 73 74 75
		action = irq_desc[i].action;
		if (action) {
			seq_printf(p, "%3d: ", i);
			for_each_present_cpu(cpu)
76
				seq_printf(p, "%10u ", kstat_irqs_cpu(i, cpu));
77 78
			seq_printf(p, " %10s",
				   irq_desc[i].irq_data.chip->name ? : "-");
79 80 81 82 83 84 85 86
			seq_printf(p, "  %s", action->name);
			for (action = action->next;
			     action;
			     action = action->next)
				seq_printf(p, ", %s", action->name);

			seq_putc(p, '\n');
		}
L
Linus Torvalds 已提交
87

88
		raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
89 90
	} else if (i == NR_IRQS) {
		seq_printf(p, "Err: %10u\n", atomic_read(&irq_err_count));
L
Linus Torvalds 已提交
91 92 93 94 95 96
	}

	return 0;
}

/*
97
 * on-CPU PIC operations
L
Linus Torvalds 已提交
98
 */
99
static void frv_cpupic_ack(struct irq_data *d)
L
Linus Torvalds 已提交
100
{
101
	__clr_RC(d->irq);
102 103
	__clr_IRL();
}
L
Linus Torvalds 已提交
104

105
static void frv_cpupic_mask(struct irq_data *d)
106
{
107
	__set_MASK(d->irq);
108
}
L
Linus Torvalds 已提交
109

110
static void frv_cpupic_mask_ack(struct irq_data *d)
111
{
112 113
	__set_MASK(d->irq);
	__clr_RC(d->irq);
114 115
	__clr_IRL();
}
L
Linus Torvalds 已提交
116

117
static void frv_cpupic_unmask(struct irq_data *d)
118
{
119
	__clr_MASK(d->irq);
120
}
L
Linus Torvalds 已提交
121

122 123
static struct irq_chip frv_cpu_pic = {
	.name		= "cpu",
124 125 126 127
	.irq_ack	= frv_cpupic_ack,
	.irq_mask	= frv_cpupic_mask,
	.irq_mask_ack	= frv_cpupic_mask_ack,
	.irq_unmask	= frv_cpupic_unmask,
128
};
129

L
Linus Torvalds 已提交
130
/*
S
Simon Arlott 已提交
131
 * handles all normal device IRQs
L
Linus Torvalds 已提交
132 133 134 135 136 137
 * - registers are referred to by the __frame variable (GR28)
 * - IRQ distribution is complicated in this arch because of the many PICs, the
 *   way they work and the way they cascade
 */
asmlinkage void do_IRQ(void)
{
138
	irq_enter();
139
	generic_handle_irq(__get_IRL());
140
	irq_exit();
141
}
L
Linus Torvalds 已提交
142 143 144 145 146 147 148 149 150 151

/*
 * handles all NMIs when not co-opted by the debugger
 * - registers are referred to by the __frame variable (GR28)
 */
asmlinkage void do_NMI(void)
{
}

/*
152
 * initialise the interrupt system
L
Linus Torvalds 已提交
153
 */
154
void __init init_IRQ(void)
L
Linus Torvalds 已提交
155
{
156
	int level;
L
Linus Torvalds 已提交
157

158 159 160
	for (level = 1; level <= 14; level++)
		set_irq_chip_and_handler(level, &frv_cpu_pic,
					 handle_level_irq);
L
Linus Torvalds 已提交
161

162
	set_irq_handler(IRQ_CPU_TIMER0, handle_edge_irq);
L
Linus Torvalds 已提交
163

164 165 166 167
	/* set the trigger levels for internal interrupt sources
	 * - timers all falling-edge
	 * - ERR0 is rising-edge
	 * - all others are high-level
L
Linus Torvalds 已提交
168
	 */
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
	__set_IITMR(0, 0x003f0000);	/* DMA0-3, TIMER0-2 */
	__set_IITMR(1, 0x20000000);	/* ERR0-1, UART0-1, DMA4-7 */

	/* route internal interrupts */
	set_IRR(4, IRQ_DMA3_LEVEL, IRQ_DMA2_LEVEL, IRQ_DMA1_LEVEL,
		IRQ_DMA0_LEVEL);
	set_IRR(5, 0, IRQ_TIMER2_LEVEL, IRQ_TIMER1_LEVEL, IRQ_TIMER0_LEVEL);
	set_IRR(6, IRQ_GDBSTUB_LEVEL, IRQ_GDBSTUB_LEVEL,
		IRQ_UART1_LEVEL, IRQ_UART0_LEVEL);
	set_IRR(7, IRQ_DMA7_LEVEL, IRQ_DMA6_LEVEL, IRQ_DMA5_LEVEL,
		IRQ_DMA4_LEVEL);

	/* route external interrupts */
	set_IRR(2, IRQ_XIRQ7_LEVEL, IRQ_XIRQ6_LEVEL, IRQ_XIRQ5_LEVEL,
		IRQ_XIRQ4_LEVEL);
	set_IRR(3, IRQ_XIRQ3_LEVEL, IRQ_XIRQ2_LEVEL, IRQ_XIRQ1_LEVEL,
		IRQ_XIRQ0_LEVEL);

#if defined(CONFIG_MB93091_VDK)
	__set_TM1(0x55550000);		/* XIRQ7-0 all active low */
#elif defined(CONFIG_MB93093_PDK)
	__set_TM1(0x15550000);		/* XIRQ7 active high, 6-0 all active low */
#else
#error dont know external IRQ trigger levels for this setup
#endif
L
Linus Torvalds 已提交
194 195 196

	fpga_init();
#ifdef CONFIG_FUJITSU_MB93493
197
	mb93493_init();
L
Linus Torvalds 已提交
198
#endif
199
}