Re: 8259A initialization with AMD SC520 chip (586)

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Mon May 22 2000 - 09:32:53 EST


On Mon, 22 May 2000, Alan Cox wrote:
[SNIPPED...]

>
> 256 clocks. Assuming parallel execution of both instructions 128 clocks. 128
> clocks at 1GHz, is 8uS. So for likely future cpus we can assume it gets you
> 2uS - ok. Providing of course transmeta doesnt code morph it out !
>

Yep. Maybe the whole kernel is morphed out by now! They got Linus early
in the project.

> > The IRQ, if it happens, will break everything anyway. You can't do
> >
> > out 0x20, 0x11 ; Start setup sequence
> > ... get interrupted
> > out 0x20, 0x20 ; ISR sends EOI to controller.
> >
> > ... so this is not relavant. The mask registers, 0x21, and 0xA1 have
> > been masked off in setup.S anyway.
>
> Good point.
>

Here is a patch. It's a bit slow starting on my '386 since each of these
spin-waits takes about 1/12 second on that box. However, on normal
machines, it's microseconds.

--- linux-2.3.36/arch/i386/kernel/i8259.c.orig Mon May 22 08:53:59 2000
+++ linux-2.3.36/arch/i386/kernel/i8259.c Mon May 22 10:00:49 2000
@@ -321,22 +321,28 @@
         outb(0xff, 0xA1); /* mask all of 8259A-2 */
 
         /*
- * outb_p - this has to work on a wide range of PC hardware.
+ * SPIN_WAIT - this has to work on a wide range of PC hardware.
          */
- outb_p(0x11, 0x20); /* ICW1: select 8259A-1 init */
- outb_p(0x20 + 0, 0x21); /* ICW2: 8259A-1 IR0-7 mapped to 0x20-0x27 */
- outb_p(0x04, 0x21); /* 8259A-1 (the master) has a slave on IR2 */
+ outb(0x11, 0x20); /* ICW1: select 8259A-1 init */
+ SPIN_WAIT;
+ outb(0x20 + 0, 0x21); /* ICW2: 8259A-1 IR0-7 mapped to 0x20-0x27 */
+ SPIN_WAIT;
+ outb(0x04, 0x21); /* 8259A-1 (the master) has a slave on IR2 */
+ SPIN_WAIT;
         if (auto_eoi)
- outb_p(0x03, 0x21); /* master does Auto EOI */
+ outb(0x03, 0x21); /* master does Auto EOI */
         else
- outb_p(0x01, 0x21); /* master expects normal EOI */
-
- outb_p(0x11, 0xA0); /* ICW1: select 8259A-2 init */
- outb_p(0x20 + 8, 0xA1); /* ICW2: 8259A-2 IR0-7 mapped to 0x28-0x2f */
- outb_p(0x02, 0xA1); /* 8259A-2 is a slave on master's IR2 */
- outb_p(0x01, 0xA1); /* (slave's support for AEOI in flat mode
+ outb(0x01, 0x21); /* master expects normal EOI */
+ SPIN_WAIT;
+ outb(0x11, 0xA0); /* ICW1: select 8259A-2 init */
+ SPIN_WAIT;
+ outb(0x20 + 8, 0xA1); /* ICW2: 8259A-2 IR0-7 mapped to 0x28-0x2f */
+ SPIN_WAIT;
+ outb(0x02, 0xA1); /* 8259A-2 is a slave on master's IR2 */
+ SPIN_WAIT;
+ outb(0x01, 0xA1); /* (slave's support for AEOI in flat mode
                                     is to be investigated) */
-
+ SPIN_WAIT;
         if (auto_eoi)
                 /*
                  * in AEOI mode we just have to mask the interrupt
@@ -344,7 +350,7 @@
                  */
                 i8259A_irq_type.ack = disable_8259A_irq;
 
- udelay(100); /* wait for 8259A to initialize */
+ SPIN_WAIT;
 
         outb(cached_21, 0x21); /* restore master IRQ mask */
         outb(cached_A1, 0xA1); /* restore slave IRQ mask */
--- linux-2.3.36/include/asm-i386/io.h.orig Mon May 22 09:49:37 2000
+++ linux-2.3.36/include/asm-i386/io.h Mon May 22 09:56:42 2000
@@ -46,6 +46,10 @@
 #define __FULL_SLOW_DOWN_IO __SLOW_DOWN_IO
 #endif
 
+#define SPIN_WAIT \
+__asm__ __volatile__ \
+("pushl %ecx\n\txor %cx,%cx\n\tloop 1f\n1:\tpopl %ecx\n")
+
 /*
  * Talk about misusing macros..
  */

Cheers,
Dick Johnson

Penguin : Linux version 2.3.41 on an i686 machine (800.63 BogoMips).

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 23 2000 - 21:00:21 EST