cyvar.h revision 1.1 1 1.1 christos /* $NetBSD: cyvar.h,v 1.1 1996/09/24 18:02:36 christos 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.1 christos #define CY_PORT(x) (minor(x) & 0xf)
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.1 christos #define cd_read_reg(sc,chip,reg) bus_mem_read_1(sc->sc_bc, \
44 1.1 christos sc->sc_memh, sc->sc_cd1400_offs[chip] + \
45 1.1 christos (((reg << 1)) << sc->sc_bustype))
46 1.1 christos
47 1.1 christos #define cd_write_reg(sc,chip,reg,val) bus_mem_write_1(sc->sc_bc, \
48 1.1 christos sc->sc_memh, 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.1 christos struct tty *cy_tty;
62 1.1 christos int cy_openflags;
63 1.1 christos int cy_fifo_overruns;
64 1.1 christos int cy_ibuf_overruns;
65 1.1 christos u_char cy_channel_control; /* last CCR channel control
66 1.1 christos * command bits */
67 1.1 christos u_char cy_carrier_stat; /* copied from MSVR2 */
68 1.1 christos u_char cy_flags;
69 1.1 christos u_char *cy_ibuf, *cy_ibuf_end;
70 1.1 christos u_char *cy_ibuf_rd_ptr, *cy_ibuf_wr_ptr;
71 1.1 christos #ifdef CY_DEBUG1
72 1.1 christos int cy_rx_int_count;
73 1.1 christos int cy_tx_int_count;
74 1.1 christos int cy_modem_int_count;
75 1.1 christos int cy_start_count;
76 1.1 christos #endif /* CY_DEBUG1 */
77 1.1 christos };
78 1.1 christos
79 1.1 christos #define CY_F_CARRIER_CHANGED 0x01
80 1.1 christos #define CY_F_START_BREAK 0x02
81 1.1 christos #define CY_F_END_BREAK 0x04
82 1.1 christos #define CY_F_STOP 0x08
83 1.1 christos #define CY_F_SEND_NUL 0x10
84 1.1 christos #define CY_F_START 0x20
85 1.1 christos
86 1.1 christos /* software state for one card */
87 1.1 christos struct cy_softc {
88 1.1 christos struct device sc_dev;
89 1.1 christos void *sc_ih;
90 1.1 christos bus_chipset_tag_t sc_bc;
91 1.1 christos bus_mem_handle_t sc_memh;
92 1.1 christos int sc_bustype;
93 1.1 christos int sc_nchips; /* Number of cd1400's on this card */
94 1.1 christos int sc_cd1400_offs[CY_MAX_CD1400s];
95 1.1 christos struct cy_port sc_ports[CY_MAX_PORTS];
96 1.1 christos #ifdef CY_DEBUG1
97 1.1 christos int sc_poll_count1;
98 1.1 christos int sc_poll_count2;
99 1.1 christos #endif
100 1.1 christos };
101 1.1 christos
102 1.1 christos int cy_find __P((struct cy_softc *));
103 1.1 christos void cy_attach __P((struct device *, struct device *, void *));
104 1.1 christos int cy_intr __P((void *));
105