cyvar.h revision 1.6 1 /* $NetBSD: cyvar.h,v 1.6 2001/01/20 02:24:16 thorpej Exp $ */
2
3 /*
4 * cy_var.h
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
14 /* #define CY_DEBUG */
15 #define CY_DEBUG1
16
17 /*
18 * Maximum number of ports per card
19 */
20 #define CY_MAX_PORTS (CD1400_NO_OF_CHANNELS * CY_MAX_CD1400s)
21
22 #define CY_RX_FIFO_THRESHOLD 6
23
24 /*
25 * Automatic RTS (or actually DTR, the RTS and DTR lines need to be
26 * exchanged) handshake threshold used if CY_HW_RTS is defined
27 */
28 #define CY_RX_DTR_THRESHOLD 9
29
30 /*
31 * Port number on card encoded in low 5 bits
32 * card number in next 2 bits (only space for 4 cards)
33 * high bit reserved for dialout flag
34 */
35 #define CY_PORT(x) (minor(x) & 0x1f)
36 #define CY_CARD(x) ((minor(x) >> 5) & 3)
37 #define CY_DIALOUT(x) ((minor(x) & 0x80) != 0)
38 #define CY_DIALIN(x) (!CY_DIALOUT(x))
39
40 /*
41 * read/write cd1400 registers (when sc_softc-structure is available)
42 */
43 #define cd_read_reg(sc,chip,reg) bus_space_read_1(sc->sc_memt, \
44 sc->sc_bsh, sc->sc_cd1400_offs[chip] + \
45 (((reg << 1)) << sc->sc_bustype))
46
47 #define cd_write_reg(sc,chip,reg,val) bus_space_write_1(sc->sc_memt, \
48 sc->sc_bsh, sc->sc_cd1400_offs[chip] + \
49 (((reg << 1))<< sc->sc_bustype), (val))
50
51 /*
52 * ibuf is a simple ring buffer. It is always used two
53 * bytes at a time (status and data)
54 */
55 #define CY_IBUF_SIZE (2*512)
56
57 /* software state for one port */
58 struct cy_port {
59 int cy_port_num;
60 int cy_chip;
61 int cy_clock;
62 struct tty *cy_tty;
63 int cy_openflags;
64 int cy_fifo_overruns;
65 int cy_ibuf_overruns;
66 u_char cy_channel_control; /* last CCR channel control
67 * command bits */
68 u_char cy_carrier_stat; /* copied from MSVR2 */
69 u_char cy_flags;
70 u_char *cy_ibuf, *cy_ibuf_end;
71 u_char *cy_ibuf_rd_ptr, *cy_ibuf_wr_ptr;
72 #ifdef CY_DEBUG1
73 int cy_rx_int_count;
74 int cy_tx_int_count;
75 int cy_modem_int_count;
76 int cy_start_count;
77 #endif /* CY_DEBUG1 */
78 };
79
80 #define CY_F_CARRIER_CHANGED 0x01
81 #define CY_F_START_BREAK 0x02
82 #define CY_F_END_BREAK 0x04
83 #define CY_F_STOP 0x08
84 #define CY_F_SEND_NUL 0x10
85 #define CY_F_START 0x20
86
87 /* software state for one card */
88 struct cy_softc {
89 struct device sc_dev;
90 void *sc_ih;
91 bus_space_tag_t sc_memt;
92 bus_space_handle_t sc_bsh;
93 int sc_bustype;
94 int sc_nchips; /* Number of cd1400's on this card */
95 int sc_cd1400_offs[CY_MAX_CD1400s];
96 struct cy_port sc_ports[CY_MAX_PORTS];
97 #ifdef CY_DEBUG1
98 int sc_poll_count1;
99 int sc_poll_count2;
100 #endif
101 };
102
103 int cy_find(struct cy_softc *);
104 void cy_attach(struct device *, struct device *, void *);
105 int cy_intr(void *);
106