1 /* $NetBSD: comvar.h,v 1.68 2009/11/12 20:37:44 dyoung Exp $ */
4 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Christopher G. Demetriou
17 * for the NetBSD Project.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "opt_multiprocessor.h"
35 #include "opt_lockdebug.h"
39 #if NRND > 0 && defined(RND_COM)
43 #include <sys/callout.h>
44 #include <sys/timepps.h>
45 #include <sys/mutex.h>
47 #include <dev/ic/comreg.h> /* for COM_NPORTS */
51 int comcnattach(bus_space_tag_t
, bus_addr_t
, int, int, int, tcflag_t
);
52 int comcnattach1(struct com_regs
*, int, int, int, tcflag_t
);
55 int com_kgdb_attach(bus_space_tag_t
, bus_addr_t
, int, int, int, tcflag_t
);
56 int com_kgdb_attach1(struct com_regs
*, int, int, int, tcflag_t
);
59 int com_is_console(bus_space_tag_t
, bus_addr_t
, bus_space_handle_t
*);
61 /* Hardware flag masks */
62 #define COM_HW_NOIEN 0x01
63 #define COM_HW_FIFO 0x02
64 /* 0x04 free for use */
65 #define COM_HW_FLOW 0x08
66 #define COM_HW_DEV_OK 0x20
67 #define COM_HW_CONSOLE 0x40
68 #define COM_HW_KGDB 0x80
69 #define COM_HW_TXFIFO_DISABLE 0x100
70 #define COM_HW_NO_TXPRELOAD 0x200
72 /* Buffer size for character buffer */
74 #define COM_RING_SIZE 2048
78 #define COM_REG_RXDATA 0
79 #define COM_REG_TXDATA 1
80 #define COM_REG_DLBL 2
81 #define COM_REG_DLBH 3
84 #define COM_REG_FIFO 6
89 #define COM_REG_MDR1 8
91 #define COM_REG_LSR 10
92 #define COM_REG_MSR 11
95 bus_space_tag_t cr_iot
;
96 bus_space_handle_t cr_ioh
;
99 bus_size_t cr_map
[16];
102 extern const bus_size_t com_std_map
[16];
104 #define COM_INIT_REGS(regs, tag, hdl, addr) \
108 regs.cr_iobase = addr; \
109 regs.cr_nports = COM_NPORTS; \
110 memcpy(regs.cr_map, com_std_map, sizeof (regs.cr_map)); \
114 #define COM_REG_RXDATA com_data
115 #define COM_REG_TXDATA com_data
116 #define COM_REG_DLBL com_dlbl
117 #define COM_REG_DLBH com_dlbh
118 #define COM_REG_IER com_ier
119 #define COM_REG_IIR com_iir
120 #define COM_REG_FIFO com_fifo
121 #define COM_REG_EFR com_efr
122 #define COM_REG_LCR com_lctl
123 #define COM_REG_MCR com_mcr
124 #define COM_REG_LSR com_lsr
125 #define COM_REG_MSR com_msr
126 #define COM_REG_TCR com_msr
127 #define COM_REG_TLR com_scratch
128 #define COM_REG_MDR1 8
131 bus_space_tag_t cr_iot
;
132 bus_space_handle_t cr_ioh
;
133 bus_addr_t cr_iobase
;
134 bus_size_t cr_nports
;
137 #define COM_INIT_REGS(regs, tag, hdl, addr) \
141 regs.cr_iobase = addr; \
142 regs.cr_nports = COM_NPORTS; \
147 struct comcons_info
{
148 struct com_regs regs
;
160 struct callout sc_diag_callout
;
164 struct com_regs sc_regs
;
165 bus_space_handle_t sc_hayespioh
;
178 u_char
*volatile sc_rbget
,
180 volatile u_int sc_rbavail
;
188 volatile u_char sc_rx_flags
,
189 #define RX_TTY_BLOCKED 0x01
190 #define RX_TTY_OVERFLOWED 0x02
191 #define RX_IBUF_BLOCKED 0x04
192 #define RX_IBUF_OVERFLOWED 0x08
193 #define RX_ANY_BLOCK 0x0f
200 volatile u_char sc_heldchange
;
201 volatile u_char sc_msr
, sc_msr_delta
, sc_msr_mask
, sc_mcr
,
202 sc_mcr_active
, sc_lcr
, sc_ier
, sc_fifo
, sc_dlbl
, sc_dlbh
, sc_efr
;
203 u_char sc_mcr_dtr
, sc_mcr_rts
, sc_msr_cts
, sc_msr_dcd
;
210 * There are a great many almost-ns16550-compatible UARTs out
211 * there, which have minor differences. The type field here
212 * lets us distinguish between them.
215 #define COM_TYPE_NORMAL 0 /* normal 16x50 */
216 #define COM_TYPE_HAYESP 1 /* Hayes ESP modem */
217 #define COM_TYPE_PXA2x0 2 /* Intel PXA2x0 processor built-in */
218 #define COM_TYPE_AU1x00 3 /* AMD/Alchemy Au1x000 proc. built-in */
219 #define COM_TYPE_OMAP 4 /* TI OMAP processor built-in */
220 #define COM_TYPE_16550_NOERS 5 /* like a 16550, no ERS */
222 /* power management hooks */
223 int (*enable
)(struct com_softc
*);
224 void (*disable
)(struct com_softc
*);
227 struct pps_state sc_pps_state
; /* pps state */
229 #if NRND > 0 && defined(RND_COM)
230 rndsource_element_t rnd_source
;
235 int comprobe1(bus_space_tag_t
, bus_space_handle_t
);
237 void com_attach_subr(struct com_softc
*);
238 int com_probe_subr(struct com_regs
*);
239 int com_detach(device_t
, int);
240 bool com_resume(device_t
, pmf_qual_t
);
241 bool com_cleanup(device_t
, int);
242 bool com_suspend(device_t
, pmf_qual_t
);
245 #define IPL_SERIAL IPL_TTY
246 #define splserial() spltty()