Merge from vendor branch BINUTILS:
[dragonfly.git] / sys / dev / netif / mii_layer / mii.h
1 /*      $NetBSD: mii.h,v 1.1 1998/08/10 23:55:17 thorpej Exp $  */
2  
3 /*
4  * Copyright (c) 1997 Manuel Bouyer.  All rights reserved.
5  *
6  * Modification to match BSD/OS 3.0 MII interface by Jason R. Thorpe,
7  * Numerical Aerospace Simulation Facility, NASA Ames Research Center.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by Manuel Bouyer.
20  * 4. The name of the author may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $FreeBSD: src/sys/dev/mii/mii.h,v 1.2 1999/08/28 00:42:14 peter Exp $
35  * $DragonFly: src/sys/dev/netif/mii_layer/mii.h,v 1.3 2005/10/12 00:57:41 dillon Exp $
36  */
37
38 #ifndef _DEV_MII_MII_H_
39 #define _DEV_MII_MII_H_
40
41 /*
42  * Registers common to all PHYs.
43  */
44
45 #define MII_NPHY        32      /* max # of PHYs per MII */
46
47 /*
48  * MII commands, used if a device must drive the MII lines
49  * manually.
50  */
51 #define MII_COMMAND_START       0x01
52 #define MII_COMMAND_READ        0x02
53 #define MII_COMMAND_WRITE       0x01
54 #define MII_COMMAND_ACK         0x02
55
56 /*
57  * MII registers are bits
58  *
59  * note 1: Most adapters seem to have adopted these bits for GigE support,
60  *         but they have not been verified against any standard.  
61  *         Theoretically the speed select will extend to 10GigE as well.
62  *
63  *         The netgear GigE switch reports both the bits I have labeled
64  *         ANLPAR_1000 and ANLPAR_1000_FD, but it is unclear what they mean
65  *         other then probably being related to GigE.
66  */
67 #define MII_BMCR        0x00    /* Basic mode control register (rw) */
68 #define BMCR_RESET      0x8000  /* reset */
69 #define BMCR_LOOP       0x4000  /* loopback */
70 #define BMCR_S100       0x2000  /* speed (10/100) select (low bit) */
71 #define BMCR_AUTOEN     0x1000  /* autonegotiation enable */
72 #define BMCR_PDOWN      0x0800  /* power down */
73 #define BMCR_ISO        0x0400  /* isolate */
74 #define BMCR_STARTNEG   0x0200  /* restart autonegotiation */
75 #define BMCR_FDX        0x0100  /* Set duplex mode */
76 #define BMCR_CTEST      0x0080  /* collision test */
77 #define BMCR_S1000      0x0040  /* speed select (high bit) (note 1) */
78
79 #define MII_BMSR        0x01    /* Basic mode status register (ro) */
80 #define BMSR_100T4      0x8000  /* 100 base T4 capable */
81 #define BMSR_100TXFDX   0x4000  /* 100 base Tx full duplex capable */
82 #define BMSR_100TXHDX   0x2000  /* 100 base Tx half duplex capable */
83 #define BMSR_10TFDX     0x1000  /* 10 base T full duplex capable */
84 #define BMSR_10THDX     0x0800  /* 10 base T half duplex capable */
85 #define BMSR_1000       0x0100  /* 1000baseT extended status present */
86 #define BMSR_ACOMP      0x0020  /* Autonegotiation complete */
87 #define BMSR_RFAULT     0x0010  /* Link partner fault */
88 #define BMSR_ANEG       0x0008  /* Autonegotiation capable */
89 #define BMSR_LINK       0x0004  /* Link status */
90 #define BMSR_JABBER     0x0002  /* Jabber detected */
91 #define BMSR_EXT        0x0001  /* Extended capability */
92
93 #define BMSR_MEDIAMASK  (BMSR_100T4|BMSR_100TXFDX|BMSR_100TXHDX|BMSR_10TFDX| \
94                          BMSR_10THDX|BMSR_1000|BMSR_ANEG)
95
96 #define MII_PHYIDR1     0x02    /* ID register 1 (ro) */
97
98 #define MII_PHYIDR2     0x03    /* ID register 2 (ro) */
99 #define IDR2_OUILSB     0xfc00  /* OUI LSB */
100 #define IDR2_MODEL      0x03f0  /* vendor model */
101 #define IDR2_REV        0x000f  /* vendor revision */
102
103 #define MII_OUI(id1, id2)       (((id1) << 6) | ((id2) >> 10))
104 #define MII_MODEL(id2)          (((id2) & IDR2_MODEL) >> 4)
105 #define MII_REV(id2)            ((id2) & IDR2_REV)
106
107 #define MII_ANAR        0x04    /* Autonegotiation advertisement (rw) */
108 #define ANAR_NP         0x8000  /* Next page (ro) */
109 #define ANAR_ACK        0x4000  /* link partner abilities acknowledged (ro) */
110 #define ANAR_RF         0x2000  /* remote fault (ro) */
111 #define ANAR_1000_FD    0x0800  /* local device supports GigE/FD (note 1) */
112 #define ANAR_1000       0x0400  /* local device supports GigE    (note 1) */
113 #define ANAR_T4         0x0200  /* local device supports 100bT4 */
114 #define ANAR_TX_FD      0x0100  /* local device supports 100bTx FD */
115 #define ANAR_TX         0x0080  /* local device supports 100bTx */
116 #define ANAR_10_FD      0x0040  /* local device supports 10bT FD */
117 #define ANAR_10         0x0020  /* local device supports 10bT */
118 #define ANAR_CSMA       0x0001  /* protocol selector CSMA/CD */
119
120 #define MII_ANLPAR      0x05    /* Autonegotiation lnk partner abilities (rw) */
121 #define ANLPAR_NP       0x8000  /* Next page (ro) */
122 #define ANLPAR_ACK      0x4000  /* link partner accepted ACK (ro) */
123 #define ANLPAR_RF       0x2000  /* remote fault (ro) */
124 #define ANLPAR_1000_FD  0x0800  /* link partner supports GigE/FD (note 1) */
125 #define ANLPAR_1000     0x0400  /* link partner supports GigE    (note 1) */
126 #define ANLPAR_T4       0x0200  /* link partner supports 100bT4 */
127 #define ANLPAR_TX_FD    0x0100  /* link partner supports 100bTx FD */
128 #define ANLPAR_TX       0x0080  /* link partner supports 100bTx */
129 #define ANLPAR_10_FD    0x0040  /* link partner supports 10bT FD */
130 #define ANLPAR_10       0x0020  /* link partner supports 10bT */
131 #define ANLPAR_CSMA     0x0001  /* protocol selector CSMA/CD */
132
133 #define MII_ANER        0x06    /* Autonegotiation expansion (ro) */
134 #define ANER_MLF        0x0010  /* multiple link detection fault */
135 #define ANER_LPNP       0x0008  /* link parter next page-able */
136 #define ANER_NP         0x0004  /* next page-able */
137 #define ANER_PAGE_RX    0x0002  /* Page received */
138 #define ANER_LPAN       0x0001  /* link parter autoneg-able */
139
140 #endif /* _DEV_MII_MII_H_ */