===== arch/sparc64/kernel/auxio.c 1.3 vs edited =====
--- 1.3/arch/sparc64/kernel/auxio.c	Mon Feb  4 23:39:40 2002
+++ edited/arch/sparc64/kernel/auxio.c	Sun Oct 13 01:42:17 2002
@@ -1,28 +1,113 @@
 /* auxio.c: Probing for the Sparc AUXIO register at boot time.
  *
  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
+ *
+ * Refactoring for unified NCR/PCIO support 2002 Eric Brower (ebrower@usa.net)
  */
 
 #include <linux/config.h>
-#include <linux/stddef.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/smp.h>
 #include <linux/init.h>
-#include <linux/delay.h>
 #include <linux/ioport.h>
 
 #include <asm/oplib.h>
 #include <asm/io.h>
-#include <asm/auxio.h>
 #include <asm/sbus.h>
 #include <asm/ebus.h>
-#include <asm/fhc.h>
-#include <asm/spitfire.h>
-#include <asm/starfire.h>
+#include <asm/auxio.h>
+
+/* This cannot be static, as it is referenced in entry.S */
+unsigned long auxio_register = 0UL;
+
+enum auxio_type {
+	AUXIO_TYPE_NODEV,
+	AUXIO_TYPE_SBUS,
+	AUXIO_TYPE_EBUS
+};
 
-/* Probe and map in the Auxiliary I/O register */
-unsigned long auxio_register = 0;
+static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV;
+
+static void __auxio_sbus_set(u8 bits_on, u8 bits_off)
+{
+	if(auxio_register) {
+		unsigned char regval;
+		unsigned long flags;
+		unsigned char newval;
+
+		save_flags(flags); cli();
+
+		regval =  sbus_readb(auxio_register);
+		newval =  regval | bits_on;
+		newval &= ~bits_off;
+		newval &= ~AUXIO_AUX1_MASK;
+		sbus_writeb(newval, auxio_register);
+
+		restore_flags(flags);
+	}
+}
+
+static void __auxio_ebus_set(u8 bits_on, u8 bits_off)
+{
+	if(auxio_register) {
+		unsigned char regval;
+		unsigned long flags;
+		unsigned char newval;
+
+		save_flags(flags); cli();
+
+		regval =  (u8)readl(auxio_register);
+		newval =  regval | bits_on;
+		newval &= ~bits_off;
+		writel((u32)newval, auxio_register);
+
+		restore_flags(flags);
+	}
+}
+
+static inline void __auxio_ebus_set_led(int on)
+{
+	(on) ? __auxio_ebus_set(AUXIO_PCIO_LED, 0) :
+		__auxio_ebus_set(0, AUXIO_PCIO_LED) ;
+}
+
+static inline void __auxio_sbus_set_led(int on)
+{
+	(on) ? __auxio_sbus_set(AUXIO_AUX1_LED, 0) :
+		__auxio_sbus_set(0, AUXIO_AUX1_LED) ;
+}
+
+void auxio_set_led(int on)
+{
+	switch(auxio_devtype) {
+	case AUXIO_TYPE_SBUS:
+		__auxio_sbus_set_led(on);
+		break;
+	case AUXIO_TYPE_EBUS:
+		__auxio_ebus_set_led(on);
+		break;
+	default:
+		break;
+	}
+}
+
+static inline void __auxio_sbus_set_lte(int on)
+{
+	(on) ? __auxio_sbus_set(AUXIO_AUX1_LTE, 0) : 
+		__auxio_sbus_set(0, AUXIO_AUX1_LTE) ;
+}
+
+void auxio_set_lte(int on)
+{
+	switch(auxio_devtype) {
+	case AUXIO_TYPE_SBUS:
+		__auxio_sbus_set_lte(on);
+		break;
+	case AUXIO_TYPE_EBUS:
+		/* FALL-THROUGH */
+	default:
+		break;
+	}
+}
 
 void __init auxio_probe(void)
 {
@@ -37,11 +122,15 @@
         }
 
 found_sdev:
