2 * Copyright (c) 1997, 1998, 1999, 2000-2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
36 * Definitions for the ASIX Electronics AX88172 to ethernet controller.
41 * Vendor specific commands
42 * ASIX conveniently doesn't document the 'set NODEID' command in their
43 * datasheet (thanks a lot guys).
44 * To make handling these commands easier, I added some extra data
45 * which is decided by the axe_cmd() routine. Commands are encoded
46 * in 16 bites, with the format: LDCC. L and D are both nibbles in
47 * the high byte. L represents the data length (0 to 15) and D
48 * represents the direction (0 for vendor read, 1 for vendor write).
49 * CC is the command byte, as specified in the manual.
52 #define AXE_CMD_DIR(x) (((x) & 0x0F00) >> 8)
53 #define AXE_CMD_LEN(x) (((x) & 0xF000) >> 12)
54 #define AXE_CMD_CMD(x) ((x) & 0x00FF)
56 #define AXE_CMD_READ_RXTX_SRAM 0x2002
57 #define AXE_CMD_WRITE_RX_SRAM 0x0103
58 #define AXE_CMD_WRITE_TX_SRAM 0x0104
59 #define AXE_CMD_MII_OPMODE_SW 0x0106
60 #define AXE_CMD_MII_READ_REG 0x2007
61 #define AXE_CMD_MII_WRITE_REG 0x2108
62 #define AXE_CMD_MII_READ_OPMODE 0x1009
63 #define AXE_CMD_MII_OPMODE_HW 0x010A
64 #define AXE_CMD_SROM_READ 0x200B
65 #define AXE_CMD_SROM_WRITE 0x010C
66 #define AXE_CMD_SROM_WR_ENABLE 0x010D
67 #define AXE_CMD_SROM_WR_DISABLE 0x010E
68 #define AXE_CMD_RXCTL_READ 0x200F
69 #define AXE_CMD_RXCTL_WRITE 0x0110
70 #define AXE_CMD_READ_IPG012 0x3011
71 #define AXE_CMD_WRITE_IPG0 0x0112
72 #define AXE_CMD_WRITE_IPG1 0x0113
73 #define AXE_CMD_WRITE_IPG2 0x0114
74 #define AXE_CMD_READ_MCAST 0x8015
75 #define AXE_CMD_WRITE_MCAST 0x8116
76 #define AXE_CMD_READ_NODEID 0x6017
77 #define AXE_CMD_WRITE_NODEID 0x6118
78 #define AXE_CMD_READ_PHYID 0x2019
79 #define AXE_CMD_READ_MEDIA 0x101A
80 #define AXE_CMD_WRITE_MEDIA 0x011B
81 #define AXE_CMD_READ_MONITOR_MODE 0x101C
82 #define AXE_CMD_WRITE_MONITOR_MODE 0x011D
83 #define AXE_CMD_READ_GPIO 0x101E
84 #define AXE_CMD_WRITE_GPIO 0x011F
86 #define AXE_RXCMD_PROMISC 0x0001
87 #define AXE_RXCMD_ALLMULTI 0x0002
88 #define AXE_RXCMD_UNICAST 0x0004
89 #define AXE_RXCMD_BROADCAST 0x0008
90 #define AXE_RXCMD_MULTICAST 0x0010
91 #define AXE_RXCMD_ENABLE 0x0080
93 #define AXE_NOPHY 0xE0
95 #define AXE_TIMEOUT 1000
96 #define AXE_MIN_FRAMELEN 60
97 #define AXE_RX_FRAMES 1
98 #define AXE_TX_FRAMES 1
100 #define AXE_CTL_READ 0x01
101 #define AXE_CTL_WRITE 0x02
103 #define AXE_CONFIG_NO 1
104 #define AXE_IFACE_IDX 0
107 * The interrupt endpoint is currently unused
110 #define AXE_ENDPT_RX 0x0
111 #define AXE_ENDPT_TX 0x1
112 #define AXE_ENDPT_INTR 0x2
113 #define AXE_ENDPT_MAX 0x3
120 #define AXE_INC(x, y) (x) = (x + 1) % y
123 #if defined(__FreeBSD__)
124 #define GET_MII(sc) (device_get_softc((sc)->axe_miibus))
125 #elif defined(__NetBSD__)
126 #define GET_MII(sc) (&(sc)->axe_mii)
127 #elif defined(__OpenBSD__)
128 #define GET_MII(sc) (&(sc)->axe_mii)
130 struct ifnet *axe_ifp;
133 usbd_device_handle axe_udev;
134 usbd_interface_handle axe_iface;
135 int axe_ed[AXE_ENDPT_MAX];
136 usbd_pipe_handle axe_ep[AXE_ENDPT_MAX];
139 struct ue_cdata axe_cdata;
140 struct callout_handle axe_stat_ch;
141 #if __FreeBSD_version >= 500000
146 unsigned char axe_ipgs[3];
147 unsigned char axe_phyaddrs[2];
148 struct timeval axe_rx_notice;
149 struct usb_qdat axe_qdat;
153 #define AXE_LOCK(_sc) mtx_lock(&(_sc)->axe_mtx)
154 #define AXE_UNLOCK(_sc) mtx_unlock(&(_sc)->axe_mtx)
156 #define AXE_LOCK(_sc)
157 #define AXE_UNLOCK(_sc)