Skip to contentSkip to conversation

EISA interrupts

parisc-linux Matthew Wilcox 3 participants 4 messages Nov 3, 2001 – Nov 7, 2001

lore
Share & tools
lore
#0 lore raw

To get ISA/EISA interrupts working, I think we're going to need to program the 82357 ISP chip properly. You don't need any knowledge of the Mongoose/Wax chip to do this; all you need to know is that the byte read from 0xfc01f000 in eisa_irq is the byte generated by the 82357. Any volunteers? It should be straightforward, but I don't have time to do it myself. The data sheet's linked to from the p-l.org documentation page.

Signature · 1 line
Revolutions do not require corporate support.
#1 lore raw
Quoted 8 lines · On 2001.11.03 08:24 Matthew Wilcox wrote:

To get ISA/EISA interrupts working, I think we're going to need to program the 82357 ISP chip properly. You don't need any knowledge of the Mongoose/Wax chip to do this; all you need to know is that the byte read from 0xfc01f000 in eisa_irq is the byte generated by the 82357. Any volunteers? It should be straightforward, but I don't have time to do it myself. The data sheet's linked to from the p-l.org documentation page.

I'am on it since aboput a week,
I might have a few questions soon though.

/Daniel
--

#2 lore raw
In reply to Matthew Wilcox
Quoted 3 lines · On 2001.11.03 08:24 Matthew Wilcox wrote:

To get ISA/EISA interrupts working, I think we're going to need to program the 82357 ISP chip properly.

Here is the first version of my patch. It gives me interrupts to my ISA NE2000 clone.

In order to use an ISA card you will have to specify the IRQ as edge triggerd on the kernel command line options eisa_irq_edge.
Use eisa_irq_edge=9,10 to set IRQ 9 and 10 to edge mode.

The trig-mode of the irq lines could be read from the EEPROM on the system board but I have not yet fully understood its format, so I solved it with a commandline option for now.

/Daniel

Index: drivers/gsc/eisa.c
===================================================================
RCS file: /var/cvs/linux/drivers/gsc/eisa.c,v
retrieving revision 1.7

gsc/eisa.c +213 -23
diff -u -p -u -r1.7 eisa.c
@@ -27,7 +27,14 @@
 #include <asm/gsc.h>
 #include <asm/hardware.h>
 #include <asm/processor.h>
+#include <asm/delay.h>
 
+#if 0
+#define EISA_DBG(msg, arg... ) printk(KERN_ALERT "eisa: " msg , ## arg )
+#else
+#define EISA_DBG(msg, arg... )  
+#endif
+
 /* We can only have one EISA adapter in the system because neither
  * implementation can be flexed.
  */
@@ -36,7 +43,6 @@ struct eisa_ba {
 } eisa_dev;
 
 /* Port ops */
