summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>2004-09-27 21:12:41 +0000
committerJason Wright <jason@cvs.openbsd.org>2004-09-27 21:12:41 +0000
commit67d880f1499035d75c968e479e4826a369ed625c (patch)
treec4c2b9b4cff2efcdf1edca3d3f51798cd219b947 /sys/arch
parent6208d149720daeacdcd839c01029b1e4e87dd803 (diff)
Important stuff: blinky lights for fhc
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc64/conf/files.sparc644
-rw-r--r--sys/arch/sparc64/dev/fhc.c47
-rw-r--r--sys/arch/sparc64/dev/fhcvar.h5
-rw-r--r--sys/arch/sparc64/sparc64/machdep.c12
4 files changed, 62 insertions, 6 deletions
diff --git a/sys/arch/sparc64/conf/files.sparc64 b/sys/arch/sparc64/conf/files.sparc64
index 7d718a4ccdd..1f7e0a9fe65 100644
--- a/sys/arch/sparc64/conf/files.sparc64
+++ b/sys/arch/sparc64/conf/files.sparc64
@@ -1,4 +1,4 @@
-# $OpenBSD: files.sparc64,v 1.51 2004/09/23 18:00:58 jason Exp $
+# $OpenBSD: files.sparc64,v 1.52 2004/09/27 21:12:40 jason Exp $
# $NetBSD: files.sparc64,v 1.50 2001/08/10 20:53:50 eeh Exp $
# maxpartitions must be first item in files.${ARCH}
@@ -22,7 +22,7 @@ file arch/sparc64/dev/central.c central
define fhc {}
device fhc
-file arch/sparc64/dev/fhc.c fhc
+file arch/sparc64/dev/fhc.c fhc needs-flag
attach fhc at central with fhc_central
file arch/sparc64/dev/fhc_central.c fhc_central
diff --git a/sys/arch/sparc64/dev/fhc.c b/sys/arch/sparc64/dev/fhc.c
index 659d08d34ce..b37506eff7f 100644
--- a/sys/arch/sparc64/dev/fhc.c
+++ b/sys/arch/sparc64/dev/fhc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fhc.c,v 1.8 2004/09/27 19:23:07 jason Exp $ */
+/* $OpenBSD: fhc.c,v 1.9 2004/09/27 21:12:40 jason Exp $ */
/*
* Copyright (c) 2004 Jason L. Wright (jason@thought.net)
@@ -49,6 +49,8 @@ struct cfdriver fhc_cd = {
int fhc_print(void *, const char *);
+extern int sparc_led_blink;
+
bus_space_tag_t fhc_alloc_bus_tag(struct fhc_softc *);
int _fhc_bus_map(bus_space_tag_t, bus_space_tag_t, bus_addr_t, bus_size_t,
int, bus_space_handle_t *);
@@ -67,6 +69,8 @@ fhc_attach(struct fhc_softc *sc)
printf(" board %d: %s", sc->sc_board,
getpropstring(sc->sc_node, "board-model"));
+ timeout_set(&sc->sc_to, fhc_led_blink, sc);
+
sc->sc_cbt = fhc_alloc_bus_tag(sc);
sc->sc_ign = sc->sc_board << 1;
@@ -120,6 +124,9 @@ fhc_attach(struct fhc_softc *sc)
if (fa.fa_nintr != NULL)
free(fa.fa_intr, M_DEVBUF);
}
+
+ if (sparc_led_blink)
+ fhc_led_blink(sc);
}
int
@@ -296,3 +303,41 @@ fhc_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int ihandle,
return (ih);
}
+
+void
+fhc_led_blink(void *vsc)
+{
+ struct fhc_softc *sc = vsc;
+ int i, s;
+ u_int32_t r;
+
+ if (sc == NULL) {
+ for (i = 0; i < fhc_cd.cd_ndevs; i++) {
+ sc = fhc_cd.cd_devs[i];
+ if (sc != NULL)
+ fhc_led_blink(sc);
+ }
+ return;
+ }
+
+ s = splhigh();
+ r = bus_space_read_4(sc->sc_bt, sc->sc_preg, FHC_P_CTRL);
+ r ^= FHC_P_CTRL_RLED;
+ r &= ~(FHC_P_CTRL_AOFF | FHC_P_CTRL_BOFF | FHC_P_CTRL_SLINE);
+ bus_space_write_4(sc->sc_bt, sc->sc_preg, FHC_P_CTRL, r);
+ bus_space_read_4(sc->sc_bt, sc->sc_preg, FHC_P_CTRL);
+ splx(s);
+
+ 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/fhcvar.h b/sys/arch/sparc64/dev/fhcvar.h
index f0307e972f7..ed2eb90a582 100644
--- a/sys/arch/sparc64/dev/fhcvar.h
+++ b/sys/arch/sparc64/dev/fhcvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fhcvar.h,v 1.5 2004/09/27 19:23:07 jason Exp $ */
+/* $OpenBSD: fhcvar.h,v 1.6 2004/09/27 21:12:40 jason Exp $ */
/*
* Copyright (c) 2004 Jason L. Wright (jason@thought.net).
@@ -50,6 +50,7 @@ struct fhc_softc {
bus_space_tag_t sc_cbt;
int sc_nrange;
struct fhc_range *sc_range;
+ struct timeout sc_to;
bus_space_handle_t sc_preg; /* internal regs */
bus_space_handle_t sc_ireg; /* ign regs */
bus_space_handle_t sc_freg; /* fanfail regs */
@@ -73,3 +74,5 @@ struct fhc_attach_args {
#define fhc_bus_map(t, slot, offset, sz, flags, hp) \
bus_space_map(t, BUS_ADDR(slot, offset), sz, flags, hp)
+
+void fhc_led_blink(void *);
diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c
index 8fa324c10a9..b03577c4762 100644
--- a/sys/arch/sparc64/sparc64/machdep.c
+++ b/sys/arch/sparc64/sparc64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.70 2004/08/02 21:40:46 brad Exp $ */
+/* $OpenBSD: machdep.c,v 1.71 2004/09/27 21:12:40 jason Exp $ */
/* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */
/*-
@@ -79,6 +79,7 @@
*/
#include "auxio.h"
+#include "fhc.h"
#include <sys/param.h>
#include <sys/extent.h>
@@ -194,9 +195,16 @@ int physmem;
u_long _randseed;
extern caddr_t msgbufaddr;
+#if (NAUXIO > 0) || (NFHC > 0)
+int sparc_led_blink;
+#endif
+
#if NAUXIO > 0
#include <sparc64/dev/auxiovar.h>
-int sparc_led_blink;
+#endif
+
+#if NFHC > 0
+#include <sparc64/dev/fhcvar.h>
#endif
#ifdef APERTURE