-	if (!sdev) {
+	if (sdev) {
+		auxio_devtype  = AUXIO_TYPE_SBUS;
+		auxio_register = sbus_ioremap(&sdev->resource[0], 0,
+		  		sdev->reg_addrs[0].reg_size, "auxiliaryIO");
+	}
 #ifdef CONFIG_PCI
+	else {
 		struct linux_ebus *ebus;
 		struct linux_ebus_device *edev = 0;
-		unsigned long led_auxio;
 
 		for_each_ebus(ebus) {
 			for_each_ebusdev(edev, ebus) {
@@ -50,19 +139,12 @@
 			}
 		}
 	ebus_done:
-
 		if (edev) {
-			led_auxio = edev->resource[0].start;
-			outl(0x01, led_auxio);
-			return;
+			auxio_devtype  = AUXIO_TYPE_EBUS;
+			auxio_register = (unsigned long)
+				ioremap(edev->resource[0].start, sizeof(u32));
 		}
-#endif
-		auxio_register = 0UL;
-		return;
 	}
-
-	/* Map the register both read and write */
-	auxio_register = sbus_ioremap(&sdev->resource[0], 0,
-				      sdev->reg_addrs[0].reg_size, "auxiliaryIO");
-	TURN_ON_LED;
+	auxio_set_led(AUXIO_LED_ON);
+#endif
 }
===== arch/sparc64/kernel/entry.S 1.12 vs edited =====
--- 1.12/arch/sparc64/kernel/entry.S	Mon Aug 26 02:36:41 2002
+++ edited/arch/sparc64/kernel/entry.S	Sun Oct 13 00:40:08 2002
@@ -20,6 +20,7 @@
 #include <asm/processor.h>
 #include <asm/visasm.h>
 #include <asm/estate.h>
+#include <asm/auxio.h>
 
 /* #define SYSCALL_TRACING	1 */
 
@@ -662,9 +663,11 @@
 	sethi		%hi(auxio_register), %g1
 	ldx		[%g1 + %lo(auxio_register)], %g7
 	lduba		[%g7] ASI_PHYS_BYPASS_EC_E, %g5
-	or		%g5, 0xc2, %g5
+	or		%g5, AUXIO_AUX1_FTCNT, %g5
+/*	andn		%g5, AUXIO_AUX1_MASK, %g5 */
 	stba		%g5, [%g7] ASI_PHYS_BYPASS_EC_E
-	andn		%g5, 0x02, %g5
+	andn		%g5, AUXIO_AUX1_FTCNT, %g5
+/*	andn		%g5, AUXIO_AUX1_MASK, %g5 */
 
 	nop; nop;  nop; nop;  nop; nop;
 	nop; nop;  nop; nop;  nop; nop;
===== arch/sparc64/kernel/power.c 1.5 vs edited =====
--- 1.5/arch/sparc64/kernel/power.c	Mon Jun 17 14:54:31 2002
+++ edited/arch/sparc64/kernel/power.c	Sun Oct 13 01:45:17 2002
@@ -12,14 +12,13 @@
 #include <linux/delay.h>
 
 #include <asm/ebus.h>
+#include <asm/auxio.h>
 
 #define __KERNEL_SYSCALLS__
 #include <linux/unistd.h>
 
 #ifdef CONFIG_PCI
 static unsigned long power_reg = 0UL;
-#define POWER_SYSTEM_OFF (1 << 0)
-#define POWER_COURTESY_OFF (1 << 1)
 
 static DECLARE_WAIT_QUEUE_HEAD(powerd_wait);
 static int button_pressed;
@@ -48,7 +47,7 @@
 			 * same effect, so until I figure out
 			 * what the difference is...
 			 */
