1 /*	$OpenBSD: pccomvar.h,v 1.14 2002/03/14 01:26:33 millert Exp $	*/
2 /*	$NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $	*/
3 
4 /*
5  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by Christopher G. Demetriou
18  *	for the NetBSD Project.
19  * 4. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /* XXX - should be shared among com.c and pccom.c */
35 struct commulti_attach_args {
36 	int		ca_slave;		/* slave number */
37 
38 	bus_space_tag_t ca_iot;
39 	bus_space_handle_t ca_ioh;
40 	int		ca_iobase;
41 	int		ca_noien;
42 };
43 
44 struct com_softc {
45 	struct device sc_dev;
46 	void *sc_ih;
47 	bus_space_tag_t sc_iot;
48 	struct tty *sc_tty;
49 	struct timeout sc_dtr_tmo;
50 	struct timeout sc_diag_tmo;
51 
52 	int sc_overflows;
53 	int sc_floods;
54 	int sc_errors;
55 
56 	int sc_halt;
57 
58 	int sc_iobase;
59 	int sc_frequency;
60 #ifdef COM_HAYESP
61 	int sc_hayespbase;
62 #endif
63 
64 	bus_space_handle_t sc_ioh;
65 	bus_space_handle_t sc_hayespioh;
66 	isa_chipset_tag_t sc_ic;
67 
68 	u_char sc_uarttype;
69 #define COM_UART_UNKNOWN	0x00		/* unknown */
70 #define COM_UART_8250		0x01		/* no fifo */
71 #define COM_UART_16450		0x02		/* no fifo */
72 #define COM_UART_16550		0x03		/* no working fifo */
73 #define COM_UART_16550A		0x04		/* 16 byte fifo */
74 #define COM_UART_ST16650	0x05		/* no working fifo */
75 #define COM_UART_ST16650V2	0x06		/* 32 byte fifo */
76 #define COM_UART_TI16750	0x07		/* 64 byte fifo */
77 #define COM_UART_XR16850	0x10		/* 128 byte fifo */
78 	u_char sc_uartrev;
79 
80 	u_char sc_hwflags;
81 #define	COM_HW_NOIEN	0x01
82 #define	COM_HW_FIFO	0x02
83 #define	COM_HW_HAYESP	0x04
84 #define	COM_HW_CONSOLE	0x40
85 #define COM_HW_KGDB	0x80
86 	u_char sc_swflags;
87 #define	COM_SW_SOFTCAR	0x01
88 #define	COM_SW_CLOCAL	0x02
89 #define	COM_SW_CRTSCTS	0x04
90 #define	COM_SW_MDMBUF	0x08
91 	int	sc_fifolen;
92 	u_char sc_msr, sc_mcr, sc_lcr, sc_ier;
93 	u_char sc_dtr;
94 
95 	u_char	sc_cua;
96 
97 	u_char	sc_initialize;		/* force initialization */
98 
99 #define RBUFSIZE 512
100 #define RBUFMASK 511
101 	u_int sc_rxget;
102 	volatile u_int sc_rxput;
103 	u_char sc_rxbuf[RBUFSIZE];
104 	u_char *sc_tba;
105 	int sc_tbc;
106 
107 	/* power management hooks */
108 	int (*enable)(struct com_softc *);
109 	void (*disable)(struct com_softc *);
110 	int enabled;
111 };
112 
113 int	comprobe1(bus_space_tag_t, bus_space_handle_t);
114 void	cominit(bus_space_tag_t, bus_space_handle_t, int);
115 int	comstop(struct tty *, int);
116 int	comintr(void *);
117 int	com_detach(struct device *, int);
118 int	com_activate(struct device *, enum devact);
119 
120 #ifdef COM_HAYESP
121 int comprobeHAYESP(bus_space_handle_t hayespioh, struct com_softc *sc);
122 #endif
123 void	comdiag(void *);
124 int	comspeed(long, long);
125 int	comparam(struct tty *, struct termios *);
126 void	comstart(struct tty *);
127 void	comsoft(void);
128 int	comhwiflow(struct tty *, int);
129 void	com_raisedtr(void *);
130 
131 struct consdev;
132 void	comcnprobe(struct consdev *);
133 void	comcninit(struct consdev *);
134 int	comcngetc(dev_t);
135 void	comcnputc(dev_t, int);
136 void	comcnpollc(dev_t, int);
137 int	com_common_getc(bus_space_tag_t, bus_space_handle_t);
138 void	com_common_putc(bus_space_tag_t, bus_space_handle_t, int);
139 
140 #if defined(DDB) || defined(KGDB)
141 void	com_enable_debugport(struct com_softc *);
142 #endif /* DDB || KGDB */
143 
144 #ifdef KGDB
145 int	com_kgdb_attach(bus_space_tag_t, int, int, int, tcflag_t);
146 int	kgdbintr(void *);
147 #endif /* KGDB */
148 
149 extern int comconsaddr;
150 extern int comconsinit;
151 extern int comconsattached;
152 extern bus_space_tag_t comconsiot;
153 extern bus_space_handle_t comconsioh;
154 extern tcflag_t comconscflag;
155