xref: /netbsd-src/sys/dev/ic/cyvar.h (revision 595211a09862b9f9a0081f4c332279a82ac197d1)
1*595211a0Smatt /*	$NetBSD: cyvar.h,v 1.9 2008/03/26 17:50:32 matt Exp $	*/
2ded50ae7Schristos 
3ded50ae7Schristos /*
4ded50ae7Schristos  * cy_var.h
5ded50ae7Schristos  *
6ded50ae7Schristos  * Driver for Cyclades Cyclom-8/16/32 multiport serial cards
7ded50ae7Schristos  * (currently not tested with Cyclom-32 cards)
8ded50ae7Schristos  *
9ded50ae7Schristos  * Timo Rossi, 1996
10ded50ae7Schristos  *
11ded50ae7Schristos  * Supports both ISA and PCI Cyclom cards
12ded50ae7Schristos  */
13ded50ae7Schristos 
14ded50ae7Schristos /* #define CY_DEBUG */
15ded50ae7Schristos #define CY_DEBUG1
16ded50ae7Schristos 
17ded50ae7Schristos /*
18ded50ae7Schristos  * Maximum number of ports per card
19ded50ae7Schristos  */
20ded50ae7Schristos #define	CY_MAX_PORTS		(CD1400_NO_OF_CHANNELS * CY_MAX_CD1400s)
21ded50ae7Schristos 
22ded50ae7Schristos #define CY_RX_FIFO_THRESHOLD  6
23ded50ae7Schristos 
24ded50ae7Schristos /*
25ded50ae7Schristos  * Automatic RTS (or actually DTR, the RTS and DTR lines need to be
26ded50ae7Schristos  * exchanged) handshake threshold used if CY_HW_RTS is defined
27ded50ae7Schristos  */
28ded50ae7Schristos #define CY_RX_DTR_THRESHOLD   9
29ded50ae7Schristos 
30ded50ae7Schristos /*
31ded50ae7Schristos  * read/write cd1400 registers (when sc_softc-structure is available)
32ded50ae7Schristos  */
3316c4c5afSthorpej #define cd_read_reg(sc,chip,reg) bus_space_read_1(sc->sc_memt, \
3416c4c5afSthorpej     sc->sc_bsh, sc->sc_cd1400_offs[chip] + \
35ded50ae7Schristos     (((reg << 1)) << sc->sc_bustype))
36ded50ae7Schristos 
3716c4c5afSthorpej #define cd_write_reg(sc,chip,reg,val) bus_space_write_1(sc->sc_memt, \
3816c4c5afSthorpej     sc->sc_bsh, sc->sc_cd1400_offs[chip] + \
39ded50ae7Schristos     (((reg << 1))<< sc->sc_bustype), (val))
40ded50ae7Schristos 
41ded50ae7Schristos /*
42ded50ae7Schristos  * ibuf is a simple ring buffer. It is always used two
43ded50ae7Schristos  * bytes at a time (status and data)
44ded50ae7Schristos  */
45ded50ae7Schristos #define CY_IBUF_SIZE (2*512)
46ded50ae7Schristos 
47ded50ae7Schristos /* software state for one port */
48ded50ae7Schristos struct cy_port {
4913ad8f5bSthorpej 	struct cy_softc *cy_softc;
50ded50ae7Schristos 	int             cy_port_num;
51ded50ae7Schristos 	int             cy_chip;
52b9627d00Stron 	int             cy_clock;
53ded50ae7Schristos 	struct tty     *cy_tty;
54ded50ae7Schristos 	int             cy_openflags;
55ded50ae7Schristos 	int             cy_fifo_overruns;
56ded50ae7Schristos 	int             cy_ibuf_overruns;
57ded50ae7Schristos 	u_char          cy_channel_control;	/* last CCR channel control
58ded50ae7Schristos 						 * command bits */
59ded50ae7Schristos 	u_char          cy_carrier_stat;	/* copied from MSVR2 */
60ded50ae7Schristos 	u_char          cy_flags;
61ded50ae7Schristos 	u_char         *cy_ibuf, *cy_ibuf_end;
62ded50ae7Schristos 	u_char         *cy_ibuf_rd_ptr, *cy_ibuf_wr_ptr;
63ded50ae7Schristos #ifdef CY_DEBUG1
64ded50ae7Schristos 	int             cy_rx_int_count;
65ded50ae7Schristos 	int             cy_tx_int_count;
66ded50ae7Schristos 	int             cy_modem_int_count;
67ded50ae7Schristos 	int             cy_start_count;
68ded50ae7Schristos #endif /* CY_DEBUG1 */
69ded50ae7Schristos };
70ded50ae7Schristos 
71ded50ae7Schristos #define CY_F_CARRIER_CHANGED  0x01
72ded50ae7Schristos #define CY_F_START_BREAK      0x02
73ded50ae7Schristos #define CY_F_END_BREAK        0x04
74ded50ae7Schristos #define CY_F_STOP             0x08
75ded50ae7Schristos #define CY_F_SEND_NUL         0x10
76ded50ae7Schristos #define CY_F_START            0x20
77ded50ae7Schristos 
78ded50ae7Schristos /* software state for one card */
79ded50ae7Schristos struct cy_softc {
80*595211a0Smatt 	device_t	sc_dev;
81ded50ae7Schristos 	void           *sc_ih;
8216c4c5afSthorpej 	bus_space_tag_t sc_memt;
8316c4c5afSthorpej 	bus_space_handle_t sc_bsh;
84ded50ae7Schristos 	int             sc_bustype;
85ded50ae7Schristos 	int		sc_nchips;	/* Number of cd1400's on this card */
86ded50ae7Schristos 	int             sc_cd1400_offs[CY_MAX_CD1400s];
87ded50ae7Schristos 	struct cy_port  sc_ports[CY_MAX_PORTS];
8813ad8f5bSthorpej 	int		sc_nchannels;	/* total number of ports */
89ded50ae7Schristos #ifdef CY_DEBUG1
90ded50ae7Schristos 	int             sc_poll_count1;
91ded50ae7Schristos 	int             sc_poll_count2;
92ded50ae7Schristos #endif
93ded50ae7Schristos };
94ded50ae7Schristos 
9544ff75e3Sthorpej int	cy_find(struct cy_softc *);
96c38c39fcSthorpej void	cy_attach(struct cy_softc *);
9744ff75e3Sthorpej int	cy_intr(void *);
98