-			writel(POWER_COURTESY_OFF | POWER_SYSTEM_OFF, power_reg);
+			writel(AUXIO_PCIO_CPWR_OFF | AUXIO_PCIO_SPWR_OFF, power_reg);
 		} else
 #endif /* CONFIG_PCI */
 			if (poweroff_method != NULL) {
===== arch/sparc64/kernel/sparc64_ksyms.c 1.19 vs edited =====
--- 1.19/arch/sparc64/kernel/sparc64_ksyms.c	Fri Jun  7 23:49:33 2002
+++ edited/arch/sparc64/kernel/sparc64_ksyms.c	Sun Oct 13 02:06:59 2002
@@ -200,7 +200,8 @@
 EXPORT_SYMBOL(mstk48t02_regs);
 EXPORT_SYMBOL(request_fast_irq);
 #if CONFIG_SUN_AUXIO
-EXPORT_SYMBOL(auxio_register);
+EXPORT_SYMBOL(auxio_set_led);
+EXPORT_SYMBOL(auxio_set_lte);
 #endif
 #if CONFIG_SBUS
 EXPORT_SYMBOL(sbus_root);
===== drivers/fc4/soc.c 1.6 vs edited =====
--- 1.6/drivers/fc4/soc.c	Thu Mar 21 21:33:41 2002
+++ edited/drivers/fc4/soc.c	Mon Oct  7 09:19:32 2002
@@ -40,7 +40,6 @@
 
 #include <asm/openprom.h>
 #include <asm/oplib.h>
-#include <asm/auxio.h>
 #include <asm/pgtable.h>
 #include <asm/irq.h>
 
===== drivers/fc4/socal.c 1.5 vs edited =====
--- 1.5/drivers/fc4/socal.c	Thu Mar 21 21:33:41 2002
+++ edited/drivers/fc4/socal.c	Mon Oct  7 09:18:23 2002
@@ -36,7 +36,6 @@
 
 #include <asm/openprom.h>
 #include <asm/oplib.h>
-#include <asm/auxio.h>
 #include <asm/pgtable.h>
 #include <asm/irq.h>
 
===== drivers/net/sunlance.c 1.11 vs edited =====
--- 1.11/drivers/net/sunlance.c	Mon May 13 15:54:46 2002
+++ edited/drivers/net/sunlance.c	Wed Oct  9 08:48:54 2002
@@ -1421,7 +1421,7 @@
 				       "'tpe-link-test?'\n", dev->name);
 				printk(KERN_NOTICE "%s: warning: mail any problems "
 				       "to ecd@skynet.be\n", dev->name);
-				set_auxio(AUXIO_LINK_TEST, 0);
+				auxio_set_lte(AUXIO_LTE_ON);
 			}
 no_link_test:
 			lp->auto_select = 1;
===== include/asm-sparc64/auxio.h 1.2 vs edited =====
--- 1.2/include/asm-sparc64/auxio.h	Mon Feb  4 23:41:04 2002
+++ edited/include/asm-sparc64/auxio.h	Sun Oct 13 01:42:56 2002
@@ -1,112 +1,98 @@
 /* $Id: auxio.h,v 1.3 2001/06/05 08:16:34 davem Exp $
- * auxio.h:  Definitions and code for the Auxiliary I/O register.
+ * auxio.h:  Definitions and code for the Auxiliary I/O registers
  *
  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
+ *
+ * Refactoring for unified NCR/PCIO support 2002 Eric Brower (ebrower@usa.net)
  */
 #ifndef _SPARC64_AUXIO_H
 #define _SPARC64_AUXIO_H
 
