Home | History | Annotate | Line # | Download | only in mii
mii.h revision 1.7
      1  1.7     matt /*	$NetBSD: mii.h,v 1.7 2001/05/15 23:16:40 matt Exp $	*/
      2  1.1  thorpej 
      3  1.1  thorpej /*
      4  1.1  thorpej  * Copyright (c) 1997 Manuel Bouyer.  All rights reserved.
      5  1.1  thorpej  *
      6  1.1  thorpej  * Modification to match BSD/OS 3.0 MII interface by Jason R. Thorpe,
      7  1.1  thorpej  * Numerical Aerospace Simulation Facility, NASA Ames Research Center.
      8  1.1  thorpej  *
      9  1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     10  1.1  thorpej  * modification, are permitted provided that the following conditions
     11  1.1  thorpej  * are met:
     12  1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     13  1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     14  1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     16  1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     17  1.1  thorpej  * 3. All advertising materials mentioning features or use of this software
     18  1.1  thorpej  *    must display the following acknowledgement:
     19  1.1  thorpej  *	This product includes software developed by Manuel Bouyer.
     20  1.1  thorpej  * 4. The name of the author may not be used to endorse or promote products
     21  1.1  thorpej  *    derived from this software without specific prior written permission.
     22  1.1  thorpej  *
     23  1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24  1.1  thorpej  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  1.1  thorpej  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  1.1  thorpej  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27  1.1  thorpej  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28  1.1  thorpej  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29  1.1  thorpej  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30  1.1  thorpej  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31  1.1  thorpej  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32  1.1  thorpej  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33  1.1  thorpej  */
     34  1.1  thorpej 
     35  1.1  thorpej #ifndef _DEV_MII_MII_H_
     36  1.1  thorpej #define	_DEV_MII_MII_H_
     37  1.1  thorpej 
     38  1.1  thorpej /*
     39  1.1  thorpej  * Registers common to all PHYs.
     40  1.1  thorpej  */
     41  1.1  thorpej 
     42  1.1  thorpej #define	MII_NPHY	32	/* max # of PHYs per MII */
     43  1.1  thorpej 
     44  1.1  thorpej /*
     45  1.1  thorpej  * MII commands, used if a device must drive the MII lines
     46  1.1  thorpej  * manually.
     47  1.1  thorpej  */
     48  1.1  thorpej #define	MII_COMMAND_START	0x01
     49  1.1  thorpej #define	MII_COMMAND_READ	0x02
     50  1.1  thorpej #define	MII_COMMAND_WRITE	0x01
     51  1.1  thorpej #define	MII_COMMAND_ACK		0x02
     52  1.1  thorpej 
     53  1.1  thorpej #define	MII_BMCR	0x00 	/* Basic mode control register (rw) */
     54  1.1  thorpej #define	BMCR_RESET	0x8000	/* reset */
     55  1.1  thorpej #define	BMCR_LOOP	0x4000	/* loopback */
     56  1.5  thorpej #define	BMCR_SPEED0	0x2000	/* speed selection (LSB) */
     57  1.1  thorpej #define	BMCR_AUTOEN	0x1000	/* autonegotiation enable */
     58  1.1  thorpej #define	BMCR_PDOWN	0x0800	/* power down */
     59  1.1  thorpej #define	BMCR_ISO	0x0400	/* isolate */
     60  1.1  thorpej #define	BMCR_STARTNEG	0x0200	/* restart autonegotiation */
     61  1.1  thorpej #define	BMCR_FDX	0x0100	/* Set duplex mode */
     62  1.1  thorpej #define	BMCR_CTEST	0x0080	/* collision test */
     63  1.5  thorpej #define	BMCR_SPEED1	0x0040	/* speed selection (MSB) */
     64  1.5  thorpej 
     65  1.5  thorpej #define	BMCR_S10	0x0000		/* 10 Mb/s */
     66  1.5  thorpej #define	BMCR_S100	BMCR_SPEED0	/* 100 Mb/s */
     67  1.5  thorpej #define	BMCR_S1000	BMCR_SPEED1	/* 1000 Mb/s */
     68  1.5  thorpej 
     69  1.5  thorpej #define	BMCR_SPEED(x)	((x) & (BMCR_SPEED0|BMCR_SPEED1))
     70  1.1  thorpej 
     71  1.1  thorpej #define	MII_BMSR	0x01	/* Basic mode status register (ro) */
     72  1.1  thorpej #define	BMSR_100T4	0x8000	/* 100 base T4 capable */
     73  1.1  thorpej #define	BMSR_100TXFDX	0x4000	/* 100 base Tx full duplex capable */
     74  1.1  thorpej #define	BMSR_100TXHDX	0x2000	/* 100 base Tx half duplex capable */
     75  1.1  thorpej #define	BMSR_10TFDX	0x1000	/* 10 base T full duplex capable */
     76  1.1  thorpej #define	BMSR_10THDX	0x0800	/* 10 base T half duplex capable */
     77  1.5  thorpej #define	BMSR_100T2FDX	0x0400	/* 100 base T2 full duplex capable */
     78  1.5  thorpej #define	BMSR_100T2HDX	0x0200	/* 100 base T2 half duplex capable */
     79  1.7     matt #define	BMSR_EXTSTAT	0x0100	/* Extended status in register 15 */
     80  1.3  thorpej #define	BMSR_MFPS	0x0040	/* MII Frame Preamble Suppression */
     81  1.1  thorpej #define	BMSR_ACOMP	0x0020	/* Autonegotiation complete */
     82  1.1  thorpej #define	BMSR_RFAULT	0x0010	/* Link partner fault */
     83  1.1  thorpej #define	BMSR_ANEG	0x0008	/* Autonegotiation capable */
     84  1.1  thorpej #define	BMSR_LINK	0x0004	/* Link status */
     85  1.1  thorpej #define	BMSR_JABBER	0x0002	/* Jabber detected */
     86  1.5  thorpej #define	BMSR_EXTCAP	0x0001	/* Extended capability */
     87  1.5  thorpej 
     88  1.5  thorpej /*
     89  1.5  thorpej  * Note that the EXTSTAT bit indicates that there is extended status
     90  1.5  thorpej  * info available in register 15, but 802.3 section 22.2.4.3 also
     91  1.5  thorpej  * states that that all 1000 Mb/s capable PHYs will set this bit to 1.
     92  1.5  thorpej  */
     93  1.1  thorpej 
     94  1.5  thorpej #define	BMSR_MEDIAMASK	(BMSR_100T4|BMSR_100TXFDX|BMSR_100TXHDX| \
     95  1.5  thorpej 			 BMSR_10TFDX|BMSR_10THDX|BMSR_100T2FDX|BMSR_100T2HDX)
     96  1.1  thorpej 
     97  1.1  thorpej /*
     98  1.1  thorpej  * Convert BMSR media capabilities to ANAR bits for autonegotiation.
     99  1.1  thorpej  * Note the shift chopps off the BMSR_ANEG bit.
    100  1.1  thorpej  */
    101  1.1  thorpej #define	BMSR_MEDIA_TO_ANAR(x)	(((x) & BMSR_MEDIAMASK) >> 6)
    102  1.1  thorpej 
    103  1.1  thorpej #define	MII_PHYIDR1	0x02	/* ID register 1 (ro) */
    104  1.1  thorpej 
    105  1.1  thorpej #define	MII_PHYIDR2	0x03	/* ID register 2 (ro) */
    106  1.1  thorpej #define	IDR2_OUILSB	0xfc00	/* OUI LSB */
    107  1.1  thorpej #define	IDR2_MODEL	0x03f0	/* vendor model */
    108  1.1  thorpej #define	IDR2_REV	0x000f	/* vendor revision */
    109  1.1  thorpej 
    110  1.1  thorpej #define	MII_ANAR	0x04	/* Autonegotiation advertisement (rw) */
    111  1.5  thorpej 		/* section 28.2.4.1 and 37.2.6.1 */
    112  1.1  thorpej #define ANAR_NP		0x8000	/* Next page (ro) */
    113  1.1  thorpej #define	ANAR_ACK	0x4000	/* link partner abilities acknowledged (ro) */
    114  1.1  thorpej #define ANAR_RF		0x2000	/* remote fault (ro) */
    115  1.2  thorpej #define	ANAR_FC		0x0400	/* local device supports PAUSE */
    116  1.1  thorpej #define ANAR_T4		0x0200	/* local device supports 100bT4 */
    117  1.1  thorpej #define ANAR_TX_FD	0x0100	/* local device supports 100bTx FD */
    118  1.1  thorpej #define ANAR_TX		0x0080	/* local device supports 100bTx */
    119  1.1  thorpej #define ANAR_10_FD	0x0040	/* local device supports 10bT FD */
    120  1.1  thorpej #define ANAR_10		0x0020	/* local device supports 10bT */
    121  1.1  thorpej #define	ANAR_CSMA	0x0001	/* protocol selector CSMA/CD */
    122  1.1  thorpej 
    123  1.1  thorpej #define	MII_ANLPAR	0x05	/* Autonegotiation lnk partner abilities (rw) */
    124  1.5  thorpej 		/* section 28.2.4.1 and 37.2.6.1 */
    125  1.1  thorpej #define ANLPAR_NP	0x8000	/* Next page (ro) */
    126  1.1  thorpej #define	ANLPAR_ACK	0x4000	/* link partner accepted ACK (ro) */
    127  1.1  thorpej #define ANLPAR_RF	0x2000	/* remote fault (ro) */
    128  1.2  thorpej #define	ANLPAR_FC	0x0400	/* link partner supports PAUSE */
    129  1.1  thorpej #define ANLPAR_T4	0x0200	/* link partner supports 100bT4 */
    130  1.1  thorpej #define ANLPAR_TX_FD	0x0100	/* link partner supports 100bTx FD */
    131  1.1  thorpej #define ANLPAR_TX	0x0080	/* link partner supports 100bTx */
    132  1.1  thorpej #define ANLPAR_10_FD	0x0040	/* link partner supports 10bT FD */
    133  1.1  thorpej #define ANLPAR_10	0x0020	/* link partner supports 10bT */
    134  1.1  thorpej #define	ANLPAR_CSMA	0x0001	/* protocol selector CSMA/CD */
    135  1.1  thorpej 
    136  1.1  thorpej #define	MII_ANER	0x06	/* Autonegotiation expansion (ro) */
    137  1.5  thorpej 		/* section 28.2.4.1 and 37.2.6.1 */
    138  1.1  thorpej #define ANER_MLF	0x0010	/* multiple link detection fault */
    139  1.1  thorpej #define ANER_LPNP	0x0008	/* link parter next page-able */
    140  1.1  thorpej #define ANER_NP		0x0004	/* next page-able */
    141  1.1  thorpej #define ANER_PAGE_RX	0x0002	/* Page received */
    142  1.1  thorpej #define ANER_LPAN	0x0001	/* link parter autoneg-able */
    143  1.5  thorpej 
    144  1.5  thorpej #define	MII_ANNP	0x07	/* Autonegotiation next page */
    145  1.5  thorpej 		/* section 28.2.4.1 and 37.2.6.1 */
    146  1.5  thorpej 
    147  1.5  thorpej #define	MII_ANLPRNP	0x08	/* Autonegotiation link partner rx next page */
    148  1.5  thorpej 		/* section 32.5.1 and 37.2.6.1 */
    149  1.5  thorpej 
    150  1.5  thorpej #define	MII_100T2CR	0x09	/* 100base-T2 control register */
    151  1.5  thorpej 
    152  1.5  thorpej #define	MII_100T2SR	0x0a	/* 100base-T2 status register */
    153  1.5  thorpej 
    154  1.5  thorpej #define	MII_EXTSR	0x0f	/* Extended status register */
    155  1.5  thorpej #define	EXTSR_1000XFDX	0x8000	/* 1000X full-duplex capable */
    156  1.5  thorpej #define	EXTSR_1000XHDX	0x4000	/* 1000X half-duplex capable */
    157  1.5  thorpej #define	EXTSR_1000TFDX	0x2000	/* 1000T full-duplex capable */
    158  1.5  thorpej #define	EXTSR_1000THDX	0x1000	/* 1000T half-duplex capable */
    159  1.6  thorpej 
    160  1.6  thorpej #define	EXTSR_MEDIAMASK	(EXTSR_1000XFDX|EXTSR_1000XHDX| \
    161  1.6  thorpej 			 EXTSR_1000TFDX|EXTSR_1000THDX)
    162  1.1  thorpej 
    163  1.1  thorpej #endif /* _DEV_MII_MII_H_ */
    164