xref: /openbsd-src/sys/dev/isa/cy_isa.c (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*	$OpenBSD: cy_isa.c,v 1.4 1999/11/30 23:48:07 aaron Exp $	*/
2 
3 /*
4  * cy.c
5  *
6  * Driver for Cyclades Cyclom-8/16/32 multiport serial cards
7  * (currently not tested with Cyclom-32 cards)
8  *
9  * Timo Rossi, 1996
10  *
11  * Supports both ISA and PCI Cyclom cards
12  *
13  * Uses CD1400 automatic CTS flow control, and
14  * if CY_HW_RTS is defined, uses CD1400 automatic input flow control.
15  * This requires a special cable that exchanges the RTS and DTR lines.
16  *
17  * Lots of debug output can be enabled by defining CY_DEBUG
18  * Some debugging counters (number of receive/transmit interrupts etc.)
19  * can be enabled by defining CY_DEBUG1
20  *
21  * This version uses the bus_mem/io_??() stuff
22  *
23  * NOT TESTED !!!
24  *
25  */
26 
27 #include <sys/types.h>
28 #include <sys/param.h>
29 #include <sys/ioctl.h>
30 #include <sys/syslog.h>
31 #include <sys/fcntl.h>
32 #include <sys/tty.h>
33 #include <sys/proc.h>
34 #include <sys/conf.h>
35 #include <sys/user.h>
36 #include <sys/select.h>
37 #include <sys/device.h>
38 #include <sys/malloc.h>
39 #include <sys/systm.h>
40 #include <machine/bus.h>
41 #include <dev/isa/isavar.h>
42 #include <dev/isa/isareg.h>
43 
44 #include <dev/ic/cd1400reg.h>
45 #include <dev/ic/cyreg.h>
46 
47 int cy_probe_isa __P((struct device *, void *, void *));
48 int cy_probe_common __P((int card, bus_space_tag_t,
49 			 bus_space_handle_t, int bustype));
50 
51 void cyattach __P((struct device *, struct device *, void *));
52 
53 struct cfattach cy_isa_ca = {
54   sizeof(struct cy_softc), cy_probe_isa, cyattach
55 };
56 
57 /*
58  * ISA probe
59  */
60 int
61 cy_probe_isa(parent, match, aux)
62      struct device *parent;
63      void *match, *aux;
64 {
65   int card = ((struct device *)match)->dv_unit;
66   struct isa_attach_args *ia = aux;
67   bus_space_tag_t memt;
68   bus_space_handle_t memh;
69 
70   if(ia->ia_irq == IRQUNK) {
71     printf("cy%d error: interrupt not defined\n", card);
72     return 0;
73   }
74 
75   memt = ia->ia_memt;
76   if(bus_space_map(memt, ia->ia_maddr, 0x2000, 0, &memh) != 0)
77     return 0;
78 
79   if(cy_probe_common(card, memt, memh, CY_BUSTYPE_ISA) == 0) {
80     bus_space_unmap(memt, memh, 0x2000);
81     return 0;
82   }
83 
84   ia->ia_iosize = 0;
85   ia->ia_msize = 0x2000;
86   return 1;
87 }
88