-#include <asm/system.h>
-#include <asm/io.h>
-
-/* FIXME: All of this should be checked for sun4u. It has /sbus/auxio, but
-   I don't know whether it is the same and don't have a floppy */
+/* AUXIO implementations:
+ * sbus-based NCR89C105 "Slavio"
+ *	LED/Floppy (AUX1) register
+ *	Power (AUX2) register
+ *
+ * ebus-based auxio on PCIO 
+ *	LED Auxio Register
+ *	Power Auxio Register
+ *
+ * Register definitions from NCR _NCR89C105 Chip Specification_
+ * 
+ * SLAVIO AUX1 @ 0x1900000
+ * -------------------------------------------------
+ * | (R) | (R) |  D  | (R) |  E  |  M  |  T  |  L  |
+ * -------------------------------------------------
+ * (R) - bit 7:6,4 are reserved and should be masked in s/w
+ *  D  - Floppy Density Sense (1=high density) R/O
+ *  E  - Link Test Enable, directly reflected on AT&T 7213 LTE pin
+ *  M  - Monitor/Mouse Mux, directly reflected on MON_MSE_MUX pin
+ *  T  - Terminal Count: sends TC pulse to 82077 floppy controller
+ *  L  - System LED on front panel (0=off, 1=on) 
+ */
+#define AUXIO_AUX1_MASK		0xc0 /* Mask bits 		*/
+#define AUXIO_AUX1_FDENS	0x20 /* Floppy Density Sense	*/
+#define AUXIO_AUX1_LTE 		0x08 /* Link Test Enable 	*/
+#define AUXIO_AUX1_MMUX		0x04 /* Monitor/Mouse Mux	*/
+#define AUXIO_AUX1_FTCNT	0x02 /* Terminal Count, 	*/
+#define AUXIO_AUX1_LED		0x01 /* System LED		*/
+
+/* SLAVIO AUX2 @ 0x1910000
+ * -------------------------------------------------
+ * | (R) | (R) |  D  | (R) | (R) | (R) |  C  |  F  |
+ * -------------------------------------------------
+ * (R) - bits 7:6,4:2 are reserved and should be masked in s/w
+ *  D  - Power Failure Detect (1=power fail)
+ *  C  - Clear Power Failure Detect Int (1=clear)
+ *  F  - Power Off (1=power off)
+ */
+#define AUXIO_AUX2_MASK		0xdc /* Mask Bits		*/
+#define AUXIO_AUX2_PFAILDET	0x20 /* Power Fail Detect	*/
+#define AUXIO_AUX2_PFAILCLR 	0x02 /* Clear Pwr Fail Det Intr	*/
+#define AUXIO_AUX2_PWR_OFF	0x01 /* Power Off		*/
 
-extern unsigned long auxio_register;
+/* Register definitions from Sun Microsystems _PCIO_ p/n 802-7837
+ *
+ * PCIO LED Auxio @ 0x726000
+ * -------------------------------------------------
+ * |             31:1 Unused                 | LED |
+ * -------------------------------------------------
+ * Bits 31:1 unused
+ * LED - System LED on front panel (0=off, 1=on)
+ */
+#define AUXIO_PCIO_LED		0x01 /* System LED 		*/ 
 
