2005-04-16 18:20:36 -04:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* setup_voyagergx.c: */
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* 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.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
Copyright 2003 (c) Lineo uSolutions,Inc.
|
|
|
|
*/
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/init.h>
|
2006-10-19 03:16:18 -04:00
|
|
|
#include <linux/io.h>
|
2006-09-27 04:17:27 -04:00
|
|
|
#include <asm/voyagergx.h>
|
2006-10-19 03:16:18 -04:00
|
|
|
#include <asm/rts7751r2d.h>
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
static void disable_voyagergx_irq(unsigned int irq)
|
|
|
|
{
|
2006-09-27 05:03:34 -04:00
|
|
|
unsigned long val;
|
|
|
|
unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2007-02-15 04:20:52 -05:00
|
|
|
pr_debug("disable_voyagergx_irq(%d): mask=%x\n", irq, mask);
|
|
|
|
val = readl((void __iomem *)VOYAGER_INT_MASK);
|
|
|
|
val &= ~mask;
|
|
|
|
writel(val, (void __iomem *)VOYAGER_INT_MASK);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void enable_voyagergx_irq(unsigned int irq)
|
|
|
|
{
|
2007-02-15 04:20:52 -05:00
|
|
|
unsigned long val;
|
|
|
|
unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2007-02-15 04:20:52 -05:00
|
|
|
pr_debug("disable_voyagergx_irq(%d): mask=%x\n", irq, mask);
|
|
|
|
val = readl((void __iomem *)VOYAGER_INT_MASK);
|
|
|
|
val |= mask;
|
|
|
|
writel(val, (void __iomem *)VOYAGER_INT_MASK);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mask_and_ack_voyagergx(unsigned int irq)
|
|
|
|
{
|
|
|
|
disable_voyagergx_irq(irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void end_voyagergx_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
|
|
|
|
enable_voyagergx_irq(irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int startup_voyagergx_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
enable_voyagergx_irq(irq);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shutdown_voyagergx_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
disable_voyagergx_irq(irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct hw_interrupt_type voyagergx_irq_type = {
|
2007-02-15 04:20:52 -05:00
|
|
|
.typename = "VOYAGERGX-IRQ",
|
|
|
|
.startup = startup_voyagergx_irq,
|
|
|
|
.shutdown = shutdown_voyagergx_irq,
|
|
|
|
.enable = enable_voyagergx_irq,
|
|
|
|
.disable = disable_voyagergx_irq,
|
|
|
|
.ack = mask_and_ack_voyagergx,
|
|
|
|
.end = end_voyagergx_irq,
|
2005-04-16 18:20:36 -04:00
|
|
|
};
|
|
|
|
|
2006-10-06 02:31:16 -04:00
|
|
|
static irqreturn_t voyagergx_interrupt(int irq, void *dev_id)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
|
|
|
printk(KERN_INFO
|
|
|
|
"VoyagerGX: spurious interrupt, status: 0x%x\n",
|
2007-02-15 04:20:52 -05:00
|
|
|
(unsigned int)readl((void __iomem *)INT_STATUS));
|
2005-04-16 18:20:36 -04:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
int (*func)(int, void *);
|
|
|
|
void *dev;
|
|
|
|
} voyagergx_demux[VOYAGER_IRQ_NUM];
|
|
|
|
|
|
|
|
void voyagergx_register_irq_demux(int irq,
|
|
|
|
int (*demux)(int irq, void *dev), void *dev)
|
|
|
|
{
|
2007-02-15 04:20:52 -05:00
|
|
|
voyagergx_demux[irq - VOYAGER_IRQ_BASE].func = demux;
|
|
|
|
voyagergx_demux[irq - VOYAGER_IRQ_BASE].dev = dev;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void voyagergx_unregister_irq_demux(int irq)
|
|
|
|
{
|
2007-02-15 04:20:52 -05:00
|
|
|
voyagergx_demux[irq - VOYAGER_IRQ_BASE].func = 0;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int voyagergx_irq_demux(int irq)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (irq == IRQ_VOYAGER ) {
|
|
|
|
unsigned long i = 0, bit __attribute__ ((unused));
|
2007-02-15 04:20:52 -05:00
|
|
|
unsigned long val = readl((void __iomem *)INT_STATUS);
|
|
|
|
|
|
|
|
if (val & (1 << 1))
|
2005-04-16 18:20:36 -04:00
|
|
|
i = 1;
|
2007-02-15 04:20:52 -05:00
|
|
|
else if (val & (1 << 2))
|
2005-04-16 18:20:36 -04:00
|
|
|
i = 2;
|
2007-02-15 04:20:52 -05:00
|
|
|
else if (val & (1 << 6))
|
2005-04-16 18:20:36 -04:00
|
|
|
i = 6;
|
2007-02-15 04:20:52 -05:00
|
|
|
else if (val & (1 << 10))
|
2005-04-16 18:20:36 -04:00
|
|
|
i = 10;
|
2007-02-15 04:20:52 -05:00
|
|
|
else if (val & (1 << 11))
|
2005-04-16 18:20:36 -04:00
|
|
|
i = 11;
|
2007-02-15 04:20:52 -05:00
|
|
|
else if (val & (1 << 12))
|
2005-04-16 18:20:36 -04:00
|
|
|
i = 12;
|
2007-02-15 04:20:52 -05:00
|
|
|
else if (val & (1 << 17))
|
2005-04-16 18:20:36 -04:00
|
|
|
i = 17;
|
2007-02-15 04:20:52 -05:00
|
|
|
else
|
2005-04-16 18:20:36 -04:00
|
|
|
printk("Unexpected IRQ irq = %d status = 0x%08lx\n", irq, val);
|
2007-02-15 04:20:52 -05:00
|
|
|
pr_debug("voyagergx_irq_demux %d \n", i);
|
2005-04-16 18:20:36 -04:00
|
|
|
if (i < VOYAGER_IRQ_NUM) {
|
|
|
|
irq = VOYAGER_IRQ_BASE + i;
|
|
|
|
if (voyagergx_demux[i].func != 0)
|
|
|
|
irq = voyagergx_demux[i].func(irq, voyagergx_demux[i].dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return irq;
|
|
|
|
}
|
|
|
|
|
2006-02-01 06:06:05 -05:00
|
|
|
static struct irqaction irq0 = {
|
|
|
|
.name = "voyagergx",
|
|
|
|
.handler = voyagergx_interrupt,
|
2006-07-01 22:29:25 -04:00
|
|
|
.flags = IRQF_DISABLED,
|
2006-02-01 06:06:05 -05:00
|
|
|
.mask = CPU_MASK_NONE,
|
|
|
|
};
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
void __init setup_voyagergx_irq(void)
|
|
|
|
{
|
|
|
|
int i, flag;
|
|
|
|
|
|
|
|
printk(KERN_INFO "VoyagerGX configured at 0x%x on irq %d(mapped into %d to %d)\n",
|
|
|
|
VOYAGER_BASE,
|
|
|
|
IRQ_VOYAGER,
|
|
|
|
VOYAGER_IRQ_BASE,
|
|
|
|
VOYAGER_IRQ_BASE + VOYAGER_IRQ_NUM - 1);
|
|
|
|
|
|
|
|
for (i=0; i<VOYAGER_IRQ_NUM; i++) {
|
|
|
|
flag = 0;
|
|
|
|
switch (VOYAGER_IRQ_BASE + i) {
|
|
|
|
case VOYAGER_USBH_IRQ:
|
|
|
|
case VOYAGER_8051_IRQ:
|
|
|
|
case VOYAGER_UART0_IRQ:
|
|
|
|
case VOYAGER_UART1_IRQ:
|
|
|
|
case VOYAGER_AC97_IRQ:
|
|
|
|
flag = 1;
|
|
|
|
}
|
|
|
|
if (flag == 1)
|
[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 05:24:36 -04:00
|
|
|
irq_desc[VOYAGER_IRQ_BASE + i].chip = &voyagergx_irq_type;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
setup_irq(IRQ_VOYAGER, &irq0);
|
|
|
|
}
|