if_udavreg.h revision 1.4 1 1.4 ad /* $NetBSD: if_udavreg.h,v 1.4 2007/12/05 07:15:54 ad Exp $ */
2 1.1 itojun /* $nabe: if_udavreg.h,v 1.2 2003/08/21 16:26:40 nabe Exp $ */
3 1.1 itojun /*
4 1.1 itojun * Copyright (c) 2003
5 1.1 itojun * Shingo WATANABE <nabe (at) nabechan.org>. All rights reserved.
6 1.1 itojun *
7 1.1 itojun * Redistribution and use in source and binary forms, with or without
8 1.1 itojun * modification, are permitted provided that the following conditions
9 1.1 itojun * are met:
10 1.1 itojun * 1. Redistributions of source code must retain the above copyright
11 1.1 itojun * notice, this list of conditions and the following disclaimer.
12 1.1 itojun * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 itojun * notice, this list of conditions and the following disclaimer in the
14 1.1 itojun * documentation and/or other materials provided with the distribution.
15 1.2 tsutsui * 3. Neither the name of the author nor the names of any co-contributors
16 1.1 itojun * may be used to endorse or promote products derived from this software
17 1.1 itojun * without specific prior written permission.
18 1.1 itojun *
19 1.1 itojun * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 1.1 itojun * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 1.1 itojun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 1.1 itojun * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 1.1 itojun * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 1.1 itojun * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 1.1 itojun * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 1.1 itojun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 1.1 itojun * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 1.1 itojun * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 1.1 itojun * SUCH DAMAGE.
30 1.1 itojun *
31 1.1 itojun */
32 1.1 itojun
33 1.1 itojun #define UDAV_IFACE_INDEX 0
34 1.1 itojun #define UDAV_CONFIG_NO 1
35 1.1 itojun
36 1.1 itojun #define UDAV_TX_LIST_CNT 1
37 1.1 itojun #define UDAV_RX_LIST_CNT 1
38 1.1 itojun
39 1.1 itojun #define UDAV_TX_TIMEOUT 1000
40 1.1 itojun #define UDAV_TIMEOUT 10000
41 1.1 itojun
42 1.1 itojun #define ETHER_ALIGN 2
43 1.1 itojun
44 1.1 itojun
45 1.1 itojun /* Packet length */
46 1.1 itojun #define UDAV_MAX_MTU 1536 /* XXX: max frame size is unknown */
47 1.1 itojun #define UDAV_MIN_FRAME_LEN 60
48 1.1 itojun #define UDAV_BUFSZ UDAV_MAX_MTU
49 1.1 itojun
50 1.1 itojun /* Request */
51 1.1 itojun #define UDAV_REQ_REG_READ 0x00 /* Read from register(s) */
52 1.1 itojun #define UDAV_REQ_REG_WRITE 0x01 /* Write to register(s) */
53 1.1 itojun #define UDAV_REQ_REG_WRITE1 0x03 /* Write to a register */
54 1.1 itojun
55 1.1 itojun #define UDAV_REQ_MEM_READ 0x02 /* Read from memory */
56 1.1 itojun #define UDAV_REQ_MEM_WRITE 0x05 /* Write to memory */
57 1.1 itojun #define UDAV_REQ_MEM_WRITE1 0x07 /* Write a byte to memory */
58 1.1 itojun
59 1.1 itojun /* Registers */
60 1.1 itojun #define UDAV_NCR 0x00 /* Network Control Register */
61 1.1 itojun #define UDAV_NCR_EXT_PHY (1<<7) /* Select External PHY */
62 1.1 itojun #define UDAV_NCR_WAKEEN (1<<6) /* Wakeup Event Enable */
63 1.1 itojun #define UDAV_NCR_FCOL (1<<4) /* Force Collision Mode */
64 1.1 itojun #define UDAV_NCR_FDX (1<<3) /* Full-Duplex Mode (RO on Int. PHY) */
65 1.1 itojun #define UDAV_NCR_LBK1 (1<<2) /* Lookback Mode */
66 1.1 itojun #define UDAV_NCR_LBK0 (1<<1) /* Lookback Mode */
67 1.1 itojun #define UDAV_NCR_RST (1<<0) /* Software reset */
68 1.1 itojun
69 1.1 itojun #define UDAV_RCR 0x05 /* RX Control Register */
70 1.1 itojun #define UDAV_RCR_WTDIS (1<<6) /* Watchdog Timer Disable */
71 1.1 itojun #define UDAV_RCR_DIS_LONG (1<<5) /* Discard Long Packet(over 1522Byte) */
72 1.1 itojun #define UDAV_RCR_DIS_CRC (1<<4) /* Discard CRC Error Packet */
73 1.1 itojun #define UDAV_RCR_ALL (1<<3) /* Pass All Multicast */
74 1.1 itojun #define UDAV_RCR_RUNT (1<<2) /* Pass Runt Packet */
75 1.1 itojun #define UDAV_RCR_PRMSC (1<<1) /* Promiscuous Mode */
76 1.1 itojun #define UDAV_RCR_RXEN (1<<0) /* RX Enable */
77 1.1 itojun
78 1.1 itojun #define UDAV_RSR 0x06 /* RX Status Register */
79 1.1 itojun #define UDAV_RSR_RF (1<<7) /* Runt Frame */
80 1.1 itojun #define UDAV_RSR_MF (1<<6) /* Multicast Frame */
81 1.1 itojun #define UDAV_RSR_LCS (1<<5) /* Late Collision Seen */
82 1.1 itojun #define UDAV_RSR_RWTO (1<<4) /* Receive Watchdog Time-Out */
83 1.1 itojun #define UDAV_RSR_PLE (1<<3) /* Physical Layer Error */
84 1.1 itojun #define UDAV_RSR_AE (1<<2) /* Alignment Error */
85 1.1 itojun #define UDAV_RSR_CE (1<<1) /* CRC Error */
86 1.1 itojun #define UDAV_RSR_FOE (1<<0) /* FIFO Overflow Error */
87 1.1 itojun #define UDAV_RSR_ERR (UDAV_RSR_RF | UDAV_RSR_LCS | UDAV_RSR_RWTO |\
88 1.1 itojun UDAV_RSR_PLE | UDAV_RSR_AE | UDAV_RSR_CE |\
89 1.1 itojun UDAV_RSR_FOE)
90 1.1 itojun
91 1.1 itojun #define UDAV_EPCR 0x0b /* EEPROM & PHY Control Register */
92 1.1 itojun #define UDAV_EPCR_REEP (1<<5) /* Reload EEPROM */
93 1.1 itojun #define UDAV_EPCR_WEP (1<<4) /* Write EEPROM enable */
94 1.1 itojun #define UDAV_EPCR_EPOS (1<<3) /* EEPROM or PHY Operation Select */
95 1.1 itojun #define UDAV_EPCR_ERPRR (1<<2) /* EEPROM/PHY Register Read Command */
96 1.1 itojun #define UDAV_EPCR_ERPRW (1<<1) /* EEPROM/PHY Register Write Command */
97 1.1 itojun #define UDAV_EPCR_ERRE (1<<0) /* EEPROM/PHY Access Status */
98 1.1 itojun
99 1.1 itojun #define UDAV_EPAR 0x0c /* EEPROM & PHY Control Register */
100 1.1 itojun #define UDAV_EPAR_PHY_ADR1 (1<<7) /* PHY Address bit 1 */
101 1.1 itojun #define UDAV_EPAR_PHY_ADR0 (1<<6) /* PHY Address bit 0 */
102 1.1 itojun #define UDAV_EPAR_EROA (1<<0) /* EEPROM Word/PHY Register Address */
103 1.1 itojun #define UDAV_EPAR_EROA_MASK (0x1f) /* [5:0] */
104 1.1 itojun
105 1.1 itojun #define UDAV_EPDRL 0x0d /* EEPROM & PHY Data Register */
106 1.1 itojun #define UDAV_EPDRH 0x0e /* EEPROM & PHY Data Register */
107 1.1 itojun
108 1.1 itojun #define UDAV_PAR0 0x10 /* Ethernet Address, load from EEPROM */
109 1.1 itojun #define UDAV_PAR1 0x11 /* Ethernet Address, load from EEPROM */
110 1.1 itojun #define UDAV_PAR2 0x12 /* Ethernet Address, load from EEPROM */
111 1.1 itojun #define UDAV_PAR3 0x13 /* Ethernet Address, load from EEPROM */
112 1.1 itojun #define UDAV_PAR4 0x14 /* Ethernet Address, load from EEPROM */
113 1.1 itojun #define UDAV_PAR5 0x15 /* Ethernet Address, load from EEPROM */
114 1.1 itojun #define UDAV_PAR UDAV_PAR0
115 1.1 itojun
116 1.1 itojun #define UDAV_MAR0 0x16 /* Multicast Register */
117 1.1 itojun #define UDAV_MAR1 0x17 /* Multicast Register */
118 1.1 itojun #define UDAV_MAR2 0x18 /* Multicast Register */
119 1.1 itojun #define UDAV_MAR3 0x19 /* Multicast Register */
120 1.1 itojun #define UDAV_MAR4 0x1a /* Multicast Register */
121 1.1 itojun #define UDAV_MAR5 0x1b /* Multicast Register */
122 1.1 itojun #define UDAV_MAR6 0x1c /* Multicast Register */
123 1.1 itojun #define UDAV_MAR7 0x1d /* Multicast Register */
124 1.1 itojun #define UDAV_MAR UDAV_MAR0
125 1.1 itojun
126 1.1 itojun #define UDAV_GPCR 0x1e /* General purpose control register */
127 1.1 itojun #define UDAV_GPCR_GEP_CNTL6 (1<<6) /* General purpose control 6 */
128 1.1 itojun #define UDAV_GPCR_GEP_CNTL5 (1<<5) /* General purpose control 5 */
129 1.1 itojun #define UDAV_GPCR_GEP_CNTL4 (1<<4) /* General purpose control 4 */
130 1.1 itojun #define UDAV_GPCR_GEP_CNTL3 (1<<3) /* General purpose control 3 */
131 1.1 itojun #define UDAV_GPCR_GEP_CNTL2 (1<<2) /* General purpose control 2 */
132 1.1 itojun #define UDAV_GPCR_GEP_CNTL1 (1<<1) /* General purpose control 1 */
133 1.1 itojun #define UDAV_GPCR_GEP_CNTL0 (1<<0) /* General purpose control 0 */
134 1.1 itojun
135 1.1 itojun #define UDAV_GPR 0x1f /* General purpose register */
136 1.1 itojun #define UDAV_GPR_GEPIO6 (1<<6) /* General purpose 6 */
137 1.1 itojun #define UDAV_GPR_GEPIO5 (1<<5) /* General purpose 5 */
138 1.1 itojun #define UDAV_GPR_GEPIO4 (1<<4) /* General purpose 4 */
139 1.1 itojun #define UDAV_GPR_GEPIO3 (1<<3) /* General purpose 3 */
140 1.1 itojun #define UDAV_GPR_GEPIO2 (1<<2) /* General purpose 2 */
141 1.1 itojun #define UDAV_GPR_GEPIO1 (1<<1) /* General purpose 1 */
142 1.1 itojun #define UDAV_GPR_GEPIO0 (1<<0) /* General purpose 0 */
143 1.1 itojun
144 1.1 itojun #define GET_IFP(sc) (&(sc)->sc_ec.ec_if)
145 1.1 itojun #define GET_MII(sc) (&(sc)->sc_mii)
146 1.1 itojun
147 1.1 itojun struct udav_chain {
148 1.1 itojun struct udav_softc *udav_sc;
149 1.1 itojun usbd_xfer_handle udav_xfer;
150 1.1 itojun char *udav_buf;
151 1.1 itojun struct mbuf *udav_mbuf;
152 1.1 itojun int udav_idx;
153 1.1 itojun };
154 1.1 itojun
155 1.1 itojun struct udav_cdata {
156 1.1 itojun struct udav_chain udav_tx_chain[UDAV_TX_LIST_CNT];
157 1.1 itojun struct udav_chain udav_rx_chain[UDAV_TX_LIST_CNT];
158 1.1 itojun #if 0
159 1.1 itojun /* XXX: Intrrupt Endpoint is not yet supported! */
160 1.1 itojun struct udav_intrpkg udav_ibuf;
161 1.1 itojun #endif
162 1.1 itojun int udav_tx_prod;
163 1.1 itojun int udav_tx_cons;
164 1.1 itojun int udav_tx_cnt;
165 1.1 itojun int udav_rx_prod;
166 1.1 itojun };
167 1.1 itojun
168 1.1 itojun struct udav_softc {
169 1.1 itojun USBBASEDEVICE sc_dev; /* base device */
170 1.1 itojun usbd_device_handle sc_udev;
171 1.1 itojun
172 1.1 itojun /* USB */
173 1.1 itojun usbd_interface_handle sc_ctl_iface;
174 1.1 itojun /* int sc_ctl_iface_no; */
175 1.1 itojun int sc_bulkin_no; /* bulk in endpoint */
176 1.1 itojun int sc_bulkout_no; /* bulk out endpoint */
177 1.1 itojun int sc_intrin_no; /* intr in endpoint */
178 1.1 itojun usbd_pipe_handle sc_pipe_rx;
179 1.1 itojun usbd_pipe_handle sc_pipe_tx;
180 1.1 itojun usbd_pipe_handle sc_pipe_intr;
181 1.1 itojun usb_callout_t sc_stat_ch;
182 1.1 itojun u_int sc_rx_errs;
183 1.1 itojun /* u_int sc_intr_errs; */
184 1.1 itojun struct timeval sc_rx_notice;
185 1.1 itojun
186 1.1 itojun /* Ethernet */
187 1.1 itojun struct ethercom sc_ec; /* ethernet common */
188 1.1 itojun struct mii_data sc_mii;
189 1.4 ad kmutex_t sc_mii_lock;
190 1.1 itojun int sc_link;
191 1.1 itojun #define sc_media udav_mii.mii_media
192 1.1 itojun #if NRND > 0
193 1.1 itojun rndsource_element_t rnd_source;
194 1.1 itojun #endif
195 1.1 itojun struct udav_cdata sc_cdata;
196 1.1 itojun
197 1.1 itojun int sc_attached;
198 1.1 itojun int sc_dying;
199 1.1 itojun int sc_refcnt;
200 1.1 itojun
201 1.1 itojun struct usb_task sc_tick_task;
202 1.1 itojun struct usb_task sc_stop_task;
203 1.1 itojun
204 1.1 itojun u_int16_t sc_flags;
205 1.1 itojun };
206