xref: /minix3/sys/dev/pci/if_lmc.h (revision 7eb99bda90fc3b15ed07bfd8809650d0818ad5f7)
1*7eb99bdaSLionel Sambuc /*-
2*7eb99bdaSLionel Sambuc  * $NetBSD: if_lmc.h,v 1.21 2012/10/27 17:18:33 chs Exp $
3*7eb99bdaSLionel Sambuc  *
4*7eb99bdaSLionel Sambuc  * Copyright (c) 2002-2006 David Boggs. (boggs@boggs.palo-alto.ca.us)
5*7eb99bdaSLionel Sambuc  * All rights reserved.
6*7eb99bdaSLionel Sambuc  *
7*7eb99bdaSLionel Sambuc  * BSD LICENSE:
8*7eb99bdaSLionel Sambuc  *
9*7eb99bdaSLionel Sambuc  * Redistribution and use in source and binary forms, with or without
10*7eb99bdaSLionel Sambuc  * modification, are permitted provided that the following conditions
11*7eb99bdaSLionel Sambuc  * are met:
12*7eb99bdaSLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
13*7eb99bdaSLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
14*7eb99bdaSLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
15*7eb99bdaSLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
16*7eb99bdaSLionel Sambuc  *    documentation and/or other materials provided with the distribution.
17*7eb99bdaSLionel Sambuc  *
18*7eb99bdaSLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19*7eb99bdaSLionel Sambuc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*7eb99bdaSLionel Sambuc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*7eb99bdaSLionel Sambuc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22*7eb99bdaSLionel Sambuc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23*7eb99bdaSLionel Sambuc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24*7eb99bdaSLionel Sambuc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25*7eb99bdaSLionel Sambuc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26*7eb99bdaSLionel Sambuc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27*7eb99bdaSLionel Sambuc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28*7eb99bdaSLionel Sambuc  * SUCH DAMAGE.
29*7eb99bdaSLionel Sambuc  *
30*7eb99bdaSLionel Sambuc  * GNU GENERAL PUBLIC LICENSE:
31*7eb99bdaSLionel Sambuc  *
32*7eb99bdaSLionel Sambuc  * This program is free software; you can redistribute it and/or modify it
33*7eb99bdaSLionel Sambuc  * under the terms of the GNU General Public License as published by the Free
34*7eb99bdaSLionel Sambuc  * Software Foundation; either version 2 of the License, or (at your option)
35*7eb99bdaSLionel Sambuc  * any later version.
36*7eb99bdaSLionel Sambuc  *
37*7eb99bdaSLionel Sambuc  * This program is distributed in the hope that it will be useful, but WITHOUT
38*7eb99bdaSLionel Sambuc  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
39*7eb99bdaSLionel Sambuc  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
40*7eb99bdaSLionel Sambuc  * more details.
41*7eb99bdaSLionel Sambuc  *
42*7eb99bdaSLionel Sambuc  * You should have received a copy of the GNU General Public License along with
43*7eb99bdaSLionel Sambuc  * this program; if not, write to the Free Software Foundation, Inc., 59
44*7eb99bdaSLionel Sambuc  * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
45*7eb99bdaSLionel Sambuc  */
46*7eb99bdaSLionel Sambuc 
47*7eb99bdaSLionel Sambuc #ifndef IF_LMC_H
48*7eb99bdaSLionel Sambuc #define IF_LMC_H
49*7eb99bdaSLionel Sambuc 
50*7eb99bdaSLionel Sambuc #define DEVICE_NAME		"lmc"
51*7eb99bdaSLionel Sambuc 
52*7eb99bdaSLionel Sambuc #define VER_YEAR		2006
53*7eb99bdaSLionel Sambuc #define VER_MONTH		4
54*7eb99bdaSLionel Sambuc #define VER_DAY			11
55*7eb99bdaSLionel Sambuc 
56*7eb99bdaSLionel Sambuc /* netgraph stuff */
57*7eb99bdaSLionel Sambuc #define NG_LMC_NODE_TYPE	"if_"DEVICE_NAME
58*7eb99bdaSLionel Sambuc #define NGM_LMC_COOKIE		1144752198	/* date -u +'%s' */
59*7eb99bdaSLionel Sambuc 
60*7eb99bdaSLionel Sambuc /* Tulip PCI configuration registers */
61*7eb99bdaSLionel Sambuc #define TLP_CFID		0x00	/*  0: CFg ID register     */
62*7eb99bdaSLionel Sambuc #define TLP_CFCS		0x04	/*  1: CFg Command/Status  */
63*7eb99bdaSLionel Sambuc #define TLP_CFRV		0x08	/*  2: CFg ReVision        */
64*7eb99bdaSLionel Sambuc #define TLP_CFLT		0x0C	/*  3: CFg Latency Timer   */
65*7eb99bdaSLionel Sambuc #define TLP_CBIO		0x10	/*  4: Cfg Base IO address */
66*7eb99bdaSLionel Sambuc #define TLP_CBMA		0x14	/*  5: Cfg Base Mem Addr   */
67*7eb99bdaSLionel Sambuc #define TLP_CSID		0x2C	/* 11: Cfg Subsys ID reg   */
68*7eb99bdaSLionel Sambuc #define TLP_CFIT		0x3C	/* 15: CFg InTerrupt       */
69*7eb99bdaSLionel Sambuc #define TLP_CFDD		0x40	/* 16: CFg Driver Data     */
70*7eb99bdaSLionel Sambuc 
71*7eb99bdaSLionel Sambuc #define TLP_CFID_TULIP		0x00091011	/* DEC 21140A Ethernet chip */
72*7eb99bdaSLionel Sambuc 
73*7eb99bdaSLionel Sambuc #define TLP_CFCS_MSTR_ABORT	0x20000000
74*7eb99bdaSLionel Sambuc #define TLP_CFCS_TARG_ABORT	0x10000000
75*7eb99bdaSLionel Sambuc #define TLP_CFCS_SYS_ERROR	0x00000100
76*7eb99bdaSLionel Sambuc #define TLP_CFCS_PAR_ERROR	0x00000040
77*7eb99bdaSLionel Sambuc #define TLP_CFCS_MWI_ENABLE	0x00000010
78*7eb99bdaSLionel Sambuc #define TLP_CFCS_BUS_MASTER	0x00000004
79*7eb99bdaSLionel Sambuc #define TLP_CFCS_MEM_ENABLE	0x00000002
80*7eb99bdaSLionel Sambuc #define TLP_CFCS_IO_ENABLE	0x00000001
81*7eb99bdaSLionel Sambuc 
82*7eb99bdaSLionel Sambuc #define TLP_CFLT_LATENCY	0x0000FF00
83*7eb99bdaSLionel Sambuc #define TLP_CFLT_CACHE		0x000000FF
84*7eb99bdaSLionel Sambuc 
85*7eb99bdaSLionel Sambuc #define CSID_LMC_HSSI		0x00031376	/* LMC 5200 HSSI card */
86*7eb99bdaSLionel Sambuc #define CSID_LMC_T3		0x00041376	/* LMC 5245 T3   card */
87*7eb99bdaSLionel Sambuc #define CSID_LMC_SSI		0x00051376	/* LMC 1000 SSI  card */
88*7eb99bdaSLionel Sambuc #define CSID_LMC_T1E1		0x00061376	/* LMC 1200 T1E1 card */
89*7eb99bdaSLionel Sambuc #define CSID_LMC_HSSIc		0x00071376	/* LMC 5200 HSSI cPCI */
90*7eb99bdaSLionel Sambuc #define CSID_LMC_SDSL		0x00081376	/* LMC 1168 SDSL card */
91*7eb99bdaSLionel Sambuc 
92*7eb99bdaSLionel Sambuc #define TLP_CFIT_MAX_LAT	0xFF000000
93*7eb99bdaSLionel Sambuc 
94*7eb99bdaSLionel Sambuc #define TLP_CFDD_SLEEP		0x80000000
95*7eb99bdaSLionel Sambuc #define TLP_CFDD_SNOOZE		0x40000000
96*7eb99bdaSLionel Sambuc 
97*7eb99bdaSLionel Sambuc /* Tulip Control and Status Registers */
98*7eb99bdaSLionel Sambuc #define TLP_CSR_STRIDE		 8	/* 64 bits */
99*7eb99bdaSLionel Sambuc #define TLP_BUS_MODE		 0 * TLP_CSR_STRIDE
100*7eb99bdaSLionel Sambuc #define TLP_TX_POLL		 1 * TLP_CSR_STRIDE
101*7eb99bdaSLionel Sambuc #define TLP_RX_POLL		 2 * TLP_CSR_STRIDE
102*7eb99bdaSLionel Sambuc #define TLP_RX_LIST		 3 * TLP_CSR_STRIDE
103*7eb99bdaSLionel Sambuc #define TLP_TX_LIST		 4 * TLP_CSR_STRIDE
104*7eb99bdaSLionel Sambuc #define TLP_STATUS		 5 * TLP_CSR_STRIDE
105*7eb99bdaSLionel Sambuc #define TLP_OP_MODE		 6 * TLP_CSR_STRIDE
106*7eb99bdaSLionel Sambuc #define TLP_INT_ENBL		 7 * TLP_CSR_STRIDE
107*7eb99bdaSLionel Sambuc #define TLP_MISSED		 8 * TLP_CSR_STRIDE
108*7eb99bdaSLionel Sambuc #define TLP_SROM_MII		 9 * TLP_CSR_STRIDE
109*7eb99bdaSLionel Sambuc #define TLP_BIOS_ROM		10 * TLP_CSR_STRIDE
110*7eb99bdaSLionel Sambuc #define TLP_TIMER		11 * TLP_CSR_STRIDE
111*7eb99bdaSLionel Sambuc #define TLP_GPIO		12 * TLP_CSR_STRIDE
112*7eb99bdaSLionel Sambuc #define TLP_CSR13		13 * TLP_CSR_STRIDE
113*7eb99bdaSLionel Sambuc #define TLP_CSR14		14 * TLP_CSR_STRIDE
114*7eb99bdaSLionel Sambuc #define TLP_WDOG		15 * TLP_CSR_STRIDE
115*7eb99bdaSLionel Sambuc #define TLP_CSR_SIZE		128	/* IO bus space size */
116*7eb99bdaSLionel Sambuc 
117*7eb99bdaSLionel Sambuc /* CSR 0 - PCI Bus Mode Register */
118*7eb99bdaSLionel Sambuc #define TLP_BUS_WRITE_INVAL	0x01000000	/* DONT USE! */
119*7eb99bdaSLionel Sambuc #define TLP_BUS_READ_LINE	0x00800000
120*7eb99bdaSLionel Sambuc #define TLP_BUS_READ_MULT	0x00200000
121*7eb99bdaSLionel Sambuc #define TLP_BUS_DESC_BIGEND	0x00100000
122*7eb99bdaSLionel Sambuc #define TLP_BUS_TAP		0x000E0000
123*7eb99bdaSLionel Sambuc #define TLP_BUS_CAL		0x0000C000
124*7eb99bdaSLionel Sambuc #define TLP_BUS_PBL		0x00003F00
125*7eb99bdaSLionel Sambuc #define TLP_BUS_DATA_BIGEND	0x00000080
126*7eb99bdaSLionel Sambuc #define TLP_BUS_DSL		0x0000007C
127*7eb99bdaSLionel Sambuc #define TLP_BUS_ARB		0x00000002
128*7eb99bdaSLionel Sambuc #define TLP_BUS_RESET		0x00000001
129*7eb99bdaSLionel Sambuc #define TLP_BUS_CAL_SHIFT	14
130*7eb99bdaSLionel Sambuc #define TLP_BUS_PBL_SHIFT	 8
131*7eb99bdaSLionel Sambuc 
132*7eb99bdaSLionel Sambuc /* CSR 5 - Status Register */
133*7eb99bdaSLionel Sambuc #define TLP_STAT_FATAL_BITS	0x03800000
134*7eb99bdaSLionel Sambuc #define TLP_STAT_TX_FSM		0x00700000
135*7eb99bdaSLionel Sambuc #define TLP_STAT_RX_FSM		0x000E0000
136*7eb99bdaSLionel Sambuc #define TLP_STAT_FATAL_ERROR	0x00002000
137*7eb99bdaSLionel Sambuc #define TLP_STAT_TX_UNDERRUN	0x00000020
138*7eb99bdaSLionel Sambuc #define TLP_STAT_FATAL_SHIFT	23
139*7eb99bdaSLionel Sambuc 
140*7eb99bdaSLionel Sambuc /* CSR 6 - Operating Mode Register */
141*7eb99bdaSLionel Sambuc #define TLP_OP_RECEIVE_ALL	0x40000000
142*7eb99bdaSLionel Sambuc #define TLP_OP_MUST_BE_ONE	0x02000000
143*7eb99bdaSLionel Sambuc #define TLP_OP_NO_HEART_BEAT	0x00080000
144*7eb99bdaSLionel Sambuc #define TLP_OP_PORT_SELECT	0x00040000
145*7eb99bdaSLionel Sambuc #define TLP_OP_TX_THRESH	0x0000C000
146*7eb99bdaSLionel Sambuc #define TLP_OP_TX_RUN		0x00002000
147*7eb99bdaSLionel Sambuc #define TLP_OP_LOOP_MODE	0x00000C00
148*7eb99bdaSLionel Sambuc #define TLP_OP_EXT_LOOP		0x00000800
149*7eb99bdaSLionel Sambuc #define TLP_OP_INT_LOOP		0x00000400
150*7eb99bdaSLionel Sambuc #define TLP_OP_FULL_DUPLEX	0x00000200
151*7eb99bdaSLionel Sambuc #define TLP_OP_PROMISCUOUS	0x00000040
152*7eb99bdaSLionel Sambuc #define TLP_OP_PASS_BAD_PKT	0x00000008
153*7eb99bdaSLionel Sambuc #define TLP_OP_RX_RUN		0x00000002
154*7eb99bdaSLionel Sambuc #define TLP_OP_TR_SHIFT		14
155*7eb99bdaSLionel Sambuc #define TLP_OP_INIT		(TLP_OP_PORT_SELECT   | \
156*7eb99bdaSLionel Sambuc 				 TLP_OP_FULL_DUPLEX   | \
157*7eb99bdaSLionel Sambuc 				 TLP_OP_MUST_BE_ONE   | \
158*7eb99bdaSLionel Sambuc 				 TLP_OP_NO_HEART_BEAT | \
159*7eb99bdaSLionel Sambuc 				 TLP_OP_RECEIVE_ALL   | \
160*7eb99bdaSLionel Sambuc 				 TLP_OP_PROMISCUOUS   | \
161*7eb99bdaSLionel Sambuc 				 TLP_OP_PASS_BAD_PKT  | \
162*7eb99bdaSLionel Sambuc 				 TLP_OP_RX_RUN        | \
163*7eb99bdaSLionel Sambuc 				 TLP_OP_TX_RUN)
164*7eb99bdaSLionel Sambuc 
165*7eb99bdaSLionel Sambuc /* CSR 7 - Interrupt Enable Register */
166*7eb99bdaSLionel Sambuc #define TLP_INT_NORMAL_INTR	0x00010000
167*7eb99bdaSLionel Sambuc #define TLP_INT_ABNRML_INTR	0x00008000
168*7eb99bdaSLionel Sambuc #define TLP_INT_FATAL_ERROR	0x00002000
169*7eb99bdaSLionel Sambuc #define TLP_INT_RX_NO_BUFS	0x00000080
170*7eb99bdaSLionel Sambuc #define TLP_INT_RX_INTR		0x00000040
171*7eb99bdaSLionel Sambuc #define TLP_INT_TX_UNDERRUN	0x00000020
172*7eb99bdaSLionel Sambuc #define TLP_INT_TX_INTR		0x00000001
173*7eb99bdaSLionel Sambuc #define TLP_INT_DISABLE		0
174*7eb99bdaSLionel Sambuc #define TLP_INT_TX		(TLP_INT_NORMAL_INTR | \
175*7eb99bdaSLionel Sambuc 				 TLP_INT_ABNRML_INTR | \
176*7eb99bdaSLionel Sambuc 				 TLP_INT_FATAL_ERROR | \
177*7eb99bdaSLionel Sambuc 				 TLP_INT_TX_UNDERRUN | \
178*7eb99bdaSLionel Sambuc 				 TLP_INT_TX_INTR)
179*7eb99bdaSLionel Sambuc #define TLP_INT_RX		(TLP_INT_NORMAL_INTR | \
180*7eb99bdaSLionel Sambuc 				 TLP_INT_ABNRML_INTR | \
181*7eb99bdaSLionel Sambuc 				 TLP_INT_FATAL_ERROR | \
182*7eb99bdaSLionel Sambuc 				 TLP_INT_RX_NO_BUFS  | \
183*7eb99bdaSLionel Sambuc 				 TLP_INT_RX_INTR)
184*7eb99bdaSLionel Sambuc #define TLP_INT_TXRX		(TLP_INT_TX | TLP_INT_RX)
185*7eb99bdaSLionel Sambuc 
186*7eb99bdaSLionel Sambuc /* CSR 8 - RX Missed Frames & Overrun Register */
187*7eb99bdaSLionel Sambuc #define TLP_MISS_OCO		0x10000000
188*7eb99bdaSLionel Sambuc #define TLP_MISS_OVERRUN	0x0FFE0000
189*7eb99bdaSLionel Sambuc #define TLP_MISS_MFO		0x00010000
190*7eb99bdaSLionel Sambuc #define TLP_MISS_MISSED		0x0000FFFF
191*7eb99bdaSLionel Sambuc #define TLP_OVERRUN_SHIFT	17
192*7eb99bdaSLionel Sambuc 
193*7eb99bdaSLionel Sambuc /* CSR 9 - SROM & MII & Boot ROM Register */
194*7eb99bdaSLionel Sambuc #define TLP_MII_MDIN		0x00080000
195*7eb99bdaSLionel Sambuc #define TLP_MII_MDOE		0x00040000
196*7eb99bdaSLionel Sambuc #define TLP_MII_MDOUT		0x00020000
197*7eb99bdaSLionel Sambuc #define TLP_MII_MDC		0x00010000
198*7eb99bdaSLionel Sambuc 
199*7eb99bdaSLionel Sambuc #define TLP_BIOS_RD		0x00004000
200*7eb99bdaSLionel Sambuc #define TLP_BIOS_WR		0x00002000
201*7eb99bdaSLionel Sambuc #define TLP_BIOS_SEL		0x00001000
202*7eb99bdaSLionel Sambuc 
203*7eb99bdaSLionel Sambuc #define TLP_SROM_RD		0x00004000
204*7eb99bdaSLionel Sambuc #define TLP_SROM_SEL		0x00000800
205*7eb99bdaSLionel Sambuc #define TLP_SROM_DOUT		0x00000008
206*7eb99bdaSLionel Sambuc #define TLP_SROM_DIN		0x00000004
207*7eb99bdaSLionel Sambuc #define TLP_SROM_CLK		0x00000002
208*7eb99bdaSLionel Sambuc #define TLP_SROM_CS		0x00000001
209*7eb99bdaSLionel Sambuc 
210*7eb99bdaSLionel Sambuc /* CSR 12 - General Purpose IO register */
211*7eb99bdaSLionel Sambuc #define TLP_GPIO_DIR		0x00000100
212*7eb99bdaSLionel Sambuc 
213*7eb99bdaSLionel Sambuc /* CSR 15 - Watchdog Timer Register */
214*7eb99bdaSLionel Sambuc #define TLP_WDOG_RX_OFF		0x00000010
215*7eb99bdaSLionel Sambuc #define TLP_WDOG_TX_OFF		0x00000001
216*7eb99bdaSLionel Sambuc #define TLP_WDOG_INIT		(TLP_WDOG_TX_OFF | \
217*7eb99bdaSLionel Sambuc 				 TLP_WDOG_RX_OFF)
218*7eb99bdaSLionel Sambuc 
219*7eb99bdaSLionel Sambuc /* GPIO bits common to all cards */
220*7eb99bdaSLionel Sambuc #define GPIO_INIT		0x01	/*    from Xilinx                  */
221*7eb99bdaSLionel Sambuc #define GPIO_RESET		0x02	/* to      Xilinx                  */
222*7eb99bdaSLionel Sambuc /* bits 2 and 3 vary with card type -- see below */
223*7eb99bdaSLionel Sambuc #define GPIO_MODE		0x10	/* to      Xilinx                  */
224*7eb99bdaSLionel Sambuc #define GPIO_DP			0x20	/* to/from Xilinx                  */
225*7eb99bdaSLionel Sambuc #define GPIO_DATA		0x40	/* serial data                     */
226*7eb99bdaSLionel Sambuc #define GPIO_CLK		0x80	/* serial clock                    */
227*7eb99bdaSLionel Sambuc 
228*7eb99bdaSLionel Sambuc /* HSSI GPIO bits */
229*7eb99bdaSLionel Sambuc #define GPIO_HSSI_ST		0x04	/* send timing sense (deprecated)  */
230*7eb99bdaSLionel Sambuc #define GPIO_HSSI_TXCLK		0x08	/* clock source                    */
231*7eb99bdaSLionel Sambuc 
232*7eb99bdaSLionel Sambuc /* HSSIc GPIO bits */
233*7eb99bdaSLionel Sambuc #define GPIO_HSSI_SYNTH		0x04	/* Synth osc chip select           */
234*7eb99bdaSLionel Sambuc #define GPIO_HSSI_DCE		0x08	/* provide clock on TXCLOCK output */
235*7eb99bdaSLionel Sambuc 
236*7eb99bdaSLionel Sambuc /* T3   GPIO bits */
237*7eb99bdaSLionel Sambuc #define GPIO_T3_DAC		0x04	/* DAC chip select                 */
238*7eb99bdaSLionel Sambuc #define GPIO_T3_INTEN		0x08	/* Framer Interupt enable          */
239*7eb99bdaSLionel Sambuc 
240*7eb99bdaSLionel Sambuc /* SSI  GPIO bits */
241*7eb99bdaSLionel Sambuc #define GPIO_SSI_SYNTH		0x04	/* Synth osc chip select           */
242*7eb99bdaSLionel Sambuc #define GPIO_SSI_DCE		0x08	/* provide clock on TXCLOCK output */
243*7eb99bdaSLionel Sambuc 
244*7eb99bdaSLionel Sambuc /* T1E1 GPIO bits */
245*7eb99bdaSLionel Sambuc #define GPIO_T1_INTEN		0x08	/* Framer Interupt enable          */
246*7eb99bdaSLionel Sambuc 
247*7eb99bdaSLionel Sambuc /* MII register 16 bits common to all cards */
248*7eb99bdaSLionel Sambuc /* NB: LEDs  for HSSI & SSI are in DIFFERENT bits than for T1E1 & T3; oops */
249*7eb99bdaSLionel Sambuc /* NB: CRC32 for HSSI & SSI is  in DIFFERENT bit  than for T1E1 & T3; oops */
250*7eb99bdaSLionel Sambuc #define MII16_LED_ALL		0x0780	/* RW: LED bit mask                */
251*7eb99bdaSLionel Sambuc #define MII16_FIFO		0x0800	/* RW: 1=reset, 0=not reset        */
252*7eb99bdaSLionel Sambuc 
253*7eb99bdaSLionel Sambuc /* MII register 16 bits for HSSI */
254*7eb99bdaSLionel Sambuc #define MII16_HSSI_TA		0x0001	/* RW: host ready;  host->modem    */
255*7eb99bdaSLionel Sambuc #define MII16_HSSI_CA		0x0002	/* RO: modem ready; modem->host    */
256*7eb99bdaSLionel Sambuc #define MII16_HSSI_LA		0x0004	/* RW: loopback A;  host->modem    */
257*7eb99bdaSLionel Sambuc #define MII16_HSSI_LB		0x0008	/* RW: loopback B;  host->modem    */
258*7eb99bdaSLionel Sambuc #define MII16_HSSI_LC		0x0010	/* RO: loopback C;  modem->host    */
259*7eb99bdaSLionel Sambuc #define MII16_HSSI_TM		0x0020	/* RO: test mode;   modem->host    */
260*7eb99bdaSLionel Sambuc #define MII16_HSSI_CRC32	0x0040	/* RW: CRC length 16/32            */
261*7eb99bdaSLionel Sambuc #define MII16_HSSI_LED_LL	0x0080	/* RW: lower left  - green         */
262*7eb99bdaSLionel Sambuc #define MII16_HSSI_LED_LR	0x0100	/* RW: lower right - green         */
263*7eb99bdaSLionel Sambuc #define MII16_HSSI_LED_UL	0x0200	/* RW: upper left  - green         */
264*7eb99bdaSLionel Sambuc #define MII16_HSSI_LED_UR	0x0400	/* RW: upper right - red           */
265*7eb99bdaSLionel Sambuc #define MII16_HSSI_FIFO		0x0800	/* RW: reset fifos                 */
266*7eb99bdaSLionel Sambuc #define MII16_HSSI_FORCECA	0x1000	/* RW: [cPCI] force CA on          */
267*7eb99bdaSLionel Sambuc #define MII16_HSSI_CLKMUX	0x6000	/* RW: [cPCI] TX clock selection   */
268*7eb99bdaSLionel Sambuc #define MII16_HSSI_LOOP		0x8000	/* RW: [cPCI] LOOP TX into RX      */
269*7eb99bdaSLionel Sambuc #define MII16_HSSI_MODEM	0x003F	/* TA+CA+LA+LB+LC+TM               */
270*7eb99bdaSLionel Sambuc 
271*7eb99bdaSLionel Sambuc /* MII register 16 bits for DS3 */
272*7eb99bdaSLionel Sambuc #define MII16_DS3_ZERO		0x0001	/* RW: short/long cables           */
273*7eb99bdaSLionel Sambuc #define MII16_DS3_TRLBK		0x0002	/* RW: loop towards host           */
274*7eb99bdaSLionel Sambuc #define MII16_DS3_LNLBK		0x0004	/* RW: loop towards net            */
275*7eb99bdaSLionel Sambuc #define MII16_DS3_RAIS		0x0008	/* RO: LIU receive AIS      (depr) */
276*7eb99bdaSLionel Sambuc #define MII16_DS3_TAIS		0x0010	/* RW: LIU transmit AIS     (depr) */
277*7eb99bdaSLionel Sambuc #define MII16_DS3_BIST		0x0020	/* RO: LIU QRSS patt match  (depr) */
278*7eb99bdaSLionel Sambuc #define MII16_DS3_DLOS		0x0040	/* RO: LIU Digital LOS      (depr) */
279*7eb99bdaSLionel Sambuc #define MII16_DS3_LED_BLU	0x0080	/* RW: lower right - blue          */
280*7eb99bdaSLionel Sambuc #define MII16_DS3_LED_YEL	0x0100	/* RW: lower left  - yellow        */
281*7eb99bdaSLionel Sambuc #define MII16_DS3_LED_RED	0x0200	/* RW: upper right - red           */
282*7eb99bdaSLionel Sambuc #define MII16_DS3_LED_GRN	0x0400	/* RW: upper left  - green         */
283*7eb99bdaSLionel Sambuc #define MII16_DS3_FIFO		0x0800	/* RW: reset fifos                 */
284*7eb99bdaSLionel Sambuc #define MII16_DS3_CRC32		0x1000	/* RW: CRC length 16/32            */
285*7eb99bdaSLionel Sambuc #define MII16_DS3_SCRAM		0x2000	/* RW: payload scrambler           */
286*7eb99bdaSLionel Sambuc #define MII16_DS3_POLY		0x4000	/* RW: 1=Larse, 0=DigLink|Kentrox  */
287*7eb99bdaSLionel Sambuc #define MII16_DS3_FRAME		0x8000	/* RW: 1=stop txframe pulses       */
288*7eb99bdaSLionel Sambuc 
289*7eb99bdaSLionel Sambuc /* MII register 16 bits for SSI */
290*7eb99bdaSLionel Sambuc #define MII16_SSI_DTR		0x0001	/* RW: DTR host->modem             */
291*7eb99bdaSLionel Sambuc #define MII16_SSI_DSR		0x0002	/* RO: DSR modem->host             */
292*7eb99bdaSLionel Sambuc #define MII16_SSI_RTS		0x0004	/* RW: RTS host->modem             */
293*7eb99bdaSLionel Sambuc #define MII16_SSI_CTS		0x0008	/* RO: CTS modem->host             */
294*7eb99bdaSLionel Sambuc #define MII16_SSI_DCD		0x0010	/* RW: DCD modem<->host            */
295*7eb99bdaSLionel Sambuc #define MII16_SSI_RI		0x0020	/* RO: RI  modem->host             */
296*7eb99bdaSLionel Sambuc #define MII16_SSI_CRC32		0x0040	/* RW: CRC length 16/32            */
297*7eb99bdaSLionel Sambuc #define MII16_SSI_LED_LL	0x0080	/* RW: lower left  - green         */
298*7eb99bdaSLionel Sambuc #define MII16_SSI_LED_LR	0x0100	/* RW: lower right - green         */
299*7eb99bdaSLionel Sambuc #define MII16_SSI_LED_UL	0x0200	/* RW: upper left  - green         */
300*7eb99bdaSLionel Sambuc #define MII16_SSI_LED_UR	0x0400	/* RW: upper right - red           */
301*7eb99bdaSLionel Sambuc #define MII16_SSI_FIFO		0x0800	/* RW: reset fifos                 */
302*7eb99bdaSLionel Sambuc #define MII16_SSI_LL		0x1000	/* RW: LL: host->modem             */
303*7eb99bdaSLionel Sambuc #define MII16_SSI_RL		0x2000	/* RW: RL: host->modem             */
304*7eb99bdaSLionel Sambuc #define MII16_SSI_TM		0x4000	/* RO: TM: modem->host             */
305*7eb99bdaSLionel Sambuc #define MII16_SSI_LOOP		0x8000	/* RW: Loop at ext conn            */
306*7eb99bdaSLionel Sambuc #define MII16_SSI_MODEM		0x703F	/* DTR+DSR+RTS+CTS+DCD+RI+LL+RL+TM */
307*7eb99bdaSLionel Sambuc 
308*7eb99bdaSLionel Sambuc /* Mii register 17 has the SSI cable bits */
309*7eb99bdaSLionel Sambuc #define MII17_SSI_CABLE_SHIFT	3	/* shift to get cable type         */
310*7eb99bdaSLionel Sambuc #define MII17_SSI_CABLE_MASK	0x0038	/* RO: mask  to get cable type     */
311*7eb99bdaSLionel Sambuc #define MII17_SSI_PRESCALE	0x0040	/* RW: divide by: 0=16; 1=512      */
312*7eb99bdaSLionel Sambuc #define MII17_SSI_ITF		0x0100	/* RW: fill with: 0=flags; 1=ones  */
313*7eb99bdaSLionel Sambuc #define MII17_SSI_NRZI		0x0400	/* RW: coding: NRZ= 0; NRZI=1      */
314*7eb99bdaSLionel Sambuc 
315*7eb99bdaSLionel Sambuc /* MII register 16 bits for T1/E1 */
316*7eb99bdaSLionel Sambuc #define MII16_T1_UNUSED1	0x0001
317*7eb99bdaSLionel Sambuc #define MII16_T1_INVERT		0x0002	/* RW: invert data (for SF/AMI)    */
318*7eb99bdaSLionel Sambuc #define MII16_T1_XOE		0x0004	/* RW: TX Output Enable; 0=disable */
319*7eb99bdaSLionel Sambuc #define MII16_T1_RST		0x0008	/* RW: Bt8370 chip reset           */
320*7eb99bdaSLionel Sambuc #define MII16_T1_Z		0x0010	/* RW: output impedance T1=1 E1=0  */
321*7eb99bdaSLionel Sambuc #define MII16_T1_INTR		0x0020	/* RO: interrupt from Bt8370       */
322*7eb99bdaSLionel Sambuc #define MII16_T1_ONESEC		0x0040	/* RO: one second square wave      */
323*7eb99bdaSLionel Sambuc #define MII16_T1_LED_BLU	0x0080	/* RW: lower right - blue          */
324*7eb99bdaSLionel Sambuc #define MII16_T1_LED_YEL	0x0100	/* RW: lower left  - yellow        */
325*7eb99bdaSLionel Sambuc #define MII16_T1_LED_RED	0x0200	/* RW: upper right - red           */
326*7eb99bdaSLionel Sambuc #define MII16_T1_LED_GRN	0x0400	/* RW: upper left  - green         */
327*7eb99bdaSLionel Sambuc #define MII16_T1_FIFO		0x0800	/* RW: reset fifos                 */
328*7eb99bdaSLionel Sambuc #define MII16_T1_CRC32		0x1000	/* RW: CRC length 16/32            */
329*7eb99bdaSLionel Sambuc #define MII16_T1_UNUSED2	0xE000
330*7eb99bdaSLionel Sambuc 
331*7eb99bdaSLionel Sambuc /* T3 framer:  RW=Read/Write;  RO=Read-Only;  RC=Read/Clr;  WO=Write-Only  */
332*7eb99bdaSLionel Sambuc #define T3CSR_STAT0		0x00	/* RO: real-time status            */
333*7eb99bdaSLionel Sambuc #define T3CSR_CTL1		0x01	/* RW: global control bits         */
334*7eb99bdaSLionel Sambuc #define T3CSR_FEBE		0x02	/* RC: Far End Block Error Counter */
335*7eb99bdaSLionel Sambuc #define T3CSR_CERR		0x03	/* RC: C-bit Parity Error Counter  */
336*7eb99bdaSLionel Sambuc #define T3CSR_PERR		0x04	/* RC: P-bit Parity Error Counter  */
337*7eb99bdaSLionel Sambuc #define T3CSR_TX_FEAC		0x05	/* RW: Far End Alarm & Control     */
338*7eb99bdaSLionel Sambuc #define T3CSR_RX_FEAC		0x06	/* RO: Far End Alarm & Control     */
339*7eb99bdaSLionel Sambuc #define T3CSR_STAT7		0x07	/* RL: latched real-time status    */
340*7eb99bdaSLionel Sambuc #define T3CSR_CTL8		0x08	/* RW: extended global ctl bits    */
341*7eb99bdaSLionel Sambuc #define T3CSR_STAT9		0x09	/* RL: extended status bits        */
342*7eb99bdaSLionel Sambuc #define T3CSR_FERR		0x0A	/* RC: F-bit Error Counter         */
343*7eb99bdaSLionel Sambuc #define T3CSR_MERR		0x0B	/* RC: M-bit Error Counter         */
344*7eb99bdaSLionel Sambuc #define T3CSR_CTL12		0x0C	/* RW: more extended ctl bits      */
345*7eb99bdaSLionel Sambuc #define T3CSR_DBL_FEAC		0x0D	/* RW: TX double FEAC              */
346*7eb99bdaSLionel Sambuc #define T3CSR_CTL14		0x0E	/* RW: even more extended ctl bits */
347*7eb99bdaSLionel Sambuc #define T3CSR_FEAC_STK		0x0F	/* RO: RX FEAC stack               */
348*7eb99bdaSLionel Sambuc #define T3CSR_STAT16		0x10	/* RL: extended latched status     */
349*7eb99bdaSLionel Sambuc #define T3CSR_INTEN		0x11	/* RW: interrupt enable            */
350*7eb99bdaSLionel Sambuc #define T3CSR_CVLO		0x12	/* RC: coding violation cntr LSB   */
351*7eb99bdaSLionel Sambuc #define T3CSR_CVHI		0x13	/* RC: coding violation cntr MSB   */
352*7eb99bdaSLionel Sambuc #define T3CSR_CTL20		0x14	/* RW: yet more extended ctl bits  */
353*7eb99bdaSLionel Sambuc 
354*7eb99bdaSLionel Sambuc #define CTL1_XTX		0x01	/* Transmit X-bit value            */
355*7eb99bdaSLionel Sambuc #define CTL1_3LOOP		0x02	/* framer loop back                */
356*7eb99bdaSLionel Sambuc #define CTL1_SER		0x04	/* SERial interface selected       */
357*7eb99bdaSLionel Sambuc #define CTL1_M13MODE		0x08	/* M13 frame format                */
358*7eb99bdaSLionel Sambuc #define CTL1_TXIDL		0x10	/* Transmit Idle signal            */
359*7eb99bdaSLionel Sambuc #define CTL1_ENAIS		0x20	/* Enable AIS upon LOS             */
360*7eb99bdaSLionel Sambuc #define CTL1_TXAIS		0x40	/* Transmit Alarm Indication Sig   */
361*7eb99bdaSLionel Sambuc #define CTL1_NOFEBE		0x80	/* No Far End Block Errors         */
362*7eb99bdaSLionel Sambuc 
363*7eb99bdaSLionel Sambuc #define CTL5_EMODE		0x80	/* rev B Extended features enabled */
364*7eb99bdaSLionel Sambuc #define CTL5_START		0x40	/* transmit the FEAC msg now       */
365*7eb99bdaSLionel Sambuc 
366*7eb99bdaSLionel Sambuc #define CTL8_FBEC		0x80	/* F-Bit Error Count control       */
367*7eb99bdaSLionel Sambuc #define CTL8_TBLU		0x20	/* Transmit Blue signal            */
368*7eb99bdaSLionel Sambuc #define CTL8_OUT_DIS		0x10	/* Output Disable                  */
369*7eb99bdaSLionel Sambuc 
370*7eb99bdaSLionel Sambuc #define STAT9_SEF		0x80	/* Severely Errored Frame          */
371*7eb99bdaSLionel Sambuc #define STAT9_RBLU		0x20	/* Receive Blue signal             */
372*7eb99bdaSLionel Sambuc 
373*7eb99bdaSLionel Sambuc #define CTL12_RTPLLEN		0x80	/* Rx-to-Tx Payload Lpbk Lock ENbl */
374*7eb99bdaSLionel Sambuc #define CTL12_RTPLOOP		0x40	/* Rx-to-Tx Payload Loopback       */
375*7eb99bdaSLionel Sambuc #define CTL12_DLCB1		0x08	/* Data Link C-Bits forced to 1    */
376*7eb99bdaSLionel Sambuc #define CTL12_C21		0x04	/* C2 forced to 1                  */
377*7eb99bdaSLionel Sambuc #define CTL12_MCB1		0x02	/* Most C-Bits forced to 1         */
378*7eb99bdaSLionel Sambuc 
379*7eb99bdaSLionel Sambuc #define CTL13_DFEXEC		0x40	/* Execute Double FEAC             */
380*7eb99bdaSLionel Sambuc 
381*7eb99bdaSLionel Sambuc #define CTL14_FEAC10		0x80	/* Transmit FEAC word 10 times     */
382*7eb99bdaSLionel Sambuc #define CTL14_RGCEN		0x20	/* Receive Gapped Clock Out Enbl   */
383*7eb99bdaSLionel Sambuc #define CTL14_TGCEN		0x10	/* Timing Gen Gapped Clk Out Enbl  */
384*7eb99bdaSLionel Sambuc 
385*7eb99bdaSLionel Sambuc #define FEAC_STK_MORE		0x80	/* FEAC stack has more FEACs       */
386*7eb99bdaSLionel Sambuc #define FEAC_STK_VALID		0x40	/* FEAC stack is valid             */
387*7eb99bdaSLionel Sambuc #define FEAC_STK_FEAC		0x3F	/* FEAC stack FEAC data            */
388*7eb99bdaSLionel Sambuc 
389*7eb99bdaSLionel Sambuc #define STAT16_XERR		0x01	/* X-bit Error                     */
390*7eb99bdaSLionel Sambuc #define STAT16_SEF		0x02	/* Severely Errored Frame          */
391*7eb99bdaSLionel Sambuc #define STAT16_RTLOC		0x04	/* Rx/Tx Loss Of Clock             */
392*7eb99bdaSLionel Sambuc #define STAT16_FEAC		0x08	/* new FEAC msg                    */
393*7eb99bdaSLionel Sambuc #define STAT16_RIDL		0x10	/* channel IDLe signal             */
394*7eb99bdaSLionel Sambuc #define STAT16_RAIS		0x20	/* Alarm Indication Signal         */
395*7eb99bdaSLionel Sambuc #define STAT16_ROOF		0x40	/* Out Of Frame sync               */
396*7eb99bdaSLionel Sambuc #define STAT16_RLOS		0x80	/* Loss Of Signal                  */
397*7eb99bdaSLionel Sambuc 
398*7eb99bdaSLionel Sambuc #define CTL20_CVEN		0x01	/* Coding Violation Counter Enbl   */
399*7eb99bdaSLionel Sambuc 
400*7eb99bdaSLionel Sambuc /* T1.107 Bit Oriented C-Bit Parity Far End Alarm Control and Status codes */
401*7eb99bdaSLionel Sambuc #define T3BOP_OOF		0x00	/* Yellow alarm status             */
402*7eb99bdaSLionel Sambuc #define T3BOP_LINE_UP		0x07	/* line loopback activate          */
403*7eb99bdaSLionel Sambuc #define T3BOP_LINE_DOWN		0x1C	/* line loopback deactivate        */
404*7eb99bdaSLionel Sambuc #define T3BOP_LOOP_DS3		0x1B	/* loopback full DS3               */
405*7eb99bdaSLionel Sambuc #define T3BOP_IDLE		0x1A	/* IDLE alarm status               */
406*7eb99bdaSLionel Sambuc #define T3BOP_AIS		0x16	/* AIS  alarm status               */
407*7eb99bdaSLionel Sambuc #define T3BOP_LOS		0x0E	/* LOS  alarm status               */
408*7eb99bdaSLionel Sambuc 
409*7eb99bdaSLionel Sambuc /* T1E1 regs;  RW=Read/Write;  RO=Read-Only;  RC=Read/Clr;  WO=Write-Only  */
410*7eb99bdaSLionel Sambuc #define Bt8370_DID		0x000	/* RO: Device ID                   */
411*7eb99bdaSLionel Sambuc #define Bt8370_CR0		0x001	/* RW; Primary Control Register    */
412*7eb99bdaSLionel Sambuc #define Bt8370_JAT_CR		0x002	/* RW: Jitter Attenuator CR        */
413*7eb99bdaSLionel Sambuc #define Bt8370_IRR		0x003	/* RO: Interrupt Request Reg       */
414*7eb99bdaSLionel Sambuc #define Bt8370_ISR7		0x004	/* RC: Alarm 1 Interrupt Status    */
415*7eb99bdaSLionel Sambuc #define Bt8370_ISR6		0x005	/* RC: Alarm 2 Interrupt Status    */
416*7eb99bdaSLionel Sambuc #define Bt8370_ISR5		0x006	/* RC: Error Interrupt Status      */
417*7eb99bdaSLionel Sambuc #define Bt8370_ISR4		0x007	/* RC; Cntr Ovfl Interrupt Status  */
418*7eb99bdaSLionel Sambuc #define Bt8370_ISR3		0x008	/* RC: Timer Interrupt Status      */
419*7eb99bdaSLionel Sambuc #define Bt8370_ISR2		0x009	/* RC: Data Link 1 Int Status      */
420*7eb99bdaSLionel Sambuc #define Bt8370_ISR1		0x00A	/* RC: Data Link 2 Int Status      */
421*7eb99bdaSLionel Sambuc #define Bt8370_ISR0		0x00B	/* RC: Pattrn Interrupt Status     */
422*7eb99bdaSLionel Sambuc #define Bt8370_IER7		0x00C	/* RW: Alarm 1 Interrupt Enable    */
423*7eb99bdaSLionel Sambuc #define Bt8370_IER6		0x00D	/* RW: Alarm 2 Interrupt Enable    */
424*7eb99bdaSLionel Sambuc #define Bt8370_IER5		0x00E	/* RW: Error Interrupt Enable      */
425*7eb99bdaSLionel Sambuc #define Bt8370_IER4		0x00F	/* RW: Cntr Ovfl Interrupt Enable  */
426*7eb99bdaSLionel Sambuc 
427*7eb99bdaSLionel Sambuc #define Bt8370_IER3		0x010	/* RW: Timer Interrupt Enable      */
428*7eb99bdaSLionel Sambuc #define Bt8370_IER2		0x011	/* RW: Data Link 1 Int Enable      */
429*7eb99bdaSLionel Sambuc #define Bt8370_IER1		0x012	/* RW: Data Link 2 Int Enable      */
430*7eb99bdaSLionel Sambuc #define Bt8370_IER0		0x013	/* RW: Pattern Interrupt Enable    */
431*7eb99bdaSLionel Sambuc #define Bt8370_LOOP		0x014	/* RW: Loopback Config Reg         */
432*7eb99bdaSLionel Sambuc #define Bt8370_DL3_TS		0x015	/* RW: External Data Link Channel  */
433*7eb99bdaSLionel Sambuc #define Bt8370_DL3_BIT		0x016	/* RW: External Data Link Bit      */
434*7eb99bdaSLionel Sambuc #define Bt8370_FSTAT		0x017	/* RO: Offline Framer Status       */
435*7eb99bdaSLionel Sambuc #define Bt8370_PIO		0x018	/* RW: Programmable Input/Output   */
436*7eb99bdaSLionel Sambuc #define Bt8370_POE		0x019	/* RW: Programmable Output Enable  */
437*7eb99bdaSLionel Sambuc #define Bt8370_CMUX		0x01A	/* RW: Clock Input Mux             */
438*7eb99bdaSLionel Sambuc #define Bt8370_TMUX		0x01B	/* RW: Test Mux Config             */
439*7eb99bdaSLionel Sambuc #define Bt8370_TEST		0x01C	/* RW: Test Config                 */
440*7eb99bdaSLionel Sambuc 
441*7eb99bdaSLionel Sambuc #define Bt8370_LIU_CR		0x020	/* RW: Line Intf Unit Config Reg   */
442*7eb99bdaSLionel Sambuc #define Bt8370_RSTAT		0x021	/* RO; Receive LIU Status          */
443*7eb99bdaSLionel Sambuc #define Bt8370_RLIU_CR		0x022	/* RW: Receive LIU Config          */
444*7eb99bdaSLionel Sambuc #define Bt8370_LPF		0x023	/* RW: RPLL Low Pass Filter        */
445*7eb99bdaSLionel Sambuc #define Bt8370_VGA_MAX		0x024	/* RW: Variable Gain Amplifier Max */
446*7eb99bdaSLionel Sambuc #define Bt8370_EQ_DAT		0x025	/* RW: Equalizer Coeff Data Reg    */
447*7eb99bdaSLionel Sambuc #define Bt8370_EQ_PTR		0x026	/* RW: Equzlizer Coeff Table Ptr   */
448*7eb99bdaSLionel Sambuc #define Bt8370_DSLICE		0x027	/* RW: Data Slicer Threshold       */
449*7eb99bdaSLionel Sambuc #define Bt8370_EQ_OUT		0x028	/* RW: Equalizer Output Levels     */
450*7eb99bdaSLionel Sambuc #define Bt8370_VGA		0x029	/* RO: Variable Gain Ampl Status   */
451*7eb99bdaSLionel Sambuc #define Bt8370_PRE_EQ		0x02A	/* RW: Pre-Equalizer               */
452*7eb99bdaSLionel Sambuc 
453*7eb99bdaSLionel Sambuc #define Bt8370_COEFF0		0x030	/* RO: LMS Adj Eq Coeff Status     */
454*7eb99bdaSLionel Sambuc #define Bt8370_GAIN0		0x038	/* RW: Equalizer Gain Thresh       */
455*7eb99bdaSLionel Sambuc #define Bt8370_GAIN1		0x039	/* RW: Equalizer Gain Thresh       */
456*7eb99bdaSLionel Sambuc #define Bt8370_GAIN2		0x03A	/* RW: Equalizer Gain Thresh       */
457*7eb99bdaSLionel Sambuc #define Bt8370_GAIN3		0x03B	/* RW: Equalizer Gain Thresh       */
458*7eb99bdaSLionel Sambuc #define Bt8370_GAIN4		0x03C	/* RW: Equalizer Gain Thresh       */
459*7eb99bdaSLionel Sambuc 
460*7eb99bdaSLionel Sambuc #define Bt8370_RCR0		0x040	/* RW: Rx Configuration            */
461*7eb99bdaSLionel Sambuc #define Bt8370_RPATT		0x041	/* RW: Rx Test Pattern Config      */
462*7eb99bdaSLionel Sambuc #define Bt8370_RLB		0x042	/* RW: Rx Loopback Code Detr Conf  */
463*7eb99bdaSLionel Sambuc #define Bt8370_LBA		0x043	/* RW: Loopback Activate Code Patt */
464*7eb99bdaSLionel Sambuc #define Bt8370_LBD		0x044	/* RW: Loopback Deact Code Patt    */
465*7eb99bdaSLionel Sambuc #define Bt8370_RALM		0x045	/* RW: Rx Alarm Signal Config      */
466*7eb99bdaSLionel Sambuc #define Bt8370_LATCH		0x046	/* RW: Alarm/Err/Cntr Latch Config */
467*7eb99bdaSLionel Sambuc #define Bt8370_ALM1		0x047	/* RO: Alarm 1 Status              */
468*7eb99bdaSLionel Sambuc #define Bt8370_ALM2		0x048	/* RO: Alarm 2 Status              */
469*7eb99bdaSLionel Sambuc #define Bt8370_ALM3		0x049	/* RO: Alarm 3 Status              */
470*7eb99bdaSLionel Sambuc 
471*7eb99bdaSLionel Sambuc #define Bt8370_FERR_LO		0x050	/* RC: Framing Bit Error Cntr LSB  */
472*7eb99bdaSLionel Sambuc #define Bt8370_FERR_HI		0x051	/* RC: Framing Bit Error Cntr MSB  */
473*7eb99bdaSLionel Sambuc #define Bt8370_CRC_LO		0x052	/* RC: CRC    Error   Counter LSB  */
474*7eb99bdaSLionel Sambuc #define Bt8370_CRC_HI		0x053	/* RC: CRC    Error   Counter MSB  */
475*7eb99bdaSLionel Sambuc #define Bt8370_LCV_LO		0x054	/* RC: Line Code Viol Counter LSB  */
476*7eb99bdaSLionel Sambuc #define Bt8370_LCV_HI		0x055	/* RC: Line Code Viol Counter MSB  */
477*7eb99bdaSLionel Sambuc #define Bt8370_FEBE_LO		0x056	/* RC: Far End Block Err Cntr LSB  */
478*7eb99bdaSLionel Sambuc #define Bt8370_FEBE_HI		0x057	/* RC: Far End Block Err Cntr MSB  */
479*7eb99bdaSLionel Sambuc #define Bt8370_BERR_LO		0x058	/* RC: PRBS Bit Error Counter LSB  */
480*7eb99bdaSLionel Sambuc #define Bt8370_BERR_HI		0x059	/* RC: PRBS Bit Error Counter MSB  */
481*7eb99bdaSLionel Sambuc #define Bt8370_AERR		0x05A	/* RC: SEF/LOF/COFA counter        */
482*7eb99bdaSLionel Sambuc #define Bt8370_RSA4		0x05B	/* RO: Rx Sa4 Byte Buffer          */
483*7eb99bdaSLionel Sambuc #define Bt8370_RSA5		0x05C	/* RO: Rx Sa5 Byte Buffer          */
484*7eb99bdaSLionel Sambuc #define Bt8370_RSA6		0x05D	/* RO: Rx Sa6 Byte Buffer          */
485*7eb99bdaSLionel Sambuc #define Bt8370_RSA7		0x05E	/* RO: Rx Sa7 Byte Buffer          */
486*7eb99bdaSLionel Sambuc #define Bt8370_RSA8		0x05F	/* RO: Rx Sa8 Byte Buffer          */
487*7eb99bdaSLionel Sambuc 
488*7eb99bdaSLionel Sambuc #define Bt8370_SHAPE0		0x060	/* RW: Tx Pulse Shape Config       */
489*7eb99bdaSLionel Sambuc #define Bt8370_TLIU_CR		0x068	/* RW: Tx LIU Config Reg           */
490*7eb99bdaSLionel Sambuc 
491*7eb99bdaSLionel Sambuc #define Bt8370_TCR0		0x070	/* RW: Tx Framer Config            */
492*7eb99bdaSLionel Sambuc #define Bt8370_TCR1		0x071	/* RW: Txter Configuration         */
493*7eb99bdaSLionel Sambuc #define Bt8370_TFRM		0x072	/* RW: Tx Frame Format             */
494*7eb99bdaSLionel Sambuc #define Bt8370_TERROR		0x073	/* RW: Tx Error Insert             */
495*7eb99bdaSLionel Sambuc #define Bt8370_TMAN		0x074	/* RW: Tx Manual Sa/FEBE Config    */
496*7eb99bdaSLionel Sambuc #define Bt8370_TALM		0x075	/* RW: Tx Alarm Signal Config      */
497*7eb99bdaSLionel Sambuc #define Bt8370_TPATT		0x076	/* RW: Tx Test Pattern Config      */
498*7eb99bdaSLionel Sambuc #define Bt8370_TLB		0x077	/* RW: Tx Inband Loopback Config   */
499*7eb99bdaSLionel Sambuc #define Bt8370_LBP		0x078	/* RW: Tx Inband Loopback Patt     */
500*7eb99bdaSLionel Sambuc #define Bt8370_TSA4		0x07B	/* RW: Tx Sa4 Byte Buffer          */
501*7eb99bdaSLionel Sambuc #define Bt8370_TSA5		0x07C	/* RW: Tx Sa5 Byte Buffer          */
502*7eb99bdaSLionel Sambuc #define Bt8370_TSA6		0x07D	/* RW: Tx Sa6 Byte Buffer          */
503*7eb99bdaSLionel Sambuc #define Bt8370_TSA7		0x07E	/* RW: Tx Sa7 Byte Buffer          */
504*7eb99bdaSLionel Sambuc #define Bt8370_TSA8		0x07F	/* RW: Tx Sa8 Byte Buffer          */
505*7eb99bdaSLionel Sambuc 
506*7eb99bdaSLionel Sambuc #define Bt8370_CLAD_CR		0x090	/* RW: Clock Rate Adapter Config   */
507*7eb99bdaSLionel Sambuc #define Bt8370_CSEL		0x091	/* RW: CLAD Frequency Select       */
508*7eb99bdaSLionel Sambuc #define Bt8370_CPHASE		0x092	/* RW: CLAD Phase Det Scale Factor */
509*7eb99bdaSLionel Sambuc #define Bt8370_CTEST		0x093	/* RW: CLAD Test                   */
510*7eb99bdaSLionel Sambuc 
511*7eb99bdaSLionel Sambuc #define Bt8370_BOP		0x0A0	/* RW: Bit Oriented Protocol Xcvr  */
512*7eb99bdaSLionel Sambuc #define Bt8370_TBOP		0x0A1	/* RW: Tx BOP Codeword             */
513*7eb99bdaSLionel Sambuc #define Bt8370_RBOP		0x0A2	/* RO; Rx BOP Codeword             */
514*7eb99bdaSLionel Sambuc #define Bt8370_BOP_STAT		0x0A3	/* RO: BOP Status                  */
515*7eb99bdaSLionel Sambuc #define Bt8370_DL1_TS		0x0A4	/* RW: DL1 Time Slot Enable        */
516*7eb99bdaSLionel Sambuc #define Bt8370_DL1_BIT		0x0A5	/* RW: DL1 Bit Enable              */
517*7eb99bdaSLionel Sambuc #define Bt8370_DL1_CTL		0x0A6	/* RW: DL1 Control                 */
518*7eb99bdaSLionel Sambuc #define Bt8370_RDL1_FFC		0x0A7	/* RW: RDL1 FIFO Fill Control      */
519*7eb99bdaSLionel Sambuc #define Bt8370_RDL1		0x0A8	/* RO: RDL1 FIFO                   */
520*7eb99bdaSLionel Sambuc #define Bt8370_RDL1_STAT	0x0A9	/* RO: RDL1 Status                 */
521*7eb99bdaSLionel Sambuc #define Bt8370_PRM		0x0AA	/* RW: Performance Report Message  */
522*7eb99bdaSLionel Sambuc #define Bt8370_TDL1_FEC		0x0AB	/* RW: TDL1 FIFO Empty Control     */
523*7eb99bdaSLionel Sambuc #define Bt8370_TDL1_EOM		0x0AC	/* WO: TDL1 End Of Message Control */
524*7eb99bdaSLionel Sambuc #define Bt8370_TDL1		0x0AD	/* RW: TDL1 FIFO                   */
525*7eb99bdaSLionel Sambuc #define Bt8370_TDL1_STAT	0x0AE	/* RO: TDL1 Status                 */
526*7eb99bdaSLionel Sambuc #define Bt8370_DL2_TS		0x0AF	/* RW: DL2 Time Slot Enable        */
527*7eb99bdaSLionel Sambuc 
528*7eb99bdaSLionel Sambuc #define Bt8370_DL2_BIT		0x0B0	/* RW: DL2 Bit Enable              */
529*7eb99bdaSLionel Sambuc #define Bt8370_DL2_CTL		0x0B1	/* RW: DL2 Control                 */
530*7eb99bdaSLionel Sambuc #define Bt8370_RDL2_FFC		0x0B2	/* RW: RDL2 FIFO Fill Control      */
531*7eb99bdaSLionel Sambuc #define Bt8370_RDL2		0x0B3	/* RO: RDL2 FIFO                   */
532*7eb99bdaSLionel Sambuc #define Bt8370_RDL2_STAT	0x0B4	/* RO: RDL2 Status                 */
533*7eb99bdaSLionel Sambuc #define Bt8370_TDL2_FEC		0x0B6	/* RW: TDL2 FIFO Empty Control     */
534*7eb99bdaSLionel Sambuc #define Bt8370_TDL2_EOM		0x0B7	/* WO; TDL2 End Of Message Control */
535*7eb99bdaSLionel Sambuc #define Bt8370_TDL2		0x0B8	/* RW: TDL2 FIFO                   */
536*7eb99bdaSLionel Sambuc #define Bt8370_TDL2_STAT	0x0B9	/* RO: TDL2 Status                 */
537*7eb99bdaSLionel Sambuc #define Bt8370_DL_TEST1		0x0BA	/* RW: DLINK Test Config           */
538*7eb99bdaSLionel Sambuc #define Bt8370_DL_TEST2		0x0BB	/* RW: DLINK Test Status           */
539*7eb99bdaSLionel Sambuc #define Bt8370_DL_TEST3		0x0BC	/* RW: DLINK Test Status           */
540*7eb99bdaSLionel Sambuc #define Bt8370_DL_TEST4		0x0BD	/* RW: DLINK Test Control          */
541*7eb99bdaSLionel Sambuc #define Bt8370_DL_TEST5		0x0BE	/* RW: DLINK Test Control          */
542*7eb99bdaSLionel Sambuc 
543*7eb99bdaSLionel Sambuc #define Bt8370_SBI_CR		0x0D0	/* RW: System Bus Interface Config */
544*7eb99bdaSLionel Sambuc #define Bt8370_RSB_CR		0x0D1	/* RW: Rx System Bus Config        */
545*7eb99bdaSLionel Sambuc #define Bt8370_RSYNC_BIT	0x0D2	/* RW: Rx System Bus Sync Bit Offs */
546*7eb99bdaSLionel Sambuc #define Bt8370_RSYNC_TS		0x0D3	/* RW: Rx System Bus Sync TS Offs  */
547*7eb99bdaSLionel Sambuc #define Bt8370_TSB_CR		0x0D4	/* RW: Tx System Bus Config        */
548*7eb99bdaSLionel Sambuc #define Bt8370_TSYNC_BIT	0x0D5	/* RW: Tx System Bus Sync Bit OFfs */
549*7eb99bdaSLionel Sambuc #define Bt8370_TSYNC_TS		0x0D6	/* RW: Tx System Bus Sync TS Offs  */
550*7eb99bdaSLionel Sambuc #define Bt8370_RSIG_CR		0x0D7	/* RW: Rx Siganalling Config       */
551*7eb99bdaSLionel Sambuc #define Bt8370_RSYNC_FRM	0x0D8	/* RW: Sig Reinsertion Frame Offs  */
552*7eb99bdaSLionel Sambuc #define Bt8370_SSTAT		0x0D9	/* RO: Slip Buffer Status          */
553*7eb99bdaSLionel Sambuc #define Bt8370_STACK		0x0DA	/* RO: Rx Signalling Stack         */
554*7eb99bdaSLionel Sambuc #define Bt8370_RPHASE		0x0DB	/* RO: RSLIP Phase Status          */
555*7eb99bdaSLionel Sambuc #define Bt8370_TPHASE		0x0DC	/* RO: TSLIP Phase Status          */
556*7eb99bdaSLionel Sambuc #define Bt8370_PERR		0x0DD	/* RO: RAM Parity Status           */
557*7eb99bdaSLionel Sambuc 
558*7eb99bdaSLionel Sambuc #define Bt8370_SBCn		0x0E0	/* RW: System Bus Per-Channel Ctl  */
559*7eb99bdaSLionel Sambuc #define Bt8370_TPCn		0x100	/* RW: Tx Per-Channel Control      */
560*7eb99bdaSLionel Sambuc #define Bt8370_TSIGn		0x120	/* RW: Tx Signalling Buffer        */
561*7eb99bdaSLionel Sambuc #define Bt8370_TSLIP_LOn	0x140	/* RW: Tx PCM Slip Buffer Lo       */
562*7eb99bdaSLionel Sambuc #define Bt8370_TSLIP_HIn	0x160	/* RW: Tx PCM Slip Buffer Hi       */
563*7eb99bdaSLionel Sambuc #define Bt8370_RPCn		0x180	/* RW: Rx Per-Channel Control      */
564*7eb99bdaSLionel Sambuc #define Bt8370_RSIGn		0x1A0	/* RW: Rx Signalling Buffer        */
565*7eb99bdaSLionel Sambuc #define Bt8370_RSLIP_LOn	0x1C0	/* RW: Rx PCM Slip Buffer Lo       */
566*7eb99bdaSLionel Sambuc #define Bt8370_RSLIP_HIn	0x1E0	/* RW: Rx PCM Slip Buffer Hi       */
567*7eb99bdaSLionel Sambuc 
568*7eb99bdaSLionel Sambuc /* Bt8370_LOOP (0x14) framer loopback control register bits */
569*7eb99bdaSLionel Sambuc #define LOOP_ANALOG		0x01	/* inward  loop thru LIU           */
570*7eb99bdaSLionel Sambuc #define LOOP_FRAMER		0x02	/* inward  loop thru framer        */
571*7eb99bdaSLionel Sambuc #define LOOP_LINE		0x04	/* outward loop thru LIU           */
572*7eb99bdaSLionel Sambuc #define LOOP_PAYLOAD		0x08	/* outward loop of payload         */
573*7eb99bdaSLionel Sambuc #define LOOP_DUAL		0x06	/* inward framer + outward line    */
574*7eb99bdaSLionel Sambuc 
575*7eb99bdaSLionel Sambuc /* Bt8370_ALM1 (0x47) receiver alarm status register bits */
576*7eb99bdaSLionel Sambuc #define ALM1_SIGFRZ		0x01	/* Rx Signalling Freeze            */
577*7eb99bdaSLionel Sambuc #define ALM1_RLOF		0x02	/* Rx loss of frame alignment      */
578*7eb99bdaSLionel Sambuc #define ALM1_RLOS		0x04	/* Rx digital loss of signal       */
579*7eb99bdaSLionel Sambuc #define ALM1_RALOS		0x08	/* Rx analog  loss of signal       */
580*7eb99bdaSLionel Sambuc #define ALM1_RAIS		0x10	/* Rx Alarm Indication Signal      */
581*7eb99bdaSLionel Sambuc #define ALM1_RYEL		0x40	/* Rx Yellow alarm indication      */
582*7eb99bdaSLionel Sambuc #define ALM1_RMYEL		0x80	/* Rx multiframe YELLOW alarm      */
583*7eb99bdaSLionel Sambuc 
584*7eb99bdaSLionel Sambuc /* Bt8370_ALM3 (0x49) receive framer status register bits */
585*7eb99bdaSLionel Sambuc #define ALM3_FRED		0x04	/* Rx Out Of T1/FAS alignment      */
586*7eb99bdaSLionel Sambuc #define ALM3_MRED		0x08	/* Rx Out Of MFAS alignment        */
587*7eb99bdaSLionel Sambuc #define ALM3_SRED		0x10	/* Rx Out Of CAS alignment         */
588*7eb99bdaSLionel Sambuc #define ALM3_SEF		0x20	/* Rx Severely Errored Frame       */
589*7eb99bdaSLionel Sambuc #define ALM3_RMAIS		0x40	/* Rx TS16 AIS (CAS)               */
590*7eb99bdaSLionel Sambuc 
591*7eb99bdaSLionel Sambuc /* Bt8370_TALM (0x75) transmit alarm control register bits */
592*7eb99bdaSLionel Sambuc #define TALM_TAIS		0x01	/* Tx Alarm Indication Signal      */
593*7eb99bdaSLionel Sambuc #define TALM_TYEL		0x02	/* Tx Yellow alarm                 */
594*7eb99bdaSLionel Sambuc #define TALM_TMYEL		0x04	/* Tx Multiframe Yellow alarm      */
595*7eb99bdaSLionel Sambuc #define TALM_AUTO_AIS		0x08	/* auto send AIS on LOS            */
596*7eb99bdaSLionel Sambuc #define TALM_AUTO_YEL		0x10	/* auto send YEL on LOF            */
597*7eb99bdaSLionel Sambuc #define TALM_AUTO_MYEL		0x20	/* auto send E1-Y16 on loss-of-CAS */
598*7eb99bdaSLionel Sambuc 
599*7eb99bdaSLionel Sambuc /* 8370 BOP (Bit Oriented Protocol) command fragments */
600*7eb99bdaSLionel Sambuc #define RBOP_OFF		0x00	/* BOP Rx disabled                 */
601*7eb99bdaSLionel Sambuc #define RBOP_25			0xE0	/* BOP Rx requires 25 BOPs         */
602*7eb99bdaSLionel Sambuc #define TBOP_OFF		0x00	/* BOP Tx disabled                 */
603*7eb99bdaSLionel Sambuc #define TBOP_25			0x0B	/* BOP Tx sends 25 BOPs            */
604*7eb99bdaSLionel Sambuc #define TBOP_CONT		0x0F	/* BOP Tx sends continuously       */
605*7eb99bdaSLionel Sambuc 
606*7eb99bdaSLionel Sambuc /* T1.403 Bit-Oriented ESF Data-Link Message codes */
607*7eb99bdaSLionel Sambuc #define T1BOP_OOF		0x00	/* Yellow alarm status             */
608*7eb99bdaSLionel Sambuc #define T1BOP_LINE_UP		0x07	/* line loopback activate          */
609*7eb99bdaSLionel Sambuc #define T1BOP_LINE_DOWN		0x1C	/* line loopback deactivate        */
610*7eb99bdaSLionel Sambuc #define T1BOP_PAY_UP		0x0A	/* payload loopback activate       */
611*7eb99bdaSLionel Sambuc #define T1BOP_PAY_DOWN		0x19	/* payload loopback deactivate     */
612*7eb99bdaSLionel Sambuc #define T1BOP_NET_UP		0x09	/* network loopback activate       */
613*7eb99bdaSLionel Sambuc #define T1BOP_NET_DOWN		0x12	/* network loopback deactivate     */
614*7eb99bdaSLionel Sambuc 
615*7eb99bdaSLionel Sambuc /* Unix & Linux reserve 16 device-private IOCTLs */
616*7eb99bdaSLionel Sambuc #if BSD
617*7eb99bdaSLionel Sambuc # define LMCIOCGSTAT		_IOWR('i', 240, struct status)
618*7eb99bdaSLionel Sambuc # define LMCIOCGCFG		_IOWR('i', 241, struct config)
619*7eb99bdaSLionel Sambuc # define LMCIOCSCFG		 _IOW('i', 242, struct config)
620*7eb99bdaSLionel Sambuc # define LMCIOCREAD		_IOWR('i', 243, struct ioctl)
621*7eb99bdaSLionel Sambuc # define LMCIOCWRITE		 _IOW('i', 244, struct ioctl)
622*7eb99bdaSLionel Sambuc # define LMCIOCTL		_IOWR('i', 245, struct ioctl)
623*7eb99bdaSLionel Sambuc #endif
624*7eb99bdaSLionel Sambuc 
625*7eb99bdaSLionel Sambuc struct iohdr				/* all LMCIOCs begin with this     */
626*7eb99bdaSLionel Sambuc   {
627*7eb99bdaSLionel Sambuc   char ifname[IFNAMSIZ];		/* interface name, e.g. "lmc0"     */
628*7eb99bdaSLionel Sambuc   u_int32_t cookie;			/* interface version number        */
629*7eb99bdaSLionel Sambuc   u_int16_t direction;			/* missing in Linux IOCTL          */
630*7eb99bdaSLionel Sambuc   u_int16_t length;			/* missing in Linux IOCTL          */
631*7eb99bdaSLionel Sambuc   struct iohdr *iohdr;			/* missing in Linux IOCTL          */
632*7eb99bdaSLionel Sambuc   u_int32_t spare;			/* pad this struct to **32 bytes** */
633*7eb99bdaSLionel Sambuc   };
634*7eb99bdaSLionel Sambuc 
635*7eb99bdaSLionel Sambuc #define DIR_IO   0
636*7eb99bdaSLionel Sambuc #define DIR_IOW  1			/* copy data user->kernel          */
637*7eb99bdaSLionel Sambuc #define DIR_IOR  2			/* copy data kernel->user          */
638*7eb99bdaSLionel Sambuc #define DIR_IOWR 3			/* copy data kernel<->user         */
639*7eb99bdaSLionel Sambuc 
640*7eb99bdaSLionel Sambuc struct hssi_snmp
641*7eb99bdaSLionel Sambuc   {
642*7eb99bdaSLionel Sambuc   u_int16_t sigs;			/* MII16_HSSI & MII16_HSSI_MODEM   */
643*7eb99bdaSLionel Sambuc   };
644*7eb99bdaSLionel Sambuc 
645*7eb99bdaSLionel Sambuc struct ssi_snmp
646*7eb99bdaSLionel Sambuc   {
647*7eb99bdaSLionel Sambuc   u_int16_t sigs;			/* MII16_SSI & MII16_SSI_MODEM     */
648*7eb99bdaSLionel Sambuc   };
649*7eb99bdaSLionel Sambuc 
650*7eb99bdaSLionel Sambuc struct t3_snmp
651*7eb99bdaSLionel Sambuc   {
652*7eb99bdaSLionel Sambuc   u_int16_t febe;			/*  8 bits - Far End Block err cnt */
653*7eb99bdaSLionel Sambuc   u_int16_t lcv;			/* 16 bits - BPV           err cnt */
654*7eb99bdaSLionel Sambuc   u_int16_t pcv;			/*  8 bits - P-bit         err cnt */
655*7eb99bdaSLionel Sambuc   u_int16_t ccv;			/*  8 bits - C-bit         err cnt */
656*7eb99bdaSLionel Sambuc   u_int16_t line;			/* line status bit vector          */
657*7eb99bdaSLionel Sambuc   u_int16_t loop;			/* loop status bit vector          */
658*7eb99bdaSLionel Sambuc   };
659*7eb99bdaSLionel Sambuc 
660*7eb99bdaSLionel Sambuc struct t1_snmp
661*7eb99bdaSLionel Sambuc   {
662*7eb99bdaSLionel Sambuc   u_int16_t prm[4];			/* T1.403 Performance Report Msg   */
663*7eb99bdaSLionel Sambuc   u_int16_t febe;			/* 10 bits - E1 FAR CRC    err cnt */
664*7eb99bdaSLionel Sambuc   u_int16_t lcv;			/* 16 bits - BPV + EXZ     err cnt */
665*7eb99bdaSLionel Sambuc   u_int16_t fe;				/* 12 bits - Ft/Fs/FPS/FAS err cnt */
666*7eb99bdaSLionel Sambuc   u_int16_t crc;			/* 10 bits - CRC6/CRC4     err cnt */
667*7eb99bdaSLionel Sambuc   u_int16_t line;			/* line status bit vector          */
668*7eb99bdaSLionel Sambuc   u_int16_t loop;			/* loop status bit vector          */
669*7eb99bdaSLionel Sambuc   };
670*7eb99bdaSLionel Sambuc 
671*7eb99bdaSLionel Sambuc /* SNMP trunk MIB Send codes */
672*7eb99bdaSLionel Sambuc #define TSEND_NORMAL		   1	/* Send data (normal or looped)    */
673*7eb99bdaSLionel Sambuc #define TSEND_LINE		   2	/* Send 'line loopback activate'   */
674*7eb99bdaSLionel Sambuc #define TSEND_PAYLOAD		   3	/* Send 'payload loop activate'    */
675*7eb99bdaSLionel Sambuc #define TSEND_RESET		   4	/* Send 'loopback deactivate'      */
676*7eb99bdaSLionel Sambuc #define TSEND_QRS		   5	/* Send Quasi Random Signal        */
677*7eb99bdaSLionel Sambuc 
678*7eb99bdaSLionel Sambuc /* ANSI T1.403 Performance Report Msg -- once a second from the far end    */
679*7eb99bdaSLionel Sambuc #define T1PRM_FE		0x8000	/* Frame Sync Bit Error Event >= 1 */
680*7eb99bdaSLionel Sambuc #define T1PRM_SE		0x4000	/* Severely Err Framing Event >= 1 */
681*7eb99bdaSLionel Sambuc #define T1PRM_LB		0x2000	/* Payload Loopback Activated      */
682*7eb99bdaSLionel Sambuc #define T1PRM_G1		0x1000	/* CRC Error Event = 1             */
683*7eb99bdaSLionel Sambuc #define T1PRM_R			0x0800	/* Reserved                        */
684*7eb99bdaSLionel Sambuc #define T1PRM_G2		0x0400	/* 1 < CRC Error Event <= 5        */
685*7eb99bdaSLionel Sambuc #define T1PRM_SEQ		0x0300	/* modulo 4 counter                */
686*7eb99bdaSLionel Sambuc #define T1PRM_G3		0x0080	/* 5 < CRC Error Event <= 10       */
687*7eb99bdaSLionel Sambuc #define T1PRM_LV		0x0040	/* Line Code Violation Event >= 1  */
688*7eb99bdaSLionel Sambuc #define T1PRM_G4		0x0020	/* 10 < CRC Error Event <= 100     */
689*7eb99bdaSLionel Sambuc #define T1PRM_U			0x0018	/* Under study for synchronization */
690*7eb99bdaSLionel Sambuc #define T1PRM_G5		0x0004	/* 100 < CRC Error Event <= 319    */
691*7eb99bdaSLionel Sambuc #define T1PRM_SL		0x0002	/* Slip Event >= 1                 */
692*7eb99bdaSLionel Sambuc #define T1PRM_G6		0x0001	/* CRC Error Event >= 320          */
693*7eb99bdaSLionel Sambuc 
694*7eb99bdaSLionel Sambuc /* SNMP Line Status */
695*7eb99bdaSLionel Sambuc #define TLINE_NORM		0x0001	/* no alarm present                */
696*7eb99bdaSLionel Sambuc #define TLINE_RX_RAI		0x0002	/* receiving RAI = Yellow alarm    */
697*7eb99bdaSLionel Sambuc #define TLINE_TX_RAI		0x0004	/* sending   RAI = Yellow alarm    */
698*7eb99bdaSLionel Sambuc #define TLINE_RX_AIS		0x0008	/* receiving AIS =  blue  alarm    */
699*7eb99bdaSLionel Sambuc #define TLINE_TX_AIS		0x0010	/* sending   AIS =  blue  alarm    */
700*7eb99bdaSLionel Sambuc #define TLINE_LOF		0x0020	/* near end  LOF =   red  alarm    */
701*7eb99bdaSLionel Sambuc #define TLINE_LOS		0x0040	/* near end loss of Signal         */
702*7eb99bdaSLionel Sambuc #define TLINE_LOOP		0x0080	/* near end is looped              */
703*7eb99bdaSLionel Sambuc #define T1LINE_RX_TS16_AIS	0x0100	/* near end receiving TS16 AIS     */
704*7eb99bdaSLionel Sambuc #define T1LINE_RX_TS16_LOMF	0x0200	/* near end sending   TS16 LOMF    */
705*7eb99bdaSLionel Sambuc #define T1LINE_TX_TS16_LOMF	0x0400	/* near end receiving TS16 LOMF    */
706*7eb99bdaSLionel Sambuc #define T1LINE_RX_TEST		0x0800	/* near end receiving QRS Signal   */
707*7eb99bdaSLionel Sambuc #define T1LINE_SEF		0x1000	/* near end severely errored frame */
708*7eb99bdaSLionel Sambuc #define T3LINE_RX_IDLE		0x0100	/* near end receiving IDLE signal  */
709*7eb99bdaSLionel Sambuc #define T3LINE_SEF		0x0200	/* near end severely errored frame */
710*7eb99bdaSLionel Sambuc 
711*7eb99bdaSLionel Sambuc /* SNMP Loopback Status */
712*7eb99bdaSLionel Sambuc #define TLOOP_NONE		0x01	/* no loopback                     */
713*7eb99bdaSLionel Sambuc #define TLOOP_NEAR_PAYLOAD	0x02	/* near end payload loopback       */
714*7eb99bdaSLionel Sambuc #define TLOOP_NEAR_LINE		0x04	/* near end line loopback          */
715*7eb99bdaSLionel Sambuc #define TLOOP_NEAR_OTHER	0x08	/* near end looped somehow         */
716*7eb99bdaSLionel Sambuc #define TLOOP_NEAR_INWARD	0x10	/* near end looped inward          */
717*7eb99bdaSLionel Sambuc #define TLOOP_FAR_PAYLOAD	0x20	/* far  end payload loopback       */
718*7eb99bdaSLionel Sambuc #define TLOOP_FAR_LINE		0x40	/* far  end line loopback          */
719*7eb99bdaSLionel Sambuc 
720*7eb99bdaSLionel Sambuc /* event counters record interesting statistics */
721*7eb99bdaSLionel Sambuc struct cntrs
722*7eb99bdaSLionel Sambuc   {
723*7eb99bdaSLionel Sambuc   struct timeval reset_time;		/* time when cntrs were reset      */
724*7eb99bdaSLionel Sambuc   u_int64_t ibytes;			/* Rx bytes   with good status     */
725*7eb99bdaSLionel Sambuc   u_int64_t obytes;			/* Tx bytes                        */
726*7eb99bdaSLionel Sambuc   u_int64_t ipackets;			/* Rx packets with good status     */
727*7eb99bdaSLionel Sambuc   u_int64_t opackets;			/* Tx packets                      */
728*7eb99bdaSLionel Sambuc   u_int32_t ierrors;			/* Rx packets with bad status      */
729*7eb99bdaSLionel Sambuc   u_int32_t oerrors;			/* Tx packets with bad status      */
730*7eb99bdaSLionel Sambuc   u_int32_t idrops;			/* Rx packets dropped by SW        */
731*7eb99bdaSLionel Sambuc   u_int32_t missed;			/* Rx pkts missed: no DMA descs    */
732*7eb99bdaSLionel Sambuc   u_int32_t odrops;			/* Tx packets dropped by SW        */
733*7eb99bdaSLionel Sambuc   u_int32_t fifo_over;			/* Rx fifo overruns  from DMA desc */
734*7eb99bdaSLionel Sambuc   u_int32_t overruns;			/* Rx fifo overruns  from CSR      */
735*7eb99bdaSLionel Sambuc   u_int32_t fifo_under;			/* Tx fifo underruns from DMA desc */
736*7eb99bdaSLionel Sambuc   u_int32_t underruns;			/* Rx fifo underruns from CSR      */
737*7eb99bdaSLionel Sambuc   u_int32_t fdl_pkts;			/* Rx T1 Facility Data Link pkts   */
738*7eb99bdaSLionel Sambuc   u_int32_t crc_errs;			/* Rx T1 frame CRC errors          */
739*7eb99bdaSLionel Sambuc   u_int32_t lcv_errs;			/* Rx T1 T3 Line Coding Violation  */
740*7eb99bdaSLionel Sambuc   u_int32_t frm_errs;			/* Rx T1 T3 Frame bit errors       */
741*7eb99bdaSLionel Sambuc   u_int32_t febe_errs;			/* Rx T1 T3 Far End Bit Errors     */
742*7eb99bdaSLionel Sambuc   u_int32_t par_errs;			/* Rx T3 P-bit parity errors       */
743*7eb99bdaSLionel Sambuc   u_int32_t cpar_errs;			/* Rx T3 C-bit parity errors       */
744*7eb99bdaSLionel Sambuc   u_int32_t mfrm_errs;			/* Rx T3 Multi-frame bit errors    */
745*7eb99bdaSLionel Sambuc   u_int32_t rxbuf;			/* Rx out of packet buffers        */
746*7eb99bdaSLionel Sambuc   u_int32_t txdma;			/* Tx out of DMA desciptors        */
747*7eb99bdaSLionel Sambuc   u_int32_t lck_watch;			/* lock conflict in watchdog       */
748*7eb99bdaSLionel Sambuc   u_int32_t lck_intr;			/* lock conflict in interrupt      */
749*7eb99bdaSLionel Sambuc   u_int32_t spare1;			/* debugging temp                  */
750*7eb99bdaSLionel Sambuc   u_int32_t spare2;			/* debugging temp                  */
751*7eb99bdaSLionel Sambuc   u_int32_t spare3;			/* debugging temp                  */
752*7eb99bdaSLionel Sambuc   u_int32_t spare4;			/* debugging temp                  */
753*7eb99bdaSLionel Sambuc   };
754*7eb99bdaSLionel Sambuc 
755*7eb99bdaSLionel Sambuc /* sc->status is the READ ONLY status of the card.                         */
756*7eb99bdaSLionel Sambuc /* Accessed using socket IO control calls or netgraph control messages.    */
757*7eb99bdaSLionel Sambuc struct status
758*7eb99bdaSLionel Sambuc   {
759*7eb99bdaSLionel Sambuc   struct iohdr iohdr;			/* common ioctl header             */
760*7eb99bdaSLionel Sambuc   u_int32_t card_type;			/* PCI device number               */
761*7eb99bdaSLionel Sambuc   u_int16_t link_state;			/* actual state: up, down, test    */
762*7eb99bdaSLionel Sambuc   u_int32_t tx_speed;			/* measured TX bits/sec            */
763*7eb99bdaSLionel Sambuc   u_int32_t cable_type;			/* SSI only: cable type            */
764*7eb99bdaSLionel Sambuc   u_int32_t time_slots;			/* T1E1 only: actual TSs in use    */
765*7eb99bdaSLionel Sambuc   u_int32_t stack;			/* actual line stack in use        */
766*7eb99bdaSLionel Sambuc   u_int32_t proto;			/* actual line proto in use        */
767*7eb99bdaSLionel Sambuc   u_int32_t keep_alive;			/* actual keep-alive status        */
768*7eb99bdaSLionel Sambuc   u_int32_t ticks;			/* incremented by watchdog @ 1 Hz  */
769*7eb99bdaSLionel Sambuc   struct cntrs cntrs;			/* event counters                  */
770*7eb99bdaSLionel Sambuc   union
771*7eb99bdaSLionel Sambuc     {
772*7eb99bdaSLionel Sambuc     struct hssi_snmp hssi;		/* data for RFC-???? HSSI MIB      */
773*7eb99bdaSLionel Sambuc     struct t3_snmp t3;			/* data for RFC-2496 T3 MIB        */
774*7eb99bdaSLionel Sambuc     struct ssi_snmp ssi;		/* data for RFC-1659 RS232 MIB     */
775*7eb99bdaSLionel Sambuc     struct t1_snmp t1;			/* data for RFC-2495 T1 MIB        */
776*7eb99bdaSLionel Sambuc     } snmp;
777*7eb99bdaSLionel Sambuc   };
778*7eb99bdaSLionel Sambuc 
779*7eb99bdaSLionel Sambuc /* protocol stack codes */
780*7eb99bdaSLionel Sambuc #define STACK_NONE		   0	/* not set                   fnobl */
781*7eb99bdaSLionel Sambuc #define STACK_RAWIP		   1	/* driver                    yyyyy */
782*7eb99bdaSLionel Sambuc #define STACK_SPPP		   2	/* fbsd, nbsd, obsd          yyynn */
783*7eb99bdaSLionel Sambuc #define STACK_P2P		   3	/* bsd/os                    nnnyn */
784*7eb99bdaSLionel Sambuc #define STACK_GEN_HDLC		   4	/* linux                     nnnny */
785*7eb99bdaSLionel Sambuc #define STACK_SYNC_PPP		   5	/* linux                     nnnny */
786*7eb99bdaSLionel Sambuc #define STACK_NETGRAPH		   6	/* fbsd                      ynnnn */
787*7eb99bdaSLionel Sambuc 
788*7eb99bdaSLionel Sambuc /* line protocol codes */
789*7eb99bdaSLionel Sambuc #define PROTO_NONE		   0	/* not set                   fnobl */
790*7eb99bdaSLionel Sambuc #define PROTO_IP_HDLC		   1	/* raw IP4/6 pkts in HDLC    yyyyy */
791*7eb99bdaSLionel Sambuc #define PROTO_PPP		   2	/* Point-to-Point Protocol   yyyyy */
792*7eb99bdaSLionel Sambuc #define PROTO_C_HDLC		   3	/* Cisco HDLC Protocol       yyyyy */
793*7eb99bdaSLionel Sambuc #define PROTO_FRM_RLY		   4	/* Frame Relay Protocol      ynnyy */
794*7eb99bdaSLionel Sambuc #define PROTO_ETH_HDLC		   5	/* raw Ether pkts in HDLC    nnnny */
795*7eb99bdaSLionel Sambuc #define PROTO_X25		   6	/* X.25/LAPB Protocol        nnnny */
796*7eb99bdaSLionel Sambuc 
797*7eb99bdaSLionel Sambuc /* oper_status codes (same as SNMP status codes) */
798*7eb99bdaSLionel Sambuc #define STATE_UP		   1	/* may/will    tx/rx pkts          */
799*7eb99bdaSLionel Sambuc #define STATE_DOWN		   2	/* can't/won't tx/rx pkts          */
800*7eb99bdaSLionel Sambuc #define STATE_TEST		   3	/* currently not used              */
801*7eb99bdaSLionel Sambuc 
802*7eb99bdaSLionel Sambuc struct synth				/* programmable oscillator params  */
803*7eb99bdaSLionel Sambuc   {
804*7eb99bdaSLionel Sambuc   unsigned n:7;				/*   numerator (3..127)            */
805*7eb99bdaSLionel Sambuc   unsigned m:7;				/* denominator (3..127)            */
806*7eb99bdaSLionel Sambuc   unsigned v:1;				/* mul by 1|8                      */
807*7eb99bdaSLionel Sambuc   unsigned x:2;				/* div by 1|2|4|8                  */
808*7eb99bdaSLionel Sambuc   unsigned r:2;				/* div by 1|2|4|8                  */
809*7eb99bdaSLionel Sambuc   unsigned prescale:13;			/* log(final divisor): 2, 4 or 9   */
810*7eb99bdaSLionel Sambuc   } __packed;
811*7eb99bdaSLionel Sambuc 
812*7eb99bdaSLionel Sambuc #define SYNTH_FREF	        20e6	/* reference xtal =  20 MHz        */
813*7eb99bdaSLionel Sambuc #define SYNTH_FMIN	        50e6	/* internal VCO min  50 MHz        */
814*7eb99bdaSLionel Sambuc #define SYNTH_FMAX	       250e6	/* internal VCO max 250 MHz        */
815*7eb99bdaSLionel Sambuc 
816*7eb99bdaSLionel Sambuc /* sc->config is the READ/WRITE configuration of the card.                 */
817*7eb99bdaSLionel Sambuc /* Accessed using socket IO control calls or netgraph control messages.    */
818*7eb99bdaSLionel Sambuc struct config
819*7eb99bdaSLionel Sambuc   {
820*7eb99bdaSLionel Sambuc   struct iohdr iohdr;			/* common ioctl header             */
821*7eb99bdaSLionel Sambuc   u_int32_t crc_len;			/* ALL: CRC-16 or CRC-32 or none   */
822*7eb99bdaSLionel Sambuc   u_int32_t loop_back;			/* ALL: many kinds of loopbacks    */
823*7eb99bdaSLionel Sambuc   u_int32_t tx_clk_src;			/* T1, HSSI: ST, RT, int, ext      */
824*7eb99bdaSLionel Sambuc   u_int32_t format;			/* T3, T1: ckt framing format      */
825*7eb99bdaSLionel Sambuc   u_int32_t time_slots;			/* T1: 64Kb time slot config       */
826*7eb99bdaSLionel Sambuc   u_int32_t cable_len;			/* T3, T1: cable length in meters  */
827*7eb99bdaSLionel Sambuc   u_int32_t scrambler;			/* T3: payload scrambler config    */
828*7eb99bdaSLionel Sambuc   u_int32_t dte_dce;			/* SSI, HSSIc: drive TXCLK         */
829*7eb99bdaSLionel Sambuc   struct synth synth;			/* SSI, HSSIc: synth oscil params  */
830*7eb99bdaSLionel Sambuc   u_int32_t rx_gain_max;		/* T1: receiver gain limit 0-50 dB */
831*7eb99bdaSLionel Sambuc   u_int32_t tx_pulse;			/* T1: transmitter pulse shape     */
832*7eb99bdaSLionel Sambuc   u_int32_t tx_lbo;			/* T1: transmitter atten 0-22.5 dB */
833*7eb99bdaSLionel Sambuc   u_int32_t debug;			/* ALL: extra printout             */
834*7eb99bdaSLionel Sambuc   u_int32_t stack;			/* ALL: use this line stack        */
835*7eb99bdaSLionel Sambuc   u_int32_t proto;			/* ALL: use this line proto        */
836*7eb99bdaSLionel Sambuc   u_int32_t keep_alive;			/* SPPP: use keep-alive packets    */
837*7eb99bdaSLionel Sambuc   };
838*7eb99bdaSLionel Sambuc 
839*7eb99bdaSLionel Sambuc #define CFG_CRC_0		   0	/* no CRC                          */
840*7eb99bdaSLionel Sambuc #define CFG_CRC_16		   2	/* X^16+X^12+X^5+1 (default)       */
841*7eb99bdaSLionel Sambuc #define CFG_CRC_32		   4	/* X^32+X^26+X^23+X^22+X^16+X^12+  */
842*7eb99bdaSLionel Sambuc 					/* X^11+X^10+X^8+X^7+X^5+X^4+X^2+X+1 */
843*7eb99bdaSLionel Sambuc #define CFG_LOOP_NONE		   1	/* SNMP don't loop back anything   */
844*7eb99bdaSLionel Sambuc #define CFG_LOOP_PAYLOAD	   2	/* SNMP loop outward thru framer   */
845*7eb99bdaSLionel Sambuc #define CFG_LOOP_LINE		   3	/* SNMP loop outward thru LIU      */
846*7eb99bdaSLionel Sambuc #define CFG_LOOP_OTHER		   4	/* SNMP loop  inward thru LIU      */
847*7eb99bdaSLionel Sambuc #define CFG_LOOP_INWARD		   5	/* SNMP loop  inward thru framer   */
848*7eb99bdaSLionel Sambuc #define CFG_LOOP_DUAL		   6	/* SNMP loop  inward & outward     */
849*7eb99bdaSLionel Sambuc #define CFG_LOOP_TULIP		  16	/* ALL: loop  inward thru Tulip    */
850*7eb99bdaSLionel Sambuc #define CFG_LOOP_PINS		  17	/* HSSIc, SSI: loop inward-pins    */
851*7eb99bdaSLionel Sambuc #define CFG_LOOP_LL		  18	/* HSSI, SSI: assert LA/LL mdm pin */
852*7eb99bdaSLionel Sambuc #define CFG_LOOP_RL		  19	/* HSSI, SSI: assert LB/RL mdm pin */
853*7eb99bdaSLionel Sambuc 
854*7eb99bdaSLionel Sambuc #define CFG_CLKMUX_ST		   1	/* TX clk <- Send timing           */
855*7eb99bdaSLionel Sambuc #define CFG_CLKMUX_INT		   2	/* TX clk <- internal source       */
856*7eb99bdaSLionel Sambuc #define CFG_CLKMUX_RT		   3	/* TX clk <- Receive (loop) timing */
857*7eb99bdaSLionel Sambuc #define CFG_CLKMUX_EXT		   4	/* TX clk <- ext connector         */
858*7eb99bdaSLionel Sambuc 
859*7eb99bdaSLionel Sambuc /* values 0-31 are Bt8370 CR0 register values (LSB is zero if E1).         */
860*7eb99bdaSLionel Sambuc /* values 32-99 are reserved for other T1E1 formats, (even number if E1)   */
861*7eb99bdaSLionel Sambuc /* values 100 and up are used for T3 frame formats.                        */
862*7eb99bdaSLionel Sambuc #define CFG_FORMAT_T1SF		   9	/* T1-SF          AMI              */
863*7eb99bdaSLionel Sambuc #define CFG_FORMAT_T1ESF	  27	/* T1-ESF+CRC     B8ZS     X^6+X+1 */
864*7eb99bdaSLionel Sambuc #define CFG_FORMAT_E1FAS	   0	/* E1-FAS         HDB3 TS0         */
865*7eb99bdaSLionel Sambuc #define CFG_FORMAT_E1FASCRC	   8	/* E1-FAS+CRC     HDB3 TS0 X^4+X+1 */
866*7eb99bdaSLionel Sambuc #define CFG_FORMAT_E1FASCAS	  16	/* E1-FAS    +CAS HDB3 TS0 & TS16  */
867*7eb99bdaSLionel Sambuc #define CFG_FORMAT_E1FASCRCCAS	  24	/* E1-FAS+CRC+CAS HDB3 TS0 & TS16  */
868*7eb99bdaSLionel Sambuc #define CFG_FORMAT_E1NONE	  32	/* E1-NO framing  HDB3             */
869*7eb99bdaSLionel Sambuc #define CFG_FORMAT_T3CPAR	 100	/* T3-C-Bit par   B3ZS             */
870*7eb99bdaSLionel Sambuc #define CFG_FORMAT_T3M13	 101	/* T3-M13 format  B3ZS             */
871*7eb99bdaSLionel Sambuc 
872*7eb99bdaSLionel Sambuc /* format aliases that improve code readability */
873*7eb99bdaSLionel Sambuc #define FORMAT_T1ANY		((sc->config.format & 1)==1)
874*7eb99bdaSLionel Sambuc #define FORMAT_E1ANY		((sc->config.format & 1)==0)
875*7eb99bdaSLionel Sambuc #define FORMAT_E1CAS		((sc->config.format & 0x11)==0x10)
876*7eb99bdaSLionel Sambuc #define FORMAT_E1CRC		((sc->config.format & 0x09)==0x08)
877*7eb99bdaSLionel Sambuc #define FORMAT_E1NONE		 (sc->config.format == CFG_FORMAT_E1NONE)
878*7eb99bdaSLionel Sambuc #define FORMAT_T1ESF		 (sc->config.format == CFG_FORMAT_T1ESF)
879*7eb99bdaSLionel Sambuc #define FORMAT_T1SF		 (sc->config.format == CFG_FORMAT_T1SF)
880*7eb99bdaSLionel Sambuc #define FORMAT_T3CPAR		 (sc->config.format == CFG_FORMAT_T3CPAR)
881*7eb99bdaSLionel Sambuc 
882*7eb99bdaSLionel Sambuc #define CFG_SCRAM_OFF		   1	/* DS3 payload scrambler off       */
883*7eb99bdaSLionel Sambuc #define CFG_SCRAM_DL_KEN	   2	/* DS3 DigitalLink/Kentrox X^43+1  */
884*7eb99bdaSLionel Sambuc #define CFG_SCRAM_LARS		   3	/* DS3 Larscom X^20+X^17+1 w/28ZS  */
885*7eb99bdaSLionel Sambuc 
886*7eb99bdaSLionel Sambuc #define CFG_DTE			   1	/* HSSIc, SSI: rcv TXCLK; rcv DCD  */
887*7eb99bdaSLionel Sambuc #define CFG_DCE			   2	/* HSSIc, SSI: drv TXCLK; drv DCD  */
888*7eb99bdaSLionel Sambuc 
889*7eb99bdaSLionel Sambuc #define CFG_GAIN_SHORT		0x24	/* 0-20 dB of equalized gain       */
890*7eb99bdaSLionel Sambuc #define CFG_GAIN_MEDIUM		0x2C	/* 0-30 dB of equalized gain       */
891*7eb99bdaSLionel Sambuc #define CFG_GAIN_LONG		0x34	/* 0-40 dB of equalized gain       */
892*7eb99bdaSLionel Sambuc #define CFG_GAIN_EXTEND		0x3F	/* 0-64 dB of equalized gain       */
893*7eb99bdaSLionel Sambuc #define CFG_GAIN_AUTO		0xFF	/* auto-set based on cable length  */
894*7eb99bdaSLionel Sambuc 
895*7eb99bdaSLionel Sambuc #define CFG_PULSE_T1DSX0	   0	/* T1 DSX   0- 40 meters           */
896*7eb99bdaSLionel Sambuc #define CFG_PULSE_T1DSX1	   2	/* T1 DSX  40- 80 meters           */
897*7eb99bdaSLionel Sambuc #define CFG_PULSE_T1DSX2	   4	/* T1 DSX  80-120 meters           */
898*7eb99bdaSLionel Sambuc #define CFG_PULSE_T1DSX3	   6	/* T1 DSX 120-160 meters           */
899*7eb99bdaSLionel Sambuc #define CFG_PULSE_T1DSX4	   8	/* T1 DSX 160-200 meters           */
900*7eb99bdaSLionel Sambuc #define CFG_PULSE_E1COAX	  10	/* E1  75 ohm coax pair            */
901*7eb99bdaSLionel Sambuc #define CFG_PULSE_E1TWIST	  12	/* E1 120 ohm twisted pairs        */
902*7eb99bdaSLionel Sambuc #define CFG_PULSE_T1CSU		  14	/* T1 CSU 200-2000 meters; set LBO */
903*7eb99bdaSLionel Sambuc #define CFG_PULSE_AUTO		0xFF	/* auto-set based on cable length  */
904*7eb99bdaSLionel Sambuc 
905*7eb99bdaSLionel Sambuc #define CFG_LBO_0DB		   0	/* T1CSU LBO =  0.0 dB; FCC opt A  */
906*7eb99bdaSLionel Sambuc #define CFG_LBO_7DB		  16	/* T1CSU LBO =  7.5 dB; FCC opt B  */
907*7eb99bdaSLionel Sambuc #define CFG_LBO_15DB		  32	/* T1CSU LBO = 15.0 dB; FCC opt C  */
908*7eb99bdaSLionel Sambuc #define CFG_LBO_22DB		  48	/* T1CSU LBO = 22.5 dB; final span */
909*7eb99bdaSLionel Sambuc #define CFG_LBO_AUTO		0xFF	/* auto-set based on cable length  */
910*7eb99bdaSLionel Sambuc 
911*7eb99bdaSLionel Sambuc struct ioctl
912*7eb99bdaSLionel Sambuc   {
913*7eb99bdaSLionel Sambuc   struct iohdr iohdr;			/* common ioctl header             */
914*7eb99bdaSLionel Sambuc   u_int32_t cmd;			/* command                         */
915*7eb99bdaSLionel Sambuc   u_int32_t address;			/* command address                 */
916*7eb99bdaSLionel Sambuc   u_int32_t data;			/* command data                    */
917*7eb99bdaSLionel Sambuc   char *ucode;				/* user-land address of ucode      */
918*7eb99bdaSLionel Sambuc   };
919*7eb99bdaSLionel Sambuc 
920*7eb99bdaSLionel Sambuc #define IOCTL_RW_PCI		   1	/* RW: Tulip PCI config registers  */
921*7eb99bdaSLionel Sambuc #define IOCTL_RW_CSR		   2	/* RW: Tulip Control & Status Regs */
922*7eb99bdaSLionel Sambuc #define IOCTL_RW_SROM		   3	/* RW: Tulip Serial Rom            */
923*7eb99bdaSLionel Sambuc #define IOCTL_RW_BIOS		   4	/* RW: Tulip Boot rom              */
924*7eb99bdaSLionel Sambuc #define IOCTL_RW_MII		   5	/* RW: MII registers               */
925*7eb99bdaSLionel Sambuc #define IOCTL_RW_FRAME		   6	/* RW: Framer registers            */
926*7eb99bdaSLionel Sambuc #define IOCTL_WO_SYNTH		   7	/* WO: Synthesized oscillator      */
927*7eb99bdaSLionel Sambuc #define IOCTL_WO_DAC		   8	/* WO: Digital/Analog Converter    */
928*7eb99bdaSLionel Sambuc 
929*7eb99bdaSLionel Sambuc #define IOCTL_XILINX_RESET	  16	/* reset Xilinx: all FFs set to 0  */
930*7eb99bdaSLionel Sambuc #define IOCTL_XILINX_ROM	  17	/* load  Xilinx program from ROM   */
931*7eb99bdaSLionel Sambuc #define IOCTL_XILINX_FILE	  18	/* load  Xilinx program from file  */
932*7eb99bdaSLionel Sambuc 
933*7eb99bdaSLionel Sambuc #define IOCTL_SET_STATUS	  50	/* set mdm ctrl bits (internal)    */
934*7eb99bdaSLionel Sambuc #define IOCTL_SNMP_SEND		  51	/* trunk MIB send code             */
935*7eb99bdaSLionel Sambuc #define IOCTL_SNMP_LOOP		  52	/* trunk MIB loop configuration    */
936*7eb99bdaSLionel Sambuc #define IOCTL_SNMP_SIGS		  53	/* RS232-like modem control sigs   */
937*7eb99bdaSLionel Sambuc #define IOCTL_RESET_CNTRS	  54	/* reset event counters            */
938*7eb99bdaSLionel Sambuc 
939*7eb99bdaSLionel Sambuc /* storage for these strings is allocated here! */
940*7eb99bdaSLionel Sambuc const char *ssi_cables[] =
941*7eb99bdaSLionel Sambuc   {
942*7eb99bdaSLionel Sambuc   "V.10/EIA423",
943*7eb99bdaSLionel Sambuc   "V.11/EIA530A",
944*7eb99bdaSLionel Sambuc   "RESERVED",
945*7eb99bdaSLionel Sambuc   "X.21",
946*7eb99bdaSLionel Sambuc   "V.35",
947*7eb99bdaSLionel Sambuc   "V.36/EIA449",
948*7eb99bdaSLionel Sambuc   "V.28/EIA232",
949*7eb99bdaSLionel Sambuc   "NO CABLE",
950*7eb99bdaSLionel Sambuc   NULL,
951*7eb99bdaSLionel Sambuc   };
952*7eb99bdaSLionel Sambuc 
953*7eb99bdaSLionel Sambuc /***************************************************************************/
954*7eb99bdaSLionel Sambuc /*    Declarations above here are shared with the user lmcconfig program.  */
955*7eb99bdaSLionel Sambuc /*    Declarations below here are private to the kernel device driver.     */
956*7eb99bdaSLionel Sambuc /***************************************************************************/
957*7eb99bdaSLionel Sambuc 
958*7eb99bdaSLionel Sambuc #if KERNEL || _KERNEL || __KERNEL__
959*7eb99bdaSLionel Sambuc 
960*7eb99bdaSLionel Sambuc /* Hide the minor differences between Operating Systems */
961*7eb99bdaSLionel Sambuc 
962*7eb99bdaSLionel Sambuc typedef int intr_return_t;
963*7eb99bdaSLionel Sambuc # define  READ_PCI_CFG(sc, addr)       pci_conf_read ((sc)->pa_pc, (sc)->pa_tag, addr)
964*7eb99bdaSLionel Sambuc # define WRITE_PCI_CFG(sc, addr, data) pci_conf_write((sc)->pa_pc, (sc)->pa_tag, addr, data)
965*7eb99bdaSLionel Sambuc # define  READ_CSR(sc, csr)	 bus_space_read_4 ((sc)->csr_tag, (sc)->csr_handle, csr)
966*7eb99bdaSLionel Sambuc # define WRITE_CSR(sc, csr, val) bus_space_write_4((sc)->csr_tag, (sc)->csr_handle, csr, val)
967*7eb99bdaSLionel Sambuc # define NAME_UNIT		device_xname(sc->sc_dev)
968*7eb99bdaSLionel Sambuc # define BOOT_VERBOSE		(boothowto & AB_VERBOSE)
969*7eb99bdaSLionel Sambuc # define TOP_LOCK(sc)		(mutex_spin_enter(&(sc)->top_lock), 0)
970*7eb99bdaSLionel Sambuc # define TOP_TRYLOCK(sc)	mutex_tryenter(&(sc)->top_lock)
971*7eb99bdaSLionel Sambuc # define TOP_UNLOCK(sc)		mutex_spin_exit(&(sc)->top_lock)
972*7eb99bdaSLionel Sambuc # define BOTTOM_TRYLOCK(sc)	__cpu_simple_lock_try(&(sc)->bottom_lock)
973*7eb99bdaSLionel Sambuc # define BOTTOM_UNLOCK(sc)	__cpu_simple_unlock  (&(sc)->bottom_lock)
974*7eb99bdaSLionel Sambuc # define CHECK_CAP		kauth_authorize_network(curlwp->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_FIRMWARE, sc->ifp, NULL, NULL)
975*7eb99bdaSLionel Sambuc # define DISABLE_INTR		int spl = splnet()
976*7eb99bdaSLionel Sambuc # define ENABLE_INTR		splx(spl)
977*7eb99bdaSLionel Sambuc # define IRQ_NONE		0
978*7eb99bdaSLionel Sambuc # define IRQ_HANDLED		1
979*7eb99bdaSLionel Sambuc # define IFP2SC(ifp)		(ifp)->if_softc
980*7eb99bdaSLionel Sambuc # define COPY_BREAK		MHLEN
981*7eb99bdaSLionel Sambuc # define SLEEP(usecs)		tsleep(sc, PZERO, DEVICE_NAME, 1+(usecs/tick))
982*7eb99bdaSLionel Sambuc # define DMA_SYNC(map, size, flags) bus_dmamap_sync(ring->tag, map, 0, size, flags)
983*7eb99bdaSLionel Sambuc # define DMA_LOAD(map, addr, size)  bus_dmamap_load(ring->tag, map, addr, size, 0, BUS_DMA_NOWAIT)
984*7eb99bdaSLionel Sambuc #  define LMC_BPF_MTAP(sc, mbuf)	bpf_mtap((sc)->ifp, mbuf)
985*7eb99bdaSLionel Sambuc #  define LMC_BPF_ATTACH(sc, dlt, len)	bpf_attach((sc)->ifp, dlt, len)
986*7eb99bdaSLionel Sambuc #  define LMC_BPF_DETACH(sc)		bpf_detach((sc)->ifp)
987*7eb99bdaSLionel Sambuc 
988*7eb99bdaSLionel Sambuc static int driver_announced = 0;	/* print driver info once only */
989*7eb99bdaSLionel Sambuc 
990*7eb99bdaSLionel Sambuc #define SNDQ_MAXLEN	32		/* packets awaiting transmission */
991*7eb99bdaSLionel Sambuc #define DESCS_PER_PKT	 4		/* DMA descriptors per TX pkt */
992*7eb99bdaSLionel Sambuc #define NUM_TX_DESCS	(DESCS_PER_PKT * SNDQ_MAXLEN)
993*7eb99bdaSLionel Sambuc /* Increase DESCS_PER_PKT if status.cntrs.txdma increments. */
994*7eb99bdaSLionel Sambuc 
995*7eb99bdaSLionel Sambuc /* A Tulip DMA descriptor can point to two chunks of memory.
996*7eb99bdaSLionel Sambuc  * Each chunk has a max length of 2047 bytes (ask the VMS guys).
997*7eb99bdaSLionel Sambuc  * 2047 isn't a multiple of a cache line size (32 bytes typically).
998*7eb99bdaSLionel Sambuc  * So back off to 2048-32 = 2016 bytes per chunk (2 chunks per descr).
999*7eb99bdaSLionel Sambuc  */
1000*7eb99bdaSLionel Sambuc #define MAX_CHUNK_LEN	(2048-32)
1001*7eb99bdaSLionel Sambuc #define MAX_DESC_LEN	(2 * MAX_CHUNK_LEN)
1002*7eb99bdaSLionel Sambuc 
1003*7eb99bdaSLionel Sambuc /* Tulip DMA descriptor; THIS STRUCT MUST MATCH THE HARDWARE */
1004*7eb99bdaSLionel Sambuc struct dma_desc
1005*7eb99bdaSLionel Sambuc   {
1006*7eb99bdaSLionel Sambuc   u_int32_t status;			/* hardware->to->software */
1007*7eb99bdaSLionel Sambuc #if BYTE_ORDER == LITTLE_ENDIAN		/* left-to-right packing */
1008*7eb99bdaSLionel Sambuc   unsigned length1:11;			/* buffer1 length */
1009*7eb99bdaSLionel Sambuc   unsigned length2:11;			/* buffer2 length */
1010*7eb99bdaSLionel Sambuc   unsigned control:10;			/* software->to->hardware */
1011*7eb99bdaSLionel Sambuc #else					/* right-to-left packing */
1012*7eb99bdaSLionel Sambuc   unsigned control:10;			/* software->to->hardware */
1013*7eb99bdaSLionel Sambuc   unsigned length2:11;			/* buffer2 length */
1014*7eb99bdaSLionel Sambuc   unsigned length1:11;			/* buffer1 length */
1015*7eb99bdaSLionel Sambuc #endif
1016*7eb99bdaSLionel Sambuc   u_int32_t address1;			/* buffer1 bus address */
1017*7eb99bdaSLionel Sambuc   u_int32_t address2;			/* buffer2 bus address */
1018*7eb99bdaSLionel Sambuc   bus_dmamap_t map;			/* bus dmamap for this descriptor */
1019*7eb99bdaSLionel Sambuc # define TLP_BUS_DSL_VAL	(sizeof(bus_dmamap_t) & TLP_BUS_DSL)
1020*7eb99bdaSLionel Sambuc   } __packed;
1021*7eb99bdaSLionel Sambuc 
1022*7eb99bdaSLionel Sambuc /* Tulip DMA descriptor status bits */
1023*7eb99bdaSLionel Sambuc #define TLP_DSTS_OWNER		0x80000000
1024*7eb99bdaSLionel Sambuc #define TLP_DSTS_RX_DESC_ERR	0x00004000
1025*7eb99bdaSLionel Sambuc #define TLP_DSTS_RX_FIRST_DESC	0x00000200
1026*7eb99bdaSLionel Sambuc #define TLP_DSTS_RX_LAST_DESC	0x00000100
1027*7eb99bdaSLionel Sambuc #define TLP_DSTS_RX_MII_ERR	0x00000008
1028*7eb99bdaSLionel Sambuc #define TLP_DSTS_RX_DRIBBLE	0x00000004
1029*7eb99bdaSLionel Sambuc #define TLP_DSTS_TX_UNDERRUN	0x00000002
1030*7eb99bdaSLionel Sambuc #define TLP_DSTS_RX_OVERRUN	0x00000001	/* not documented in rev AF */
1031*7eb99bdaSLionel Sambuc #define TLP_DSTS_RX_BAD		(TLP_DSTS_RX_MII_ERR  | \
1032*7eb99bdaSLionel Sambuc 				 TLP_DSTS_RX_DRIBBLE  | \
1033*7eb99bdaSLionel Sambuc 				 TLP_DSTS_RX_DESC_ERR | \
1034*7eb99bdaSLionel Sambuc 				 TLP_DSTS_RX_OVERRUN)
1035*7eb99bdaSLionel Sambuc 
1036*7eb99bdaSLionel Sambuc /* Tulip DMA descriptor control bits */
1037*7eb99bdaSLionel Sambuc #define TLP_DCTL_TX_INTERRUPT	0x0200
1038*7eb99bdaSLionel Sambuc #define TLP_DCTL_TX_LAST_SEG	0x0100
1039*7eb99bdaSLionel Sambuc #define TLP_DCTL_TX_FIRST_SEG	0x0080
1040*7eb99bdaSLionel Sambuc #define TLP_DCTL_TX_NO_CRC	0x0010
1041*7eb99bdaSLionel Sambuc #define TLP_DCTL_END_RING	0x0008
1042*7eb99bdaSLionel Sambuc #define TLP_DCTL_TX_NO_PAD	0x0002
1043*7eb99bdaSLionel Sambuc 
1044*7eb99bdaSLionel Sambuc /* DMA descriptors are kept in a ring.
1045*7eb99bdaSLionel Sambuc  * Ring is empty when (read == write).
1046*7eb99bdaSLionel Sambuc  * Ring is full  when (read == wrap(write+1)),
1047*7eb99bdaSLionel Sambuc  * The ring also contains a tailq of data buffers.
1048*7eb99bdaSLionel Sambuc  */
1049*7eb99bdaSLionel Sambuc struct desc_ring
1050*7eb99bdaSLionel Sambuc   {
1051*7eb99bdaSLionel Sambuc   struct dma_desc *read;		/* next  descriptor to be read */
1052*7eb99bdaSLionel Sambuc   struct dma_desc *write;		/* next  descriptor to be written */
1053*7eb99bdaSLionel Sambuc   struct dma_desc *first;		/* first descriptor in ring */
1054*7eb99bdaSLionel Sambuc   struct dma_desc *last;		/* last  descriptor in ring */
1055*7eb99bdaSLionel Sambuc   struct dma_desc *temp;		/* temporary write pointer for tx */
1056*7eb99bdaSLionel Sambuc   u_int32_t dma_addr;			/* bus addr for desc array XXX */
1057*7eb99bdaSLionel Sambuc   int size_descs;			/* bus_dmamap_sync needs this */
1058*7eb99bdaSLionel Sambuc   int num_descs;			/* used to set rx quota */
1059*7eb99bdaSLionel Sambuc #if IFNET || NETGRAPH
1060*7eb99bdaSLionel Sambuc   struct mbuf *head;			/* tail-queue of mbufs */
1061*7eb99bdaSLionel Sambuc   struct mbuf *tail;
1062*7eb99bdaSLionel Sambuc #elif NETDEV
1063*7eb99bdaSLionel Sambuc   struct sk_buff *head;			/* tail-queue of skbuffs */
1064*7eb99bdaSLionel Sambuc   struct sk_buff *tail;
1065*7eb99bdaSLionel Sambuc #endif
1066*7eb99bdaSLionel Sambuc   bus_dma_tag_t tag;			/* bus_dma_tag for desc array */
1067*7eb99bdaSLionel Sambuc   bus_dmamap_t map;			/* bus_dmamap  for desc array */
1068*7eb99bdaSLionel Sambuc   bus_dma_segment_t segs[2];		/* bus_dmamap_load() or bus_dmamem_alloc() */
1069*7eb99bdaSLionel Sambuc   int nsegs;				/* bus_dmamap_load() or bus_dmamem_alloc() */
1070*7eb99bdaSLionel Sambuc   };
1071*7eb99bdaSLionel Sambuc 
1072*7eb99bdaSLionel Sambuc /* break circular definition */
1073*7eb99bdaSLionel Sambuc typedef struct softc softc_t;
1074*7eb99bdaSLionel Sambuc 
1075*7eb99bdaSLionel Sambuc struct card				/* an object */
1076*7eb99bdaSLionel Sambuc   {
1077*7eb99bdaSLionel Sambuc   void (*ident) (softc_t *);
1078*7eb99bdaSLionel Sambuc   void (*watchdog) (softc_t *);
1079*7eb99bdaSLionel Sambuc   int (*ioctl) (softc_t *, struct ioctl *);
1080*7eb99bdaSLionel Sambuc   void (*attach) (softc_t *, struct config *);
1081*7eb99bdaSLionel Sambuc   void (*detach) (softc_t *);
1082*7eb99bdaSLionel Sambuc   };
1083*7eb99bdaSLionel Sambuc 
1084*7eb99bdaSLionel Sambuc struct stack				/* an object */
1085*7eb99bdaSLionel Sambuc   {
1086*7eb99bdaSLionel Sambuc #if IFNET || NETGRAPH
1087*7eb99bdaSLionel Sambuc   int (*ioctl) (softc_t *, u_long, void *);
1088*7eb99bdaSLionel Sambuc   void (*input) (softc_t *, struct mbuf *);
1089*7eb99bdaSLionel Sambuc   void (*output) (softc_t *);
1090*7eb99bdaSLionel Sambuc #elif NETDEV
1091*7eb99bdaSLionel Sambuc   int (*ioctl) (softc_t *, struct ifreq *, int);
1092*7eb99bdaSLionel Sambuc   int (*type) (softc_t *, struct sk_buff *);
1093*7eb99bdaSLionel Sambuc   int (*mtu) (softc_t *, int);
1094*7eb99bdaSLionel Sambuc #endif
1095*7eb99bdaSLionel Sambuc   void (*watchdog) (softc_t *);
1096*7eb99bdaSLionel Sambuc   int (*open) (softc_t *, struct config *);
1097*7eb99bdaSLionel Sambuc   int (*attach) (softc_t *, struct config *);
1098*7eb99bdaSLionel Sambuc   int (*detach) (softc_t *);
1099*7eb99bdaSLionel Sambuc   };
1100*7eb99bdaSLionel Sambuc 
1101*7eb99bdaSLionel Sambuc /* This is the instance data, or "software context" for the device driver. */
1102*7eb99bdaSLionel Sambuc struct softc
1103*7eb99bdaSLionel Sambuc   {
1104*7eb99bdaSLionel Sambuc 
1105*7eb99bdaSLionel Sambuc   device_t sc_dev;
1106*7eb99bdaSLionel Sambuc   pcitag_t pa_tag;
1107*7eb99bdaSLionel Sambuc   pci_chipset_tag_t pa_pc;
1108*7eb99bdaSLionel Sambuc   bus_dma_tag_t pa_dmat;
1109*7eb99bdaSLionel Sambuc   bus_space_tag_t csr_tag;
1110*7eb99bdaSLionel Sambuc   bus_space_handle_t csr_handle;
1111*7eb99bdaSLionel Sambuc   pci_intr_handle_t intr_handle;
1112*7eb99bdaSLionel Sambuc   void *irq_cookie;
1113*7eb99bdaSLionel Sambuc   void *sdh_cookie;
1114*7eb99bdaSLionel Sambuc   struct mbuf *tx_mbuf;			/* hang mbuf here while building dma descs */
1115*7eb99bdaSLionel Sambuc   kmutex_t top_lock;			/* lock card->watchdog vs ioctls           */
1116*7eb99bdaSLionel Sambuc   __cpu_simple_lock_t bottom_lock;	/* lock buf queues & descriptor rings   */
1117*7eb99bdaSLionel Sambuc 
1118*7eb99bdaSLionel Sambuc   /* State for kernel-resident Line Protocols */
1119*7eb99bdaSLionel Sambuc #if IFNET
1120*7eb99bdaSLionel Sambuc # if SPPP
1121*7eb99bdaSLionel Sambuc   struct sppp spppcom;
1122*7eb99bdaSLionel Sambuc   struct sppp *sppp;
1123*7eb99bdaSLionel Sambuc # elif P2P
1124*7eb99bdaSLionel Sambuc   struct p2pcom p2pcom;
1125*7eb99bdaSLionel Sambuc   struct p2pcom *p2p;
1126*7eb99bdaSLionel Sambuc # else
1127*7eb99bdaSLionel Sambuc   struct ifnet ifnet;
1128*7eb99bdaSLionel Sambuc # endif
1129*7eb99bdaSLionel Sambuc   struct ifnet *ifp;
1130*7eb99bdaSLionel Sambuc   struct ifmedia ifm;
1131*7eb99bdaSLionel Sambuc #endif					/* IFNET */
1132*7eb99bdaSLionel Sambuc 
1133*7eb99bdaSLionel Sambuc #if NETDEV
1134*7eb99bdaSLionel Sambuc # if GEN_HDLC
1135*7eb99bdaSLionel Sambuc   hdlc_device *hdlcdev;			/* contains struct net_device_stats */
1136*7eb99bdaSLionel Sambuc # else
1137*7eb99bdaSLionel Sambuc   struct net_device_stats netdev_stats;
1138*7eb99bdaSLionel Sambuc # endif
1139*7eb99bdaSLionel Sambuc # if SYNC_PPP
1140*7eb99bdaSLionel Sambuc   struct ppp_device *ppd;
1141*7eb99bdaSLionel Sambuc   struct ppp_device ppp_dev;		/* contains a struct sppp */
1142*7eb99bdaSLionel Sambuc   struct sppp *sppp;
1143*7eb99bdaSLionel Sambuc # endif
1144*7eb99bdaSLionel Sambuc   struct net_device *netdev;
1145*7eb99bdaSLionel Sambuc #endif					/* NETDEV */
1146*7eb99bdaSLionel Sambuc 
1147*7eb99bdaSLionel Sambuc 
1148*7eb99bdaSLionel Sambuc 
1149*7eb99bdaSLionel Sambuc 
1150*7eb99bdaSLionel Sambuc   /* State used by all card types; lock with top_lock.                     */
1151*7eb99bdaSLionel Sambuc   struct status status;			/* lmcconfig can read              */
1152*7eb99bdaSLionel Sambuc   struct config config;			/* lmcconfig can read/write        */
1153*7eb99bdaSLionel Sambuc   const char *dev_desc;			/* string describing card          */
1154*7eb99bdaSLionel Sambuc   struct card *card;			/* card methods                    */
1155*7eb99bdaSLionel Sambuc   struct stack *stack;			/* line methods                    */
1156*7eb99bdaSLionel Sambuc   u_int32_t gpio_dir;			/* s/w copy of GPIO direction reg  */
1157*7eb99bdaSLionel Sambuc   u_int16_t led_state;			/* last value written to mii16     */
1158*7eb99bdaSLionel Sambuc   int quota;				/* used for packet flow control    */
1159*7eb99bdaSLionel Sambuc 
1160*7eb99bdaSLionel Sambuc   /* State used by card-specific watchdogs; lock with top_lock.            */
1161*7eb99bdaSLionel Sambuc   u_int32_t last_mii16;			/* SSI, HSSI: MII reg 16 one sec ago */
1162*7eb99bdaSLionel Sambuc   u_int32_t last_stat16;		/* T3:   framer reg 16 one sec ago */
1163*7eb99bdaSLionel Sambuc   u_int32_t last_alm1;			/* T1E1: framer reg 47 one sec ago */
1164*7eb99bdaSLionel Sambuc   u_int32_t last_link_state;		/* ALL: status.link_state 1 ec ago */
1165*7eb99bdaSLionel Sambuc   u_int32_t last_FEAC;			/* T3: last FEAC msg code received */
1166*7eb99bdaSLionel Sambuc   u_int32_t loop_timer;			/* T1E1, T3: secs until loop ends  */
1167*7eb99bdaSLionel Sambuc 
1168*7eb99bdaSLionel Sambuc   /* State used by the interrupt code; lock with bottom_lock.              */
1169*7eb99bdaSLionel Sambuc   struct desc_ring txring;		/* tx descriptor ring state        */
1170*7eb99bdaSLionel Sambuc   struct desc_ring rxring;		/* rx descriptor ring state        */
1171*7eb99bdaSLionel Sambuc   };					/* end of softc */
1172*7eb99bdaSLionel Sambuc 
1173*7eb99bdaSLionel Sambuc 
1174*7eb99bdaSLionel Sambuc #define HSSI_DESC "LMC5200 HSSI Card"
1175*7eb99bdaSLionel Sambuc #define T3_DESC   "LMC5245 T3 Card"
1176*7eb99bdaSLionel Sambuc #define SSI_DESC  "LMC1000 SSI Card"
1177*7eb99bdaSLionel Sambuc #define T1E1_DESC "LMC1200 T1E1 Card"
1178*7eb99bdaSLionel Sambuc 
1179*7eb99bdaSLionel Sambuc /* procedure prototypes */
1180*7eb99bdaSLionel Sambuc 
1181*7eb99bdaSLionel Sambuc static void srom_shift_bits(softc_t *, u_int32_t, u_int32_t);
1182*7eb99bdaSLionel Sambuc static u_int16_t srom_read(softc_t *, u_int8_t);
1183*7eb99bdaSLionel Sambuc static void srom_write(softc_t *, u_int8_t, u_int16_t);
1184*7eb99bdaSLionel Sambuc 
1185*7eb99bdaSLionel Sambuc static u_int8_t bios_read(softc_t *, u_int32_t);
1186*7eb99bdaSLionel Sambuc static void bios_write_phys(softc_t *, u_int32_t, u_int8_t);
1187*7eb99bdaSLionel Sambuc static void bios_write(softc_t *, u_int32_t, u_int8_t);
1188*7eb99bdaSLionel Sambuc static void bios_erase(softc_t *);
1189*7eb99bdaSLionel Sambuc 
1190*7eb99bdaSLionel Sambuc static void mii_shift_bits(softc_t *, u_int32_t, u_int32_t);
1191*7eb99bdaSLionel Sambuc static u_int16_t mii_read(softc_t *, u_int8_t);
1192*7eb99bdaSLionel Sambuc static void mii_write(softc_t *, u_int8_t, u_int16_t);
1193*7eb99bdaSLionel Sambuc 
1194*7eb99bdaSLionel Sambuc static void mii16_set_bits(softc_t *, u_int16_t);
1195*7eb99bdaSLionel Sambuc static void mii16_clr_bits(softc_t *, u_int16_t);
1196*7eb99bdaSLionel Sambuc static void mii17_set_bits(softc_t *, u_int16_t);
1197*7eb99bdaSLionel Sambuc static void mii17_clr_bits(softc_t *, u_int16_t);
1198*7eb99bdaSLionel Sambuc 
1199*7eb99bdaSLionel Sambuc static void led_off(softc_t *, u_int16_t);
1200*7eb99bdaSLionel Sambuc static void led_on(softc_t *, u_int16_t);
1201*7eb99bdaSLionel Sambuc static void led_inv(softc_t *, u_int16_t);
1202*7eb99bdaSLionel Sambuc 
1203*7eb99bdaSLionel Sambuc static void framer_write(softc_t *, u_int16_t, u_int8_t);
1204*7eb99bdaSLionel Sambuc static u_int8_t framer_read(softc_t *, u_int16_t);
1205*7eb99bdaSLionel Sambuc 
1206*7eb99bdaSLionel Sambuc static void gpio_make_input(softc_t *, u_int32_t);
1207*7eb99bdaSLionel Sambuc static void gpio_make_output(softc_t *, u_int32_t);
1208*7eb99bdaSLionel Sambuc static u_int32_t gpio_read(softc_t *);
1209*7eb99bdaSLionel Sambuc static void gpio_set_bits(softc_t *, u_int32_t);
1210*7eb99bdaSLionel Sambuc static void gpio_clr_bits(softc_t *, u_int32_t);
1211*7eb99bdaSLionel Sambuc 
1212*7eb99bdaSLionel Sambuc static void xilinx_reset(softc_t *);
1213*7eb99bdaSLionel Sambuc static void xilinx_load_from_rom(softc_t *);
1214*7eb99bdaSLionel Sambuc static int xilinx_load_from_file(softc_t *, char *, u_int32_t);
1215*7eb99bdaSLionel Sambuc 
1216*7eb99bdaSLionel Sambuc static void synth_shift_bits(softc_t *, u_int32_t, u_int32_t);
1217*7eb99bdaSLionel Sambuc static void synth_write(softc_t *, struct synth *);
1218*7eb99bdaSLionel Sambuc 
1219*7eb99bdaSLionel Sambuc static void dac_write(softc_t *, u_int16_t);
1220*7eb99bdaSLionel Sambuc 
1221*7eb99bdaSLionel Sambuc static void hssi_ident(softc_t *);
1222*7eb99bdaSLionel Sambuc static void hssi_watchdog(softc_t *);
1223*7eb99bdaSLionel Sambuc static int hssi_ioctl(softc_t *, struct ioctl *);
1224*7eb99bdaSLionel Sambuc static void hssi_attach(softc_t *, struct config *);
1225*7eb99bdaSLionel Sambuc static void hssi_detach(softc_t *);
1226*7eb99bdaSLionel Sambuc 
1227*7eb99bdaSLionel Sambuc static void t3_ident(softc_t *);
1228*7eb99bdaSLionel Sambuc static void t3_watchdog(softc_t *);
1229*7eb99bdaSLionel Sambuc static int t3_ioctl(softc_t *, struct ioctl *);
1230*7eb99bdaSLionel Sambuc static void t3_send_dbl_feac(softc_t *, int, int);
1231*7eb99bdaSLionel Sambuc static void t3_attach(softc_t *, struct config *);
1232*7eb99bdaSLionel Sambuc static void t3_detach(softc_t *);
1233*7eb99bdaSLionel Sambuc 
1234*7eb99bdaSLionel Sambuc static void ssi_ident(softc_t *);
1235*7eb99bdaSLionel Sambuc static void ssi_watchdog(softc_t *);
1236*7eb99bdaSLionel Sambuc static int ssi_ioctl(softc_t *, struct ioctl *);
1237*7eb99bdaSLionel Sambuc static void ssi_attach(softc_t *, struct config *);
1238*7eb99bdaSLionel Sambuc static void ssi_detach(softc_t *);
1239*7eb99bdaSLionel Sambuc 
1240*7eb99bdaSLionel Sambuc static void t1_ident(softc_t *);
1241*7eb99bdaSLionel Sambuc static void t1_watchdog(softc_t *);
1242*7eb99bdaSLionel Sambuc static int t1_ioctl(softc_t *, struct ioctl *);
1243*7eb99bdaSLionel Sambuc static void t1_send_bop(softc_t *, int);
1244*7eb99bdaSLionel Sambuc static void t1_attach(softc_t *, struct config *);
1245*7eb99bdaSLionel Sambuc static void t1_detach(softc_t *);
1246*7eb99bdaSLionel Sambuc 
1247*7eb99bdaSLionel Sambuc 
1248*7eb99bdaSLionel Sambuc #if SYNC_PPP
1249*7eb99bdaSLionel Sambuc static int sync_ppp_ioctl(softc_t *, struct ifreq *, int);
1250*7eb99bdaSLionel Sambuc static int sync_ppp_type(softc_t *, struct sk_buff *);
1251*7eb99bdaSLionel Sambuc static int sync_ppp_mtu(softc_t *, int);
1252*7eb99bdaSLionel Sambuc static void sync_ppp_watchdog(softc_t *);
1253*7eb99bdaSLionel Sambuc static int sync_ppp_open(softc_t *, struct config *);
1254*7eb99bdaSLionel Sambuc static int sync_ppp_attach(softc_t *, struct config *);
1255*7eb99bdaSLionel Sambuc static int sync_ppp_detach(softc_t *);
1256*7eb99bdaSLionel Sambuc #endif /* SYNC_PPP */
1257*7eb99bdaSLionel Sambuc 
1258*7eb99bdaSLionel Sambuc #if GEN_HDLC
1259*7eb99bdaSLionel Sambuc static int gen_hdlc_ioctl(softc_t *, struct ifreq *, int);
1260*7eb99bdaSLionel Sambuc static int gen_hdlc_type(softc_t *, struct sk_buff *);
1261*7eb99bdaSLionel Sambuc static int gen_hdlc_mtu(softc_t *, int);
1262*7eb99bdaSLionel Sambuc static void gen_hdlc_watchdog(softc_t *);
1263*7eb99bdaSLionel Sambuc static int gen_hdlc_open(softc_t *, struct config *);
1264*7eb99bdaSLionel Sambuc static int gen_hdlc_attach(softc_t *, struct config *);
1265*7eb99bdaSLionel Sambuc static int gen_hdlc_detach(softc_t *);
1266*7eb99bdaSLionel Sambuc static int gen_hdlc_card_params(struct net_device *, unsigned short,
1267*7eb99bdaSLionel Sambuc 				unsigned short);
1268*7eb99bdaSLionel Sambuc #endif /* GEN_HDLC */
1269*7eb99bdaSLionel Sambuc 
1270*7eb99bdaSLionel Sambuc #if P2P
1271*7eb99bdaSLionel Sambuc static int p2p_stack_ioctl(softc_t *, u_long, void *);
1272*7eb99bdaSLionel Sambuc static void p2p_stack_input(softc_t *, struct mbuf *);
1273*7eb99bdaSLionel Sambuc static void p2p_stack_output(softc_t *);
1274*7eb99bdaSLionel Sambuc static void p2p_stack_watchdog(softc_t *);
1275*7eb99bdaSLionel Sambuc static int p2p_stack_open(softc_t *, struct config *);
1276*7eb99bdaSLionel Sambuc static int p2p_stack_attach(softc_t *, struct config *);
1277*7eb99bdaSLionel Sambuc static int p2p_stack_detach(softc_t *);
1278*7eb99bdaSLionel Sambuc static int p2p_getmdm(struct p2pcom *, void *);
1279*7eb99bdaSLionel Sambuc static int p2p_mdmctl(struct p2pcom *, int);
1280*7eb99bdaSLionel Sambuc #endif /* P2P */
1281*7eb99bdaSLionel Sambuc 
1282*7eb99bdaSLionel Sambuc #if SPPP
1283*7eb99bdaSLionel Sambuc static int sppp_stack_ioctl(softc_t *, u_long, void *);
1284*7eb99bdaSLionel Sambuc static void sppp_stack_input(softc_t *, struct mbuf *);
1285*7eb99bdaSLionel Sambuc static void sppp_stack_output(softc_t *);
1286*7eb99bdaSLionel Sambuc static void sppp_stack_watchdog(softc_t *);
1287*7eb99bdaSLionel Sambuc static int sppp_stack_open(softc_t *, struct config *);
1288*7eb99bdaSLionel Sambuc static int sppp_stack_attach(softc_t *, struct config *);
1289*7eb99bdaSLionel Sambuc static int sppp_stack_detach(softc_t *);
1290*7eb99bdaSLionel Sambuc static void sppp_tls(struct sppp *);
1291*7eb99bdaSLionel Sambuc static void sppp_tlf(struct sppp *);
1292*7eb99bdaSLionel Sambuc #endif /* SPPP */
1293*7eb99bdaSLionel Sambuc 
1294*7eb99bdaSLionel Sambuc #if IFNET
1295*7eb99bdaSLionel Sambuc static int rawip_ioctl(softc_t *, u_long, void *);
1296*7eb99bdaSLionel Sambuc static void rawip_input(softc_t *, struct mbuf *);
1297*7eb99bdaSLionel Sambuc static void rawip_output(softc_t *);
1298*7eb99bdaSLionel Sambuc #elif NETDEV
1299*7eb99bdaSLionel Sambuc static int rawip_ioctl(softc_t *, struct ifreq *, int);
1300*7eb99bdaSLionel Sambuc static int rawip_type(softc_t *, struct sk_buff *);
1301*7eb99bdaSLionel Sambuc static int rawip_mtu(softc_t *, int);
1302*7eb99bdaSLionel Sambuc #endif
1303*7eb99bdaSLionel Sambuc static void rawip_watchdog(softc_t *);
1304*7eb99bdaSLionel Sambuc static int rawip_open(softc_t *, struct config *);
1305*7eb99bdaSLionel Sambuc static int rawip_attach(softc_t *, struct config *);
1306*7eb99bdaSLionel Sambuc static int rawip_detach(softc_t *);
1307*7eb99bdaSLionel Sambuc 
1308*7eb99bdaSLionel Sambuc #if IFNET
1309*7eb99bdaSLionel Sambuc static void ifnet_input(struct ifnet *, struct mbuf *);
1310*7eb99bdaSLionel Sambuc static int ifnet_output(struct ifnet *, struct mbuf *,
1311*7eb99bdaSLionel Sambuc 			const struct sockaddr *, struct rtentry *);
1312*7eb99bdaSLionel Sambuc static int ifnet_ioctl(struct ifnet *, u_long, void *);
1313*7eb99bdaSLionel Sambuc static void ifnet_start(struct ifnet *);
1314*7eb99bdaSLionel Sambuc static void ifnet_watchdog(struct ifnet *);
1315*7eb99bdaSLionel Sambuc 
1316*7eb99bdaSLionel Sambuc static void ifnet_setup(struct ifnet *);
1317*7eb99bdaSLionel Sambuc static int ifnet_attach(softc_t *);
1318*7eb99bdaSLionel Sambuc static void ifnet_detach(softc_t *);
1319*7eb99bdaSLionel Sambuc 
1320*7eb99bdaSLionel Sambuc static void ifmedia_setup(softc_t *);
1321*7eb99bdaSLionel Sambuc static int lmc_ifmedia_change(struct ifnet *);
1322*7eb99bdaSLionel Sambuc static void ifmedia_status(struct ifnet *, struct ifmediareq *);
1323*7eb99bdaSLionel Sambuc #endif /* IFNET */
1324*7eb99bdaSLionel Sambuc 
1325*7eb99bdaSLionel Sambuc #if NETDEV
1326*7eb99bdaSLionel Sambuc static int netdev_open(struct net_device *);
1327*7eb99bdaSLionel Sambuc static int netdev_stop(struct net_device *);
1328*7eb99bdaSLionel Sambuc static int netdev_start(struct sk_buff *, struct net_device *);
1329*7eb99bdaSLionel Sambuc # if NAPI
1330*7eb99bdaSLionel Sambuc static int netdev_poll(struct net_device *, int *);
1331*7eb99bdaSLionel Sambuc # endif
1332*7eb99bdaSLionel Sambuc static int netdev_ioctl(struct net_device *, struct ifreq *, int);
1333*7eb99bdaSLionel Sambuc static int netdev_mtu(struct net_device *, int);
1334*7eb99bdaSLionel Sambuc static void netdev_timeout(struct net_device *);
1335*7eb99bdaSLionel Sambuc static struct net_device_stats *netdev_stats(struct net_device *);
1336*7eb99bdaSLionel Sambuc static void netdev_watchdog(unsigned long);
1337*7eb99bdaSLionel Sambuc 
1338*7eb99bdaSLionel Sambuc static void netdev_setup(struct net_device *);
1339*7eb99bdaSLionel Sambuc static int netdev_attach(softc_t *);
1340*7eb99bdaSLionel Sambuc static void netdev_detach(softc_t *);
1341*7eb99bdaSLionel Sambuc #endif /* NETDEV */
1342*7eb99bdaSLionel Sambuc 
1343*7eb99bdaSLionel Sambuc 
1344*7eb99bdaSLionel Sambuc #if BSD
1345*7eb99bdaSLionel Sambuc static int create_ring(softc_t *, struct desc_ring *, int);
1346*7eb99bdaSLionel Sambuc static void destroy_ring(softc_t *, struct desc_ring *);
1347*7eb99bdaSLionel Sambuc 
1348*7eb99bdaSLionel Sambuc static void mbuf_enqueue(struct desc_ring *, struct mbuf *);
1349*7eb99bdaSLionel Sambuc static struct mbuf *mbuf_dequeue(struct desc_ring *);
1350*7eb99bdaSLionel Sambuc 
1351*7eb99bdaSLionel Sambuc static int rxintr_cleanup(softc_t *);
1352*7eb99bdaSLionel Sambuc static int rxintr_setup(softc_t *);
1353*7eb99bdaSLionel Sambuc static int txintr_cleanup(softc_t *);
1354*7eb99bdaSLionel Sambuc static int txintr_setup_mbuf(softc_t *, struct mbuf *);
1355*7eb99bdaSLionel Sambuc static int txintr_setup(softc_t *);
1356*7eb99bdaSLionel Sambuc 
1357*7eb99bdaSLionel Sambuc static intr_return_t bsd_interrupt(void *);
1358*7eb99bdaSLionel Sambuc # if DEVICE_POLLING
1359*7eb99bdaSLionel Sambuc static void bsd_poll(struct ifnet *, enum poll_cmd, int);
1360*7eb99bdaSLionel Sambuc # endif
1361*7eb99bdaSLionel Sambuc #endif /* BSD */
1362*7eb99bdaSLionel Sambuc 
1363*7eb99bdaSLionel Sambuc static int open_proto(softc_t *, struct config *);
1364*7eb99bdaSLionel Sambuc static int attach_stack(softc_t *, struct config *);
1365*7eb99bdaSLionel Sambuc 
1366*7eb99bdaSLionel Sambuc static int lmc_ioctl(softc_t *, u_long, void *);
1367*7eb99bdaSLionel Sambuc static void lmc_watchdog(softc_t *);
1368*7eb99bdaSLionel Sambuc 
1369*7eb99bdaSLionel Sambuc static void set_ready(softc_t *, int);
1370*7eb99bdaSLionel Sambuc static void reset_cntrs(softc_t *);
1371*7eb99bdaSLionel Sambuc 
1372*7eb99bdaSLionel Sambuc static void lmc_interrupt(void *, int, int);
1373*7eb99bdaSLionel Sambuc static void check_intr_status(softc_t *);
1374*7eb99bdaSLionel Sambuc 
1375*7eb99bdaSLionel Sambuc static int lmc_attach(softc_t *);
1376*7eb99bdaSLionel Sambuc static void lmc_detach(softc_t *);
1377*7eb99bdaSLionel Sambuc 
1378*7eb99bdaSLionel Sambuc static void tulip_loop(softc_t *, struct config *);
1379*7eb99bdaSLionel Sambuc static int tulip_attach(softc_t *);
1380*7eb99bdaSLionel Sambuc static void tulip_detach(void *);
1381*7eb99bdaSLionel Sambuc 
1382*7eb99bdaSLionel Sambuc static void print_driver_info(void);
1383*7eb99bdaSLionel Sambuc 
1384*7eb99bdaSLionel Sambuc static int nbsd_match(device_t, cfdata_t, void *);
1385*7eb99bdaSLionel Sambuc static void nbsd_attach(device_t, device_t, void *);
1386*7eb99bdaSLionel Sambuc static int nbsd_detach(device_t, int);
1387*7eb99bdaSLionel Sambuc 
1388*7eb99bdaSLionel Sambuc #endif /* KERNEL */
1389*7eb99bdaSLionel Sambuc 
1390*7eb99bdaSLionel Sambuc #endif /* IF_LMC_H */
1391