summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-01-22 13:53:17 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-01-22 13:53:17 +0000
commit9aa1d492e0529dcfaa20c3d299490c05afede407 (patch)
treec128433554020766aaa210d2d8e296341aecc649 /sys
parent27083ed6d6c3fb986af2909eb3993565b8502b84 (diff)
Minimal iop code to set the serial ports to compatible mode automagically,
so that it is not necessary to change settings from MacOS before booting into OpenBSD; from NetBSD.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/mac68k/conf/files.mac68k3
-rw-r--r--sys/arch/mac68k/include/iop.h76
-rw-r--r--sys/arch/mac68k/mac68k/iop.c65
-rw-r--r--sys/arch/mac68k/mac68k/machdep.c15
4 files changed, 147 insertions, 12 deletions
diff --git a/sys/arch/mac68k/conf/files.mac68k b/sys/arch/mac68k/conf/files.mac68k
index d31cb41db0d..f7d89b4dd34 100644
--- a/sys/arch/mac68k/conf/files.mac68k
+++ b/sys/arch/mac68k/conf/files.mac68k
@@ -1,4 +1,4 @@
-# $OpenBSD: files.mac68k,v 1.40 2006/01/18 23:21:14 miod Exp $
+# $OpenBSD: files.mac68k,v 1.41 2006/01/22 13:53:16 miod Exp $
# $NetBSD: files.mac68k,v 1.61 1997/03/01 20:22:16 scottr Exp $
# mac68k-specific configuration info
@@ -99,6 +99,7 @@ file arch/mac68k/mac68k/clock.c
file arch/mac68k/mac68k/conf.c
file arch/mac68k/mac68k/disksubr.c disk
file arch/mac68k/mac68k/intr.c
+file arch/mac68k/mac68k/iop.c
file arch/mac68k/mac68k/machdep.c
file arch/mac68k/mac68k/mainbus.c
file arch/mac68k/mac68k/mem.c
diff --git a/sys/arch/mac68k/include/iop.h b/sys/arch/mac68k/include/iop.h
new file mode 100644
index 00000000000..01fa00738c9
--- /dev/null
+++ b/sys/arch/mac68k/include/iop.h
@@ -0,0 +1,76 @@
+/* $OpenBSD: iop.h,v 1.1 2006/01/22 13:53:16 miod Exp $ */
+/* $NetBSD: iopreg.h,v 1.7 2005/12/11 12:18:03 christos Exp $ */
+
+/*
+ * Copyright (c) 2000 Allen Briggs.
+ * 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.
+ */
+
+#define SCC_IOP 0
+#define ISM_IOP 1
+
+#define IOP_CS_BYPASS 0x01
+#define IOP_CS_AUTOINC 0x02
+#define IOP_CS_RUN 0x04
+#define IOP_CS_IRQ 0x08
+#define IOP_CS_INT0 0x10
+#define IOP_CS_INT1 0x20
+#define IOP_CS_HWINT 0x40
+#define IOP_CS_DMAINACT 0x80
+
+#define IOP_RESET (IOP_CS_DMAINACT | IOP_CS_AUTOINC)
+#define IOP_BYPASS \
+ (IOP_CS_BYPASS | IOP_CS_AUTOINC | IOP_CS_RUN | IOP_CS_DMAINACT)
+#define IOP_INTERRUPT (IOP_CS_INT0 | IOP_CS_INT1)
+
+typedef struct {
+ volatile u_char ram_hi;
+ u_char pad0;
+ volatile u_char ram_lo;
+ u_char pad1;
+ volatile u_char control_status;
+ u_char pad2[3];
+ volatile u_char data;
+ u_char pad3[23];
+ union {
+ struct {
+ volatile u_char sccb_cmd;
+ u_char pad0;
+ volatile u_char scca_cmd;
+ u_char pad1;
+ volatile u_char sccb_data;
+ u_char pad2;
+ volatile u_char scca_data;
+ u_char pad3;
+ } scc;
+ struct {
+ volatile u_char wdata;
+ u_char pad0;
+ /* etc... */
+ } iwm;
+ } bypass;
+} IOPHW;
+
+void iop_serial_compatible(void);
diff --git a/sys/arch/mac68k/mac68k/iop.c b/sys/arch/mac68k/mac68k/iop.c
new file mode 100644
index 00000000000..d7da7ac1a47
--- /dev/null
+++ b/sys/arch/mac68k/mac68k/iop.c
@@ -0,0 +1,65 @@
+/* $OpenBSD: iop.c,v 1.1 2006/01/22 13:53:16 miod Exp $ */
+/* $NetBSD: iop.c,v 1.10 2005/12/24 23:24:00 perry Exp $ */
+
+/*
+ * Copyright (c) 2000 Allen Briggs.
+ * 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.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <machine/cpu.h>
+#include <machine/iop.h>
+#include <machine/viareg.h>
+
+IOPHW *mac68k_iops[2];
+
+void
+iop_serial_compatible()
+{
+ IOPHW *ioph;
+
+ switch (current_mac_model->machineid) {
+ case MACH_MACQ900:
+ case MACH_MACQ950:
+ mac68k_iops[SCC_IOP] = (IOPHW *)((u_char *)IOBase + 0xc000);
+ mac68k_iops[ISM_IOP] = (IOPHW *)((u_char *)IOBase + 0x1e000);
+ break;
+ case MACH_MACIIFX:
+ mac68k_iops[SCC_IOP] = (IOPHW *)((u_char *)IOBase + 0x4000);
+ mac68k_iops[ISM_IOP] = (IOPHW *)((u_char *)IOBase + 0x12000);
+ break;
+ default:
+ return;
+ }
+
+ ioph = mac68k_iops[SCC_IOP];
+ ioph->control_status = 0; /* Reset */
+ ioph->control_status = IOP_BYPASS; /* Set to bypass */
+
+ ioph = mac68k_iops[ISM_IOP];
+ ioph->control_status = 0; /* Reset */
+}
diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c
index dd3823682d5..b3c362c9dc4 100644
--- a/sys/arch/mac68k/mac68k/machdep.c
+++ b/sys/arch/mac68k/mac68k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.127 2006/01/13 21:04:36 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.128 2006/01/22 13:53:16 miod Exp $ */
/* $NetBSD: machdep.c,v 1.207 1998/07/08 04:39:34 thorpej Exp $ */
/*
@@ -121,6 +121,7 @@
#include <dev/cons.h>
#include <mac68k/dev/adbvar.h>
+#include <machine/iop.h>
#include <machine/psc.h>
#include <machine/viareg.h>
@@ -1690,12 +1691,8 @@ mac68k_set_io_offsets(base)
switch (current_mac_model->machineid) {
case MACH_MACQ900:
case MACH_MACQ950:
- /*
- * Note that sccA base address is based on having
- * the serial port in `compatible' mode (set in
- * the Serial Switch control panel before booting).
- */
sccA = (volatile u_char *)base + 0xc020;
+ iop_serial_compatible();
mac68k_machine.scsi96_2 = 1;
break;
case MACH_MACQ700:
@@ -1742,13 +1739,9 @@ mac68k_set_io_offsets(base)
SCSIBase = base;
break;
case MACH_CLASSIIfx:
- /*
- * Note that sccA base address is based on having
- * the serial port in `compatible' mode (set in
- * the Serial Switch control panel before booting).
- */
Via1Base = (volatile u_char *)base;
sccA = (volatile u_char *)base + 0x4020;
+ iop_serial_compatible();
SCSIBase = base;
break;
default: