2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Interrupt management for most GSC and related devices.
|
|
|
|
*
|
|
|
|
* (c) Copyright 1999 Alex deVries for The Puffin Group
|
|
|
|
* (c) Copyright 1999 Grant Grundler for Hewlett-Packard
|
|
|
|
* (c) Copyright 1999 Matthew Wilcox
|
|
|
|
* (c) Copyright 2000 Helge Deller
|
|
|
|
* (c) Copyright 2001 Matthew Wilcox for Hewlett-Packard
|
|
|
|
*
|
|
|
|
* 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/bitops.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
#include <asm/hardware.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
#include "gsc.h"
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define DEBPRINTK printk
|
|
|
|
#else
|
|
|
|
#define DEBPRINTK(x,...)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int gsc_alloc_irq(struct gsc_irq *i)
|
|
|
|
{
|
|
|
|
int irq = txn_alloc_irq(GSC_EIM_WIDTH);
|
|
|
|
if (irq < 0) {
|
|
|
|
printk("cannot get irq\n");
|
|
|
|
return irq;
|
|
|
|
}
|
|
|
|
|
|
|
|
i->txn_addr = txn_alloc_addr(irq);
|
|
|
|
i->txn_data = txn_alloc_data(irq);
|
|
|
|
i->irq = irq;
|
|
|
|
|
|
|
|
return irq;
|
|
|
|
}
|
|
|
|
|
|
|
|
int gsc_claim_irq(struct gsc_irq *i, int irq)
|
|
|
|
{
|
|
|
|
int c = irq;
|
|
|
|
|
|
|
|
irq += CPU_IRQ_BASE; /* virtualize the IRQ first */
|
|
|
|
|
|
|
|
irq = txn_claim_irq(irq);
|
|
|
|
if (irq < 0) {
|
|
|
|
printk("cannot claim irq %d\n", c);
|
|
|
|
return irq;
|
|
|
|
}
|
|
|
|
|
|
|
|
i->txn_addr = txn_alloc_addr(irq);
|
|
|
|
i->txn_data = txn_alloc_data(irq);
|
|
|
|
i->irq = irq;
|
|
|
|
|
|
|
|
return irq;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(gsc_alloc_irq);
|
|
|
|
EXPORT_SYMBOL(gsc_claim_irq);
|
|
|
|
|
|
|
|
/* Common interrupt demultiplexer used by Asp, Lasi & Wax. */
|
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 07:55:46 -06:00
|
|
|
irqreturn_t gsc_asic_intr(int gsc_asic_irq, void *dev)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
unsigned long irr;
|
|
|
|
struct gsc_asic *gsc_asic = dev;
|
|
|
|
|
|
|
|
irr = gsc_readl(gsc_asic->hpa + OFFSET_IRR);
|
|
|
|
if (irr == 0)
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
|
|
|
DEBPRINTK("%s intr, mask=0x%x\n", gsc_asic->name, irr);
|
|
|
|
|
|
|
|
do {
|
|
|
|
int local_irq = __ffs(irr);
|
|
|
|
unsigned int irq = gsc_asic->global_irq[local_irq];
|
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 07:55:46 -06:00
|
|
|
__do_IRQ(irq);
|
2005-04-16 16:20:36 -06:00
|
|
|
irr &= ~(1 << local_irq);
|
|
|
|
} while (irr);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
int gsc_find_local_irq(unsigned int irq, int *global_irqs, int limit)
|
|
|
|
{
|
|
|
|
int local_irq;
|
|
|
|
|
|
|
|
for (local_irq = 0; local_irq < limit; local_irq++) {
|
|
|
|
if (global_irqs[local_irq] == irq)
|
|
|
|
return local_irq;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NO_IRQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gsc_asic_disable_irq(unsigned int irq)
|
|
|
|
{
|
[PATCH] genirq: rename desc->handler to desc->chip
This patch-queue improves the generic IRQ layer to be truly generic, by adding
various abstractions and features to it, without impacting existing
functionality.
While the queue can be best described as "fix and improve everything in the
generic IRQ layer that we could think of", and thus it consists of many
smaller features and lots of cleanups, the one feature that stands out most is
the new 'irq chip' abstraction.
The irq-chip abstraction is about describing and coding and IRQ controller
driver by mapping its raw hardware capabilities [and quirks, if needed] in a
straightforward way, without having to think about "IRQ flow"
(level/edge/etc.) type of details.
This stands in contrast with the current 'irq-type' model of genirq
architectures, which 'mixes' raw hardware capabilities with 'flow' details.
The patchset supports both types of irq controller designs at once, and
converts i386 and x86_64 to the new irq-chip design.
As a bonus side-effect of the irq-chip approach, chained interrupt controllers
(master/slave PIC constructs, etc.) are now supported by design as well.
The end result of this patchset intends to be simpler architecture-level code
and more consolidation between architectures.
We reused many bits of code and many concepts from Russell King's ARM IRQ
layer, the merging of which was one of the motivations for this patchset.
This patch:
rename desc->handler to desc->chip.
Originally i did not want to do this, because it's a big patch. But having
both "desc->handler", "desc->handle_irq" and "action->handler" caused a
large degree of confusion and made the code appear alot less clean than it
truly is.
I have also attempted a dual approach as well by introducing a
desc->chip alias - but that just wasnt robust enough and broke
frequently.
So lets get over with this quickly. The conversion was done automatically
via scripts and converts all the code in the kernel.
This renaming patch is the first one amongst the patches, so that the
remaining patches can stay flexible and can be merged and split up
without having some big monolithic patch act as a merge barrier.
[akpm@osdl.org: build fix]
[akpm@osdl.org: another build fix]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-29 03:24:36 -06:00
|
|
|
struct gsc_asic *irq_dev = irq_desc[irq].chip_data;
|
2005-04-16 16:20:36 -06:00
|
|
|
int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32);
|
|
|
|
u32 imr;
|
|
|
|
|
2008-05-14 17:21:56 -06:00
|
|
|
DEBPRINTK(KERN_DEBUG "%s(%d) %s: IMR 0x%x\n", __func__, irq,
|
2005-04-16 16:20:36 -06:00
|
|
|
irq_dev->name, imr);
|
|
|
|
|
|
|
|
/* Disable the IRQ line by clearing the bit in the IMR */
|
|
|
|
imr = gsc_readl(irq_dev->hpa + OFFSET_IMR);
|
|
|
|
imr &= ~(1 << local_irq);
|
|
|
|
gsc_writel(imr, irq_dev->hpa + OFFSET_IMR);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gsc_asic_enable_irq(unsigned int irq)
|
|
|
|
{
|
[PATCH] genirq: rename desc->handler to desc->chip
This patch-queue improves the generic IRQ layer to be truly generic, by adding
various abstractions and features to it, without impacting existing
functionality.
While the queue can be best described as "fix and improve everything in the
generic IRQ layer that we could think of", and thus it consists of many
smaller features and lots of cleanups, the one feature that stands out most is
the new 'irq chip' abstraction.
The irq-chip abstraction is about describing and coding and IRQ controller
driver by mapping its raw hardware capabilities [and quirks, if needed] in a
straightforward way, without having to think about "IRQ flow"
(level/edge/etc.) type of details.
This stands in contrast with the current 'irq-type' model of genirq
architectures, which 'mixes' raw hardware capabilities with 'flow' details.
The patchset supports both types of irq controller designs at once, and
converts i386 and x86_64 to the new irq-chip design.
As a bonus side-effect of the irq-chip approach, chained interrupt controllers
(master/slave PIC constructs, etc.) are now supported by design as well.
The end result of this patchset intends to be simpler architecture-level code
and more consolidation between architectures.
We reused many bits of code and many concepts from Russell King's ARM IRQ
layer, the merging of which was one of the motivations for this patchset.
This patch:
rename desc->handler to desc->chip.
Originally i did not want to do this, because it's a big patch. But having
both "desc->handler", "desc->handle_irq" and "action->handler" caused a
large degree of confusion and made the code appear alot less clean than it
truly is.
I have also attempted a dual approach as well by introducing a
desc->chip alias - but that just wasnt robust enough and broke
frequently.
So lets get over with this quickly. The conversion was done automatically
via scripts and converts all the code in the kernel.
This renaming patch is the first one amongst the patches, so that the
remaining patches can stay flexible and can be merged and split up
without having some big monolithic patch act as a merge barrier.
[akpm@osdl.org: build fix]
[akpm@osdl.org: another build fix]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-29 03:24:36 -06:00
|
|
|
struct gsc_asic *irq_dev = irq_desc[irq].chip_data;
|
2005-04-16 16:20:36 -06:00
|
|
|
int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32);
|
|
|
|
u32 imr;
|
|
|
|
|
2008-05-14 17:21:56 -06:00
|
|
|
DEBPRINTK(KERN_DEBUG "%s(%d) %s: IMR 0x%x\n", __func__, irq,
|
2005-04-16 16:20:36 -06:00
|
|
|
irq_dev->name, imr);
|
|
|
|
|
|
|
|
/* Enable the IRQ line by setting the bit in the IMR */
|
|
|
|
imr = gsc_readl(irq_dev->hpa + OFFSET_IMR);
|
|
|
|
imr |= 1 << local_irq;
|
|
|
|
gsc_writel(imr, irq_dev->hpa + OFFSET_IMR);
|
|
|
|
/*
|
|
|
|
* FIXME: read IPR to make sure the IRQ isn't already pending.
|
|
|
|
* If so, we need to read IRR and manually call do_irq().
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int gsc_asic_startup_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
gsc_asic_enable_irq(irq);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct hw_interrupt_type gsc_asic_interrupt_type = {
|
|
|
|
.typename = "GSC-ASIC",
|
|
|
|
.startup = gsc_asic_startup_irq,
|
|
|
|
.shutdown = gsc_asic_disable_irq,
|
|
|
|
.enable = gsc_asic_enable_irq,
|
|
|
|
.disable = gsc_asic_disable_irq,
|
|
|
|
.ack = no_ack_irq,
|
|
|
|
.end = no_end_irq,
|
|
|
|
};
|
|
|
|
|
|
|
|
int gsc_assign_irq(struct hw_interrupt_type *type, void *data)
|
|
|
|
{
|
|
|
|
static int irq = GSC_IRQ_BASE;
|
|
|
|
|
|
|
|
if (irq > GSC_IRQ_MAX)
|
|
|
|
return NO_IRQ;
|
|
|
|
|
[PATCH] genirq: rename desc->handler to desc->chip
This patch-queue improves the generic IRQ layer to be truly generic, by adding
various abstractions and features to it, without impacting existing
functionality.
While the queue can be best described as "fix and improve everything in the
generic IRQ layer that we could think of", and thus it consists of many
smaller features and lots of cleanups, the one feature that stands out most is
the new 'irq chip' abstraction.
The irq-chip abstraction is about describing and coding and IRQ controller
driver by mapping its raw hardware capabilities [and quirks, if needed] in a
straightforward way, without having to think about "IRQ flow"
(level/edge/etc.) type of details.
This stands in contrast with the current 'irq-type' model of genirq
architectures, which 'mixes' raw hardware capabilities with 'flow' details.
The patchset supports both types of irq controller designs at once, and
converts i386 and x86_64 to the new irq-chip design.
As a bonus side-effect of the irq-chip approach, chained interrupt controllers
(master/slave PIC constructs, etc.) are now supported by design as well.
The end result of this patchset intends to be simpler architecture-level code
and more consolidation between architectures.
We reused many bits of code and many concepts from Russell King's ARM IRQ
layer, the merging of which was one of the motivations for this patchset.
This patch:
rename desc->handler to desc->chip.
Originally i did not want to do this, because it's a big patch. But having
both "desc->handler", "desc->handle_irq" and "action->handler" caused a
large degree of confusion and made the code appear alot less clean than it
truly is.
I have also attempted a dual approach as well by introducing a
desc->chip alias - but that just wasnt robust enough and broke
frequently.
So lets get over with this quickly. The conversion was done automatically
via scripts and converts all the code in the kernel.
This renaming patch is the first one amongst the patches, so that the
remaining patches can stay flexible and can be merged and split up
without having some big monolithic patch act as a merge barrier.
[akpm@osdl.org: build fix]
[akpm@osdl.org: another build fix]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-29 03:24:36 -06:00
|
|
|
irq_desc[irq].chip = type;
|
|
|
|
irq_desc[irq].chip_data = data;
|
2005-04-16 16:20:36 -06:00
|
|
|
return irq++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gsc_asic_assign_irq(struct gsc_asic *asic, int local_irq, int *irqp)
|
|
|
|
{
|
|
|
|
int irq = asic->global_irq[local_irq];
|
|
|
|
|
|
|
|
if (irq <= 0) {
|
|
|
|
irq = gsc_assign_irq(&gsc_asic_interrupt_type, asic);
|
|
|
|
if (irq == NO_IRQ)
|
|
|
|
return;
|
|
|
|
|
|
|
|
asic->global_irq[local_irq] = irq;
|
|
|
|
}
|
|
|
|
*irqp = irq;
|
|
|
|
}
|
|
|
|
|
2005-10-21 20:33:38 -06:00
|
|
|
static struct device *next_device(struct klist_iter *i)
|
|
|
|
{
|
|
|
|
struct klist_node * n = klist_next(i);
|
|
|
|
return n ? container_of(n, struct device, knode_parent) : NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl,
|
|
|
|
void (*choose_irq)(struct parisc_device *, void *))
|
|
|
|
{
|
|
|
|
struct device *dev;
|
2005-10-21 20:33:38 -06:00
|
|
|
struct klist_iter i;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-10-21 20:33:38 -06:00
|
|
|
klist_iter_init(&parent->dev.klist_children, &i);
|
|
|
|
while ((dev = next_device(&i))) {
|
2005-04-16 16:20:36 -06:00
|
|
|
struct parisc_device *padev = to_parisc_device(dev);
|
|
|
|
|
|
|
|
/* work-around for 715/64 and others which have parent
|
|
|
|
at path [5] and children at path [5/0/x] */
|
|
|
|
if (padev->id.hw_type == HPHW_FAULTY)
|
|
|
|
return gsc_fixup_irqs(padev, ctrl, choose_irq);
|
|
|
|
choose_irq(padev, ctrl);
|
|
|
|
}
|
2005-10-21 20:33:38 -06:00
|
|
|
klist_iter_exit(&i);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int gsc_common_setup(struct parisc_device *parent, struct gsc_asic *gsc_asic)
|
|
|
|
{
|
|
|
|
struct resource *res;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
gsc_asic->gsc = parent;
|
|
|
|
|
|
|
|
/* Initialise local irq -> global irq mapping */
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
gsc_asic->global_irq[i] = NO_IRQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate resource region */
|
|
|
|
res = request_mem_region(gsc_asic->hpa, 0x100000, gsc_asic->name);
|
|
|
|
if (res) {
|
|
|
|
res->flags = IORESOURCE_MEM; /* do not mark it busy ! */
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
printk(KERN_WARNING "%s IRQ %d EIM 0x%x", gsc_asic->name,
|
|
|
|
parent->irq, gsc_asic->eim);
|
|
|
|
if (gsc_readl(gsc_asic->hpa + OFFSET_IMR))
|
|
|
|
printk(" IMR is non-zero! (0x%x)",
|
|
|
|
gsc_readl(gsc_asic->hpa + OFFSET_IMR));
|
|
|
|
printk("\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern struct parisc_driver lasi_driver;
|
|
|
|
extern struct parisc_driver asp_driver;
|
|
|
|
extern struct parisc_driver wax_driver;
|
|
|
|
|
|
|
|
void __init gsc_init(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_GSC_LASI
|
|
|
|
register_parisc_driver(&lasi_driver);
|
|
|
|
register_parisc_driver(&asp_driver);
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_GSC_WAX
|
|
|
|
register_parisc_driver(&wax_driver);
|
|
|
|
#endif
|
|
|
|
}
|