Module Name: src
Committed By: tsutsui
Date: Sun Apr 29 07:17:12 UTC 2012
Modified Files:
src/sys/arch/x68k/conf: GENERIC INSTALL files.x68k majors.x68k
src/sys/arch/x68k/x68k: locore.s vectors.s
Added Files:
src/sys/arch/x68k/dev: com_intio.c
Removed Files:
src/sys/arch/x68k/dev: com.c comreg.h
Log Message:
Finally switch PSX16550 fast serial board driver to using MI com(4) driver.
Based on isaki@'s patch and debugged by both isaki@ and tsutsui@.
PSX16550 specific hardware infomation is taken from Human68k's PSXIO driver:
http://retropc.net/x68000/software/hardware/psx16550/
XXX1: TL16C550C seems to have some timing critical issue around THRE interrupt
XXX2: auto hardware flow control of TL16C550 is not implemented in MI com(4)
To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 src/sys/arch/x68k/conf/GENERIC
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/x68k/conf/INSTALL
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/x68k/conf/files.x68k
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/x68k/conf/majors.x68k
cvs rdiff -u -r1.57 -r0 src/sys/arch/x68k/dev/com.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/x68k/dev/com_intio.c
cvs rdiff -u -r1.4 -r0 src/sys/arch/x68k/dev/comreg.h
cvs rdiff -u -r1.108 -r1.109 src/sys/arch/x68k/x68k/locore.s
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x68k/x68k/vectors.s
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x68k/conf/GENERIC
diff -u src/sys/arch/x68k/conf/GENERIC:1.160 src/sys/arch/x68k/conf/GENERIC:1.161
--- src/sys/arch/x68k/conf/GENERIC:1.160 Sat Mar 10 21:51:57 2012
+++ src/sys/arch/x68k/conf/GENERIC Sun Apr 29 07:17:11 2012
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.160 2012/03/10 21:51:57 joerg Exp $
+# $NetBSD: GENERIC,v 1.161 2012/04/29 07:17:11 tsutsui Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@ include "arch/x68k/conf/std.x68k"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.160 $"
+#ident "GENERIC-$Revision: 1.161 $"
maxusers 8
@@ -290,8 +290,8 @@ pseudo-device bell # OPM bell
powsw0 at mfp0 # Front switch
#powsw1 at mfp0 # External power switch
-xcom0 at mainbus0 # NS16550 fast serial
-xcom1 at mainbus0
+com0 at intio0 addr 0xefff00 intr 240 # PSX16550, port1
+com1 at intio0 addr 0xefff10 intr 241 # PSX16550, port2
## Audio device
vs0 at intio0 addr 0xe92000 dma 3 dmaintr 106
Index: src/sys/arch/x68k/conf/INSTALL
diff -u src/sys/arch/x68k/conf/INSTALL:1.94 src/sys/arch/x68k/conf/INSTALL:1.95
--- src/sys/arch/x68k/conf/INSTALL:1.94 Sun Dec 18 05:49:33 2011
+++ src/sys/arch/x68k/conf/INSTALL Sun Apr 29 07:17:11 2012
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.94 2011/12/18 05:49:33 dholland Exp $
+# $NetBSD: INSTALL,v 1.95 2012/04/29 07:17:11 tsutsui Exp $
#
# INSTALL -- installation kernel.
@@ -8,7 +8,7 @@ include "arch/x68k/conf/std.x68k"
#options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "INSTALL-$Revision: 1.94 $"
+#ident "INSTALL-$Revision: 1.95 $"
makeoptions COPTS="-Os" # Optimise for space. Implies -O2
@@ -258,8 +258,8 @@ zstty0 at zsc0 channel 0 # built-in RS-
sram0 at intio0 addr 0xed0000 # battery-backuped static RAM
#pseudo-device bell # OPM bell
-#xcom0 at mainbus0 # NS16550 fast serial
-#xcom1 at mainbus0
+#com0 at intio0 addr 0xefff00 intr 240 # PSX16550, port1
+#com1 at intio0 addr 0xefff10 intr 241 # PSX16550, port2
## Audio device
#vs0 at intio0 addr 0xe92000 dma 3 dmaintr 106
Index: src/sys/arch/x68k/conf/files.x68k
diff -u src/sys/arch/x68k/conf/files.x68k:1.77 src/sys/arch/x68k/conf/files.x68k:1.78
--- src/sys/arch/x68k/conf/files.x68k:1.77 Sun Nov 27 09:00:32 2011
+++ src/sys/arch/x68k/conf/files.x68k Sun Apr 29 07:17:11 2012
@@ -1,4 +1,4 @@
-# $NetBSD: files.x68k,v 1.77 2011/11/27 09:00:32 isaki Exp $
+# $NetBSD: files.x68k,v 1.78 2012/04/29 07:17:11 tsutsui Exp $
#
# new style config file for x68k architecture
#
@@ -51,10 +51,6 @@ include "arch/m68k/fpe/files.fpe"
# 68060 software support package
include "arch/m68k/060sp/files.060sp"
-device xcom: tty
-attach xcom at mainbus
-file arch/x68k/dev/com.c xcom needs-count
-
# graphic devices
define grfb { addr = -1 }
@@ -149,6 +145,9 @@ device par
attach par at intio
file arch/x68k/dev/par.c par needs-flag
+attach com at intio with com_intio
+file arch/x68k/dev/com_intio.c com_intio
+
#
# SCSI drivers
#
Index: src/sys/arch/x68k/conf/majors.x68k
diff -u src/sys/arch/x68k/conf/majors.x68k:1.25 src/sys/arch/x68k/conf/majors.x68k:1.26
--- src/sys/arch/x68k/conf/majors.x68k:1.25 Sat Nov 19 12:27:43 2011
+++ src/sys/arch/x68k/conf/majors.x68k Sun Apr 29 07:17:11 2012
@@ -1,4 +1,4 @@
-# $NetBSD: majors.x68k,v 1.25 2011/11/19 12:27:43 isaki Exp $
+# $NetBSD: majors.x68k,v 1.26 2012/04/29 07:17:11 tsutsui Exp $
#
# Device majors for x68k
#
@@ -19,7 +19,7 @@ device-major zstty char 12 zstty
device-major ite char 13 ite
device-major kbd char 14 kbd
device-major ms char 15 ms
-device-major xcom char 16 xcom
+device-major com char 16 com
device-major audio char 17 audio
device-major fd char 18 block 2 fd
device-major vnd char 19 block 6 vnd
Index: src/sys/arch/x68k/x68k/locore.s
diff -u src/sys/arch/x68k/x68k/locore.s:1.108 src/sys/arch/x68k/x68k/locore.s:1.109
--- src/sys/arch/x68k/x68k/locore.s:1.108 Thu Dec 22 15:33:30 2011
+++ src/sys/arch/x68k/x68k/locore.s Sun Apr 29 07:17:12 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.108 2011/12/22 15:33:30 tsutsui Exp $ */
+/* $NetBSD: locore.s,v 1.109 2012/04/29 07:17:12 tsutsui Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -504,35 +504,6 @@ ENTRY_NOPROFILE(spurintr) /* level 0 */
ENTRY_NOPROFILE(kbdtimer)
rte
-ENTRY_NOPROFILE(com0trap)
-#include "com.h"
- INTERRUPT_SAVEREG
-#if NXCOM > 0
- addql #1,_C_LABEL(idepth)
- movel #0,%sp@-
- jbsr _C_LABEL(comintr)
- addql #4,%sp
- subql #1,_C_LABEL(idepth)
-#endif
- CPUINFO_INCREMENT(CI_NINTR)
- INTERRUPT_RESTOREREG
- addql #1,_C_LABEL(intrcnt)+36
- jra rei
-
-ENTRY_NOPROFILE(com1trap)
- INTERRUPT_SAVEREG
-#if NXCOM > 1
- addql #1,_C_LABEL(idepth)
- movel #1,%sp@-
- jbsr _C_LABEL(comintr)
- addql #4,%sp
- subql #1,_C_LABEL(idepth)
-#endif
- CPUINFO_INCREMENT(CI_NINTR)
- INTERRUPT_RESTOREREG
- addql #1,_C_LABEL(intrcnt)+36
- jra rei
-
ENTRY_NOPROFILE(intiotrap)
addql #1,_C_LABEL(idepth)
INTERRUPT_SAVEREG
Index: src/sys/arch/x68k/x68k/vectors.s
diff -u src/sys/arch/x68k/x68k/vectors.s:1.16 src/sys/arch/x68k/x68k/vectors.s:1.17
--- src/sys/arch/x68k/x68k/vectors.s:1.16 Tue Feb 8 20:20:26 2011
+++ src/sys/arch/x68k/x68k/vectors.s Sun Apr 29 07:17:12 2012
@@ -1,4 +1,4 @@
-| $NetBSD: vectors.s,v 1.16 2011/02/08 20:20:26 rmind Exp $
+| $NetBSD: vectors.s,v 1.17 2012/04/29 07:17:12 tsutsui Exp $
| Copyright (c) 1988 University of Utah
| Copyright (c) 1990, 1993
@@ -198,8 +198,8 @@ GLOBAL(vectab)
BADTRAP16 /* 192-207: user interrupt vectors */
BADTRAP16 /* 208-223: user interrupt vectors */
BADTRAP16 /* 224-239: user interrupt vectors */
- VECTOR(com0trap) /* 240: unassigned, reserved */
- VECTOR(com1trap) /* 241: unassigned, reserved */
+ VECTOR(intiotrap) /* 240: PSX16550, port1 */
+ VECTOR(intiotrap) /* 241: PSX16550, port2 */
VECTOR(intiotrap) /* 242: unassigned, reserved */
VECTOR(intiotrap) /* 243: unassigned, reserved */
VECTOR(intiotrap) /* 244: unassigned, reserved */
Added files:
Index: src/sys/arch/x68k/dev/com_intio.c
diff -u /dev/null src/sys/arch/x68k/dev/com_intio.c:1.1
--- /dev/null Sun Apr 29 07:17:12 2012
+++ src/sys/arch/x68k/dev/com_intio.c Sun Apr 29 07:17:12 2012
@@ -0,0 +1,130 @@
+/* $NetBSD: com_intio.c,v 1.1 2012/04/29 07:17:12 tsutsui Exp $ */
+
+/*
+ * Copyright (c) 2009 Tetsuya Isaki. 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.
+ *
+ * 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.
+ */
+
+/*
+ * PSX16550, High-speed RS-232C board
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: com_intio.c,v 1.1 2012/04/29 07:17:12 tsutsui Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/tty.h>
+#include <sys/device.h>
+#include <sys/bus.h>
+
+#include <dev/ic/comreg.h>
+#include <dev/ic/comvar.h>
+
+#include <machine/cpu.h>
+
+#include <arch/x68k/dev/intiovar.h>
+
+#define COM_PSX16550_FREQ (22118400 / 2)
+#define COM_PSX16550_SIZE (COM_NPORTS << 1)
+#define COM_PSX16550_REG_VECT com_scratch
+
+static int com_intio_match(device_t, cfdata_t, void *);
+static void com_intio_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(com_intio, sizeof(struct com_softc),
+ com_intio_match, com_intio_attach, NULL, NULL);
+
+static int
+com_intio_match(device_t parent, cfdata_t cf, void *aux)
+{
+ struct intio_attach_args *ia = aux;
+ bus_space_tag_t iot;
+ bus_space_handle_t ioh;
+ int iobase;
+ int rv;
+
+ /* Check whether the board is inserted or not */
+ if (badaddr((void *)IIOV(ia->ia_addr)))
+ return 0;
+
+ ia->ia_size = COM_PSX16550_SIZE;
+ if (intio_map_allocate_region(parent, ia, INTIO_MAP_TESTONLY) < 0)
+ return 0;
+
+ iot = ia->ia_bst;
+ iobase = ia->ia_addr;
+
+ /* if it's in use as console, it's there. */
+ if (com_is_console(iot, iobase, NULL))
+ return 1;
+
+ if (bus_space_map(iot, iobase, ia->ia_size,
+ BUS_SPACE_MAP_SHIFTED_ODD, &ioh))
+ return 0;
+
+ rv = comprobe1(iot, ioh);
+ bus_space_unmap(iot, ioh, ia->ia_size);
+
+ return rv;
+}
+
+static void
+com_intio_attach(device_t parent, device_t self, void *aux)
+{
+ struct com_softc *sc = device_private(self);
+ struct intio_attach_args *ia = aux;
+ bus_space_tag_t iot;
+ bus_space_handle_t ioh;
+ int iobase;
+
+ intio_map_allocate_region(parent, ia, INTIO_MAP_ALLOCATE);
+
+ sc->sc_dev = self;
+ iot = ia->ia_bst;
+ iobase = ia->ia_addr;
+ if (bus_space_map(iot, iobase, ia->ia_size,
+ BUS_SPACE_MAP_SHIFTED_ODD, &ioh)) {
+ aprint_error(": can't map I/O space\n");
+ return;
+ }
+
+ /* check and set interrupt vector */
+ if (ia->ia_intr < 16 || ia->ia_intr > 255) {
+ aprint_error(": invalid intr vector (0x%02x)\n", ia->ia_intr);
+ return;
+ }
+ bus_space_write_1(iot, ioh, COM_PSX16550_REG_VECT, ia->ia_intr);
+
+ sc->sc_frequency = COM_PSX16550_FREQ;
+ COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);
+
+ /* PSX16550 uses MCR_DRS to switch interrupt priority level */
+ SET(sc->sc_mcr, MCR_DRS); /* 0: ipl2 / 1: ipl4 */
+
+ com_attach_subr(sc);
+
+ if (intio_intr_establish(ia->ia_intr, device_xname(self),
+ comintr, sc))
+ aprint_error_dev(self, "can't establish interrupt handler\n");
+}