comvar.h revision 1.52 1 1.52 kardel /* $NetBSD: comvar.h,v 1.52 2006/06/07 22:33:35 kardel Exp $ */
2 1.1 cgd
3 1.1 cgd /*
4 1.2 cgd * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
5 1.1 cgd *
6 1.1 cgd * Redistribution and use in source and binary forms, with or without
7 1.1 cgd * modification, are permitted provided that the following conditions
8 1.1 cgd * are met:
9 1.1 cgd * 1. Redistributions of source code must retain the above copyright
10 1.1 cgd * notice, this list of conditions and the following disclaimer.
11 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 cgd * notice, this list of conditions and the following disclaimer in the
13 1.1 cgd * documentation and/or other materials provided with the distribution.
14 1.1 cgd * 3. All advertising materials mentioning features or use of this software
15 1.1 cgd * must display the following acknowledgement:
16 1.1 cgd * This product includes software developed by Christopher G. Demetriou
17 1.1 cgd * for the NetBSD Project.
18 1.1 cgd * 4. The name of the author may not be used to endorse or promote products
19 1.1 cgd * derived from this software without specific prior written permission
20 1.1 cgd *
21 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 cgd * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 cgd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 cgd * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 cgd * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 cgd * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 cgd * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 cgd * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 cgd * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 cgd * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 cgd */
32 1.1 cgd
33 1.17 explorer #include "rnd.h"
34 1.38 sommerfe #include "opt_multiprocessor.h"
35 1.38 sommerfe #include "opt_lockdebug.h"
36 1.38 sommerfe #include "opt_com.h"
37 1.40 lukem #include "opt_kgdb.h"
38 1.38 sommerfe
39 1.17 explorer #if NRND > 0 && defined(RND_COM)
40 1.17 explorer #include <sys/rnd.h>
41 1.17 explorer #endif
42 1.24 thorpej
43 1.32 thorpej #include <sys/callout.h>
44 1.24 thorpej #include <sys/timepps.h>
45 1.36 sommerfe #include <sys/lock.h>
46 1.17 explorer
47 1.48 perry int comcnattach(bus_space_tag_t, bus_addr_t, int, int, int, tcflag_t);
48 1.12 drochner
49 1.12 drochner #ifdef KGDB
50 1.48 perry int com_kgdb_attach(bus_space_tag_t, bus_addr_t, int, int, int, tcflag_t);
51 1.12 drochner #endif
52 1.8 mycroft
53 1.48 perry int com_is_console(bus_space_tag_t, bus_addr_t, bus_space_handle_t *);
54 1.14 drochner
55 1.8 mycroft /* Hardware flag masks */
56 1.8 mycroft #define COM_HW_NOIEN 0x01
57 1.8 mycroft #define COM_HW_FIFO 0x02
58 1.45 thorpej /* 0x04 free for use */
59 1.18 fvdl #define COM_HW_FLOW 0x08
60 1.21 cgd #define COM_HW_DEV_OK 0x20
61 1.8 mycroft #define COM_HW_CONSOLE 0x40
62 1.11 thorpej #define COM_HW_KGDB 0x80
63 1.31 soda #define COM_HW_TXFIFO_DISABLE 0x100
64 1.43 thorpej #define COM_HW_NO_TXPRELOAD 0x200
65 1.8 mycroft
66 1.8 mycroft /* Buffer size for character buffer */
67 1.19 mycroft #define COM_RING_SIZE 2048
68 1.8 mycroft
69 1.8 mycroft struct com_softc {
70 1.8 mycroft struct device sc_dev;
71 1.8 mycroft void *sc_si;
72 1.8 mycroft struct tty *sc_tty;
73 1.32 thorpej
74 1.32 thorpej struct callout sc_diag_callout;
75 1.8 mycroft
76 1.34 eeh bus_addr_t sc_iobase; /* XXX ISA-centric name */
77 1.15 is int sc_frequency;
78 1.8 mycroft
79 1.8 mycroft bus_space_tag_t sc_iot;
80 1.8 mycroft bus_space_handle_t sc_ioh;
81 1.8 mycroft bus_space_handle_t sc_hayespioh;
82 1.8 mycroft
83 1.19 mycroft u_int sc_overflows,
84 1.19 mycroft sc_floods,
85 1.19 mycroft sc_errors;
86 1.19 mycroft
87 1.19 mycroft int sc_hwflags,
88 1.19 mycroft sc_swflags;
89 1.19 mycroft u_int sc_fifolen;
90 1.19 mycroft
91 1.19 mycroft u_int sc_r_hiwat,
92 1.19 mycroft sc_r_lowat;
93 1.19 mycroft u_char *volatile sc_rbget,
94 1.19 mycroft *volatile sc_rbput;
95 1.19 mycroft volatile u_int sc_rbavail;
96 1.19 mycroft u_char *sc_rbuf,
97 1.19 mycroft *sc_ebuf;
98 1.8 mycroft
99 1.8 mycroft u_char *sc_tba;
100 1.19 mycroft u_int sc_tbc,
101 1.19 mycroft sc_heldtbc;
102 1.8 mycroft
103 1.10 mycroft volatile u_char sc_rx_flags,
104 1.10 mycroft #define RX_TTY_BLOCKED 0x01
105 1.10 mycroft #define RX_TTY_OVERFLOWED 0x02
106 1.10 mycroft #define RX_IBUF_BLOCKED 0x04
107 1.10 mycroft #define RX_IBUF_OVERFLOWED 0x08
108 1.10 mycroft #define RX_ANY_BLOCK 0x0f
109 1.8 mycroft sc_tx_busy,
110 1.8 mycroft sc_tx_done,
111 1.8 mycroft sc_tx_stopped,
112 1.8 mycroft sc_st_check,
113 1.8 mycroft sc_rx_ready;
114 1.8 mycroft
115 1.8 mycroft volatile u_char sc_heldchange;
116 1.19 mycroft volatile u_char sc_msr, sc_msr_delta, sc_msr_mask, sc_mcr,
117 1.19 mycroft sc_mcr_active, sc_lcr, sc_ier, sc_fifo, sc_dlbl, sc_dlbh, sc_efr;
118 1.19 mycroft u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd;
119 1.42 enami
120 1.42 enami #ifdef COM_HAYESP
121 1.42 enami u_char sc_prescaler;
122 1.42 enami #endif
123 1.45 thorpej
124 1.45 thorpej /*
125 1.45 thorpej * There are a great many almost-ns16550-compatible UARTs out
126 1.45 thorpej * there, which have minor differences. The type field here
127 1.45 thorpej * lets us distinguish between them.
128 1.45 thorpej */
129 1.45 thorpej int sc_type;
130 1.45 thorpej #define COM_TYPE_NORMAL 0 /* normal 16x50 */
131 1.45 thorpej #define COM_TYPE_HAYESP 1 /* Hayes ESP modem */
132 1.45 thorpej #define COM_TYPE_PXA2x0 2 /* Intel PXA2x0 processor built-in */
133 1.47 simonb #define COM_TYPE_AU1x00 3 /* AMD/Alchemy Au1x000 proc. built-in */
134 1.20 marc
135 1.20 marc /* power management hooks */
136 1.48 perry int (*enable)(struct com_softc *);
137 1.48 perry void (*disable)(struct com_softc *);
138 1.20 marc int enabled;
139 1.23 jonathan
140 1.52 kardel #ifdef __HAVE_TIMECOUNTER
141 1.52 kardel struct pps_state sc_pps_state; /* pps state */
142 1.52 kardel #else /* !__HAVE_TIMECOUNTER */
143 1.23 jonathan /* PPS signal on DCD, with or without inkernel clock disciplining */
144 1.30 mycroft u_char sc_ppsmask; /* pps signal mask */
145 1.30 mycroft u_char sc_ppsassert; /* pps leading edge */
146 1.30 mycroft u_char sc_ppsclear; /* pps trailing edge */
147 1.23 jonathan pps_info_t ppsinfo;
148 1.23 jonathan pps_params_t ppsparam;
149 1.52 kardel #endif /* !__HAVE_TIMECOUNTER */
150 1.19 mycroft
151 1.17 explorer #if NRND > 0 && defined(RND_COM)
152 1.17 explorer rndsource_element_t rnd_source;
153 1.36 sommerfe #endif
154 1.36 sommerfe struct simplelock sc_lock;
155 1.1 cgd };
156 1.1 cgd
157 1.48 perry int comprobe1(bus_space_tag_t, bus_space_handle_t);
158 1.48 perry int comintr(void *);
159 1.48 perry void com_attach_subr(struct com_softc *);
160 1.48 perry int com_detach(struct device *, int);
161 1.48 perry int com_activate(struct device *, enum devact);
162 1.3 cgd
163 1.39 thorpej #ifndef __HAVE_GENERIC_SOFT_INTERRUPTS
164 1.22 cgd #ifdef __NO_SOFT_SERIAL_INTERRUPT
165 1.8 mycroft #define IPL_SERIAL IPL_TTY
166 1.8 mycroft #define splserial() spltty()
167 1.8 mycroft #define IPL_SOFTSERIAL IPL_TTY
168 1.8 mycroft #define splsoftserial() spltty()
169 1.8 mycroft #endif
170 1.8 mycroft #endif
171