Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/evbsh5/dev A couple of additions:
details: https://anonhg.NetBSD.org/src/rev/28cc111a28c2
branches: trunk
changeset: 537733:28cc111a28c2
user: scw <scw%NetBSD.org@localhost>
date: Sat Oct 05 10:59:10 2002 +0000
description:
A couple of additions:
- sysfpga_sreset()
Hit the soft-reset register to reset the board.
- sysfpga_twinkle_led()
Might as well put the blinkenlight on the Cayman to good use as
a "heartbeat" indicator.
diffstat:
sys/arch/evbsh5/dev/sysfpga.c | 52 +++++++++++++++++++++++++++++++++++++++-
sys/arch/evbsh5/dev/sysfpgareg.h | 4 ++-
sys/arch/evbsh5/dev/sysfpgavar.h | 3 +-
3 files changed, 56 insertions(+), 3 deletions(-)
diffs (131 lines):
diff -r fa59044503a1 -r 28cc111a28c2 sys/arch/evbsh5/dev/sysfpga.c
--- a/sys/arch/evbsh5/dev/sysfpga.c Sat Oct 05 10:47:51 2002 +0000
+++ b/sys/arch/evbsh5/dev/sysfpga.c Sat Oct 05 10:59:10 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysfpga.c,v 1.9 2002/10/02 05:33:54 thorpej Exp $ */
+/* $NetBSD: sysfpga.c,v 1.10 2002/10/05 10:59:10 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@@ -42,7 +42,9 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/callout.h>
#include <sys/device.h>
+#include <sys/kernel.h>
#include <machine/cpu.h>
#include <machine/bus.h>
@@ -65,6 +67,7 @@
struct device sc_dev;
bus_space_tag_t sc_bust;
bus_space_handle_t sc_bush;
+ struct callout sc_ledco;
u_int8_t sc_intmr[SYSFPGA_NGROUPS];
void *sc_ih[SYSFPGA_NGROUPS];
#if NSUPERIO > 0
@@ -103,6 +106,9 @@
#define sysfpga_reg_write(s,r,v) \
bus_space_write_4((s)->sc_bust, (s)->sc_bush, (r), (v))
+
+static void sysfpga_twinkle_led(void *);
+
#if NSUPERIO > 0
static int sysfpga_intr_handler_irl1(void *);
#endif
@@ -207,6 +213,13 @@
#endif
/*
+ * Arrange to twinkle the "Discrete LED" periodically
+ * as a crude "heartbeat" indication.
+ */
+ callout_init(&sc->sc_ledco);
+ sysfpga_twinkle_led(sc);
+
+ /*
* Attach configured children
*/
sa._sa_base = fa->fa_offset;
@@ -233,6 +246,35 @@
return (UNCONF);
}
+static void
+sysfpga_twinkle_led(void *arg)
+{
+ struct sysfpga_softc *sc = arg;
+ u_int32_t ledcr;
+ int next;
+
+ /*
+ * Flip the state of the Cayman's discrete LED
+ */
+ ledcr = sysfpga_reg_read(sc, SYSFPGA_REG_LEDCR);
+ ledcr ^= SYSFPGA_LEDCR_SLED_MASK;
+ sysfpga_reg_write(sc, SYSFPGA_REG_LEDCR, ledcr);
+ ledcr &= SYSFPGA_LEDCR_SLED_MASK;
+
+ /*
+ * We flash the LED twice per second, with 25% duty-cycle for ON
+ */
+#define TWINKLE_PERIOD (hz / 2)
+
+ next = (ledcr == SYSFPGA_LEDCR_SLED_ON) ?
+ TWINKLE_PERIOD / 4 :
+ TWINKLE_PERIOD - (TWINKLE_PERIOD / 4);
+
+#undef TWINKLE_PERIOD
+
+ callout_reset(&sc->sc_ledco, next, sysfpga_twinkle_led, sc);
+}
+
#if NSUPERIO > 0
static int
sysfpga_intr_handler_irl1(void *arg)
@@ -481,3 +523,11 @@
sysfpga_reg_write(sysfpga_sc, SYSFPGA_REG_NMISR, 0);
}
+
+void
+sysfpga_sreset(void)
+{
+
+ sysfpga_reg_write(sysfpga_sc, SYSFPGA_REG_SOFT_RESET,
+ SYSFPGA_SOFT_RESET_ASSERT);
+}
diff -r fa59044503a1 -r 28cc111a28c2 sys/arch/evbsh5/dev/sysfpgareg.h
--- a/sys/arch/evbsh5/dev/sysfpgareg.h Sat Oct 05 10:47:51 2002 +0000
+++ b/sys/arch/evbsh5/dev/sysfpgareg.h Sat Oct 05 10:59:10 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysfpgareg.h,v 1.1 2002/07/05 13:31:39 scw Exp $ */
+/* $NetBSD: sysfpgareg.h,v 1.2 2002/10/05 10:59:10 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@@ -104,4 +104,6 @@
#define SYSFPGA_DATE_MONTH(r) (((r) >> 16) & 0xff)
#define SYSFPGA_DATE_YEAR(r) (((r) >> 24) & 0xff)
+#define SYSFPGA_SOFT_RESET_ASSERT 0xDEAD
+
#endif /* _SH5_SYSFPGAREG_H */
diff -r fa59044503a1 -r 28cc111a28c2 sys/arch/evbsh5/dev/sysfpgavar.h
--- a/sys/arch/evbsh5/dev/sysfpgavar.h Sat Oct 05 10:47:51 2002 +0000
+++ b/sys/arch/evbsh5/dev/sysfpgavar.h Sat Oct 05 10:59:10 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysfpgavar.h,v 1.4 2002/09/28 11:16:38 scw Exp $ */
+/* $NetBSD: sysfpgavar.h,v 1.5 2002/10/05 10:59:10 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@@ -96,5 +96,6 @@
extern void *sysfpga_intr_establish(int, int, int, int (*)(void *), void *);
extern void sysfpga_intr_disestablish(void *);
extern void sysfpga_nmi_clear(void);
+extern void sysfpga_sreset(void);
#endif /* _SH5_SYSFPGAVAR_H */
Home |
Main Index |
Thread Index |
Old Index