Skip to contentSkip to conversation

sparc64 auxio changes

PATCH New Eric 1 participant 1 message Nov 5, 2002 Network drivers

lore
Share & tools
lore

Eric

author
#0 lore raw

PATCH 1/1 sparc64 auxio changes

Attached is a patch for community review-- it applies to all sparc64 systems, but I especially need testers with SBus-based systems as I have no access to any at this time.

This patch refactors AUXIO support for sparc64, mainly documentation. The salient changes are as follows:

1) SBus-based (NCR) impl now ANDN's mask bits rather than OR'ing -- this is a significant change, should be fine, needs testing --
2) Exported auxio_register replaced with exported functions for LED, LTE
3) Documentation updated for both sparc64 auxio implementations
4) Floppy asm uses macros rather than hard-coded values for auxio regs, removed OR'ing of mask bits (AND'ing should not be required in this case, but is present and commented-out)
5) Modified sunlance.c as appropriate
6) Removed a few stale auxio #include's from drivers (probably more)

Pete, the ANDN changes and register documentation should apply to sun4m systems as well-- I believe they use the same NCR chipset, and sun4m makes much more use of the auxio than does sun4u. I don't have such a patch for you, but could you please comment?

Things to test:
lance ethernet auto carrier detection when OBP "tpe-link-test?" is true system led illuminates/extinguishes as appropriate
things compile (esp. when CONFIG_PCI is not selected)
SBus floppy still works (uh, does it work at all on SBus?)

Thanks in advance for any comments. I have a trivial driver to twiddle the system LED and lance LTE if you cannot figure it out for yourself-- I'll post it to the list if anyone is interested.

E

===== arch/sparc64/kernel/auxio.c 1.3 vs edited =====

arch/sparc64/kernel/auxio.c +106 -24
@@ -1,28 +1,113 @@
 /* auxio.c: Probing for the Sparc AUXIO register at boot time.
  *
  * Copyright (C) 1996 David S. Miller ([email protected])
+ *
+ * Refactoring for unified NCR/PCIO support 2002 Eric Brower ([email protected])
  */
 
 #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 =====

arch/sparc64/kernel/entry.S +5 -2
@@ -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 =====

arch/sparc64/kernel/power.c +2 -3
@@ -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 =====

arch/sparc64/kernel/sparc64_ksyms.c +2 -1
@@ -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 =====

drivers/fc4/soc.c +0 -1
@@ -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 =====

drivers/fc4/socal.c +0 -1
@@ -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 =====

drivers/net/sunlance.c +1 -1
@@ -1421,7 +1421,7 @@
 				       "'tpe-link-test?'\n", dev->name);
 				printk(KERN_NOTICE "%s: warning: mail any problems "
 				       "to [email protected]\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 =====

include/asm-sparc64/auxio.h +81 -95

193 lines not on this page · raw message