summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-08-22 14:17:05 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-08-22 14:17:05 +0000
commitc31ac6a5afbf940eae73a23ee5d0b8cffc799b4b (patch)
tree3e4eb497d7ae5fc41d32717569c8f28c9e528569
parenta512cd805bdfefe09dafb92d2c80fd1fc9ed7902 (diff)
auxio from NetBSD
-rw-r--r--sys/arch/sparc64/dev/auxio.c167
-rw-r--r--sys/arch/sparc64/dev/auxioreg.h82
2 files changed, 249 insertions, 0 deletions
diff --git a/sys/arch/sparc64/dev/auxio.c b/sys/arch/sparc64/dev/auxio.c
new file mode 100644
index 00000000000..ec99cf7aa86
--- /dev/null
+++ b/sys/arch/sparc64/dev/auxio.c
@@ -0,0 +1,167 @@
+/* $NetBSD: auxio.c,v 1.1 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.
+ */
+
+/*
+ * AUXIO registers support on the sbus & ebus2.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+
+#include <machine/autoconf.h>
+#include <machine/cpu.h>
+
+#include <sparc64/dev/ebusreg.h>
+#include <sparc64/dev/ebusvar.h>
+#include <sparc64/dev/sbusvar.h>
+#include <sparc64/dev/auxioreg.h>
+#include <sparc64/dev/auxiovar.h>
+
+#define AUXIO_ROM_NAME "auxio"
+
+/*
+ * ebus code.
+ */
+int auxio_ebus_match __P((struct device *, void *, void *));
+void auxio_ebus_attach __P((struct device *, struct device *, void *));
+int auxio_sbus_match __P((struct device *, void *, void *));
+void auxio_sbus_attach __P((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
+};
+
+struct cfdriver auxio_cd = {
+ NULL, "auxio", DV_DULL
+};
+
+int
+auxio_ebus_match(parent, cf, aux)
+ struct device *parent;
+ void *cf;
+ void *aux;
+{
+ struct ebus_attach_args *ea = aux;
+
+ return (strcmp(AUXIO_ROM_NAME, ea->ea_name) == 0);
+}
+
+void
+auxio_ebus_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct auxio_softc *sc = (struct auxio_softc *)self;
+ struct ebus_attach_args *ea = aux;
+
+ if (ea->ea_nregs < 1 || ea->ea_nvaddrs < 1) {
+ printf(": no registers??\n");
+ return;
+ }
+
+ if (ea->ea_nregs != 5 || ea->ea_nvaddrs != 5) {
+ printf(": not 5 (%d) registers, only setting led",
+ ea->ea_nregs);
+ 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_registers.auxio_led = (u_int32_t *)(u_long)ea->ea_vaddrs[0];
+
+ if (!auxio_reg)
+ auxio_reg = (u_char *)(u_long)ea->ea_vaddrs[0];
+
+ printf("\n");
+}
+
+int
+auxio_sbus_match(parent, cf, aux)
+ struct device *parent;
+ void *cf;
+ void *aux;
+{
+ struct sbus_attach_args *sa = aux;
+
+ return (strcmp(AUXIO_ROM_NAME, sa->sa_name) == 0);
+}
+
+void
+auxio_sbus_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct auxio_softc *sc = (struct auxio_softc *)self;
+ struct sbus_attach_args *sa = aux;
+
+ if (sa->sa_nreg < 1 || sa->sa_npromvaddrs < 1) {
+ printf(": no registers??\n");
+ return;
+ }
+
+ if (sa->sa_nreg != 1 || sa->sa_npromvaddrs != 1) {
+ 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;
+
+ if (!auxio_reg)
+ auxio_reg = (u_char *)(u_long)sa->sa_promvaddr;
+
+ 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;
+}
diff --git a/sys/arch/sparc64/dev/auxioreg.h b/sys/arch/sparc64/dev/auxioreg.h
new file mode 100644
index 00000000000..38b943ce320
--- /dev/null
+++ b/sys/arch/sparc64/dev/auxioreg.h
@@ -0,0 +1,82 @@
+/* $NetBSD: auxioreg.h,v 1.3 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.
+ */
+
+/*
+ * The AUXIO registers; their offset in the Ebus2 address space, plus the
+ * bits for each register. Note that the fdthree (FD), SUNW,CS4231 (AUDIO)
+ * and power (POWER) devices on the Ebus2 have their AUXIO regsiters mapped
+ * into their own "reg" properties, not the "auxio" device's "reg" properties.
+ */
+#define AUXIO_FD 0x00720000
+#define AUXIO_FD_DENSENSE_INPUT 0x0
+#define AUXIO_FD_DENSENSE_OUTPUT 0x1
+
+#define AUXIO_AUDIO 0x00722000
+#define AUXIO_AUDIO_POWERDOWN 0x0
+
+#define AUXIO_POWER 0x00724000
+#define AUXIO_POWER_SYSTEM_OFF 0x0
+#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_PCI 0x00728000
+#define AUXIO_PCI_SLOT0 0x0 /* two bits each */
+#define AUXIO_PCI_SLOT1 0x2
+#define AUXIO_PCI_SLOT2 0x4
+#define AUXIO_PCI_SLOT3 0x6
+#define AUXIO_PCI_MODE 0x8
+
+#define AUXIO_FREQ 0x0072a000
+#define AUXIO_FREQ_FREQ0 0x0
+#define AUXIO_FREQ_FREQ1 0x1
+#define AUXIO_FREQ_FREQ2 0x2
+
+#define AUXIO_SCSI 0x0072c000
+#define AUXIO_SCSI_INT_OSC_EN 0x0
+#define AUXIO_SCSI_EXT_OSC_EN 0x1
+
+#define AUXIO_TEMP 0x0072f000
+#define AUXIO_TEMP_SELECT 0x0
+#define AUXIO_TEMP_CLOCK 0x1
+#define AUXIO_TEMP_ENABLE 0x2
+#define AUXIO_TEMP_DATAOUT 0x3
+#define AUXIO_TEMP_DATAINT 0x4