diff options
author | Jason Wright <jason@cvs.openbsd.org> | 1998-03-25 07:55:00 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 1998-03-25 07:55:00 +0000 |
commit | ddc8a01cb9f1a4e25776691f1a03fa45034da2ff (patch) | |
tree | 1ef1f8feb840dd14cbab948b6d90ed9e2f46431b /sys/arch | |
parent | 3edbf78187b27bebe5b6eb6f4bcf60231e84c5e0 (diff) |
Driver for the 8 leds on the back of sun4 machines.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/sparc/conf/GENERIC | 5 | ||||
-rw-r--r-- | sys/arch/sparc/conf/SUN4 | 5 | ||||
-rw-r--r-- | sys/arch/sparc/conf/files.sparc | 6 | ||||
-rw-r--r-- | sys/arch/sparc/dev/led.c | 110 | ||||
-rw-r--r-- | sys/arch/sparc/dev/led.h | 38 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/autoconf.c | 3 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/machdep.c | 19 |
7 files changed, 178 insertions, 8 deletions
diff --git a/sys/arch/sparc/conf/GENERIC b/sys/arch/sparc/conf/GENERIC index 634a5d682bf..191b214e58d 100644 --- a/sys/arch/sparc/conf/GENERIC +++ b/sys/arch/sparc/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.24 1998/03/04 19:49:10 johns Exp $ +# $OpenBSD: GENERIC,v 1.25 1998/03/25 07:54:50 jason Exp $ # $NetBSD: GENERIC,v 1.48 1997/08/23 19:19:01 mjacob Exp $ # Machine architecture; required by config(8) @@ -78,6 +78,9 @@ timer0 at obio0 addr 0xef000000 # sun4/300 eeprom0 at obio0 addr 0xf2000000 # sun4/200 eeprom0 at obio0 addr 0x02000000 # sun4/100 +# 8 segment led display on sun4 systems +led0 at mainbus0 # sun4 + # Zilog 8530 serial chips. Each has two-channels. # zs0 is ttya and ttyb. zs1 is the keyboard and mouse. zs0 at mainbus0 # sun4c diff --git a/sys/arch/sparc/conf/SUN4 b/sys/arch/sparc/conf/SUN4 index 5fb14db4a42..3f918a57413 100644 --- a/sys/arch/sparc/conf/SUN4 +++ b/sys/arch/sparc/conf/SUN4 @@ -1,4 +1,4 @@ -# $OpenBSD: SUN4,v 1.19 1998/03/04 19:49:04 johns Exp $ +# $OpenBSD: SUN4,v 1.20 1998/03/25 07:54:52 jason Exp $ # $NetBSD: GENERIC,v 1.28.2.1 1996/07/02 23:55:22 jtc Exp $ # Machine architecture; required by config(8) @@ -52,6 +52,9 @@ timer0 at obio0 addr 0xef000000 # sun4/300 eeprom0 at obio0 addr 0xf2000000 # sun4/200 eeprom0 at obio0 addr 0x02000000 # sun4/100 +# 8 segment led display on sun4 systems +led0 at mainbus0 # sun4 + # Zilog 8530 serial chips. Each has two-channels. # zs0 is ttya and ttyb. zs1 is the keyboard and mouse. zs0 at obio0 addr 0xf1000000 level 12 flags 0x103 # sun4/200 and sun4/300 diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc index dc6105a328a..4d9d9c3182c 100644 --- a/sys/arch/sparc/conf/files.sparc +++ b/sys/arch/sparc/conf/files.sparc @@ -1,4 +1,4 @@ -# $OpenBSD: files.sparc,v 1.14 1997/09/17 06:47:05 downsj Exp $ +# $OpenBSD: files.sparc,v 1.15 1998/03/25 07:54:53 jason Exp $ # $NetBSD: files.sparc,v 1.44 1997/08/31 21:29:16 pk Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 @@ -49,6 +49,10 @@ device power attach power at obio file arch/sparc/dev/power.c power needs-count +device led +attach led at mainbus +file arch/sparc/dev/led.c led needs-count + device cpu attach cpu at mainbus file arch/sparc/sparc/cpu.c diff --git a/sys/arch/sparc/dev/led.c b/sys/arch/sparc/dev/led.c new file mode 100644 index 00000000000..da631ded13c --- /dev/null +++ b/sys/arch/sparc/dev/led.c @@ -0,0 +1,110 @@ +/* $Id: led.c,v 1.1 1998/03/25 07:54:56 jason Exp $ */ + +/* + * Copyright (c) 1998 Jason L. Wright (jason@thought.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jason Wright + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/device.h> +#include <sys/kernel.h> +#include <sys/systm.h> + +#include <machine/autoconf.h> +#include <machine/ctlreg.h> +#include <sparc/sparc/asm.h> +#include <sparc/dev/led.h> + +/* + * This is the driver for the "led" register available on some Sun4 + * machines. + */ + +static int ledmatch __P((struct device *, void *, void *)); +static void ledattach __P((struct device *, struct device *, void *)); + +struct cfattach led_ca = { + sizeof(struct device), ledmatch, ledattach +}; + +struct cfdriver led_cd = { + NULL, "led", DV_DULL +}; + +extern int sparc_led_blink; /* from machdep */ + +static char led_attached = 0; +static int led_index = 0; +static char led_patterns[] = + { 0xff, 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe, + 0xff, 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f, }; + +static int +ledmatch(parent, vcf, aux) + struct device *parent; + void *aux, *vcf; +{ + register struct confargs *ca = aux; + + if (CPU_ISSUN4) + return (strcmp("led", ca->ca_ra.ra_name) == 0); + return (0); +} + +/* ARGSUSED */ +static void +ledattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + led_attached = 1; + printf("\n"); +} + +/* + * led_sun4_cycle: + * check to see whether we were configured and whether + * machdep.led_blink != 0, if so, put a new pattern into + * the register. + */ +void +led_sun4_cycle(zero) + void *zero; +{ + int s; + + if (!sparc_led_blink || !led_attached) + return; + led_index = (led_index + 1) % sizeof(led_patterns); + s = splhigh(); + stba(AC_DIAG_REG, ASI_CONTROL, led_patterns[led_index]); + splx(s); + s = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 3)); + timeout(led_sun4_cycle, (caddr_t)0, s); +} diff --git a/sys/arch/sparc/dev/led.h b/sys/arch/sparc/dev/led.h new file mode 100644 index 00000000000..e77e4b4fb67 --- /dev/null +++ b/sys/arch/sparc/dev/led.h @@ -0,0 +1,38 @@ +/* $Id: led.h,v 1.1 1998/03/25 07:54:56 jason Exp $ */ + +/* + * Copyright (c) 1998 Jason L. Wright (jason@thought.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jason Wright + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Sun-4 diag register. + */ + +void led_sun4_cycle __P((void *)); diff --git a/sys/arch/sparc/sparc/autoconf.c b/sys/arch/sparc/sparc/autoconf.c index ee080bd584a..a09fbaa9dd3 100644 --- a/sys/arch/sparc/sparc/autoconf.c +++ b/sys/arch/sparc/sparc/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.26 1998/03/09 09:15:28 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.27 1998/03/25 07:54:57 jason Exp $ */ /* $NetBSD: autoconf.c,v 1.73 1997/07/29 09:41:53 fair Exp $ */ /* @@ -1074,6 +1074,7 @@ mainbus_attach(parent, dev, aux) static const char *const oldmon_special[] = { "vmel", "vmes", + "led", NULL }; #endif /* SUN4 */ diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c index dd2fb1a2ff0..01c12b203a4 100644 --- a/sys/arch/sparc/sparc/machdep.c +++ b/sys/arch/sparc/sparc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.32 1998/03/01 09:24:28 johns Exp $ */ +/* $OpenBSD: machdep.c,v 1.33 1998/03/25 07:54:59 jason Exp $ */ /* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */ /* @@ -98,6 +98,11 @@ #include "auxreg.h" +#ifdef SUN4 +#include <sparc/dev/led.h> +#include "led.h" +#endif + vm_map_t buffer_map; extern vm_offset_t avail_end; @@ -463,7 +468,7 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) size_t newlen; struct proc *p; { -#if NAUXREG > 0 +#if (NAUXREG > 0) || (NLED > 0) int ret, oldval; #endif @@ -473,7 +478,7 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) switch (name[0]) { case CPU_LED_BLINK: -#if NAUXREG > 0 +#if (NLED > 0) || (NAUXREG > 0) oldval = sparc_led_blink; ret = sysctl_int(oldp, oldlenp, newp, newlen, &sparc_led_blink); @@ -482,8 +487,14 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) * If we were false and are now true, call led_blink(). * led_blink() itself will catch the other case. */ - if (!oldval && sparc_led_blink > oldval) + if (!oldval && sparc_led_blink > oldval) { +#if NAUXREG > 0 led_blink((caddr_t *)0); +#endif +#if NLED > 0 + led_sun4_cycle((caddr_t *)0); +#endif + } return (ret); #else |