mii.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 FILE_LICENCE ( GPL2_ONLY );
00014
00015 #ifndef _MII_H_
00016 #define _MII_H_
00017
00018
00019
00020 #define MII_BMCR 0x00
00021 #define MII_BMSR 0x01
00022 #define MII_PHYSID1 0x02
00023 #define MII_PHYSID2 0x03
00024 #define MII_ADVERTISE 0x04
00025 #define MII_LPA 0x05
00026 #define MII_EXPANSION 0x06
00027 #define MII_CTRL1000 0x09
00028 #define MII_STAT1000 0x0a
00029 #define MII_ESTATUS 0x0f
00030 #define MII_DCOUNTER 0x12
00031 #define MII_FCSCOUNTER 0x13
00032 #define MII_NWAYTEST 0x14
00033 #define MII_RERRCOUNTER 0x15
00034 #define MII_SREVISION 0x16
00035 #define MII_RESV1 0x17
00036 #define MII_LBRERROR 0x18
00037 #define MII_PHYADDR 0x19
00038 #define MII_RESV2 0x1a
00039 #define MII_TPISTATUS 0x1b
00040 #define MII_NCONFIG 0x1c
00041
00042
00043 #define BMCR_RESV 0x003f
00044 #define BMCR_SPEED1000 0x0040
00045 #define BMCR_CTST 0x0080
00046 #define BMCR_FULLDPLX 0x0100
00047 #define BMCR_ANRESTART 0x0200
00048 #define BMCR_ISOLATE 0x0400
00049 #define BMCR_PDOWN 0x0800
00050 #define BMCR_ANENABLE 0x1000
00051 #define BMCR_SPEED100 0x2000
00052 #define BMCR_LOOPBACK 0x4000
00053 #define BMCR_RESET 0x8000
00054
00055
00056 #define BMSR_ERCAP 0x0001
00057 #define BMSR_JCD 0x0002
00058 #define BMSR_LSTATUS 0x0004
00059 #define BMSR_ANEGCAPABLE 0x0008
00060 #define BMSR_RFAULT 0x0010
00061 #define BMSR_ANEGCOMPLETE 0x0020
00062 #define BMSR_RESV 0x00c0
00063 #define BMSR_ESTATEN 0x0100
00064 #define BMSR_100HALF2 0x0200
00065 #define BMSR_100FULL2 0x0400
00066 #define BMSR_10HALF 0x0800
00067 #define BMSR_10FULL 0x1000
00068 #define BMSR_100HALF 0x2000
00069 #define BMSR_100FULL 0x4000
00070 #define BMSR_100BASE4 0x8000
00071
00072
00073 #define ADVERTISE_SLCT 0x001f
00074 #define ADVERTISE_CSMA 0x0001
00075 #define ADVERTISE_10HALF 0x0020
00076 #define ADVERTISE_1000XFULL 0x0020
00077 #define ADVERTISE_10FULL 0x0040
00078 #define ADVERTISE_1000XHALF 0x0040
00079 #define ADVERTISE_100HALF 0x0080
00080 #define ADVERTISE_1000XPAUSE 0x0080
00081 #define ADVERTISE_100FULL 0x0100
00082 #define ADVERTISE_1000XPSE_ASYM 0x0100
00083 #define ADVERTISE_100BASE4 0x0200
00084 #define ADVERTISE_PAUSE_CAP 0x0400
00085 #define ADVERTISE_PAUSE_ASYM 0x0800
00086 #define ADVERTISE_RESV 0x1000
00087 #define ADVERTISE_RFAULT 0x2000
00088 #define ADVERTISE_LPACK 0x4000
00089 #define ADVERTISE_NPAGE 0x8000
00090
00091 #define ADVERTISE_FULL (ADVERTISE_100FULL | ADVERTISE_10FULL | \
00092 ADVERTISE_CSMA)
00093 #define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \
00094 ADVERTISE_100HALF | ADVERTISE_100FULL)
00095
00096
00097 #define LPA_SLCT 0x001f
00098 #define LPA_10HALF 0x0020
00099 #define LPA_1000XFULL 0x0020
00100 #define LPA_10FULL 0x0040
00101 #define LPA_1000XHALF 0x0040
00102 #define LPA_100HALF 0x0080
00103 #define LPA_1000XPAUSE 0x0080
00104 #define LPA_100FULL 0x0100
00105 #define LPA_1000XPAUSE_ASYM 0x0100
00106 #define LPA_100BASE4 0x0200
00107 #define LPA_PAUSE_CAP 0x0400
00108 #define LPA_PAUSE_ASYM 0x0800
00109 #define LPA_RESV 0x1000
00110 #define LPA_RFAULT 0x2000
00111 #define LPA_LPACK 0x4000
00112 #define LPA_NPAGE 0x8000
00113
00114 #define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
00115 #define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
00116
00117
00118 #define EXPANSION_NWAY 0x0001
00119 #define EXPANSION_LCWP 0x0002
00120 #define EXPANSION_ENABLENPAGE 0x0004
00121 #define EXPANSION_NPCAPABLE 0x0008
00122 #define EXPANSION_MFAULTS 0x0010
00123 #define EXPANSION_RESV 0xffe0
00124
00125 #define ESTATUS_1000_TFULL 0x2000
00126 #define ESTATUS_1000_THALF 0x1000
00127
00128
00129 #define NWAYTEST_RESV1 0x00ff
00130 #define NWAYTEST_LOOPBACK 0x0100
00131 #define NWAYTEST_RESV2 0xfe00
00132
00133
00134 #define ADVERTISE_1000FULL 0x0200
00135 #define ADVERTISE_1000HALF 0x0100
00136
00137
00138 #define LPA_1000LOCALRXOK 0x2000
00139 #define LPA_1000REMRXOK 0x1000
00140 #define LPA_1000FULL 0x0800
00141 #define LPA_1000HALF 0x0400
00142
00143 #include <gpxe/netdevice.h>
00144
00145 struct mii_if_info {
00146 int phy_id;
00147 int advertising;
00148 int phy_id_mask;
00149 int reg_num_mask;
00150
00151 unsigned int full_duplex : 1;
00152 unsigned int force_media : 1;
00153 unsigned int supports_gmii : 1;
00154
00155 struct net_device *dev;
00156 int (*mdio_read) (struct net_device *dev, int phy_id, int location);
00157 void (*mdio_write) (struct net_device *dev, int phy_id, int location, int val);
00158 };
00159
00160
00161 extern int mii_link_ok (struct mii_if_info *mii);
00162 extern void mii_check_link (struct mii_if_info *mii);
00163 extern unsigned int mii_check_media (struct mii_if_info *mii,
00164 unsigned int ok_to_print,
00165 unsigned int init_media);
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 static inline unsigned int mii_nway_result (unsigned int negotiated)
00183 {
00184 unsigned int ret;
00185
00186 if (negotiated & LPA_100FULL)
00187 ret = LPA_100FULL;
00188 else if (negotiated & LPA_100BASE4)
00189 ret = LPA_100BASE4;
00190 else if (negotiated & LPA_100HALF)
00191 ret = LPA_100HALF;
00192 else if (negotiated & LPA_10FULL)
00193 ret = LPA_10FULL;
00194 else
00195 ret = LPA_10HALF;
00196
00197 return ret;
00198 }
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 static inline unsigned int mii_duplex (unsigned int duplex_lock,
00210 unsigned int negotiated)
00211 {
00212 if (duplex_lock)
00213 return 1;
00214 if (mii_nway_result(negotiated) & LPA_DUPLEX)
00215 return 1;
00216 return 0;
00217 }
00218
00219 #endif