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