implement `options BLINK' for sparc64 for ebus & sbus. tested on a U2
(sbus) and a U5 (ebus).
This commit is contained in:
parent
273cdba6ea
commit
abcb6203a8
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: auxio.c,v 1.1 2000/04/15 03:08:13 mrg Exp $ */
|
||||
/* $NetBSD: auxio.c,v 1.2 2001/10/22 07:31:41 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Matthew R. Green
|
||||
* Copyright (c) 2000, 2001 Matthew R. Green
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -29,11 +29,14 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* AUXIO registers support on the sbus & ebus2.
|
||||
* AUXIO registers support on the sbus & ebus2, used for the floppy driver
|
||||
* and to control the system LED, for the BLINK option.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/callout.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/malloc.h>
|
||||
@ -41,30 +44,107 @@
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/cpu.h>
|
||||
|
||||
#include <sparc64/dev/ebusreg.h>
|
||||
#include <dev/ebus/ebusreg.h>
|
||||
#include <sparc64/dev/ebusvar.h>
|
||||
#include <sparc64/dev/sbusvar.h>
|
||||
#include <sparc64/dev/auxioreg.h>
|
||||
#include <sparc64/dev/auxiovar.h>
|
||||
|
||||
/*
|
||||
* on sun4u, auxio exists with one register (LED) on the sbus, and 5
|
||||
* registers on the ebus2 (pci) (LED, PCIMODE, FREQUENCY, SCSI
|
||||
* OSCILLATOR, and TEMP SENSE.
|
||||
*/
|
||||
|
||||
struct auxio_softc {
|
||||
struct device sc_dev;
|
||||
|
||||
/* parent's tag */
|
||||
bus_space_tag_t sc_tag;
|
||||
|
||||
/* handles to the various auxio regsiter sets */
|
||||
bus_space_handle_t sc_led;
|
||||
bus_space_handle_t sc_pci;
|
||||
bus_space_handle_t sc_freq;
|
||||
bus_space_handle_t sc_scsi;
|
||||
bus_space_handle_t sc_temp;
|
||||
|
||||
int sc_flags;
|
||||
#define AUXIO_LEDONLY 0x1
|
||||
#define AUXIO_EBUS 0x2
|
||||
#define AUXIO_SBUS 0x4
|
||||
};
|
||||
|
||||
#define AUXIO_ROM_NAME "auxio"
|
||||
|
||||
/*
|
||||
* ebus code.
|
||||
*/
|
||||
int auxio_ebus_match __P((struct device *, struct cfdata *, void *));
|
||||
void auxio_ebus_attach __P((struct device *, struct device *, void *));
|
||||
int auxio_sbus_match __P((struct device *, struct cfdata *, void *));
|
||||
void auxio_sbus_attach __P((struct device *, struct device *, void *));
|
||||
void auxio_attach_common(struct auxio_softc *);
|
||||
int auxio_ebus_match(struct device *, struct cfdata *, void *);
|
||||
void auxio_ebus_attach(struct device *, struct device *, void *);
|
||||
int auxio_sbus_match(struct device *, struct cfdata *, void *);
|
||||
void auxio_sbus_attach(struct device *, struct device *, void *);
|
||||
|
||||
struct cfattach auxio_ebus_ca = {
|
||||
sizeof(struct auxio_softc), auxio_ebus_match, auxio_ebus_attach
|
||||
};
|
||||
|
||||
struct cfattach auxio_sbus_ca = {
|
||||
sizeof(struct auxio_softc), auxio_sbus_match, auxio_sbus_attach
|
||||
};
|
||||
|
||||
#ifdef BLINK
|
||||
static struct callout blink_ch = CALLOUT_INITIALIZER;
|
||||
|
||||
static void auxio_blink(void *);
|
||||
|
||||
static void
|
||||
auxio_blink(x)
|
||||
void *x;
|
||||
{
|
||||
struct auxio_softc *sc = x;
|
||||
int s;
|
||||
u_int32_t led;
|
||||
|
||||
s = splhigh();
|
||||
if (sc->sc_flags & AUXIO_EBUS)
|
||||
led = le32toh(bus_space_read_4(sc->sc_tag, sc->sc_led, 0));
|
||||
else
|
||||
led = bus_space_read_1(sc->sc_tag, sc->sc_led, 0);
|
||||
if (led & AUXIO_LED_LED)
|
||||
led = 0;
|
||||
else
|
||||
led = AUXIO_LED_LED;
|
||||
if (sc->sc_flags & AUXIO_EBUS)
|
||||
bus_space_write_4(sc->sc_tag, sc->sc_led, 0, htole32(led));
|
||||
else
|
||||
bus_space_write_1(sc->sc_tag, sc->sc_led, 0, led);
|
||||
splx(s);
|
||||
|
||||
/*
|
||||
* 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));
|
||||
callout_reset(&blink_ch, s, auxio_blink, sc);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
auxio_attach_common(sc)
|
||||
struct auxio_softc *sc;
|
||||
{
|
||||
static int do_once = 1;
|
||||
|
||||
#ifdef BLINK
|
||||
/* only start one blinker */
|
||||
if (do_once) {
|
||||
auxio_blink(sc);
|
||||
do_once = 0;
|
||||
}
|
||||
#endif
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int
|
||||
auxio_ebus_match(parent, cf, aux)
|
||||
struct device *parent;
|
||||
@ -95,17 +175,16 @@ auxio_ebus_attach(parent, self, aux)
|
||||
sc->sc_flags = AUXIO_LEDONLY|AUXIO_EBUS;
|
||||
} else {
|
||||
sc->sc_flags = AUXIO_EBUS;
|
||||
sc->sc_registers.auxio_pci = (u_int32_t *)(u_long)ea->ea_vaddrs[1];
|
||||
sc->sc_registers.auxio_freq = (u_int32_t *)(u_long)ea->ea_vaddrs[2];
|
||||
sc->sc_registers.auxio_scsi = (u_int32_t *)(u_long)ea->ea_vaddrs[3];
|
||||
sc->sc_registers.auxio_temp = (u_int32_t *)(u_long)ea->ea_vaddrs[4];
|
||||
sc->sc_pci = (bus_space_handle_t)(u_long)ea->ea_vaddrs[1];
|
||||
sc->sc_freq = (bus_space_handle_t)(u_long)ea->ea_vaddrs[2];
|
||||
sc->sc_scsi = (bus_space_handle_t)(u_long)ea->ea_vaddrs[3];
|
||||
sc->sc_temp = (bus_space_handle_t)(u_long)ea->ea_vaddrs[4];
|
||||
}
|
||||
sc->sc_registers.auxio_led = (u_int32_t *)(u_long)ea->ea_vaddrs[0];
|
||||
sc->sc_led = (bus_space_handle_t)(u_long)ea->ea_vaddrs[0];
|
||||
|
||||
if (!auxio_reg)
|
||||
auxio_reg = (u_char *)(u_long)ea->ea_vaddrs[0];
|
||||
sc->sc_tag = ea->ea_bustag;
|
||||
|
||||
printf("\n");
|
||||
auxio_attach_common(sc);
|
||||
}
|
||||
|
||||
int
|
||||
@ -133,31 +212,16 @@ auxio_sbus_attach(parent, self, aux)
|
||||
}
|
||||
|
||||
if (sa->sa_nreg != 1 || sa->sa_npromvaddrs != 1) {
|
||||
printf(": not 1 (%d/%d) registers??", sa->sa_nreg, sa->sa_npromvaddrs);
|
||||
printf(": not 1 (%d/%d) registers??", sa->sa_nreg,
|
||||
sa->sa_npromvaddrs);
|
||||
return;
|
||||
}
|
||||
|
||||
/* sbus auxio only has one set of registers */
|
||||
sc->sc_flags = AUXIO_LEDONLY|AUXIO_SBUS;
|
||||
sc->sc_registers.auxio_led = (u_int32_t *)(u_long)sa->sa_promvaddr;
|
||||
sc->sc_led = (bus_space_handle_t)(u_long)sa->sa_promvaddr;
|
||||
|
||||
if (!auxio_reg)
|
||||
auxio_reg = (u_char *)(u_long)sa->sa_promvaddr;
|
||||
sc->sc_tag = sa->sa_bustag;
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* old interface; used by fd driver for now
|
||||
*/
|
||||
unsigned int
|
||||
auxregbisc(bis, bic)
|
||||
int bis, bic;
|
||||
{
|
||||
register int v, s = splhigh();
|
||||
|
||||
v = *auxio_reg;
|
||||
*auxio_reg = ((v | bis) & ~bic) | AUXIO_LED_MB1;
|
||||
splx(s);
|
||||
return v;
|
||||
auxio_attach_common(sc);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: auxioreg.h,v 1.3 2000/04/15 03:08:13 mrg Exp $ */
|
||||
/* $NetBSD: auxioreg.h,v 1.4 2001/10/22 07:31:41 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Matthew R. Green
|
||||
@ -46,17 +46,7 @@
|
||||
#define AUXIO_POWER_COURTESY_OFF 0x1
|
||||
|
||||
#define AUXIO_LED 0x00726000
|
||||
#define AUXIO_LED_LED 0x0
|
||||
#define AUXIO_LED_MB1 0xf0 /* must be set on write */
|
||||
/* XXX: these may be useless on Ebus2 auxio! find out! */
|
||||
#define AUXIO_LED_FHD 0x20 /* floppy: high density (unreliable?)*/
|
||||
#define AUXIO_LED_FDC 0x10 /* floppy: diskette was changed */
|
||||
#define AUXIO_LED_FDS 0x08 /* floppy: drive select */
|
||||
#define AUXIO_LED_FTC 0x04 /* floppy: drives Terminal Count pin */
|
||||
#define AUXIO_LED_FEJ 0x02 /* floppy: eject disk */
|
||||
#if 0
|
||||
#define AUXIO_LED_LED 0x01 /* front panel LED */
|
||||
#endif
|
||||
#define AUXIO_LED_LED 1
|
||||
|
||||
#define AUXIO_PCI 0x00728000
|
||||
#define AUXIO_PCI_SLOT0 0x0 /* two bits each */
|
||||
|
@ -1,73 +0,0 @@
|
||||
/* $NetBSD: auxiovar.h,v 1.4 2000/04/15 03:08:13 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Matthew R. Green
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* on sun4u, auxio exists with one register (LED) on the sbus, and 5
|
||||
* registers on the ebus2 (pci) (LED, PCIMODE, FREQUENCY, SCSI
|
||||
* OSCILLATOR, and TEMP SENSE.
|
||||
*
|
||||
* clients of the auxio registers (eg, blinken lights, or the sbus
|
||||
* floppy) should search in auxio_cd for their matching auxio register
|
||||
* (to deal with multiple auxio's that may appear.)
|
||||
*/
|
||||
|
||||
struct auxio_registers {
|
||||
#if 0 /* these do not exist on the Ebus2 */
|
||||
volatile u_int32_t *auxio_fd;
|
||||
volatile u_int32_t *auxio_audio;
|
||||
volatile u_int32_t *auxio_power;
|
||||
#endif
|
||||
volatile u_int32_t *auxio_led;
|
||||
volatile u_int32_t *auxio_pci;
|
||||
volatile u_int32_t *auxio_freq;
|
||||
volatile u_int32_t *auxio_scsi;
|
||||
volatile u_int32_t *auxio_temp;
|
||||
};
|
||||
|
||||
struct auxio_softc {
|
||||
struct device sc_dev;
|
||||
struct auxio_registers sc_registers;
|
||||
int sc_flags;
|
||||
#define AUXIO_LEDONLY 0x1
|
||||
#define AUXIO_EBUS 0x2
|
||||
#define AUXIO_SBUS 0x4
|
||||
};
|
||||
|
||||
/*
|
||||
* XXX: old interfaces. we set auxio_reg the first auxio we attach.
|
||||
*/
|
||||
#ifndef _LOCORE
|
||||
/*
|
||||
* Copy of AUXIO_REG for the benefit of assembler modules (eg. trap handlers)
|
||||
* as AUXREG_VA depends on NBPG which is not a constant.
|
||||
*/
|
||||
volatile u_char *auxio_reg;
|
||||
unsigned int auxregbisc __P((int, int));
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user