summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64/dev
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/sparc64/dev
parent6208d149720daeacdcd839c01029b1e4e87dd803 (diff)
Important stuff: blinky lights for fhc
Diffstat (limited to 'sys/arch/sparc64/dev')
-rw-r--r--sys/arch/sparc64/dev/fhc.c47
-rw-r--r--sys/arch/sparc64/dev/fhcvar.h5
2 files changed, 50 insertions, 2 deletions
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 *);