1f9f848faSopenharmony_ci/* $NetBSD: mii.h,v 1.18 2014/06/16 14:43:22 msaitoh Exp $ */ 2f9f848faSopenharmony_ci 3f9f848faSopenharmony_ci/*- 4f9f848faSopenharmony_ci * SPDX-License-Identifier: BSD-2-Clause 5f9f848faSopenharmony_ci * 6f9f848faSopenharmony_ci * Copyright (c) 1997 Manuel Bouyer. All rights reserved. 7f9f848faSopenharmony_ci * 8f9f848faSopenharmony_ci * Modification to match BSD/OS 3.0 MII interface by Jason R. Thorpe, 9f9f848faSopenharmony_ci * Numerical Aerospace Simulation Facility, NASA Ames Research Center. 10f9f848faSopenharmony_ci * 11f9f848faSopenharmony_ci * Redistribution and use in source and binary forms, with or without 12f9f848faSopenharmony_ci * modification, are permitted provided that the following conditions 13f9f848faSopenharmony_ci * are met: 14f9f848faSopenharmony_ci * 1. Redistributions of source code must retain the above copyright 15f9f848faSopenharmony_ci * notice, this list of conditions and the following disclaimer. 16f9f848faSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 17f9f848faSopenharmony_ci * notice, this list of conditions and the following disclaimer in the 18f9f848faSopenharmony_ci * documentation and/or other materials provided with the distribution. 19f9f848faSopenharmony_ci * 20f9f848faSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21f9f848faSopenharmony_ci * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22f9f848faSopenharmony_ci * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23f9f848faSopenharmony_ci * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24f9f848faSopenharmony_ci * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25f9f848faSopenharmony_ci * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26f9f848faSopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27f9f848faSopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28f9f848faSopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29f9f848faSopenharmony_ci * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30f9f848faSopenharmony_ci */ 31f9f848faSopenharmony_ci 32f9f848faSopenharmony_ci#ifndef _DEV_MII_MII_H_ 33f9f848faSopenharmony_ci#define _DEV_MII_MII_H_ 34f9f848faSopenharmony_ci 35f9f848faSopenharmony_ci/* 36f9f848faSopenharmony_ci * Registers common to all PHYs. 37f9f848faSopenharmony_ci */ 38f9f848faSopenharmony_ci 39f9f848faSopenharmony_ci#define MII_NPHY 32 /* max # of PHYs per MII */ 40f9f848faSopenharmony_ci 41f9f848faSopenharmony_ci/* 42f9f848faSopenharmony_ci * MII commands, used if a device must drive the MII lines 43f9f848faSopenharmony_ci * manually. 44f9f848faSopenharmony_ci */ 45f9f848faSopenharmony_ci#define MII_COMMAND_START 0x01 46f9f848faSopenharmony_ci#define MII_COMMAND_READ 0x02 47f9f848faSopenharmony_ci#define MII_COMMAND_WRITE 0x01 48f9f848faSopenharmony_ci#define MII_COMMAND_ACK 0x02 49f9f848faSopenharmony_ci 50f9f848faSopenharmony_ci#define MII_BMCR 0x00 /* Basic mode control register (rw) */ 51f9f848faSopenharmony_ci#define BMCR_RESET 0x8000 /* reset */ 52f9f848faSopenharmony_ci#define BMCR_LOOP 0x4000 /* loopback */ 53f9f848faSopenharmony_ci#define BMCR_SPEED0 0x2000 /* speed selection (LSB) */ 54f9f848faSopenharmony_ci#define BMCR_AUTOEN 0x1000 /* autonegotiation enable */ 55f9f848faSopenharmony_ci#define BMCR_PDOWN 0x0800 /* power down */ 56f9f848faSopenharmony_ci#define BMCR_ISO 0x0400 /* isolate */ 57f9f848faSopenharmony_ci#define BMCR_STARTNEG 0x0200 /* restart autonegotiation */ 58f9f848faSopenharmony_ci#define BMCR_FDX 0x0100 /* Set duplex mode */ 59f9f848faSopenharmony_ci#define BMCR_CTEST 0x0080 /* collision test */ 60f9f848faSopenharmony_ci#define BMCR_SPEED1 0x0040 /* speed selection (MSB) */ 61f9f848faSopenharmony_ci 62f9f848faSopenharmony_ci#define BMCR_S10 0x0000 /* 10 Mb/s */ 63f9f848faSopenharmony_ci#define BMCR_S100 BMCR_SPEED0 /* 100 Mb/s */ 64f9f848faSopenharmony_ci#define BMCR_S1000 BMCR_SPEED1 /* 1000 Mb/s */ 65f9f848faSopenharmony_ci 66f9f848faSopenharmony_ci#define BMCR_SPEED(x) ((x) & (BMCR_SPEED0|BMCR_SPEED1)) 67f9f848faSopenharmony_ci 68f9f848faSopenharmony_ci#define MII_BMSR 0x01 /* Basic mode status register (ro) */ 69f9f848faSopenharmony_ci#define BMSR_100T4 0x8000 /* 100 base T4 capable */ 70f9f848faSopenharmony_ci#define BMSR_100TXFDX 0x4000 /* 100 base Tx full duplex capable */ 71f9f848faSopenharmony_ci#define BMSR_100TXHDX 0x2000 /* 100 base Tx half duplex capable */ 72f9f848faSopenharmony_ci#define BMSR_10TFDX 0x1000 /* 10 base T full duplex capable */ 73f9f848faSopenharmony_ci#define BMSR_10THDX 0x0800 /* 10 base T half duplex capable */ 74f9f848faSopenharmony_ci#define BMSR_100T2FDX 0x0400 /* 100 base T2 full duplex capable */ 75f9f848faSopenharmony_ci#define BMSR_100T2HDX 0x0200 /* 100 base T2 half duplex capable */ 76f9f848faSopenharmony_ci#define BMSR_EXTSTAT 0x0100 /* Extended status in register 15 */ 77f9f848faSopenharmony_ci#define BMSR_MFPS 0x0040 /* MII Frame Preamble Suppression */ 78f9f848faSopenharmony_ci#define BMSR_ACOMP 0x0020 /* Autonegotiation complete */ 79f9f848faSopenharmony_ci#define BMSR_RFAULT 0x0010 /* Link partner fault */ 80f9f848faSopenharmony_ci#define BMSR_ANEG 0x0008 /* Autonegotiation capable */ 81f9f848faSopenharmony_ci#define BMSR_LINK 0x0004 /* Link status */ 82f9f848faSopenharmony_ci#define BMSR_JABBER 0x0002 /* Jabber detected */ 83f9f848faSopenharmony_ci#define BMSR_EXTCAP 0x0001 /* Extended capability */ 84f9f848faSopenharmony_ci 85f9f848faSopenharmony_ci#define BMSR_DEFCAPMASK 0xffffffff 86f9f848faSopenharmony_ci 87f9f848faSopenharmony_ci/* 88f9f848faSopenharmony_ci * Note that the EXTSTAT bit indicates that there is extended status 89f9f848faSopenharmony_ci * info available in register 15, but 802.3 section 22.2.4.3 also 90f9f848faSopenharmony_ci * states that all 1000 Mb/s capable PHYs will set this bit to 1. 91f9f848faSopenharmony_ci */ 92f9f848faSopenharmony_ci 93f9f848faSopenharmony_ci#define BMSR_MEDIAMASK (BMSR_100T4|BMSR_100TXFDX|BMSR_100TXHDX| \ 94f9f848faSopenharmony_ci BMSR_10TFDX|BMSR_10THDX|BMSR_100T2FDX|BMSR_100T2HDX) 95f9f848faSopenharmony_ci 96f9f848faSopenharmony_ci/* 97f9f848faSopenharmony_ci * Convert BMSR media capabilities to ANAR bits for autonegotiation. 98f9f848faSopenharmony_ci * Note the shift chopps off the BMSR_ANEG bit. 99f9f848faSopenharmony_ci */ 100f9f848faSopenharmony_ci#define BMSR_MEDIA_TO_ANAR(x) (((x) & BMSR_MEDIAMASK) >> 6) 101f9f848faSopenharmony_ci 102f9f848faSopenharmony_ci#define MII_PHYIDR1 0x02 /* ID register 1 (ro) */ 103f9f848faSopenharmony_ci 104f9f848faSopenharmony_ci#define MII_PHYIDR2 0x03 /* ID register 2 (ro) */ 105f9f848faSopenharmony_ci#define IDR2_OUILSB 0xfc00 /* OUI LSB */ 106f9f848faSopenharmony_ci#define IDR2_MODEL 0x03f0 /* vendor model */ 107f9f848faSopenharmony_ci#define IDR2_REV 0x000f /* vendor revision */ 108f9f848faSopenharmony_ci 109f9f848faSopenharmony_ci#define MII_ANAR 0x04 /* Autonegotiation advertisement (rw) */ 110f9f848faSopenharmony_ci /* section 28.2.4.1 and 37.2.6.1 */ 111f9f848faSopenharmony_ci#define ANAR_NP 0x8000 /* Next page (ro) */ 112f9f848faSopenharmony_ci#define ANAR_ACK 0x4000 /* link partner abilities acknowledged (ro) */ 113f9f848faSopenharmony_ci#define ANAR_RF 0x2000 /* remote fault (ro) */ 114f9f848faSopenharmony_ci /* Annex 28B.2 */ 115f9f848faSopenharmony_ci#define ANAR_FC 0x0400 /* local device supports PAUSE */ 116f9f848faSopenharmony_ci#define ANAR_T4 0x0200 /* local device supports 100bT4 */ 117f9f848faSopenharmony_ci#define ANAR_TX_FD 0x0100 /* local device supports 100bTx FD */ 118f9f848faSopenharmony_ci#define ANAR_TX 0x0080 /* local device supports 100bTx */ 119f9f848faSopenharmony_ci#define ANAR_10_FD 0x0040 /* local device supports 10bT FD */ 120f9f848faSopenharmony_ci#define ANAR_10 0x0020 /* local device supports 10bT */ 121f9f848faSopenharmony_ci#define ANAR_CSMA 0x0001 /* protocol selector CSMA/CD */ 122f9f848faSopenharmony_ci#define ANAR_PAUSE_NONE (0 << 10) 123f9f848faSopenharmony_ci#define ANAR_PAUSE_SYM (1 << 10) 124f9f848faSopenharmony_ci#define ANAR_PAUSE_ASYM (2 << 10) 125f9f848faSopenharmony_ci#define ANAR_PAUSE_TOWARDS (3 << 10) 126f9f848faSopenharmony_ci 127f9f848faSopenharmony_ci /* Annex 28D */ 128f9f848faSopenharmony_ci#define ANAR_X_FD 0x0020 /* local device supports 1000BASE-X FD */ 129f9f848faSopenharmony_ci#define ANAR_X_HD 0x0040 /* local device supports 1000BASE-X HD */ 130f9f848faSopenharmony_ci#define ANAR_X_PAUSE_NONE (0 << 7) 131f9f848faSopenharmony_ci#define ANAR_X_PAUSE_SYM (1 << 7) 132f9f848faSopenharmony_ci#define ANAR_X_PAUSE_ASYM (2 << 7) 133f9f848faSopenharmony_ci#define ANAR_X_PAUSE_TOWARDS (3 << 7) 134f9f848faSopenharmony_ci 135f9f848faSopenharmony_ci#define MII_ANLPAR 0x05 /* Autonegotiation lnk partner abilities (rw) */ 136f9f848faSopenharmony_ci /* section 28.2.4.1 and 37.2.6.1 */ 137f9f848faSopenharmony_ci#define ANLPAR_NP 0x8000 /* Next page (ro) */ 138f9f848faSopenharmony_ci#define ANLPAR_ACK 0x4000 /* link partner accepted ACK (ro) */ 139f9f848faSopenharmony_ci#define ANLPAR_RF 0x2000 /* remote fault (ro) */ 140f9f848faSopenharmony_ci#define ANLPAR_FC 0x0400 /* link partner supports PAUSE */ 141f9f848faSopenharmony_ci#define ANLPAR_T4 0x0200 /* link partner supports 100bT4 */ 142f9f848faSopenharmony_ci#define ANLPAR_TX_FD 0x0100 /* link partner supports 100bTx FD */ 143f9f848faSopenharmony_ci#define ANLPAR_TX 0x0080 /* link partner supports 100bTx */ 144f9f848faSopenharmony_ci#define ANLPAR_10_FD 0x0040 /* link partner supports 10bT FD */ 145f9f848faSopenharmony_ci#define ANLPAR_10 0x0020 /* link partner supports 10bT */ 146f9f848faSopenharmony_ci#define ANLPAR_CSMA 0x0001 /* protocol selector CSMA/CD */ 147f9f848faSopenharmony_ci#define ANLPAR_PAUSE_MASK (3 << 10) 148f9f848faSopenharmony_ci#define ANLPAR_PAUSE_NONE (0 << 10) 149f9f848faSopenharmony_ci#define ANLPAR_PAUSE_SYM (1 << 10) 150f9f848faSopenharmony_ci#define ANLPAR_PAUSE_ASYM (2 << 10) 151f9f848faSopenharmony_ci#define ANLPAR_PAUSE_TOWARDS (3 << 10) 152f9f848faSopenharmony_ci 153f9f848faSopenharmony_ci#define ANLPAR_X_FD 0x0020 /* local device supports 1000BASE-X FD */ 154f9f848faSopenharmony_ci#define ANLPAR_X_HD 0x0040 /* local device supports 1000BASE-X HD */ 155f9f848faSopenharmony_ci#define ANLPAR_X_PAUSE_MASK (3 << 7) 156f9f848faSopenharmony_ci#define ANLPAR_X_PAUSE_NONE (0 << 7) 157f9f848faSopenharmony_ci#define ANLPAR_X_PAUSE_SYM (1 << 7) 158f9f848faSopenharmony_ci#define ANLPAR_X_PAUSE_ASYM (2 << 7) 159f9f848faSopenharmony_ci#define ANLPAR_X_PAUSE_TOWARDS (3 << 7) 160f9f848faSopenharmony_ci 161f9f848faSopenharmony_ci#define MII_ANER 0x06 /* Autonegotiation expansion (ro) */ 162f9f848faSopenharmony_ci /* section 28.2.4.1 and 37.2.6.1 */ 163f9f848faSopenharmony_ci#define ANER_MLF 0x0010 /* multiple link detection fault */ 164f9f848faSopenharmony_ci#define ANER_LPNP 0x0008 /* link parter next page-able */ 165f9f848faSopenharmony_ci#define ANER_NP 0x0004 /* next page-able */ 166f9f848faSopenharmony_ci#define ANER_PAGE_RX 0x0002 /* Page received */ 167f9f848faSopenharmony_ci#define ANER_LPAN 0x0001 /* link parter autoneg-able */ 168f9f848faSopenharmony_ci 169f9f848faSopenharmony_ci#define MII_ANNP 0x07 /* Autonegotiation next page */ 170f9f848faSopenharmony_ci /* section 28.2.4.1 and 37.2.6.1 */ 171f9f848faSopenharmony_ci 172f9f848faSopenharmony_ci#define MII_ANLPRNP 0x08 /* Autonegotiation link partner rx next page */ 173f9f848faSopenharmony_ci /* section 32.5.1 and 37.2.6.1 */ 174f9f848faSopenharmony_ci 175f9f848faSopenharmony_ci /* This is also the 1000baseT control register */ 176f9f848faSopenharmony_ci#define MII_100T2CR 0x09 /* 100base-T2 control register */ 177f9f848faSopenharmony_ci#define GTCR_TEST_MASK 0xe000 /* see 802.3ab ss. 40.6.1.1.2 */ 178f9f848faSopenharmony_ci#define GTCR_MAN_MS 0x1000 /* enable manual master/slave control */ 179f9f848faSopenharmony_ci#define GTCR_ADV_MS 0x0800 /* 1 = adv. master, 0 = adv. slave */ 180f9f848faSopenharmony_ci#define GTCR_PORT_TYPE 0x0400 /* 1 = DCE, 0 = DTE (NIC) */ 181f9f848faSopenharmony_ci#define GTCR_ADV_1000TFDX 0x0200 /* adv. 1000baseT FDX */ 182f9f848faSopenharmony_ci#define GTCR_ADV_1000THDX 0x0100 /* adv. 1000baseT HDX */ 183f9f848faSopenharmony_ci 184f9f848faSopenharmony_ci /* This is also the 1000baseT status register */ 185f9f848faSopenharmony_ci#define MII_100T2SR 0x0a /* 100base-T2 status register */ 186f9f848faSopenharmony_ci#define GTSR_MAN_MS_FLT 0x8000 /* master/slave config fault */ 187f9f848faSopenharmony_ci#define GTSR_MS_RES 0x4000 /* result: 1 = master, 0 = slave */ 188f9f848faSopenharmony_ci#define GTSR_LRS 0x2000 /* local rx status, 1 = ok */ 189f9f848faSopenharmony_ci#define GTSR_RRS 0x1000 /* remote rx status, 1 = ok */ 190f9f848faSopenharmony_ci#define GTSR_LP_1000TFDX 0x0800 /* link partner 1000baseT FDX capable */ 191f9f848faSopenharmony_ci#define GTSR_LP_1000THDX 0x0400 /* link partner 1000baseT HDX capable */ 192f9f848faSopenharmony_ci#define GTSR_LP_ASM_DIR 0x0200 /* link partner asym. pause dir. capable */ 193f9f848faSopenharmony_ci#define GTSR_IDLE_ERR 0x00ff /* IDLE error count */ 194f9f848faSopenharmony_ci 195f9f848faSopenharmony_ci#define MII_PSECR 0x0b /* PSE control register */ 196f9f848faSopenharmony_ci#define PSECR_PACTLMASK 0x000c /* pair control mask */ 197f9f848faSopenharmony_ci#define PSECR_PSEENMASK 0x0003 /* PSE enable mask */ 198f9f848faSopenharmony_ci#define PSECR_PINOUTB 0x0008 /* PSE pinout Alternative B */ 199f9f848faSopenharmony_ci#define PSECR_PINOUTA 0x0004 /* PSE pinout Alternative A */ 200f9f848faSopenharmony_ci#define PSECR_FOPOWTST 0x0002 /* Force Power Test Mode */ 201f9f848faSopenharmony_ci#define PSECR_PSEEN 0x0001 /* PSE Enabled */ 202f9f848faSopenharmony_ci#define PSECR_PSEDIS 0x0000 /* PSE Disabled */ 203f9f848faSopenharmony_ci 204f9f848faSopenharmony_ci#define MII_PSESR 0x0c /* PSE status register */ 205f9f848faSopenharmony_ci#define PSESR_PWRDENIED 0x1000 /* Power Denied */ 206f9f848faSopenharmony_ci#define PSESR_VALSIG 0x0800 /* Valid PD signature detected */ 207f9f848faSopenharmony_ci#define PSESR_INVALSIG 0x0400 /* Invalid PD signature detected */ 208f9f848faSopenharmony_ci#define PSESR_SHORTCIRC 0x0200 /* Short circuit condition detected */ 209f9f848faSopenharmony_ci#define PSESR_OVERLOAD 0x0100 /* Overload condition detected */ 210f9f848faSopenharmony_ci#define PSESR_MPSABSENT 0x0080 /* MPS absent condition detected */ 211f9f848faSopenharmony_ci#define PSESR_PDCLMASK 0x0070 /* PD Class mask */ 212f9f848faSopenharmony_ci#define PSESR_STATMASK 0x000e /* PSE Status mask */ 213f9f848faSopenharmony_ci#define PSESR_PAIRCTABL 0x0001 /* PAIR Control Ability */ 214f9f848faSopenharmony_ci#define PSESR_PDCL_4 (4 << 4) /* Class 4 */ 215f9f848faSopenharmony_ci#define PSESR_PDCL_3 (3 << 4) /* Class 3 */ 216f9f848faSopenharmony_ci#define PSESR_PDCL_2 (2 << 4) /* Class 2 */ 217f9f848faSopenharmony_ci#define PSESR_PDCL_1 (1 << 4) /* Class 1 */ 218f9f848faSopenharmony_ci#define PSESR_PDCL_0 (0 << 4) /* Class 0 */ 219f9f848faSopenharmony_ci 220f9f848faSopenharmony_ci#define MII_MMDACR 0x0d /* MMD access control register */ 221f9f848faSopenharmony_ci#define MMDACR_FUNCMASK 0xc000 /* function */ 222f9f848faSopenharmony_ci#define MMDACR_DADDRMASK 0x001f /* device address */ 223f9f848faSopenharmony_ci#define MMDACR_FN_ADDRESS (0 << 14) /* address */ 224f9f848faSopenharmony_ci#define MMDACR_FN_DATANPI (1 << 14) /* data, no post increment */ 225f9f848faSopenharmony_ci#define MMDACR_FN_DATAPIRW (2 << 14) /* data, post increment on r/w */ 226f9f848faSopenharmony_ci#define MMDACR_FN_DATAPIW (3 << 14) /* data, post increment on wr only */ 227f9f848faSopenharmony_ci 228f9f848faSopenharmony_ci#define MII_MMDAADR 0x0e /* MMD access address data register */ 229f9f848faSopenharmony_ci 230f9f848faSopenharmony_ci#define MII_EXTSR 0x0f /* Extended status register */ 231f9f848faSopenharmony_ci#define EXTSR_1000XFDX 0x8000 /* 1000X full-duplex capable */ 232f9f848faSopenharmony_ci#define EXTSR_1000XHDX 0x4000 /* 1000X half-duplex capable */ 233f9f848faSopenharmony_ci#define EXTSR_1000TFDX 0x2000 /* 1000T full-duplex capable */ 234f9f848faSopenharmony_ci#define EXTSR_1000THDX 0x1000 /* 1000T half-duplex capable */ 235f9f848faSopenharmony_ci 236f9f848faSopenharmony_ci#define EXTSR_MEDIAMASK (EXTSR_1000XFDX|EXTSR_1000XHDX| \ 237f9f848faSopenharmony_ci EXTSR_1000TFDX|EXTSR_1000THDX) 238f9f848faSopenharmony_ci 239f9f848faSopenharmony_ci#endif /* _DEV_MII_MII_H_ */ 240