summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-07-27 07:20:08 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-07-27 07:20:08 +0000
commitac57e1bdee0470232ee48c515e01dd78d2e2e7b7 (patch)
tree08d5c43a6fb6902b3d14db0f7680646000004bb0 /sys
parentbd6aaab462621ae72b5cbf648e9f3660fd43d174 (diff)
split cy driver up
Diffstat (limited to 'sys')
-rw-r--r--sys/conf/files6
-rw-r--r--sys/dev/ic/cy.c (renamed from sys/dev/isa/cy.c)231
-rw-r--r--sys/dev/ic/cyreg.h164
-rw-r--r--sys/dev/isa/cy_isa.c88
-rw-r--r--sys/dev/isa/cyreg.h66
-rw-r--r--sys/dev/isa/files.isa6
-rw-r--r--sys/dev/pci/cy_pci.c140
-rw-r--r--sys/dev/pci/files.pci6
8 files changed, 406 insertions, 301 deletions
diff --git a/sys/conf/files b/sys/conf/files
index b8b0305c854..b1d003c2561 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.28 1996/07/02 01:07:42 chuck Exp $
+# $OpenBSD: files,v 1.29 1996/07/27 07:20:01 deraadt Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -42,6 +42,10 @@ file dev/ic/elink3.c ep
device le: ether, ifnet
file dev/ic/am7990.c le
+# LANCE and PCnet Ethernet controllers
+device cy: tty
+file dev/ic/cy.c cy
+
# Attributes which machine-independent bus support can be attached to.
# These should be defined here, because some of these busses can have
# devices which provide these attributes, and we'd like to avoid hairy
diff --git a/sys/dev/isa/cy.c b/sys/dev/ic/cy.c
index 083d66c95dc..99cc2062c1f 100644
--- a/sys/dev/isa/cy.c
+++ b/sys/dev/ic/cy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cy.c,v 1.4 1996/06/23 13:11:05 deraadt Exp $ */
+/* $OpenBSD: cy.c,v 1.1 1996/07/27 07:20:03 deraadt Exp $ */
/*
* cy.c
@@ -59,118 +59,14 @@
#include <dev/pci/pcidevs.h>
#endif /* NPCI > 0 */
-#include <dev/isa/cyreg.h>
#include <dev/ic/cd1400reg.h>
+#include <dev/ic/cyreg.h>
/* Macros to clear/set/test flags. */
#define SET(t, f) (t) |= (f)
#define CLR(t, f) (t) &= ~(f)
#define ISSET(t, f) ((t) & (f))
-/*
- * Maximum number of ports per card
- */
-#define CY_MAX_PORTS (CD1400_NO_OF_CHANNELS * CY_MAX_CD1400s)
-
-#define RX_FIFO_THRESHOLD 6
-
-/* Automatic RTS (or actually DTR, the RTS and DTR lines need to be exchanged)
- * handshake threshold used if CY_HW_RTS is defined
- */
-#define RX_DTR_THRESHOLD 9
-
-/*
- * Port number on card encoded in low 5 bits
- * card number in next 2 bits (only space for 4 cards)
- * high bit reserved for dialout flag
- */
-#define CY_PORT(x) (minor(x) & 0xf)
-#define CY_CARD(x) ((minor(x) >> 5) & 3)
-#define CY_DIALOUT(x) ((minor(x) & 0x80) != 0)
-#define CY_DIALIN(x) (!CY_DIALOUT(x))
-
-/*
- * read/write cd1400 registers (when cy_port-structure is available)
- */
-#define cd_read_reg(cy,reg) bus_mem_read_1(cy->cy_bc, cy->cy_memh, \
- cy->cy_chip_offs+(((reg<<1))<<cy->cy_bustype))
-
-#define cd_write_reg(cy,reg,val) bus_mem_write_1(cy->cy_bc, cy->cy_memh, \
- cy->cy_chip_offs+(((reg<<1))<<cy->cy_bustype), \
- (val))
-
-/*
- * read/write cd1400 registers (when sc_softc-structure is available)
- */
-#define cd_read_reg_sc(sc,chip,reg) bus_mem_read_1(sc->sc_bc, \
- sc->sc_memh, \
- sc->sc_cd1400_offs[chip]+\
- (((reg<<1))<<sc->sc_bustype))
-
-#define cd_write_reg_sc(sc,chip,reg,val) bus_mem_write_1(sc->sc_bc, \
- sc->sc_memh, \
- sc->sc_cd1400_offs[chip]+\
- (((reg<<1))<<sc->sc_bustype), \
- (val))
-
-/*
- * ibuf is a simple ring buffer. It is always used two
- * bytes at a time (status and data)
- */
-#define IBUF_SIZE (2*512)
-
-/* software state for one port */
-struct cy_port {
- int cy_port_num;
- bus_chipset_tag_t cy_bc;
- bus_mem_handle_t cy_memh;
- int cy_chip_offs;
- int cy_bustype;
- struct tty *cy_tty;
- int cy_openflags;
- int cy_fifo_overruns;
- int cy_ibuf_overruns;
- u_char cy_channel_control; /* last CCR channel control command bits */
- u_char cy_carrier_stat; /* copied from MSVR2 */
- u_char cy_flags;
- u_char *cy_ibuf, *cy_ibuf_end;
- u_char *cy_ibuf_rd_ptr, *cy_ibuf_wr_ptr;
-#ifdef CY_DEBUG1
- int cy_rx_int_count;
- int cy_tx_int_count;
- int cy_modem_int_count;
- int cy_start_count;
-#endif /* CY_DEBUG1 */
-};
-
-#define CYF_CARRIER_CHANGED 0x01
-#define CYF_START_BREAK 0x02
-#define CYF_END_BREAK 0x04
-#define CYF_STOP 0x08
-#define CYF_SEND_NUL 0x10
-#define CYF_START 0x20
-
-/* software state for one card */
-struct cy_softc {
- struct device sc_dev;
- void *sc_ih;
- bus_chipset_tag_t sc_bc;
- bus_mem_handle_t sc_memh;
- int sc_bustype;
- int sc_nports; /* number of ports on this card */
- int sc_cd1400_offs[CY_MAX_CD1400s];
- struct cy_port sc_ports[CY_MAX_PORTS];
-#ifdef CY_DEBUG1
- int sc_poll_count1;
- int sc_poll_count2;
-#endif
-};
-
-int cy_probe_isa __P((struct device *, void *, void *));
-int cy_probe_pci __P((struct device *, void *, void *));
-int cy_probe_common __P((int card, bus_chipset_tag_t,
- bus_mem_handle_t, int bustype));
-
void cyattach __P((struct device *, struct device *, void *));
static int cyintr __P((void *));
@@ -182,18 +78,6 @@ static void cy_enable_transmitter __P((struct cy_port *));
static void cd1400_channel_cmd __P((struct cy_port *, int));
static int cy_speed __P((speed_t, int *, int *));
-#if NISA > 0
-struct cfattach cy_isa_ca = {
- sizeof(struct cy_softc), cy_probe_isa, cyattach
-};
-#endif
-
-#if NPCI > 0
-struct cfattach cy_pci_ca = {
- sizeof(struct cy_softc), cy_probe_pci, cyattach
-};
-#endif
-
struct cfdriver cy_cd = {
NULL, "cy", DV_TTY
};
@@ -204,117 +88,6 @@ static bus_mem_handle_t cy_card_memh[NCY];
static int cy_open = 0;
static int cy_events = 0;
-#if NISA > 0
-/*
- * ISA probe
- */
-int
-cy_probe_isa(parent, match, aux)
- struct device *parent;
- void *match, *aux;
-{
- int card = ((struct device *)match)->dv_unit;
- struct isa_attach_args *ia = aux;
- bus_chipset_tag_t bc;
- bus_mem_handle_t memh;
-
- if(ia->ia_irq == IRQUNK) {
- printf("cy%d error: interrupt not defined\n", card);
- return 0;
- }
-
- bc = ia->ia_bc;
- if(bus_mem_map(bc, ia->ia_maddr, 0x2000, 0, &memh) != 0)
- return 0;
-
- if(cy_probe_common(card, bc, memh, CY_BUSTYPE_ISA) == 0) {
- bus_mem_unmap(bc, memh, 0x2000);
- return 0;
- }
-
- ia->ia_iosize = 0;
- ia->ia_msize = 0x2000;
- return 1;
-}
-#endif /* NISA > 0 */
-
-#if NPCI > 0
-/*
- * PCI probe
- */
-int
-cy_probe_pci(parent, match, aux)
- struct device *parent;
- void *match, *aux;
-{
- vm_offset_t v_addr, p_addr;
- int card = ((struct device *)match)->dv_unit;
- struct pci_attach_args *pa = aux;
- bus_chipset_tag_t bc;
- bus_mem_handle_t memh;
- bus_mem_addr_t memaddr;
- bus_mem_size_t memsize;
- bus_io_handle_t ioh;
- bus_io_addr_t iobase;
- bus_io_size_t iosize;
- int cacheable;
-
- if(!(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_CYCLADES &&
- (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CYCLADES_CYCLOMY_1 ||
- PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CYCLADES_CYCLOMY_2)))
- return 0;
-
-#ifdef CY_DEBUG
- printf("cy: Found Cyclades PCI device, id = 0x%x\n", pa->pa_id);
-#endif
-
- bc = pa->pa_bc;
-
- if(pci_mem_find(pa->pa_pc, pa->pa_tag, 0x18,
- &memaddr, &memsize, &cacheable) != 0) {
- printf("cy%d: can't find PCI card memory", card);
- return 0;
- }
-
- /* map the memory (non-cacheable) */
- if(bus_mem_map(bc, memaddr, memsize, 0, &memh) != 0) {
- printf("cy%d: couldn't map PCI memory region\n", card);
- return 0;
- }
-
- /* the PCI Cyclom IO space is only used for enabling interrupts */
- if(pci_io_find(pa->pa_pc, pa->pa_tag, 0x14, &iobase, &iosize) != 0) {
- bus_mem_unmap(bc, memh, memsize);
- printf("cy%d: couldn't find PCI io region\n", card);
- return 0;
- }
-
- if(bus_io_map(bc, iobase, iosize, &ioh) != 0) {
- bus_mem_unmap(bc, memh, memsize);
- printf("cy%d: couldn't map PCI io region\n", card);
- return 0;
- }
-
-#ifdef CY_DEBUG
- printf("cy%d: pci mapped mem 0x%lx (size %d), io 0x%x (size %d)\n",
- card, memaddr, memsize, iobase, iosize);
-#endif
-
- if(cy_probe_common(card, bc, memh, CY_BUSTYPE_PCI) == 0) {
- bus_mem_unmap(bc, memh, memsize);
- bus_io_unmap(bc, ioh, iosize);
- printf("cy%d: PCI Cyclom card with no CD1400s!?\n", card);
- return 0;
- }
-
- /* Enable PCI card interrupts */
- bus_io_write_2(bc, ioh, CY_PCI_INTENA,
- bus_io_read_2(bc, ioh, CY_PCI_INTENA) | 0x900);
-
- return 1;
-}
-#endif /* NPCI > 0 */
-
/*
* Common probe routine
*/
diff --git a/sys/dev/ic/cyreg.h b/sys/dev/ic/cyreg.h
new file mode 100644
index 00000000000..9632e5abc26
--- /dev/null
+++ b/sys/dev/ic/cyreg.h
@@ -0,0 +1,164 @@
+/* $OpenBSD: cyreg.h,v 1.1 1996/07/27 07:20:03 deraadt Exp $ */
+/* $FreeBSD: cyreg.h,v 1.1 1995/07/05 12:15:51 bde Exp $ */
+
+/*-
+ * Copyright (c) 1995 Bruce Evans.
+ * All rights reserved.
+ *
+ * Modified by Timo Rossi, 1996
+ *
+ * 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. Neither the name of the author nor the names of contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ */
+
+/*
+ * Definitions for Cyclades Cyclom-Y serial boards.
+ */
+
+#define CY8_SVCACKR 0x100
+#define CY8_SVCACKT 0x200
+#define CY8_SVCACKM 0x300
+
+/* twice this in PCI mode (shifed BUSTYPE bits left) */
+#define CY_CD1400_MEMSPACING 0x400
+
+/* adjustment value for accessing the last 4 cd1400s on Cyclom-32 */
+#define CY32_ADDR_FIX 0xe00
+
+#define CY16_RESET 0x1400
+#define CY_CLEAR_INTR 0x1800 /* intr ack address */
+
+#define CY_MAX_CD1400s 8 /* for Cyclom-32 */
+
+/* I/O location for enabling interrupts on PCI Cyclom cards */
+#define CY_PCI_INTENA 0x68
+
+#define CY_CLOCK 25000000 /* baud rate clock */
+
+/*
+ * bustype is actually the shift count for the offset
+ * ISA card addresses are multiplied by 2 (shifted 1 bit)
+ * and PCI addresses multiplied by 4 (shifted 2 bits)
+ */
+#define CY_BUSTYPE_ISA 0
+#define CY_BUSTYPE_PCI 1
+
+#define RX_FIFO_THRESHOLD 6
+
+/* Automatic RTS (or actually DTR, the RTS and DTR lines need to be exchanged)
+ * handshake threshold used if CY_HW_RTS is defined
+ */
+#define RX_DTR_THRESHOLD 9
+
+/*
+ * Maximum number of ports per card
+ */
+#define CY_MAX_PORTS (CD1400_NO_OF_CHANNELS * CY_MAX_CD1400s)
+
+/*
+ * Port number on card encoded in low 5 bits
+ * card number in next 2 bits (only space for 4 cards)
+ * high bit reserved for dialout flag
+ */
+#define CY_PORT(x) (minor(x) & 0xf)
+#define CY_CARD(x) ((minor(x) >> 5) & 3)
+#define CY_DIALOUT(x) ((minor(x) & 0x80) != 0)
+#define CY_DIALIN(x) (!CY_DIALOUT(x))
+
+/*
+ * read/write cd1400 registers (when cy_port-structure is available)
+ */
+#define cd_read_reg(cy,reg) bus_mem_read_1(cy->cy_bc, cy->cy_memh, \
+ cy->cy_chip_offs+(((reg<<1))<<cy->cy_bustype))
+
+#define cd_write_reg(cy,reg,val) bus_mem_write_1(cy->cy_bc, cy->cy_memh, \
+ cy->cy_chip_offs+(((reg<<1))<<cy->cy_bustype), \
+ (val))
+
+/*
+ * read/write cd1400 registers (when sc_softc-structure is available)
+ */
+#define cd_read_reg_sc(sc,chip,reg) bus_mem_read_1(sc->sc_bc, \
+ sc->sc_memh, \
+ sc->sc_cd1400_offs[chip]+\
+ (((reg<<1))<<sc->sc_bustype))
+
+#define cd_write_reg_sc(sc,chip,reg,val) bus_mem_write_1(sc->sc_bc, \
+ sc->sc_memh, \
+ sc->sc_cd1400_offs[chip]+\
+ (((reg<<1))<<sc->sc_bustype), \
+ (val))
+
+/*
+ * ibuf is a simple ring buffer. It is always used two
+ * bytes at a time (status and data)
+ */
+#define IBUF_SIZE (2*512)
+
+/* software state for one port */
+struct cy_port {
+ int cy_port_num;
+ bus_chipset_tag_t cy_bc;
+ bus_mem_handle_t cy_memh;
+ int cy_chip_offs;
+ int cy_bustype;
+ struct tty *cy_tty;
+ int cy_openflags;
+ int cy_fifo_overruns;
+ int cy_ibuf_overruns;
+ u_char cy_channel_control; /* last CCR channel control command bits */
+ u_char cy_carrier_stat; /* copied from MSVR2 */
+ u_char cy_flags;
+ u_char *cy_ibuf, *cy_ibuf_end;
+ u_char *cy_ibuf_rd_ptr, *cy_ibuf_wr_ptr;
+#ifdef CY_DEBUG1
+ int cy_rx_int_count;
+ int cy_tx_int_count;
+ int cy_modem_int_count;
+ int cy_start_count;
+#endif /* CY_DEBUG1 */
+};
+
+#define CYF_CARRIER_CHANGED 0x01
+#define CYF_START_BREAK 0x02
+#define CYF_END_BREAK 0x04
+#define CYF_STOP 0x08
+#define CYF_SEND_NUL 0x10
+#define CYF_START 0x20
+
+/* software state for one card */
+struct cy_softc {
+ struct device sc_dev;
+ void *sc_ih;
+ bus_chipset_tag_t sc_bc;
+ bus_mem_handle_t sc_memh;
+ int sc_bustype;
+ int sc_nports; /* number of ports on this card */
+ int sc_cd1400_offs[CY_MAX_CD1400s];
+ struct cy_port sc_ports[CY_MAX_PORTS];
+#ifdef CY_DEBUG1
+ int sc_poll_count1;
+ int sc_poll_count2;
+#endif
+};
diff --git a/sys/dev/isa/cy_isa.c b/sys/dev/isa/cy_isa.c
new file mode 100644
index 00000000000..f16a63358a8
--- /dev/null
+++ b/sys/dev/isa/cy_isa.c
@@ -0,0 +1,88 @@
+/* $OpenBSD: cy_isa.c,v 1.1 1996/07/27 07:20:05 deraadt Exp $ */
+
+/*
+ * cy.c
+ *
+ * Driver for Cyclades Cyclom-8/16/32 multiport serial cards
+ * (currently not tested with Cyclom-32 cards)
+ *
+ * Timo Rossi, 1996
+ *
+ * Supports both ISA and PCI Cyclom cards
+ *
+ * Uses CD1400 automatic CTS flow control, and
+ * if CY_HW_RTS is defined, uses CD1400 automatic input flow control.
+ * This requires a special cable that exchanges the RTS and DTR lines.
+ *
+ * Lots of debug output can be enabled by defining CY_DEBUG
+ * Some debugging counters (number of receive/transmit interrupts etc.)
+ * can be enabled by defining CY_DEBUG1
+ *
+ * This version uses the bus_mem/io_??() stuff
+ *
+ * NOT TESTED !!!
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <sys/syslog.h>
+#include <sys/fcntl.h>
+#include <sys/tty.h>
+#include <sys/proc.h>
+#include <sys/conf.h>
+#include <sys/user.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/systm.h>
+#include <machine/bus.h>
+#include <dev/isa/isavar.h>
+#include <dev/isa/isareg.h>
+
+#include <dev/ic/cd1400reg.h>
+#include <dev/ic/cyreg.h>
+
+int cy_probe_isa __P((struct device *, void *, void *));
+int cy_probe_common __P((int card, bus_chipset_tag_t,
+ bus_mem_handle_t, int bustype));
+
+void cyattach __P((struct device *, struct device *, void *));
+
+struct cfattach cy_isa_ca = {
+ sizeof(struct cy_softc), cy_probe_isa, cyattach
+};
+
+/*
+ * ISA probe
+ */
+int
+cy_probe_isa(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ int card = ((struct device *)match)->dv_unit;
+ struct isa_attach_args *ia = aux;
+ bus_chipset_tag_t bc;
+ bus_mem_handle_t memh;
+
+ if(ia->ia_irq == IRQUNK) {
+ printf("cy%d error: interrupt not defined\n", card);
+ return 0;
+ }
+
+ bc = ia->ia_bc;
+ if(bus_mem_map(bc, ia->ia_maddr, 0x2000, 0, &memh) != 0)
+ return 0;
+
+ if(cy_probe_common(card, bc, memh, CY_BUSTYPE_ISA) == 0) {
+ bus_mem_unmap(bc, memh, 0x2000);
+ return 0;
+ }
+
+ ia->ia_iosize = 0;
+ ia->ia_msize = 0x2000;
+ return 1;
+}
diff --git a/sys/dev/isa/cyreg.h b/sys/dev/isa/cyreg.h
deleted file mode 100644
index e4cfc5f22e4..00000000000
--- a/sys/dev/isa/cyreg.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* $OpenBSD: cyreg.h,v 1.1 1996/06/20 11:39:11 deraadt Exp $ */
-/* $FreeBSD: cyreg.h,v 1.1 1995/07/05 12:15:51 bde Exp $ */
-
-/*-
- * Copyright (c) 1995 Bruce Evans.
- * All rights reserved.
- *
- * Modified by Timo Rossi, 1996
- *
- * 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. Neither the name of the author nor the names of contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-/*
- * Definitions for Cyclades Cyclom-Y serial boards.
- */
-
-#define CY8_SVCACKR 0x100
-#define CY8_SVCACKT 0x200
-#define CY8_SVCACKM 0x300
-
-/* twice this in PCI mode (shifed BUSTYPE bits left) */
-#define CY_CD1400_MEMSPACING 0x400
-
-/* adjustment value for accessing the last 4 cd1400s on Cyclom-32 */
-#define CY32_ADDR_FIX 0xe00
-
-#define CY16_RESET 0x1400
-#define CY_CLEAR_INTR 0x1800 /* intr ack address */
-
-#define CY_MAX_CD1400s 8 /* for Cyclom-32 */
-
-/* I/O location for enabling interrupts on PCI Cyclom cards */
-#define CY_PCI_INTENA 0x68
-
-#define CY_CLOCK 25000000 /* baud rate clock */
-
-/*
- * bustype is actually the shift count for the offset
- * ISA card addresses are multiplied by 2 (shifted 1 bit)
- * and PCI addresses multiplied by 4 (shifted 2 bits)
- */
-#define CY_BUSTYPE_ISA 0
-#define CY_BUSTYPE_PCI 1
-
diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa
index 2be8bb3c6a9..f98467cb3f3 100644
--- a/sys/dev/isa/files.isa
+++ b/sys/dev/isa/files.isa
@@ -1,4 +1,4 @@
-# $OpenBSD: files.isa,v 1.25 1996/06/26 20:07:52 dm Exp $
+# $OpenBSD: files.isa,v 1.26 1996/07/27 07:20:06 deraadt Exp $
# $NetBSD: files.isa,v 1.21 1996/05/16 03:45:55 mycroft Exp $
#
# Config.new file and device description for machine-independent ISA code.
@@ -55,10 +55,8 @@ attach com at pcmcia with com_pcmcia
file dev/isa/com.c com & (com_isa | com_commulti | com_pcmcia) needs-flag
# Cyclades Cyclom multiport serial cards
-device cy: tty
attach cy at isa with cy_isa
-attach cy at pci with cy_pci
-file dev/isa/cy.c cy needs-count
+file dev/isa/cy_isa.c cy_isa
# PC parallel ports (XXX what chip?)
device lpt
diff --git a/sys/dev/pci/cy_pci.c b/sys/dev/pci/cy_pci.c
new file mode 100644
index 00000000000..c196cc58b7f
--- /dev/null
+++ b/sys/dev/pci/cy_pci.c
@@ -0,0 +1,140 @@
+/* $OpenBSD: cy_pci.c,v 1.1 1996/07/27 07:20:07 deraadt Exp $ */
+
+/*
+ * cy.c
+ *
+ * Driver for Cyclades Cyclom-8/16/32 multiport serial cards
+ * (currently not tested with Cyclom-32 cards)
+ *
+ * Timo Rossi, 1996
+ *
+ * Supports both ISA and PCI Cyclom cards
+ *
+ * Uses CD1400 automatic CTS flow control, and
+ * if CY_HW_RTS is defined, uses CD1400 automatic input flow control.
+ * This requires a special cable that exchanges the RTS and DTR lines.
+ *
+ * Lots of debug output can be enabled by defining CY_DEBUG
+ * Some debugging counters (number of receive/transmit interrupts etc.)
+ * can be enabled by defining CY_DEBUG1
+ *
+ * This version uses the bus_mem/io_??() stuff
+ *
+ * NOT TESTED !!!
+ *
+ */
+
+#undef CY_DEBUG
+#undef CY_DEBUG1
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/ioctl.h>
+#include <sys/syslog.h>
+#include <sys/fcntl.h>
+#include <sys/tty.h>
+#include <sys/proc.h>
+#include <sys/conf.h>
+#include <sys/user.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/systm.h>
+#include <machine/bus.h>
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcidevs.h>
+
+#include <dev/ic/cd1400reg.h>
+#include <dev/ic/cyreg.h>
+
+/* Macros to clear/set/test flags. */
+#define SET(t, f) (t) |= (f)
+#define CLR(t, f) (t) &= ~(f)
+#define ISSET(t, f) ((t) & (f))
+
+int cy_probe_pci __P((struct device *, void *, void *));
+int cy_probe_common __P((int card, bus_chipset_tag_t,
+ bus_mem_handle_t, int bustype));
+
+void cyattach __P((struct device *, struct device *, void *));
+
+struct cfattach cy_pci_ca = {
+ sizeof(struct cy_softc), cy_probe_pci, cyattach
+};
+
+/*
+ * PCI probe
+ */
+int
+cy_probe_pci(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ vm_offset_t v_addr, p_addr;
+ int card = ((struct device *)match)->dv_unit;
+ struct pci_attach_args *pa = aux;
+ bus_chipset_tag_t bc;
+ bus_mem_handle_t memh;
+ bus_mem_addr_t memaddr;
+ bus_mem_size_t memsize;
+ bus_io_handle_t ioh;
+ bus_io_addr_t iobase;
+ bus_io_size_t iosize;
+ int cacheable;
+
+ if(!(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_CYCLADES &&
+ (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CYCLADES_CYCLOMY_1 ||
+ PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CYCLADES_CYCLOMY_2)))
+ return 0;
+
+#ifdef CY_DEBUG
+ printf("cy: Found Cyclades PCI device, id = 0x%x\n", pa->pa_id);
+#endif
+
+ bc = pa->pa_bc;
+
+ if(pci_mem_find(pa->pa_pc, pa->pa_tag, 0x18,
+ &memaddr, &memsize, &cacheable) != 0) {
+ printf("cy%d: can't find PCI card memory", card);
+ return 0;
+ }
+
+ /* map the memory (non-cacheable) */
+ if(bus_mem_map(bc, memaddr, memsize, 0, &memh) != 0) {
+ printf("cy%d: couldn't map PCI memory region\n", card);
+ return 0;
+ }
+
+ /* the PCI Cyclom IO space is only used for enabling interrupts */
+ if(pci_io_find(pa->pa_pc, pa->pa_tag, 0x14, &iobase, &iosize) != 0) {
+ bus_mem_unmap(bc, memh, memsize);
+ printf("cy%d: couldn't find PCI io region\n", card);
+ return 0;
+ }
+
+ if(bus_io_map(bc, iobase, iosize, &ioh) != 0) {
+ bus_mem_unmap(bc, memh, memsize);
+ printf("cy%d: couldn't map PCI io region\n", card);
+ return 0;
+ }
+
+#ifdef CY_DEBUG
+ printf("cy%d: pci mapped mem 0x%lx (size %d), io 0x%x (size %d)\n",
+ card, memaddr, memsize, iobase, iosize);
+#endif
+
+ if(cy_probe_common(card, bc, memh, CY_BUSTYPE_PCI) == 0) {
+ bus_mem_unmap(bc, memh, memsize);
+ bus_io_unmap(bc, ioh, iosize);
+ printf("cy%d: PCI Cyclom card with no CD1400s!?\n", card);
+ return 0;
+ }
+
+ /* Enable PCI card interrupts */
+ bus_io_write_2(bc, ioh, CY_PCI_INTENA,
+ bus_io_read_2(bc, ioh, CY_PCI_INTENA) | 0x900);
+
+ return 1;
+}
diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci
index c561358342f..89656fd2c19 100644
--- a/sys/dev/pci/files.pci
+++ b/sys/dev/pci/files.pci
@@ -1,4 +1,4 @@
-# $OpenBSD: files.pci,v 1.8 1996/06/21 15:34:53 chuck Exp $
+# $OpenBSD: files.pci,v 1.9 1996/07/27 07:20:07 deraadt Exp $
# $NetBSD: files.pci,v 1.16 1996/05/16 03:44:16 mycroft Exp $
#
# Config.new file and device description for machine-independent PCI code.
@@ -51,3 +51,7 @@ device en: atm, ifnet
attach en at pci with en_pci
file dev/pci/if_en_pci.c en
file dev/ic/midway.c en
+
+# Cyclades Cyclom multiport serial cards
+attach cy at pci with cy_pci
+file dev/pci/cy_pci.c cy_pci