summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/sparc64/conf/files.sparc644
-rw-r--r--sys/arch/sparc64/dev/auxio.c96
-rw-r--r--sys/arch/sparc64/dev/auxioreg.h5
-rw-r--r--sys/arch/sparc64/dev/auxiovar.h24
-rw-r--r--sys/arch/sparc64/include/cpu.h6
-rw-r--r--sys/arch/sparc64/sparc64/machdep.c28
6 files changed, 115 insertions, 48 deletions
diff --git a/sys/arch/sparc64/conf/files.sparc64 b/sys/arch/sparc64/conf/files.sparc64
index 0740fe73d3d..1b69fbf204e 100644
--- a/sys/arch/sparc64/conf/files.sparc64
+++ b/sys/arch/sparc64/conf/files.sparc64
@@ -1,4 +1,4 @@
-# $OpenBSD: files.sparc64,v 1.28 2002/01/30 23:58:02 jason Exp $
+# $OpenBSD: files.sparc64,v 1.29 2002/02/01 21:48:23 jason Exp $
# $NetBSD: files.sparc64,v 1.50 2001/08/10 20:53:50 eeh Exp $
# maxpartitions must be first item in files.${ARCH}
@@ -82,7 +82,7 @@ file arch/sparc64/sparc64/cpu.c
device auxio
attach auxio at ebus with auxio_ebus
attach auxio at sbus with auxio_sbus
-file arch/sparc64/dev/auxio.c auxio
+file arch/sparc64/dev/auxio.c auxio needs-flag
device beeper
attach beeper at ebus
diff --git a/sys/arch/sparc64/dev/auxio.c b/sys/arch/sparc64/dev/auxio.c
index 40752a8aba1..d37d0d4dd41 100644
--- a/sys/arch/sparc64/dev/auxio.c
+++ b/sys/arch/sparc64/dev/auxio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auxio.c,v 1.2 2001/08/29 02:47:58 jason Exp $ */
+/* $OpenBSD: auxio.c,v 1.3 2002/02/01 21:48:23 jason Exp $ */
/* $NetBSD: auxio.c,v 1.1 2000/04/15 03:08:13 mrg Exp $ */
/*
@@ -37,7 +37,8 @@
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/timeout.h>
+#include <sys/kernel.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
@@ -57,6 +58,7 @@ int auxio_ebus_match __P((struct device *, void *, void *));
void auxio_ebus_attach __P((struct device *, struct device *, void *));
int auxio_sbus_match __P((struct device *, void *, void *));
void auxio_sbus_attach __P((struct device *, struct device *, void *));
+void auxio_attach_common __P((struct auxio_softc *));
struct cfattach auxio_ebus_ca = {
sizeof(struct auxio_softc), auxio_ebus_match, auxio_ebus_attach
@@ -70,6 +72,8 @@ struct cfdriver auxio_cd = {
NULL, "auxio", DV_DULL
};
+extern int sparc_led_blink;
+
int
auxio_ebus_match(parent, cf, aux)
struct device *parent;
@@ -89,6 +93,8 @@ auxio_ebus_attach(parent, self, aux)
struct auxio_softc *sc = (struct auxio_softc *)self;
struct ebus_attach_args *ea = aux;
+ timeout_set(&sc->sc_to, auxio_led_blink, sc);
+
if (ea->ea_nregs < 1 || ea->ea_nvaddrs < 1) {
printf(": no registers??\n");
return;
@@ -100,17 +106,15 @@ auxio_ebus_attach(parent, self, aux)
sc->sc_flags = AUXIO_LEDONLY|AUXIO_EBUS;
} else {
sc->sc_flags = AUXIO_EBUS;
- sc->sc_registers.auxio_pci = (u_int32_t *)(u_long)ea->ea_vaddrs[1];
- sc->sc_registers.auxio_freq = (u_int32_t *)(u_long)ea->ea_vaddrs[2];
- sc->sc_registers.auxio_scsi = (u_int32_t *)(u_long)ea->ea_vaddrs[3];
- sc->sc_registers.auxio_temp = (u_int32_t *)(u_long)ea->ea_vaddrs[4];
+ sc->sc_pci = (bus_space_handle_t)(u_long)ea->ea_vaddrs[1];
+ sc->sc_freq = (bus_space_handle_t)(u_long)ea->ea_vaddrs[1];
+ sc->sc_scsi = (bus_space_handle_t)(u_long)ea->ea_vaddrs[1];
+ sc->sc_temp = (bus_space_handle_t)(u_long)ea->ea_vaddrs[1];
}
- sc->sc_registers.auxio_led = (u_int32_t *)(u_long)ea->ea_vaddrs[0];
-
- if (!auxio_reg)
- auxio_reg = (u_char *)(u_long)ea->ea_vaddrs[0];
+ sc->sc_led = (bus_space_handle_t)(u_long)ea->ea_vaddrs[0];
+ sc->sc_tag = ea->ea_bustag;
- printf("\n");
+ auxio_attach_common(sc);
}
int
@@ -132,6 +136,8 @@ auxio_sbus_attach(parent, self, aux)
struct auxio_softc *sc = (struct auxio_softc *)self;
struct sbus_attach_args *sa = aux;
+ timeout_set(&sc->sc_to, auxio_led_blink, sc);
+
if (sa->sa_nreg < 1 || sa->sa_npromvaddrs < 1) {
printf(": no registers??\n");
return;
@@ -144,25 +150,67 @@ auxio_sbus_attach(parent, self, aux)
/* sbus auxio only has one set of registers */
sc->sc_flags = AUXIO_LEDONLY|AUXIO_SBUS;
- sc->sc_registers.auxio_led = (u_int32_t *)(u_long)sa->sa_promvaddr;
+ sc->sc_led = (bus_space_handle_t)(u_long)sa->sa_promvaddr;
+ sc->sc_tag = sa->sa_bustag;
- if (!auxio_reg)
- auxio_reg = (u_char *)(u_long)sa->sa_promvaddr;
+ auxio_attach_common(sc);
+}
+void
+auxio_attach_common(sc)
+ struct auxio_softc *sc;
+{
+ if (sparc_led_blink)
+ auxio_led_blink(sc);
printf("\n");
}
-/*
- * old interface; used by fd driver for now
- */
-unsigned int
-auxregbisc(bis, bic)
- int bis, bic;
+void
+auxio_led_blink(vsc)
+ void *vsc;
{
- register int v, s = splhigh();
+ struct auxio_softc *sc = vsc;
+ u_int32_t led;
+ int i, s;
+
+ if (sc == NULL) {
+ for (i = 0; i < auxio_cd.cd_ndevs; i++) {
+ sc = auxio_cd.cd_devs[i];
+ if (sc != NULL)
+ auxio_led_blink(sc);
+ }
+ return;
+ }
+
+ s = splhigh();
+
+ if (sc->sc_flags & AUXIO_EBUS)
+ led = letoh32(bus_space_read_4(sc->sc_tag, sc->sc_led, 0));
+ else
+ led = bus_space_read_1(sc->sc_tag, sc->sc_led, 0);
+
+ if (!sparc_led_blink)
+ led |= AUXIO_LED_LED;
+ else
+ led ^= AUXIO_LED_LED;
+
+ if (sc->sc_flags & AUXIO_EBUS)
+ bus_space_write_4(sc->sc_tag, sc->sc_led, 0, htole32(led));
+ else
+ bus_space_write_1(sc->sc_tag, sc->sc_led, 0, led);
- v = *auxio_reg;
- *auxio_reg = ((v | bis) & ~bic) | AUXIO_LED_MB1;
splx(s);
- return v;
+
+ if (!sparc_led_blink)
+ return;
+
+ /*
+ * Blink rate is:
+ * full cycle every second if completely idle (loadav = 0)
+ * full cycle every 2 seconds if loadav = 1
+ * full cycle every 3 seconds if loadav = 2
+ * etc.
+ */
+ s = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 1));
+ timeout_add(&sc->sc_to, s);
}
diff --git a/sys/arch/sparc64/dev/auxioreg.h b/sys/arch/sparc64/dev/auxioreg.h
index 6beec3e03cb..d69858f6759 100644
--- a/sys/arch/sparc64/dev/auxioreg.h
+++ b/sys/arch/sparc64/dev/auxioreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: auxioreg.h,v 1.2 2001/08/29 02:47:58 jason Exp $ */
+/* $OpenBSD: auxioreg.h,v 1.3 2002/02/01 21:48:23 jason Exp $ */
/* $NetBSD: auxioreg.h,v 1.3 2000/04/15 03:08:13 mrg Exp $ */
/*
@@ -47,7 +47,6 @@
#define AUXIO_POWER_COURTESY_OFF 0x1
#define AUXIO_LED 0x00726000
-#define AUXIO_LED_LED 0x0
#define AUXIO_LED_MB1 0xf0 /* must be set on write */
/* XXX: these may be useless on Ebus2 auxio! find out! */
#define AUXIO_LED_FHD 0x20 /* floppy: high density (unreliable?)*/
@@ -55,9 +54,7 @@
#define AUXIO_LED_FDS 0x08 /* floppy: drive select */
#define AUXIO_LED_FTC 0x04 /* floppy: drives Terminal Count pin */
#define AUXIO_LED_FEJ 0x02 /* floppy: eject disk */
-#if 0
#define AUXIO_LED_LED 0x01 /* front panel LED */
-#endif
#define AUXIO_PCI 0x00728000
#define AUXIO_PCI_SLOT0 0x0 /* two bits each */
diff --git a/sys/arch/sparc64/dev/auxiovar.h b/sys/arch/sparc64/dev/auxiovar.h
index 95a59b506cf..58f5ef4ca6d 100644
--- a/sys/arch/sparc64/dev/auxiovar.h
+++ b/sys/arch/sparc64/dev/auxiovar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: auxiovar.h,v 1.2 2001/08/29 02:47:58 jason Exp $ */
+/* $OpenBSD: auxiovar.h,v 1.3 2002/02/01 21:48:23 jason Exp $ */
/* $NetBSD: auxiovar.h,v 1.4 2000/04/15 03:08:13 mrg Exp $ */
/*
@@ -39,26 +39,19 @@
* (to deal with multiple auxio's that may appear.)
*/
-struct auxio_registers {
-#if 0 /* these do not exist on the Ebus2 */
- volatile u_int32_t *auxio_fd;
- volatile u_int32_t *auxio_audio;
- volatile u_int32_t *auxio_power;
-#endif
- volatile u_int32_t *auxio_led;
- volatile u_int32_t *auxio_pci;
- volatile u_int32_t *auxio_freq;
- volatile u_int32_t *auxio_scsi;
- volatile u_int32_t *auxio_temp;
-};
-
struct auxio_softc {
struct device sc_dev;
- struct auxio_registers sc_registers;
+ bus_space_tag_t sc_tag;
+ bus_space_handle_t sc_led;
+ bus_space_handle_t sc_pci;
+ bus_space_handle_t sc_scsi;
+ bus_space_handle_t sc_freq;
+ bus_space_handle_t sc_temp;
int sc_flags;
#define AUXIO_LEDONLY 0x1
#define AUXIO_EBUS 0x2
#define AUXIO_SBUS 0x4
+ struct timeout sc_to;
};
/*
@@ -71,4 +64,5 @@ struct auxio_softc {
*/
volatile u_char *auxio_reg;
unsigned int auxregbisc __P((int, int));
+void auxio_led_blink __P((void *));
#endif
diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h
index 04b9d78b71f..9f346a0c390 100644
--- a/sys/arch/sparc64/include/cpu.h
+++ b/sys/arch/sparc64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.6 2001/11/06 18:41:10 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.7 2002/02/01 21:48:23 jason Exp $ */
/* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */
/*
@@ -52,11 +52,13 @@
* CTL_MACHDEP definitions.
*/
#define CPU_BOOTED_KERNEL 1 /* string: booted kernel name */
-#define CPU_MAXID 2 /* number of valid machdep ids */
+#define CPU_LED_BLINK 2 /* int: blink leds? */
+#define CPU_MAXID 3 /* number of valid machdep ids */
#define CTL_MACHDEP_NAMES { \
{ 0, 0 }, \
{ "booted_kernel", CTLTYPE_STRING }, \
+ { "led_blink", CTLTYPE_INT }, \
}
#ifdef _KERNEL
diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c
index 9457609d96e..0a7bcf85172 100644
--- a/sys/arch/sparc64/sparc64/machdep.c
+++ b/sys/arch/sparc64/sparc64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.32 2002/02/01 19:38:23 jason Exp $ */
+/* $OpenBSD: machdep.c,v 1.33 2002/02/01 21:48:23 jason Exp $ */
/* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */
/*-
@@ -82,6 +82,8 @@
* @(#)machdep.c 8.6 (Berkeley) 1/14/94
*/
+#include "auxio.h"
+
#include <sys/param.h>
#include <sys/extent.h>
#include <sys/signal.h>
@@ -152,6 +154,11 @@ int physmem;
u_long _randseed;
extern caddr_t msgbufaddr;
+#if NAUXIO > 0
+#include <sparc64/dev/auxiovar.h>
+int sparc_led_blink;
+#endif
+
/*
* Maximum number of DMA segments we'll allow in dmamem_load()
* routines. Can be overridden in config files, etc.
@@ -507,6 +514,9 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
size_t newlen;
struct proc *p;
{
+#if NAUXIO > 0
+ int oldval, ret;
+#endif
u_int chosen;
char bootargs[256];
char *cp = NULL;
@@ -542,6 +552,22 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
if (cp == NULL || cp[0] == '\0')
return (ENOENT);
return (sysctl_rdstring(oldp, oldlenp, newp, cp));
+ case CPU_LED_BLINK:
+#if NAUXIO > 0
+ oldval = sparc_led_blink;
+ ret = sysctl_int(oldp, oldlenp, newp, newlen,
+ &sparc_led_blink);
+
+ /*
+ * If we were false and are now true, call auxio_led_blink().
+ * auxio_led_blink() will catch the other case itself.
+ */
+ if (!oldval && sparc_led_blink > oldval)
+ auxio_led_blink(NULL);
+ return (ret);
+#else
+ return (EOPNOTSUPP);
+#endif
default:
return (EOPNOTSUPP);
}