1 /*	$NetBSD: cyvar.h,v 1.9 2008/03/26 17:50:32 matt 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  * read/write cd1400 registers (when sc_softc-structure is available)
32  */
33 #define cd_read_reg(sc,chip,reg) bus_space_read_1(sc->sc_memt, \
34     sc->sc_bsh, sc->sc_cd1400_offs[chip] + \
35     (((reg << 1)) << sc->sc_bustype))
36 
37 #define cd_write_reg(sc,chip,reg,val) bus_space_write_1(sc->sc_memt, \
38     sc->sc_bsh, sc->sc_cd1400_offs[chip] + \
39     (((reg << 1))<< sc->sc_bustype), (val))
40 
41 /*
42  * ibuf is a simple ring buffer. It is always used two
43  * bytes at a time (status and data)
44  */
45 #define CY_IBUF_SIZE (2*512)
46 
47 /* software state for one port */
48 struct cy_port {
49 	struct cy_softc *cy_softc;
50 	int             cy_port_num;
51 	int             cy_chip;
52 	int             cy_clock;
53 	struct tty     *cy_tty;
54 	int             cy_openflags;
55 	int             cy_fifo_overruns;
56 	int             cy_ibuf_overruns;
57 	u_char          cy_channel_control;	/* last CCR channel control
58 						 * command bits */
59 	u_char          cy_carrier_stat;	/* copied from MSVR2 */
60 	u_char          cy_flags;
61 	u_char         *cy_ibuf, *cy_ibuf_end;
62 	u_char         *cy_ibuf_rd_ptr, *cy_ibuf_wr_ptr;
63 #ifdef CY_DEBUG1
64 	int             cy_rx_int_count;
65 	int             cy_tx_int_count;
66 	int             cy_modem_int_count;
67 	int             cy_start_count;
68 #endif /* CY_DEBUG1 */
69 };
70 
71 #define CY_F_CARRIER_CHANGED  0x01
72 #define CY_F_START_BREAK      0x02
73 #define CY_F_END_BREAK        0x04
74 #define CY_F_STOP             0x08
75 #define CY_F_SEND_NUL         0x10
76 #define CY_F_START            0x20
77 
78 /* software state for one card */
79 struct cy_softc {
80 	device_t	sc_dev;
81 	void           *sc_ih;
82 	bus_space_tag_t sc_memt;
83 	bus_space_handle_t sc_bsh;
84 	int             sc_bustype;
85 	int		sc_nchips;	/* Number of cd1400's on this card */
86 	int             sc_cd1400_offs[CY_MAX_CD1400s];
87 	struct cy_port  sc_ports[CY_MAX_PORTS];
88 	int		sc_nchannels;	/* total number of ports */
89 #ifdef CY_DEBUG1
90 	int             sc_poll_count1;
91 	int             sc_poll_count2;
92 #endif
93 };
94 
95 int	cy_find(struct cy_softc *);
96 void	cy_attach(struct cy_softc *);
97 int	cy_intr(void *);
98