sbjcnvar.h revision 1.1 1 /* $NetBSD: sbjcnvar.h,v 1.1 2002/03/05 23:46:42 simonb Exp $ */
2
3 /*
4 * Copyright 2000, 2001
5 * Broadcom Corporation. All rights reserved.
6 *
7 * This software is furnished under license and may be used and copied only
8 * in accordance with the following terms and conditions. Subject to these
9 * conditions, you may download, copy, install, use, modify and distribute
10 * modified or unmodified copies of this software in source and/or binary
11 * form. No title or ownership is transferred hereby.
12 *
13 * 1) Any source code used, modified or distributed must reproduce and
14 * retain this copyright notice and list of conditions as they appear in
15 * the source file.
16 *
17 * 2) No right is granted to use any trade name, trademark, or logo of
18 * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any
19 * trademark or logo of Broadcom Corporation may be used to endorse or
20 * promote products derived from this software without the prior written
21 * permission of Broadcom Corporation.
22 *
23 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
26 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
27 * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
28 * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33 * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 /* from: $NetBSD: comvar.h,v 1.32 2000/03/23 07:01:30 thorpej Exp */
37
38 /*
39 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
40 *
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
43 * are met:
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 * 3. All advertising materials mentioning features or use of this software
50 * must display the following acknowledgement:
51 * This product includes software developed by Christopher G. Demetriou
52 * for the NetBSD Project.
53 * 4. The name of the author may not be used to endorse or promote products
54 * derived from this software without specific prior written permission
55 *
56 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
57 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
58 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
59 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
60 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
62 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
63 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
64 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
65 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 */
67
68 #include "rnd.h"
69 #if NRND > 0 && defined(RND_SBJCN)
70 #include <sys/rnd.h>
71 #endif
72
73 #include <sys/callout.h>
74
75 #define SBJCN_CHAN(x) ((minor(x) & 0x00001) >> 0)
76 #define SBJCN_UNIT(x) ((minor(x) & 0x7fffe) >> 1)
77 #define SBJCN_DIALOUT(x) ((minor(x) & 0x80000) != 0)
78
79 #define SBJCN_TOLERANCE 30 /* baud rate tolerance, in 0.1% units */
80
81 int sbjcn_cnattach(u_long addr, int chan, int rate,
82 tcflag_t cflag);
83 #ifdef KGDB
84 int sbjcn_kgdb_attach(u_long addr, int chan, int rate,
85 tcflag_t cflag);
86 #endif
87 int sbjcn_is_console(u_long addr, int chan);
88
89 /* Hardware flag masks */
90 #define SBJCN_HW_CONSOLE 0x01
91 #define SBJCN_HW_KGDB 0x02
92 #define SBJCN_HW_DEV_OK 0x04
93
94 /* Buffer size for character buffer */
95 #define SBJCN_RING_SIZE 2048
96
97 struct sbjcn_channel {
98 int ch_num;
99 struct sbjcn_softc *ch_sc;
100 struct tty *ch_tty; /* tty struct */
101 struct callout ch_diag_callout; /* callout for diagnostic msgs */
102 struct callout ch_callout; /* callout for channel processing */
103
104 volatile char *ch_input_reg; /* kseg1 addr of input reg */
105 volatile char *ch_output_reg; /* kseg1 addr of outpu reg */
106 volatile char *ch_control_reg;/* kseg1 addr of control reg */
107
108 volatile int ch_waiting_input; /* */
109 volatile uint64_t ch_input_buf; /* up to 7 buffered bytes */
110
111 volatile char *ch_base; /* kseg1 addr of channel regs */
112 volatile char *ch_isr_base; /* kseg1 addr of channel ISR */
113 volatile char *ch_imr_base; /* kseg1 addr of channel IMR */
114 #ifdef XXXCGDnotyet
115 volatile char *ch_inchg_base; /* kseg1 addr of channel inport-chg */
116 #endif
117
118 u_int ch_overflows;
119 u_int ch_floods;
120 u_int ch_errors;
121
122 u_int ch_hwflags;
123 u_int ch_swflags;
124
125 u_int ch_r_hiwat;
126 u_int ch_r_lowat;
127
128 /* receive ring buffer management */
129 u_char *volatile ch_rbget;
130 u_char *volatile ch_rbput;
131 volatile u_int ch_rbavail;
132 u_char *ch_rbuf;
133 u_char *ch_ebuf;
134
135 /* transmit buffer management */
136 u_char *ch_tba;
137 u_int ch_tbc;
138 u_int ch_heldtbc;
139
140 volatile u_int ch_rx_flags;
141 #define RX_TTY_BLOCKED 0x01
142 #define RX_TTY_OVERFLOWED 0x02
143 #define RX_IBUF_BLOCKED 0x04
144 #define RX_IBUF_OVERFLOWED 0x08
145 #define RX_ANY_BLOCK 0x0f
146 volatile u_int ch_tx_busy;
147 volatile u_int ch_tx_done;
148 volatile u_int ch_tx_stopped;
149 volatile u_int ch_rx_ready;
150
151 volatile u_char ch_heldchange;
152
153 volatile u_int ch_brc;
154 volatile u_char ch_imr;
155 volatile u_char ch_iports, ch_iports_delta;
156 volatile u_char ch_oports, ch_oports_active;
157 volatile u_char ch_mode1, ch_mode2;
158
159 u_char ch_i_dcd, ch_i_cts, ch_i_dsr, ch_i_ri, ch_i_mask;
160 u_char ch_o_dtr, ch_o_rts, ch_o_mask;
161
162 u_char ch_i_dcd_pin, ch_i_cts_pin, ch_i_dsr_pin, ch_i_ri_pin;
163 u_char ch_o_dtr_pin, ch_o_rts_pin;
164 };
165
166 struct sbjcn_softc {
167 struct device sc_dev; /* base device */
168
169 /* shared data structures */
170 u_long sc_addr; /* phys addr of JTAG console bus_space */
171
172 struct sbjcn_channel sc_channels[1];
173 };
174
175 /* Macros to clear/set/test flags. */
176 #define SET(t, f) (t) |= (f)
177 #define CLR(t, f) (t) &= ~(f)
178 #define ISSET(t, f) ((t) & (f))
179