2005-04-16 22:20:36 +00:00
|
|
|
/* irq.c: FRV IRQ handling
|
|
|
|
*
|
2006-09-26 06:32:04 +00:00
|
|
|
* Copyright (C) 2003, 2004, 2006 Red Hat, Inc. All Rights Reserved.
|
2005-04-16 22:20:36 +00:00
|
|
|
* 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>
|
2006-01-08 09:01:19 +00:00
|
|
|
#include <linux/module.h>
|
2007-10-19 06:40:25 +00:00
|
|
|
#include <linux/bitops.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-07-26 23:09:06 +00:00
|
|
|
#include <linux/atomic.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/smp.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>
|
|
|
|
|
2006-09-26 06:32:04 +00:00
|
|
|
#define set_IRR(N,A,B,C,D) __set_IRR(N, (A << 28) | (B << 24) | (C << 20) | (D << 16))
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-26 06:32:04 +00:00
|
|
|
extern void __init fpga_init(void);
|
|
|
|
#ifdef CONFIG_FUJITSU_MB93493
|
|
|
|
extern void __init mb93493_init(void);
|
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-26 06:32:04 +00:00
|
|
|
#define __reg16(ADDR) (*(volatile unsigned short *)(ADDR))
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
atomic_t irq_err_count;
|
|
|
|
|
2011-03-24 17:48:36 +00:00
|
|
|
int arch_show_interrupts(struct seq_file *p, int prec)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-03-24 17:48:36 +00:00
|
|
|
seq_printf(p, "%*s: ", prec, "ERR");
|
|
|
|
seq_printf(p, "%10u\n", atomic_read(&irq_err_count));
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-09-26 06:32:04 +00:00
|
|
|
* on-CPU PIC operations
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2011-02-06 19:20:38 +00:00
|
|
|
static void frv_cpupic_ack(struct irq_data *d)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-02-06 19:20:38 +00:00
|
|
|
__clr_RC(d->irq);
|
2006-09-26 06:32:04 +00:00
|
|
|
__clr_IRL();
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-02-06 19:20:38 +00:00
|
|
|
static void frv_cpupic_mask(struct irq_data *d)
|
2006-09-26 06:32:04 +00:00
|
|
|
{
|
2011-02-06 19:20:38 +00:00
|
|
|
__set_MASK(d->irq);
|
2006-09-26 06:32:04 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-02-06 19:20:38 +00:00
|
|
|
static void frv_cpupic_mask_ack(struct irq_data *d)
|
2006-09-26 06:32:04 +00:00
|
|
|
{
|
2011-02-06 19:20:38 +00:00
|
|
|
__set_MASK(d->irq);
|
|
|
|
__clr_RC(d->irq);
|
2006-09-26 06:32:04 +00:00
|
|
|
__clr_IRL();
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-02-06 19:20:38 +00:00
|
|
|
static void frv_cpupic_unmask(struct irq_data *d)
|
2006-09-26 06:32:04 +00:00
|
|
|
{
|
2011-02-06 19:20:38 +00:00
|
|
|
__clr_MASK(d->irq);
|
2006-09-26 06:32:04 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-26 06:32:04 +00:00
|
|
|
static struct irq_chip frv_cpu_pic = {
|
|
|
|
.name = "cpu",
|
2011-02-06 19:20:38 +00:00
|
|
|
.irq_ack = frv_cpupic_ack,
|
|
|
|
.irq_mask = frv_cpupic_mask,
|
|
|
|
.irq_mask_ack = frv_cpupic_mask_ack,
|
|
|
|
.irq_unmask = frv_cpupic_unmask,
|
2006-09-26 06:32:04 +00:00
|
|
|
};
|
2006-01-08 09:01:19 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2007-10-19 23:09:42 +00:00
|
|
|
* handles all normal device IRQs
|
2005-04-16 22:20:36 +00:00
|
|
|
* - 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)
|
|
|
|
{
|
[PATCH] FRV: Use virtual interrupt disablement
Make the FRV arch use virtual interrupt disablement because accesses to the
processor status register (PSR) are relatively slow and because we will
soon have the need to deal with multiple interrupt controls at the same
time (separate h/w and inter-core interrupts).
The way this is done is to dedicate one of the four integer condition code
registers (ICC2) to maintaining a virtual interrupt disablement state
whilst inside the kernel. This uses the ICC2.Z flag (Zero) to indicate
whether the interrupts are virtually disabled and the ICC2.C flag (Carry)
to indicate whether the interrupts are physically disabled.
ICC2.Z is set to indicate interrupts are virtually disabled. ICC2.C is set
to indicate interrupts are physically enabled. Under normal running
conditions Z==0 and C==1.
Disabling interrupts with local_irq_disable() doesn't then actually
physically disable interrupts - it merely sets ICC2.Z to 1. Should an
interrupt then happen, the exception prologue will note ICC2.Z is set and
branch out of line using one instruction (an unlikely BEQ). Here it will
physically disable interrupts and clear ICC2.C.
When it comes time to enable interrupts (local_irq_enable()), this simply
clears the ICC2.Z flag and invokes a trap #2 if both Z and C flags are
clear (the HI integer condition). This can be done with the TIHI
conditional trap instruction.
The trap then physically reenables interrupts and sets ICC2.C again. Upon
returning the interrupt will be taken as interrupts will then be enabled.
Note that whilst processing the trap, the whole exceptions system is
disabled, and so an interrupt can't happen till it returns.
If no pending interrupt had happened, ICC2.C would still be set, the HI
condition would not be fulfilled, and no trap will happen.
Saving interrupts (local_irq_save) is simply a matter of pulling the ICC2.Z
flag out of the CCR register, shifting it down and masking it off. This
gives a result of 0 if interrupts were enabled and 1 if they weren't.
Restoring interrupts (local_irq_restore) is then a matter of taking the
saved value mentioned previously and XOR'ing it against 1. If it was one,
the result will be zero, and if it was zero the result will be non-zero.
This result is then used to affect the ICC2.Z flag directly (it is a
condition code flag after all). An XOR instruction does not affect the
Carry flag, and so that bit of state is unchanged. The two flags can then
be sampled to see if they're both zero using the trap (TIHI) as for the
unconditional reenablement (local_irq_enable).
This patch also:
(1) Modifies the debugging stub (break.S) to handle single-stepping crossing
into the trap #2 handler and into virtually disabled interrupts.
(2) Removes superseded fixup pointers from the second instructions in the trap
tables (there's no a separate fixup table for this).
(3) Declares the trap #3 vector for use in .org directives in the trap table.
(4) Moves irq_enter() and irq_exit() in do_IRQ() to avoid problems with
virtual interrupt handling, and removes the duplicate code that has now
been folded into irq_exit() (softirq and preemption handling).
(5) Tells the compiler in the arch Makefile that ICC2 is now reserved.
(6) Documents the in-kernel ABI, including the virtual interrupts.
(7) Renames the old irq management functions to different names.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-02-14 21:53:20 +00:00
|
|
|
irq_enter();
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
generic_handle_irq(__get_IRL());
|
[PATCH] FRV: Use virtual interrupt disablement
Make the FRV arch use virtual interrupt disablement because accesses to the
processor status register (PSR) are relatively slow and because we will
soon have the need to deal with multiple interrupt controls at the same
time (separate h/w and inter-core interrupts).
The way this is done is to dedicate one of the four integer condition code
registers (ICC2) to maintaining a virtual interrupt disablement state
whilst inside the kernel. This uses the ICC2.Z flag (Zero) to indicate
whether the interrupts are virtually disabled and the ICC2.C flag (Carry)
to indicate whether the interrupts are physically disabled.
ICC2.Z is set to indicate interrupts are virtually disabled. ICC2.C is set
to indicate interrupts are physically enabled. Under normal running
conditions Z==0 and C==1.
Disabling interrupts with local_irq_disable() doesn't then actually
physically disable interrupts - it merely sets ICC2.Z to 1. Should an
interrupt then happen, the exception prologue will note ICC2.Z is set and
branch out of line using one instruction (an unlikely BEQ). Here it will
physically disable interrupts and clear ICC2.C.
When it comes time to enable interrupts (local_irq_enable()), this simply
clears the ICC2.Z flag and invokes a trap #2 if both Z and C flags are
clear (the HI integer condition). This can be done with the TIHI
conditional trap instruction.
The trap then physically reenables interrupts and sets ICC2.C again. Upon
returning the interrupt will be taken as interrupts will then be enabled.
Note that whilst processing the trap, the whole exceptions system is
disabled, and so an interrupt can't happen till it returns.
If no pending interrupt had happened, ICC2.C would still be set, the HI
condition would not be fulfilled, and no trap will happen.
Saving interrupts (local_irq_save) is simply a matter of pulling the ICC2.Z
flag out of the CCR register, shifting it down and masking it off. This
gives a result of 0 if interrupts were enabled and 1 if they weren't.
Restoring interrupts (local_irq_restore) is then a matter of taking the
saved value mentioned previously and XOR'ing it against 1. If it was one,
the result will be zero, and if it was zero the result will be non-zero.
This result is then used to affect the ICC2.Z flag directly (it is a
condition code flag after all). An XOR instruction does not affect the
Carry flag, and so that bit of state is unchanged. The two flags can then
be sampled to see if they're both zero using the trap (TIHI) as for the
unconditional reenablement (local_irq_enable).
This patch also:
(1) Modifies the debugging stub (break.S) to handle single-stepping crossing
into the trap #2 handler and into virtually disabled interrupts.
(2) Removes superseded fixup pointers from the second instructions in the trap
tables (there's no a separate fixup table for this).
(3) Declares the trap #3 vector for use in .org directives in the trap table.
(4) Moves irq_enter() and irq_exit() in do_IRQ() to avoid problems with
virtual interrupt handling, and removes the duplicate code that has now
been folded into irq_exit() (softirq and preemption handling).
(5) Tells the compiler in the arch Makefile that ICC2 is now reserved.
(6) Documents the in-kernel ABI, including the virtual interrupts.
(7) Renames the old irq management functions to different names.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-02-14 21:53:20 +00:00
|
|
|
irq_exit();
|
2006-09-26 06:32:04 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* handles all NMIs when not co-opted by the debugger
|
|
|
|
* - registers are referred to by the __frame variable (GR28)
|
|
|
|
*/
|
|
|
|
asmlinkage void do_NMI(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-09-26 06:32:04 +00:00
|
|
|
* initialise the interrupt system
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2006-09-26 06:32:04 +00:00
|
|
|
void __init init_IRQ(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-09-26 06:32:04 +00:00
|
|
|
int level;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-26 06:32:04 +00:00
|
|
|
for (level = 1; level <= 14; level++)
|
2011-03-24 15:38:49 +00:00
|
|
|
irq_set_chip_and_handler(level, &frv_cpu_pic,
|
2006-09-26 06:32:04 +00:00
|
|
|
handle_level_irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-03-24 15:38:49 +00:00
|
|
|
irq_set_handler(IRQ_CPU_TIMER0, handle_edge_irq);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-26 06:32:04 +00:00
|
|
|
/* set the trigger levels for internal interrupt sources
|
|
|
|
* - timers all falling-edge
|
|
|
|
* - ERR0 is rising-edge
|
|
|
|
* - all others are high-level
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2006-09-26 06:32:04 +00:00
|
|
|
__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
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
fpga_init();
|
|
|
|
#ifdef CONFIG_FUJITSU_MB93493
|
2006-09-26 06:32:04 +00:00
|
|
|
mb93493_init();
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
2006-09-26 06:32:04 +00:00
|
|
|
}
|