-/* This register is an unsigned char in IO space.  It does two things.
- * First, it is used to control the front panel LED light on machines
- * that have it (good for testing entry points to trap handlers and irq's)
- * Secondly, it controls various floppy drive parameters.
- */
-#define AUXIO_ORMEIN      0xf0    /* All writes must set these bits. */
-#define AUXIO_ORMEIN4M    0xc0    /* sun4m - All writes must set these bits. */
-#define AUXIO_FLPY_DENS   0x20    /* Floppy density, high if set. Read only. */
-#define AUXIO_FLPY_DCHG   0x10    /* A disk change occurred.  Read only. */
-#define AUXIO_EDGE_ON     0x10    /* sun4m - On means Jumper block is in. */
-#define AUXIO_FLPY_DSEL   0x08    /* Drive select/start-motor. Write only. */
-#define AUXIO_LINK_TEST   0x08    /* sun4m - On means TPE Carrier detect. */
-
-/* Set the following to one, then zero, after doing a pseudo DMA transfer. */
-#define AUXIO_FLPY_TCNT   0x04    /* Floppy terminal count. Write only. */
-
-/* Set the following to zero to eject the floppy. */
-#define AUXIO_FLPY_EJCT   0x02    /* Eject floppy disk.  Write only. */
-#define AUXIO_LED         0x01    /* On if set, off if unset. Read/Write */
-
-#define AUXREG   (auxio_register)
-
-/* These are available on sun4c */
-#define TURN_ON_LED   \
-do {	if (AUXREG) \
-		sbus_writeb(sbus_readb(AUXREG) | \
-			    (AUXIO_ORMEIN | AUXIO_LED), AUXREG); \
-} while(0)
-#define TURN_OFF_LED  \
-do {	if (AUXREG) \
-		sbus_writeb((sbus_readb(AUXREG) | \
-			     AUXIO_ORMEIN) & (~AUXIO_LED), \
-			    AUXREG); \
-} while(0)
-#define FLIP_LED	\
-do {	if (AUXREG)  \
-		sbus_writeb((sbus_readb(AUXREG) | \
-			     AUXIO_ORMEIN) ^ AUXIO_LEN, \
-			    AUXREG); \
-} while(0)
-#define FLPY_MOTORON	\
-do {	if (AUXREG) \
-		sbus_writeb(sbus_readb(AUXREG) | \
-			    (AUXIO_ORMEIN | AUXIO_FLPY_DSEL), \
-			    AUXREG); \
-} while(0)
-#define FLPY_MOTOROFF	\
-do {	if (AUXREG) \
-		sbus_writeb((sbus_readb(AUXREG) | \
-			     AUXIO_ORMEIN) & (~AUXIO_FLPY_DSEL), \
-			    AUXREG); \
-} while(0)
-#define FLPY_TCNTON	\
-do {	if (AUXREG) \
-		sbus_writeb((sbus_readb(AUXREG) | \
-			     AUXIO_ORMEIN) | AUXIO_FLPY_TCNT, \
-			    AUXREG); \
-} while(0)
-#define FLPY_TCNTOFF	\
-do {	if (AUXREG) \
-		sbus_writeb((sbus_readb(AUXREG) | \
-			     AUXIO_ORMEIN) & (~AUXIO_FLPY_TCNT), \
-			    AUXREG); \
-} while(0)
+/* PCIO Power Auxio @ 0x724000
+ * -------------------------------------------------
+ * |             31:2 Unused           | CPO | SPO |
+ * -------------------------------------------------
+ * Bits 31:2 unused
+ * CPO - Courtesy Power Off (1=off)
+ * SPO - System Power Off   (1=off)
+ */
+#define AUXIO_PCIO_CPWR_OFF	0x02 /* Courtesy Power Off	*/
+#define AUXIO_PCIO_SPWR_OFF	0x01 /* System Power Off	*/
 
 #ifndef __ASSEMBLY__
-extern __inline__ void set_auxio(unsigned char bits_on, unsigned char bits_off)
-{
-	unsigned char regval;
-	unsigned long flags;
-
-	save_flags(flags); cli();
 
-	if(AUXREG) {
-		unsigned char newval;
-
-		regval = sbus_readb(AUXREG);
-		newval  = regval | bits_on;
-		newval &= ~bits_off;
-		newval |= AUXIO_ORMEIN4M;
-		sbus_writeb(newval, AUXREG);
-	}
-	restore_flags(flags);
-}
-#endif /* !(__ASSEMBLY__) */
+#define AUXIO_LTE_ON	1
+#define AUXIO_LTE_OFF	0
 
+/* auxio_set_lte - Set Link Test Enable (TPE Link Detect)
+ *
+ * on - AUXIO_LTE_ON or AUXIO_LTE_OFF
+ */
+extern void auxio_set_lte(int on);
 
-/* AUXIO2 (Power Off Control) */
-extern __volatile__ unsigned char * auxio_power_register;
+#define AUXIO_LED_ON	1
+#define AUXIO_LED_OFF	0
 
-#define	AUXIO_POWER_DETECT_FAILURE	32
-#define	AUXIO_POWER_CLEAR_FAILURE	2
-#define	AUXIO_POWER_OFF			1
+/* auxio_set_led - Set system front panel LED 
+ *
+ * on - AUXIO_LED_ON or AUXIO_LED_OFF
+ */
+extern void auxio_set_led(int on);
 
+#endif /* ifndef __ASSEMBLY__ */ 
 
-#endif /* !(_SPARC_AUXIO_H) */
+#endif /* !(_SPARC64_AUXIO_H) */
