2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* Basic EISA bus support for the SGI Indigo-2.
|
|
|
|
*
|
|
|
|
* (C) 2002 Pascal Dameme <netinet@freesurf.fr>
|
|
|
|
* and Marc Zyngier <mzyngier@freesurf.fr>
|
|
|
|
*
|
|
|
|
* This code is released under both the GPL version 2 and BSD
|
|
|
|
* licenses. Either license may be used.
|
|
|
|
*
|
|
|
|
* This code offers a very basic support for this EISA bus present in
|
|
|
|
* the SGI Indigo-2. It currently only supports PIO (forget about DMA
|
|
|
|
* for the time being). This is enough for a low-end ethernet card,
|
|
|
|
* but forget about your favorite SCSI card...
|
|
|
|
*
|
|
|
|
* TODO :
|
|
|
|
* - Fix bugs...
|
|
|
|
* - Add ISA support
|
|
|
|
* - Add DMA (yeah, right...).
|
|
|
|
* - Fix more bugs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/eisa.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/delay.h>
|
2005-08-31 11:55:16 -04:00
|
|
|
#include <asm/io.h>
|
2005-04-16 18:20:36 -04:00
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/mipsregs.h>
|
|
|
|
#include <asm/addrspace.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/sgi/ioc.h>
|
|
|
|
#include <asm/sgi/mc.h>
|
|
|
|
#include <asm/sgi/ip22.h>
|
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
/* I2 has four EISA slots. */
|
|
|
|
#define IP22_EISA_MAX_SLOTS 4
|
2005-04-16 18:20:36 -04:00
|
|
|
#define EISA_MAX_IRQ 16
|
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
#define EIU_MODE_REG 0x0001ffc0
|
|
|
|
#define EIU_STAT_REG 0x0001ffc4
|
|
|
|
#define EIU_PREMPT_REG 0x0001ffc8
|
|
|
|
#define EIU_QUIET_REG 0x0001ffcc
|
|
|
|
#define EIU_INTRPT_ACK 0x00010004
|
|
|
|
|
|
|
|
static char __init *decode_eisa_sig(unsigned long addr)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2005-08-31 11:55:16 -04:00
|
|
|
static char sig_str[EISA_SIG_LEN];
|
|
|
|
u8 sig[4];
|
|
|
|
u16 rev;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
sig[i] = inb (addr + i);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
if (!i && (sig[0] & 0x80))
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
sig_str[0] = ((sig[0] >> 2) & 0x1f) + ('A' - 1);
|
|
|
|
sig_str[1] = (((sig[0] & 3) << 3) | (sig[1] >> 5)) + ('A' - 1);
|
|
|
|
sig_str[2] = (sig[1] & 0x1f) + ('A' - 1);
|
|
|
|
rev = (sig[2] << 8) | sig[3];
|
|
|
|
sprintf(sig_str + 3, "%04X", rev);
|
|
|
|
|
|
|
|
return sig_str;
|
|
|
|
}
|
|
|
|
|
2006-10-07 14:44:33 -04:00
|
|
|
static irqreturn_t ip22_eisa_intr(int irq, void *dev_id)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
|
|
|
u8 eisa_irq;
|
|
|
|
u8 dma1, dma2;
|
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
eisa_irq = inb(EIU_INTRPT_ACK);
|
|
|
|
dma1 = inb(EISA_DMA1_STATUS);
|
|
|
|
dma2 = inb(EISA_DMA2_STATUS);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
if (eisa_irq < EISA_MAX_IRQ) {
|
2006-10-07 14:44:33 -04:00
|
|
|
do_IRQ(eisa_irq);
|
2005-08-31 11:55:16 -04:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Oops, Bad Stuff Happened... */
|
|
|
|
printk(KERN_ERR "eisa_irq %d out of bound\n", eisa_irq);
|
|
|
|
|
|
|
|
outb(0x20, EISA_INT2_CTRL);
|
|
|
|
outb(0x20, EISA_INT1_CTRL);
|
2006-10-07 14:44:33 -04:00
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
return IRQ_NONE;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void enable_eisa1_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
u8 mask;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
mask = inb(EISA_INT1_MASK);
|
2005-04-16 18:20:36 -04:00
|
|
|
mask &= ~((u8) (1 << irq));
|
2005-08-31 11:55:16 -04:00
|
|
|
outb(mask, EISA_INT1_MASK);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int startup_eisa1_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
u8 edge;
|
|
|
|
|
|
|
|
/* Only use edge interrupts for EISA */
|
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
edge = inb(EISA_INT1_EDGE_LEVEL);
|
2005-04-16 18:20:36 -04:00
|
|
|
edge &= ~((u8) (1 << irq));
|
2005-08-31 11:55:16 -04:00
|
|
|
outb(edge, EISA_INT1_EDGE_LEVEL);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
enable_eisa1_irq(irq);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void disable_eisa1_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
u8 mask;
|
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
mask = inb(EISA_INT1_MASK);
|
2005-04-16 18:20:36 -04:00
|
|
|
mask |= ((u8) (1 << irq));
|
2005-08-31 11:55:16 -04:00
|
|
|
outb(mask, EISA_INT1_MASK);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define shutdown_eisa1_irq disable_eisa1_irq
|
|
|
|
|
|
|
|
static void mask_and_ack_eisa1_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
disable_eisa1_irq(irq);
|
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
outb(0x20, EISA_INT1_CTRL);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void end_eisa1_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
|
|
|
|
enable_eisa1_irq(irq);
|
|
|
|
}
|
|
|
|
|
2006-07-02 09:41:42 -04:00
|
|
|
static struct irq_chip ip22_eisa1_irq_type = {
|
2005-04-16 18:20:36 -04:00
|
|
|
.typename = "IP22 EISA",
|
|
|
|
.startup = startup_eisa1_irq,
|
|
|
|
.shutdown = shutdown_eisa1_irq,
|
|
|
|
.enable = enable_eisa1_irq,
|
|
|
|
.disable = disable_eisa1_irq,
|
|
|
|
.ack = mask_and_ack_eisa1_irq,
|
|
|
|
.end = end_eisa1_irq,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void enable_eisa2_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
u8 mask;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
mask = inb(EISA_INT2_MASK);
|
2005-04-16 18:20:36 -04:00
|
|
|
mask &= ~((u8) (1 << (irq - 8)));
|
2005-08-31 11:55:16 -04:00
|
|
|
outb(mask, EISA_INT2_MASK);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int startup_eisa2_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
u8 edge;
|
|
|
|
|
|
|
|
/* Only use edge interrupts for EISA */
|
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
edge = inb(EISA_INT2_EDGE_LEVEL);
|
2005-04-16 18:20:36 -04:00
|
|
|
edge &= ~((u8) (1 << (irq - 8)));
|
2005-08-31 11:55:16 -04:00
|
|
|
outb(edge, EISA_INT2_EDGE_LEVEL);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
enable_eisa2_irq(irq);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void disable_eisa2_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
u8 mask;
|
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
mask = inb(EISA_INT2_MASK);
|
2005-04-16 18:20:36 -04:00
|
|
|
mask |= ((u8) (1 << (irq - 8)));
|
2005-08-31 11:55:16 -04:00
|
|
|
outb(mask, EISA_INT2_MASK);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define shutdown_eisa2_irq disable_eisa2_irq
|
|
|
|
|
|
|
|
static void mask_and_ack_eisa2_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
disable_eisa2_irq(irq);
|
|
|
|
|
2005-08-31 11:55:16 -04:00
|
|
|
outb(0x20, EISA_INT2_CTRL);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void end_eisa2_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
|
|
|
|
enable_eisa2_irq(irq);
|
|
|
|
}
|
|
|
|
|
2006-07-02 09:41:42 -04:00
|
|
|
static struct irq_chip ip22_eisa2_irq_type = {
|
2005-04-16 18:20:36 -04:00
|
|
|
.typename = "IP22 EISA",
|
|
|
|
.startup = startup_eisa2_irq,
|
|
|
|
.shutdown = shutdown_eisa2_irq,
|
|
|
|
.enable = enable_eisa2_irq,
|
|
|
|
.disable = disable_eisa2_irq,
|
|
|
|
.ack = mask_and_ack_eisa2_irq,
|
|
|
|
.end = end_eisa2_irq,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct irqaction eisa_action = {
|
|
|
|
.handler = ip22_eisa_intr,
|
|
|
|
.name = "EISA",
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct irqaction cascade_action = {
|
|
|
|
.handler = no_action,
|
|
|
|
.name = "EISA cascade",
|
|
|
|
};
|
|
|
|
|
|
|
|
int __init ip22_eisa_init(void)
|
|
|
|
{
|
|
|
|
int i, c;
|
|
|
|
char *str;
|
2005-09-03 18:56:17 -04:00
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
if (!(sgimc->systemid & SGIMC_SYSID_EPRESENT)) {
|
|
|
|
printk(KERN_INFO "EISA: bus not present.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_INFO "EISA: Probing bus...\n");
|
2005-08-31 11:55:16 -04:00
|
|
|
for (c = 0, i = 1; i <= IP22_EISA_MAX_SLOTS; i++) {
|
|
|
|
if ((str = decode_eisa_sig(0x1000 * i + EISA_VENDOR_ID_OFFSET))) {
|
2005-04-16 18:20:36 -04:00
|
|
|
printk(KERN_INFO "EISA: slot %d : %s detected.\n",
|
|
|
|
i, str);
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printk(KERN_INFO "EISA: Detected %d card%s.\n", c, c < 2 ? "" : "s");
|
|
|
|
#ifdef CONFIG_ISA
|
|
|
|
printk(KERN_INFO "ISA support compiled in.\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Warning : BlackMagicAhead(tm).
|
|
|
|
Please wave your favorite dead chicken over the busses */
|
|
|
|
|
|
|
|
/* First say hello to the EIU */
|
2005-08-31 11:55:16 -04:00
|
|
|
outl(0x0000FFFF, EIU_PREMPT_REG);
|
|
|
|
outl(1, EIU_QUIET_REG);
|
|
|
|
outl(0x40f3c07F, EIU_MODE_REG);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* Now be nice to the EISA chipset */
|
2005-08-31 11:55:16 -04:00
|
|
|
outb(1, EISA_EXT_NMI_RESET_CTRL);
|
|
|
|
udelay(50); /* Wait long enough for the dust to settle */
|
|
|
|
outb(0, EISA_EXT_NMI_RESET_CTRL);
|
|
|
|
outb(0x11, EISA_INT1_CTRL);
|
|
|
|
outb(0x11, EISA_INT2_CTRL);
|
|
|
|
outb(0, EISA_INT1_MASK);
|
|
|
|
outb(8, EISA_INT2_MASK);
|
|
|
|
outb(4, EISA_INT1_MASK);
|
|
|
|
outb(2, EISA_INT2_MASK);
|
|
|
|
outb(1, EISA_INT1_MASK);
|
|
|
|
outb(1, EISA_INT2_MASK);
|
|
|
|
outb(0xfb, EISA_INT1_MASK);
|
|
|
|
outb(0xff, EISA_INT2_MASK);
|
|
|
|
outb(0, EISA_DMA2_WRITE_SINGLE);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
for (i = SGINT_EISA; i < (SGINT_EISA + EISA_MAX_IRQ); i++) {
|
|
|
|
irq_desc[i].status = IRQ_DISABLED;
|
|
|
|
irq_desc[i].action = 0;
|
|
|
|
irq_desc[i].depth = 1;
|
|
|
|
if (i < (SGINT_EISA + 8))
|
[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[i].chip = &ip22_eisa1_irq_type;
|
2005-04-16 18:20:36 -04:00
|
|
|
else
|
[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[i].chip = &ip22_eisa2_irq_type;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Cannot use request_irq because of kmalloc not being ready at such
|
|
|
|
* an early stage. Yes, I've been bitten... */
|
|
|
|
setup_irq(SGI_EISA_IRQ, &eisa_action);
|
|
|
|
setup_irq(SGINT_EISA + 2, &cascade_action);
|
|
|
|
|
|
|
|
EISA_bus = 1;
|
|
|
|
return 0;
|
|
|
|
}
|