-
 static inline unsigned long eisa_permute(u16 port)
 {
 	if (port & 0x300) {
@@ -49,62 +55,126 @@ static inline unsigned long eisa_permute
 
 u8 eisa_in8(u16 port)
 {
-	if (EISA_bus)
-		return gsc_readb(eisa_permute(port));
-	return 0xff;
+	return gsc_readb(eisa_permute(port));
 }
 
 u16 eisa_in16(u16 port)
 {
-	if (EISA_bus)
-		return le16_to_cpu(gsc_readw(eisa_permute(port)));
-	return 0xffff;
+#if 0
+	return le16_to_cpu(gsc_readw(eisa_permute(port)));
+#else
+	return gsc_readw(eisa_permute(port));
+#endif	
 }
 
 u32 eisa_in32(u16 port)
 {
-	if (EISA_bus)
-		return le32_to_cpu(gsc_readl(eisa_permute(port)));
-	return 0xffffffff;
+#if 0
+	return le32_to_cpu(gsc_readl(eisa_permute(port)));
+#else
+	return gsc_readl(eisa_permute(port));
+#endif
 }
 
 void eisa_out8(u8 data, u16 port)
 {
-	if (EISA_bus)
-		gsc_writeb(data, eisa_permute(port));
+	gsc_writeb(data, eisa_permute(port));
 }
 
 void eisa_out16(u16 data, u16 port)
 {
-	if (EISA_bus)
-		gsc_writew(cpu_to_le16(data), eisa_permute(port));
+#if 0
+	gsc_writew(cpu_to_le16(data), eisa_permute(port));
+#else
+	gsc_writew(data, eisa_permute(port));
+#endif
 }
 
 void eisa_out32(u32 data, u16 port)
 {
-	if (EISA_bus)
-		gsc_writel(cpu_to_le32(data), eisa_permute(port));
+#if 0
+	gsc_writel(cpu_to_le32(data), eisa_permute(port));
+#else
+	gsc_writel(data, eisa_permute(port));
+#endif
 }
 
 /* Interrupt handling */
 
+/* cached interrupt mask registers */
+static int master_mask;
+static int slave_mask;
+
+/* the trig level can be set with the
+ * eisa_irq_edge=n,n,n commanlnine parameter 
+ * We should really read this from the EEPROM 
+ * in the furure. 
+ */
+/* irq 13,8,2,1,0 must be edge */
+static unsigned int eisa_irq_level=0xdef8; /* these are to be level-trigged */
+
+
+/* called by free irq */
 static void eisa_disable_irq(void *irq_dev, int irq)
 {
+        EISA_DBG("disable irq %d\n", irq);
+        /* just mask for now */
+        if (irq & 8) {
+		slave_mask |= (1 << (irq&7));
+		eisa_out8(slave_mask, 0xa1);
+	} else {
+		master_mask |= (1 << (irq&7));
+		eisa_out8(master_mask, 0x21);
+	}
+        EISA_DBG("pic0 mask %02x\n", eisa_in8(0x21));
+        EISA_DBG("pic1 mask %02x\n", eisa_in8(0xa1));
 	return;
 }
 
+/* called by request irq */
 static void eisa_enable_irq(void *irq_dev, int irq)
 {
+        EISA_DBG("enable irq %d\n", irq);
+        if (irq & 8) {
+		slave_mask &= ~(1 << (irq&7));
+		eisa_out8(slave_mask, 0xa1);
+	} else {
+		master_mask &= ~(1 << (irq&7));
+		eisa_out8(master_mask, 0x21);
+	}
+        EISA_DBG("pic0 mask %02x\n", eisa_in8(0x21));
+        EISA_DBG("pic1 mask %02x\n", eisa_in8(0xa1));
+
 	return;
 }
 
 static void eisa_mask_irq(void *irq_dev, int irq)
 {
+        EISA_DBG("mask irq %d\n", irq);
+        /* mask irq */
+        if (irq & 8) {
+		slave_mask |= (1 << (irq&7));
+		eisa_out8(slave_mask, 0xa1);
+		
+	} else {
+		master_mask |= (1 << (irq&7));
+		eisa_out8(master_mask, 0x21);
+	}
+	
 	return;
 }
 
 static void eisa_unmask_irq(void *irq_dev, int irq)
 {
+        EISA_DBG("unmask irq %d\n", irq);
+        /* unmask */
+        if (irq & 8) {
+		slave_mask &= ~(1 << (irq&7));
+		eisa_out8(slave_mask, 0xa1);
+	} else {
+		master_mask &= ~(1 << (irq&7));
+		eisa_out8(master_mask, 0x21);
+	}
 	return;
 }
 
@@ -121,9 +191,89 @@ static struct irq_region eisa_irq_region
 static void eisa_irq(int _, void *intr_dev, struct pt_regs *regs)
 {
 	extern void do_irq(struct irqaction *a, int i, struct pt_regs *p);
-	int irq = gsc_readb(0xfc01f000) & 0xf; /* EISA supports 16 irqs */
+	int irq = gsc_readb(0xfc01f000); /* EISA supports 16 irqs */
+        
+        /* read IRR command */
+        eisa_out8(0x0a, 0x20);
+        eisa_out8(0x0a, 0xa0);
+	
+        EISA_DBG("irq IAR %02x 8259-1 irr %02x 8259-2 irr %02x\n",
+		 irq, eisa_in8(0x20), eisa_in8(0xa0));
+   
+        /* read ISR command */
+        eisa_out8(0x0a, 0x20);
+        eisa_out8(0x0a, 0xa0);
+        EISA_DBG("irq 8259-1 isr %02x imr %02x 8259-2 isr %02x imr %02x\n",
+		 eisa_in8(0x20), eisa_in8(0x21), eisa_in8(0xa0), eisa_in8(0xa1));
+	
+        irq &= 0xf;
+        
+        /* mask irq and write eoi */
+        if (irq & 8) {
+		slave_mask |= (1 << (irq&7));
+		eisa_out8(slave_mask, 0xa1);
+		eisa_out8(0x60 | (irq&7),0xa0);/* 'Specific EOI' to slave */
+		eisa_out8(0x62,0x20);	/* 'Specific EOI' to master-IRQ2 */
+		
+	} else {
+		master_mask |= (1 << (irq&7));
+		eisa_out8(master_mask, 0x21);
+		eisa_out8(0x60|irq,0x20);	/* 'Specific EOI' to master */
+	}
 
-	do_irq(&eisa_irq_region.action[irq], EISA_IRQ_REGION + irq, regs);
+   
+ 	do_irq(&eisa_irq_region.action[irq], EISA_IRQ_REGION + irq, regs);
+   
+        /* unmask */
+        if (irq & 8) {
+		slave_mask &= ~(1 << (irq&7));
+		eisa_out8(slave_mask, 0xa1);
+	} else {
+		master_mask &= ~(1 << (irq&7));
+		eisa_out8(master_mask, 0x21);
+	}
+
+}
+
+void init_eisa_pic(void)
+{
+        eisa_out8(0xff, 0x21); /* mask during init */
+        eisa_out8(0xff, 0xa1); /* mask during init */
+	
+        /* master pic */
+        eisa_out8(0x11,0x20); /* ICW1 */   
+        eisa_out8(0x00,0x21); /* ICW2 */   
+        eisa_out8(0x04,0x21); /* ICW3 */   
+        eisa_out8(0x01,0x21); /* ICW4 */   
+        eisa_out8(0x40,0x20); /* OCW2 */   
+	
+        /* slave pic */
+        eisa_out8(0x11,0xa0); /* ICW1 */   
+        eisa_out8(0x08,0xa1); /* ICW2 */   
+        eisa_out8(0x02,0xa1); /* ICW3 */   
+        eisa_out8(0x01,0xa1); /* ICW4 */   
+        eisa_out8(0x40,0xa0); /* OCW2 */   
+        
+	udelay(100);
+	
+        slave_mask = 0xff; 
+        master_mask = 0xfb; 
+        eisa_out8(slave_mask, 0xa1); /* OCW1 */
+        eisa_out8(master_mask, 0x21); /* OCW1 */
+	
+        /* setup trig level */
+        EISA_DBG("EISA edge/level %04x\n", eisa_irq_level);
+#if 1
+        eisa_out8(eisa_irq_level&0xff, 0x4d0); /* Set all irq's to edge  */
+        eisa_out8((eisa_irq_level >> 8) & 0xff, 0x4d1); 
+#else 
+        eisa_out8(0, 0x4d0); /* Set all irq's to edge  */
+        eisa_out8(0, 0x4d1); 
+#endif   
+        EISA_DBG("pic0 mask %02x\n", eisa_in8(0x21));
+        EISA_DBG("pic1 mask %02x\n", eisa_in8(0xa1));
+        EISA_DBG("pic0 edge/level %02x\n", eisa_in8(0x4d0));
+        EISA_DBG("pic1 edge/level %02x\n", eisa_in8(0x4d1));
 }
 
 /* Device initialisation */
@@ -135,7 +285,14 @@ static int __devinit eisa_probe(struct p
 	int result, irq;
 	char *name = is_mongoose(dev) ? "Mongoose" : "Wax";
 
-	printk("%s EISA Adapter found at 0x%08lx\n", name, dev->hpa);
+	printk(KERN_NOTICE "%s EISA Adapter found at 0x%08lx\n", 
+	       name, dev->hpa);
+   
+        if (dev->hpa != 0xfc000000) {
+    	        printk(KERN_ERR "%s HPA is not at 0xfc000000, aborting\n",
+	       	       name);
+		return -ENODEV;	   
+	}
 
 	eisa_dev.hba.lmmio_space.name = "EISA";
 	eisa_dev.hba.lmmio_space.start = (unsigned long) 0xfffffffffc000000;
@@ -157,22 +314,23 @@ static int __devinit eisa_probe(struct p
 	}
 	pcibios_register_hba(&eisa_dev.hba);
 
+        init_eisa_pic();
 	irq = busdevice_alloc_irq(dev);
 	if (!irq) {
 		printk(KERN_ERR "EISA: failed to claim IRQ\n");
 		return -ENODEV;
 	}
 
-	result = request_irq(irq, eisa_irq, 0, "EISA", NULL);
+	result = request_irq(irq, eisa_irq, SA_SHIRQ, "EISA", NULL);
 	if (result) {
 		printk(KERN_ERR "EISA: request_irq failed!\n");
 		return result;
 	}
 	irq_region[0] = &eisa_irq_region;
-
+	
 	EISA_bus = 1;
-
-	return 0;
+   
+        return 0;
 }
 
 static struct parisc_device_id __devinitdata eisa_tbl[] = {
@@ -193,3 +351,35 @@ void __init eisa_init(void)
 {
 	register_parisc_driver(&eisa_driver);
 }
+
+
+static int eisa_irq_setup(char *str)
+{
+	char *cur = str;
+	int val;
+
+	EISA_DBG("IRQ setup\n");
+	while (cur != NULL) {
+		char *pe;
+		
+		val = (int) simple_strtoul(cur, &pe, 0);
+		if (val > 15 || val < 0) {
+			printk(KERN_ERR "eisa: EISA irq value are 0-15\n");
+			continue;
+		}
+		if (val == 2) { 
+			val = 9;
+		}
+		eisa_irq_level &= ~(1<<val); /* clear the corresponding bit */
+		EISA_DBG("setting IRQ %d to edge-tigged mode\n", val);
+		
+		if (cur = strchr(cur, ',')) {
+			cur++;
+		} else {
+			break;
+		}
+	}
+	return 1;
+}
+
+__setup("eisa_irq_edge=", eisa_irq_setup);

===================================================================
RCS file: /var/cvs/linux/include/asm-parisc/irq.h,v retrieving revision 1.14

asm-parisc/irq.h +1 -1
diff -u -p -u -r1.14 irq.h
@@ -69,7 +69,7 @@ extern struct irq_region *irq_region[NR_
 
 static __inline__ int irq_cannonicalize(int irq)
 {
-	return irq;
+   return (irq==2?9:irq);
 }
 
 extern void disable_irq(int);
#3 lore raw

Hi Daniel,

Quoted 3 lines

In order to use an ISA card you will have to specify the IRQ as edge triggerd on the kernel command line options eisa_irq_edge.
Use eisa_irq_edge=9,10 to set IRQ 9 and 10 to edge mode.

Cool stuff !

I just merged it into the current CVS version and tested it on my 720...

I *sometimes* works. Somehow, maybe every 3 boot, my token ring card starts up OK and interrupts are generated. The rest of the cases, the card is detected, but fails to open and no interrupt is recorded in /proc/interrupts. Is there anything special about the 720, like an additional register which might have a random state at bootup time?

However, when trying to send IP traffic to the adapter, Linux immediately crashes in csum_partial(). Looks like some more work is required to fix the token ring driver.

Cheers,
Jochen