1 /* $NetBSD: if_axereg.h,v 1.6 2009/09/04 17:53:58 dyoung Exp $ */
4 * Copyright (c) 1997, 1998, 1999, 2000-2003
5 * Bill Paul <wpaul@windriver.com>. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Bill Paul.
18 * 4. Neither the name of the author nor the names of any co-contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
34 * $FreeBSD: src/sys/dev/usb/if_axereg.h,v 1.2 2003/06/15 21:45:43 wpaul Exp $
38 * Definitions for the ASIX Electronics AX88172 to ethernet controller.
43 * Vendor specific commands
44 * ASIX conveniently doesn't document the 'set NODEID' command in their
45 * datasheet (thanks a lot guys).
46 * To make handling these commands easier, I added some extra data
47 * which is decided by the axe_cmd() routine. Commands are encoded
48 * in 16 bites, with the format: LDCC. L and D are both nibbles in
49 * the high byte. L represents the data length (0 to 15) and D
50 * represents the direction (0 for vendor read, 1 for vendor write).
51 * CC is the command byte, as specified in the manual.
54 #define AXE_CMD_DIR(x) (((x) & 0x0F00) >> 8)
55 #define AXE_CMD_LEN(x) (((x) & 0xF000) >> 12)
56 #define AXE_CMD_CMD(x) ((x) & 0x00FF)
58 #define AXE_CMD_READ_RXTX_SRAM 0x2002
59 #define AXE_CMD_WRITE_RX_SRAM 0x0103
60 #define AXE_CMD_WRITE_TX_SRAM 0x0104
61 #define AXE_CMD_MII_OPMODE_SW 0x0106
62 #define AXE_CMD_MII_READ_REG 0x2007
63 #define AXE_CMD_MII_WRITE_REG 0x2108
64 #define AXE_CMD_MII_READ_OPMODE 0x1009
65 #define AXE_CMD_MII_OPMODE_HW 0x010A
66 #define AXE_CMD_SROM_READ 0x200B
67 #define AXE_CMD_SROM_WRITE 0x010C
68 #define AXE_CMD_SROM_WR_ENABLE 0x010D
69 #define AXE_CMD_SROM_WR_DISABLE 0x010E
70 #define AXE_CMD_RXCTL_READ 0x200F
71 #define AXE_CMD_RXCTL_WRITE 0x0110
72 #define AXE_CMD_READ_IPG012 0x3011
73 #define AXE_CMD_WRITE_IPG0 0x0112
74 #define AXE_CMD_WRITE_IPG1 0x0113
75 #define AXE_CMD_WRITE_IPG2 0x0114
76 #define AXE_CMD_READ_MCAST 0x8015
77 #define AXE_CMD_WRITE_MCAST 0x8116
78 #define AXE_CMD_READ_NODEID 0x6017
79 #define AXE_CMD_WRITE_NODEID 0x6118
80 #define AXE_CMD_READ_PHYID 0x2019
81 #define AXE_CMD_READ_MEDIA 0x101A
82 #define AXE_CMD_WRITE_MEDIA 0x011B
83 #define AXE_CMD_READ_MONITOR_MODE 0x101C
84 #define AXE_CMD_WRITE_MONITOR_MODE 0x011D
85 #define AXE_CMD_READ_GPIO 0x101E
86 #define AXE_CMD_WRITE_GPIO 0x011F
88 #define AXE_MEDIA_FULL_DUPLEX 0x02
89 #define AXE_MEDIA_TX_ABORT_ALLOW 0x04
90 #define AXE_MEDIA_FLOW_CONTROL_EN 0x10
92 #define AXE_RXCMD_PROMISC 0x0001
93 #define AXE_RXCMD_ALLMULTI 0x0002
94 #define AXE_RXCMD_UNICAST 0x0004
95 #define AXE_RXCMD_BROADCAST 0x0008
96 #define AXE_RXCMD_MULTICAST 0x0010
97 #define AXE_RXCMD_ENABLE 0x0080
99 #define AXE_NOPHY 0xE0
101 #define AXE_TIMEOUT 1000
102 #define AXE_BUFSZ 1536
103 #define AXE_MIN_FRAMELEN 60
104 #define AXE_RX_FRAMES 1
105 #define AXE_TX_FRAMES 1
107 #define AXE_RX_LIST_CNT 1
108 #define AXE_TX_LIST_CNT 1
110 #define AXE_CTL_READ 0x01
111 #define AXE_CTL_WRITE 0x02
113 #define AXE_CONFIG_NO 1
114 #define AXE_IFACE_IDX 0
117 * The interrupt endpoint is currently unused
120 #define AXE_ENDPT_RX 0x0
121 #define AXE_ENDPT_TX 0x1
122 #define AXE_ENDPT_INTR 0x2
123 #define AXE_ENDPT_MAX 0x3
126 struct usb_devno axe_dev
;
128 /* XXX No flags so far */
134 struct axe_softc
*axe_sc
;
135 usbd_xfer_handle axe_xfer
;
137 struct mbuf
*axe_mbuf
;
143 struct axe_chain axe_tx_chain
[AXE_TX_LIST_CNT
];
144 struct axe_chain axe_rx_chain
[AXE_RX_LIST_CNT
];
151 #define AXE_INC(x, y) (x) = (x + 1) % y
155 struct ethercom axe_ec
;
156 struct mii_data axe_mii
;
158 rndsource_element_t rnd_source
;
160 #define GET_IFP(sc) (&(sc)->axe_ec.ec_if)
161 #define GET_MII(sc) (&(sc)->axe_mii)
162 usbd_device_handle axe_udev
;
163 usbd_interface_handle axe_iface
;
165 u_int16_t axe_vendor
;
166 u_int16_t axe_product
;
168 int axe_ed
[AXE_ENDPT_MAX
];
169 usbd_pipe_handle axe_ep
[AXE_ENDPT_MAX
];
171 struct axe_cdata axe_cdata
;
172 struct callout axe_stat_ch
;
178 struct usb_task axe_tick_task
;
179 struct usb_task axe_stop_task
;
181 kmutex_t axe_mii_lock
;
183 unsigned char axe_ipgs
[3];
184 unsigned char axe_phyaddrs
[2];
185 struct timeval axe_rx_notice
;
189 #define AXE_LOCK(_sc) mtx_lock(&(_sc)->axe_mtx)
190 #define AXE_UNLOCK(_sc) mtx_unlock(&(_sc)->axe_mtx)
192 #define AXE_LOCK(_sc)
193 #define AXE_UNLOCK(_sc)
196 #define ETHER_ALIGN 2