summaryrefslogtreecommitdiff
path: root/sys/arch/sparc
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-03-23 17:12:27 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-03-23 17:12:27 +0000
commit7e37f85873601447a5ddb4cc23df988d09ee2e7d (patch)
treec08e0ae7e91a9b658f72ceb37ecb62b0ceb3dc02 /sys/arch/sparc
parentf4bdac6fc5f73a1ab3135e8401016f07fd7e4028 (diff)
Match power on the SPARCbook's auxio2, but prefer tctrl poweroff if
both power0 and tctrl0 are configured. This allows installation media to poweroff quickly on SPARCbooks.
Diffstat (limited to 'sys/arch/sparc')
-rw-r--r--sys/arch/sparc/dev/power.c35
-rw-r--r--sys/arch/sparc/dev/power.h4
-rw-r--r--sys/arch/sparc/sparc/machdep.c16
3 files changed, 28 insertions, 27 deletions
diff --git a/sys/arch/sparc/dev/power.c b/sys/arch/sparc/dev/power.c
index 42cedacb7d5..61c67177d4c 100644
--- a/sys/arch/sparc/dev/power.c
+++ b/sys/arch/sparc/dev/power.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: power.c,v 1.7 2003/05/13 22:25:30 miod Exp $ */
+/* $OpenBSD: power.c,v 1.8 2005/03/23 17:12:24 miod Exp $ */
/* $NetBSD: power.c,v 1.2 1996/05/16 15:56:56 abrown Exp $ */
/*
@@ -50,8 +50,8 @@
#include <sparc/dev/power.h>
-static int powermatch(struct device *, void *, void *);
-static void powerattach(struct device *, struct device *, void *);
+void powerattach(struct device *, struct device *, void *);
+int powermatch(struct device *, void *, void *);
struct cfattach power_ca = {
sizeof(struct device), powermatch, powerattach
@@ -70,24 +70,24 @@ volatile u_char *power_reg;
* shutdown or halted or whatever.
*/
-static int
-powermatch(parent, vcf, aux)
- struct device *parent;
- void *aux, *vcf;
+int
+powermatch(struct device *parent, void *vcf, void *aux)
{
- register struct confargs *ca = aux;
+ struct confargs *ca = aux;
- if (CPU_ISSUN4M)
- return (strcmp("power", ca->ca_ra.ra_name) == 0);
+ if (CPU_ISSUN4M) {
+ /* Tadpole SPARCbooks provide the power register as "auxio2" */
+ if (strcmp("power", ca->ca_ra.ra_name) == 0 ||
+ strcmp("auxio2", ca->ca_ra.ra_name) == 0)
+ return (1);
+ }
return (0);
}
/* ARGSUSED */
-static void
-powerattach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+void
+powerattach(struct device *parent, struct device *self, void *aux)
{
struct confargs *ca = aux;
struct romaux *ra = &ca->ca_ra;
@@ -100,9 +100,10 @@ powerattach(parent, self, aux)
}
void
-powerdown()
+auxio_powerdown()
{
- if (power_attached)
+ if (power_attached) {
*POWER_REG |= POWER_OFF;
- DELAY(1000000);
+ DELAY(1000000);
+ }
}
diff --git a/sys/arch/sparc/dev/power.h b/sys/arch/sparc/dev/power.h
index 15f28136164..bc718afbeaf 100644
--- a/sys/arch/sparc/dev/power.h
+++ b/sys/arch/sparc/dev/power.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: power.h,v 1.4 2003/05/13 22:25:30 miod Exp $ */
+/* $OpenBSD: power.h,v 1.5 2005/03/23 17:12:24 miod Exp $ */
/* $NetBSD: power.h,v 1.2 1996/05/16 15:56:57 abrown Exp $ */
/*
@@ -57,4 +57,4 @@
extern volatile u_char *power_reg;
#endif
-void powerdown(void); /* power off function */
+void auxio_powerdown(void); /* power off function */
diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c
index 1a0da7217a7..22fc4e63285 100644
--- a/sys/arch/sparc/sparc/machdep.c
+++ b/sys/arch/sparc/sparc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.102 2004/09/29 07:35:14 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.103 2005/03/23 17:12:26 miod Exp $ */
/* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */
/*
@@ -84,8 +84,10 @@
#include <uvm/uvm.h>
#ifdef SUN4M
-#include <sparc/dev/power.h>
#include "power.h"
+#if NPOWER > 0
+#include <sparc/dev/power.h>
+#endif
#include "scf.h"
#include "tctrl.h"
#if NTCTRL > 0
@@ -443,7 +445,7 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
size_t newlen;
struct proc *p;
{
-#if (NAUXREG > 0) || (NLED > 0)
+#if (NLED > 0) || (NAUXREG > 0) || (NSCF > 0)
int oldval;
#endif
int ret;
@@ -725,15 +727,13 @@ haltsys:
if ((howto & RB_HALT) || (howto & RB_POWERDOWN)) {
#if defined(SUN4M)
if (howto & RB_POWERDOWN) {
-#if NPOWER > 0 || NTCTRL >0
printf("attempting to power down...\n");
-#if NPOWER > 0
- powerdown();
-#endif
#if NTCTRL > 0
tadpole_powerdown();
#endif
-#endif /* NPOWER || MTCTRL */
+#if NPOWER > 0
+ auxio_powerdown();
+#endif
rominterpret("power-off");
printf("WARNING: powerdown failed!\n");
}