diff options
author | Jason Wright <jason@cvs.openbsd.org> | 1999-03-01 04:56:06 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 1999-03-01 04:56:06 +0000 |
commit | 3d7a221c1d80b005419fa5addf0c89b19e15e945 (patch) | |
tree | 6152ad1aaf3484176580a81d3e4a9dfb942c22da /sys | |
parent | a8acb50f28386be40de525479947be7b656e02e1 (diff) |
led driver support for 4/[1236]00 machines
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sparc/conf/GENERIC | 5 | ||||
-rw-r--r-- | sys/arch/sparc/conf/GENERIC_SCSI3 | 6 | ||||
-rw-r--r-- | sys/arch/sparc/conf/SUN4M | 5 | ||||
-rw-r--r-- | sys/arch/sparc/conf/files.sparc | 4 | ||||
-rw-r--r-- | sys/arch/sparc/dev/led.c | 140 | ||||
-rw-r--r-- | sys/arch/sparc/dev/led.h | 14 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/machdep.c | 4 |
7 files changed, 119 insertions, 59 deletions
diff --git a/sys/arch/sparc/conf/GENERIC b/sys/arch/sparc/conf/GENERIC index 3273a514fc6..56b7a75f4cd 100644 --- a/sys/arch/sparc/conf/GENERIC +++ b/sys/arch/sparc/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.37 1999/02/16 21:30:21 art Exp $ +# $OpenBSD: GENERIC,v 1.38 1999/03/01 04:56:03 jason Exp $ # $NetBSD: GENERIC,v 1.48 1997/08/23 19:19:01 mjacob Exp $ # Machine architecture; required by config(8) @@ -79,8 +79,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 +# 8 segment led display on sun4/sun4m systems led0 at mainbus0 # sun4 +led0 at obio0 # sun4/600 # Zilog 8530 serial chips. Each has two-channels. # zs0 is ttya and ttyb. zs1 is the keyboard and mouse. diff --git a/sys/arch/sparc/conf/GENERIC_SCSI3 b/sys/arch/sparc/conf/GENERIC_SCSI3 index 876b30e3e6e..b492755dcfd 100644 --- a/sys/arch/sparc/conf/GENERIC_SCSI3 +++ b/sys/arch/sparc/conf/GENERIC_SCSI3 @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC_SCSI3,v 1.26 1999/02/16 21:30:21 art Exp $ +# $OpenBSD: GENERIC_SCSI3,v 1.27 1999/03/01 04:56:04 jason Exp $ # $NetBSD: GENERIC,v 1.28.2.1 1996/07/02 23:55:22 jtc Exp $ # Machine architecture; required by config(8) @@ -78,6 +78,10 @@ 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/sun4m systems +led0 at mainbus0 # sun4 +led0 at obio0 # sun4/600 + # 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/SUN4M b/sys/arch/sparc/conf/SUN4M index 6952db131c2..a681d9ea779 100644 --- a/sys/arch/sparc/conf/SUN4M +++ b/sys/arch/sparc/conf/SUN4M @@ -1,4 +1,4 @@ -# $OpenBSD: SUN4M,v 1.27 1999/02/16 21:30:21 art Exp $ +# $OpenBSD: SUN4M,v 1.28 1999/03/01 04:56:04 jason Exp $ # $NetBSD: GENERIC,v 1.28.2.1 1996/07/02 23:55:22 jtc Exp $ # Machine architecture; required by config(8) @@ -50,6 +50,9 @@ memreg0 at obio0 # sun4m # Timer chip found on 4/300, sun4c, and sun4m systems. timer0 at obio0 # sun4m +# 8 segment led display on sun4/sun4m systems +led0 at obio0 # sun4m + # Zilog 8530 serial chips. Each has two-channels. # zs0 is ttya and ttyb. zs1 is the keyboard and mouse. zs0 at obio0 # sun4m diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc index 97299e6a93b..e31e795ae72 100644 --- a/sys/arch/sparc/conf/files.sparc +++ b/sys/arch/sparc/conf/files.sparc @@ -1,4 +1,4 @@ -# $OpenBSD: files.sparc,v 1.26 1999/02/01 13:09:51 jason Exp $ +# $OpenBSD: files.sparc,v 1.27 1999/03/01 04:56:03 jason Exp $ # $NetBSD: files.sparc,v 1.44 1997/08/31 21:29:16 pk Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 @@ -50,7 +50,7 @@ attach power at obio file arch/sparc/dev/power.c power needs-count device led -attach led at mainbus +attach led at mainbus, obio file arch/sparc/dev/led.c led needs-count device cpu diff --git a/sys/arch/sparc/dev/led.c b/sys/arch/sparc/dev/led.c index 87ee9a4aedf..39f13ebe86d 100644 --- a/sys/arch/sparc/dev/led.c +++ b/sys/arch/sparc/dev/led.c @@ -1,4 +1,4 @@ -/* $OpenBSD: led.c,v 1.4 1998/09/15 04:27:08 jason Exp $ */ +/* $OpenBSD: led.c,v 1.5 1999/03/01 04:56:05 jason Exp $ */ /* * Copyright (c) 1998 Jason L. Wright (jason@thought.net) @@ -31,88 +31,132 @@ * POSSIBILITY OF SUCH DAMAGE. */ +/* + * Driver for leds on the 4/100, 4/200, 4/300, and 4/600. (sun4 & sun4m) + */ + #include <sys/param.h> -#include <sys/device.h> -#include <sys/kernel.h> #include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/errno.h> +#include <sys/socket.h> +#include <sys/syslog.h> +#include <sys/device.h> +#include <sys/malloc.h> #include <machine/autoconf.h> #include <machine/ctlreg.h> #include <sparc/sparc/asm.h> +#include <sparc/cpu.h> +#include <sparc/sparc/cpuvar.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 *)); +int ledmatch __P((struct device *, void *, void *)); +void ledattach __P((struct device *, struct device *, void *)); +void led_cycle __P((void *)); struct cfattach led_ca = { - sizeof(struct device), ledmatch, ledattach + sizeof (struct led_softc), ledmatch, ledattach }; struct cfdriver led_cd = { - NULL, "led", DV_DULL + NULL, "led", DV_IFNET }; -extern int sparc_led_blink; /* from machdep */ +static u_int8_t led_pattern[] = { + 0xff, 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f, + 0xff, 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe, +}; -static char led_attached = 0; -static int led_index = 0; -/* - * These led patterns produce a line that scrolls across the display, then - * back again. Note that a value of 0 for a particular bit lights the - * corresponding LED, and 1 leaves it dark. - */ -static char led_patterns[] = - { 0xff, 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe, - 0xff, 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f, }; +struct led_softc *led_sc = NULL; +extern int sparc_led_blink; /* from machdep */ -static int +int ledmatch(parent, vcf, aux) struct device *parent; - void *aux, *vcf; + void *vcf, *aux; { - register struct confargs *ca = aux; +#if defined(SUN4) + struct cfdata *cf = vcf; +#endif + struct confargs *ca = aux; + register struct romaux *ra = &ca->ca_ra; + +#if defined(SUN4M) + if (ca->ca_bustype == BUS_OBIO) { + if (strcmp("leds", ra->ra_name)) + return (0); + return (1); + } +#endif + +#if defined(SUN4) + if (ca->ca_bustype == BUS_MAIN) { + if (strcmp(cf->cf_driver->cd_name, ra->ra_name)) + return (0); + if (CPU_ISSUN4) + return (1); + return (0); + } +#endif - if (CPU_ISSUN4) - return (strcmp("led", ca->ca_ra.ra_name) == 0); return (0); } -/* ARGSUSED */ -static void +void ledattach(parent, self, aux) struct device *parent, *self; void *aux; { - led_attached = 1; - printf("\n"); + struct confargs *ca = aux; + struct led_softc *sc = (struct led_softc *)self; + + sc->sc_node = ca->ca_ra.ra_node; - /* In case it's initialized to true... */ + if (CPU_ISSUN4M) + sc->sc_reg = mapiodev(&(ca->ca_ra.ra_reg[0]), 0, + ca->ca_ra.ra_reg[0].rr_len); + + led_sc = sc; if (sparc_led_blink) - led_sun4_cycle((caddr_t)0); + led_cycle(sc); + printf("\n"); } -/* - * Check to see whether we were configured and whether machdep.led_blink != 0. - * If so, put a new pattern into the register and schedule ourselves to - * be called again later. The timeout is set to: [(1/8) * loadavg] seconds. - */ void -led_sun4_cycle(zero) - void *zero; +led_cycle(v) + void *v; { + struct led_softc *sc = v; int s; - if (!sparc_led_blink || !led_attached) + if (sc == NULL) 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); + + sc->sc_index = (sc->sc_index + 1) % + (sizeof(led_pattern)/sizeof(led_pattern[0])); + + if (sparc_led_blink == 0) + sc->sc_index = 0; + +#if defined(SUN4M) + if (CPU_ISSUN4M) { + s = splhigh(); + (*sc->sc_reg) = led_pattern[sc->sc_index] | 0xff00; + splx(s); + } +#endif + +#if defined(SUN4) + if (CPU_ISSUN4) { + s = splhigh(); + stba(AC_DIAG_REG, ASI_CONTROL, led_pattern[sc->sc_index]); + splx(s); + } +#endif + + if (sparc_led_blink != 0) { + s = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 3)); + timeout(led_cycle, sc, s); + } } diff --git a/sys/arch/sparc/dev/led.h b/sys/arch/sparc/dev/led.h index 7cd51a3bab9..f362de852f2 100644 --- a/sys/arch/sparc/dev/led.h +++ b/sys/arch/sparc/dev/led.h @@ -1,4 +1,4 @@ -/* $OpenBSD: led.h,v 1.2 1998/03/26 07:04:31 jason Exp $ */ +/* $OpenBSD: led.h,v 1.3 1999/03/01 04:56:05 jason Exp $ */ /* * Copyright (c) 1998 Jason L. Wright (jason@thought.net) @@ -32,7 +32,15 @@ */ /* - * Sun-4 diag register. + * Driver for leds on the 4/100, 4/200, 4/300, and 4/600 */ -void led_sun4_cycle __P((void *)); +struct led_softc { + struct device sc_dev; /* base device */ + int sc_node; /* which node */ + u_int16_t * sc_reg; /* register (4/600) */ + int sc_index; /* index into patterns */ +}; +extern struct led_softc *led_sc; + +void led_cycle __P((void *)); diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c index 01c12b203a4..cbc4e005b46 100644 --- a/sys/arch/sparc/sparc/machdep.c +++ b/sys/arch/sparc/sparc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.33 1998/03/25 07:54:59 jason Exp $ */ +/* $OpenBSD: machdep.c,v 1.34 1999/03/01 04:56:05 jason Exp $ */ /* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */ /* @@ -492,7 +492,7 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) led_blink((caddr_t *)0); #endif #if NLED > 0 - led_sun4_cycle((caddr_t *)0); + led_cycle((caddr_t *)led_sc); #endif } |