Home | History | Annotate | Line # | Download | only in mii
      1  1.13  msaitoh /*	$NetBSD: igphyreg.h,v 1.13 2020/08/03 07:25:59 msaitoh Exp $	*/
      2   1.1     fvdl 
      3   1.1     fvdl /*******************************************************************************
      4   1.1     fvdl 
      5   1.3    perry   Copyright (c) 2001-2003, Intel Corporation
      6   1.1     fvdl   All rights reserved.
      7   1.1     fvdl 
      8   1.3    perry   Redistribution and use in source and binary forms, with or without
      9   1.1     fvdl   modification, are permitted provided that the following conditions are met:
     10   1.3    perry 
     11   1.3    perry    1. Redistributions of source code must retain the above copyright notice,
     12   1.1     fvdl       this list of conditions and the following disclaimer.
     13   1.3    perry 
     14   1.3    perry    2. Redistributions in binary form must reproduce the above copyright
     15   1.3    perry       notice, this list of conditions and the following disclaimer in the
     16   1.1     fvdl       documentation and/or other materials provided with the distribution.
     17   1.3    perry 
     18   1.3    perry    3. Neither the name of the Intel Corporation nor the names of its
     19   1.3    perry       contributors may be used to endorse or promote products derived from
     20   1.1     fvdl       this software without specific prior written permission.
     21   1.3    perry 
     22   1.1     fvdl   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     23   1.3    perry   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24   1.3    perry   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25   1.3    perry   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     26   1.3    perry   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27   1.3    perry   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28   1.3    perry   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29   1.3    perry   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30   1.3    perry   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31   1.1     fvdl   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     32   1.1     fvdl   POSSIBILITY OF SUCH DAMAGE.
     33   1.1     fvdl 
     34   1.1     fvdl *******************************************************************************/
     35   1.1     fvdl 
     36   1.1     fvdl /*
     37   1.1     fvdl  * Copied from the Intel code, and then modified to match NetBSD
     38   1.1     fvdl  * style for MII registers more.
     39   1.1     fvdl  */
     40   1.1     fvdl 
     41   1.1     fvdl /*
     42   1.1     fvdl  * IGP01E1000 Specific Registers
     43   1.1     fvdl  */
     44   1.1     fvdl 
     45   1.7  msaitoh /* IGP01E1000 Specific Port Config Register - R/W */
     46  1.12  msaitoh #define IGPHY_PORT_CONFIG		0x10 /* PHY specific config register */
     47   1.7  msaitoh #define PSCFR_AUTO_MDIX_PAR_DETECT	0x0010
     48   1.7  msaitoh #define PSCFR_PRE_EN			0x0020
     49   1.7  msaitoh #define PSCFR_SMART_SPEED		0x0080
     50   1.7  msaitoh #define PSCFR_DISABLE_TPLOOPBACK	0x0100
     51   1.7  msaitoh #define PSCFR_DISABLE_JABBER		0x0400
     52   1.7  msaitoh #define PSCFR_DISABLE_TRANSMIT		0x2000
     53   1.1     fvdl 
     54   1.1     fvdl /* IGP01E1000 Specific Port Status Register - R/O */
     55  1.12  msaitoh #define IGPHY_PORT_STATUS		0x11
     56  1.13  msaitoh #define IGPHY_PSSR_AUTONEG_FAILED	0x0001 /* RO LH SC */
     57  1.13  msaitoh #define IGPHY_PSSR_POLARITY_REVERSED	0x0002
     58  1.13  msaitoh #define IGPHY_PSSR_CABLE_LENGTH		0x007C
     59  1.13  msaitoh #define IGPHY_PSSR_FULL_DUPLEX		0x0200
     60  1.13  msaitoh #define IGPHY_PSSR_LINK_UP		0x0400
     61  1.13  msaitoh #define IGPHY_PSSR_MDIX			0x0800
     62  1.13  msaitoh #define IGPHY_PSSR_SPEED_MASK		0xC000 /* speed bits mask */
     63  1.13  msaitoh #define IGPHY_PSSR_SPEED_10MBPS		0x4000
     64  1.13  msaitoh #define IGPHY_PSSR_SPEED_100MBPS	0x8000
     65  1.13  msaitoh #define IGPHY_PSSR_SPEED_1000MBPS	0xC000
     66  1.13  msaitoh #define IGPHY_PSSR_CABLE_LENGTH_SHIFT 	0x0002 /* shift right 2 */
     67  1.13  msaitoh #define IGPHY_PSSR_MDIX_SHIFT		0x000B /* shift right 11 */
     68   1.1     fvdl 
     69   1.1     fvdl /* IGP01E1000 Specific Port Control Register - R/W */
     70  1.12  msaitoh #define IGPHY_PORT_CTRL			0x12
     71   1.7  msaitoh #define PSCR_TP_LOOPBACK		0x0010
     72   1.1     fvdl #define PSCR_CORRECT_NC_SCMBLR		0x0200
     73   1.1     fvdl #define PSCR_TEN_CRS_SELECT		0x0400
     74   1.1     fvdl #define PSCR_FLIP_CHIP			0x0800
     75   1.1     fvdl #define PSCR_AUTO_MDIX			0x1000
     76   1.1     fvdl #define PSCR_FORCE_MDI_MDIX 		0x2000 /* 0-MDI, 1-MDIX */
     77   1.1     fvdl 
     78   1.1     fvdl /* IGP01E1000 Specific Port Link Health Register */
     79  1.12  msaitoh #define IGPHY_LINK_HEALTH		0x13
     80   1.8  msaitoh #define PLHR_VALID_CHANNEL_A		0x0001
     81   1.8  msaitoh #define PLHR_VALID_CHANNEL_B		0x0002
     82   1.8  msaitoh #define PLHR_VALID_CHANNEL_C		0x0004
     83   1.8  msaitoh #define PLHR_VALID_CHANNEL_D		0x0008
     84   1.8  msaitoh #define PLHR_AUTONEG_ACTIVE		0x0010
     85   1.8  msaitoh #define PLHR_AUTONEG_FAULT		0x0040
     86   1.8  msaitoh #define PLHR_DATA_ERR_0			0x0100
     87   1.8  msaitoh #define PLHR_DATA_ERR_1			0x0200 /* LH */
     88   1.8  msaitoh #define PLHR_IDLE_ERROR_CNT_OFLOW	0x0400 /* LH */
     89   1.8  msaitoh #define PLHR_GIG_REM_RCVR_NOK		0x0800 /* LH */
     90   1.8  msaitoh #define PLHR_GIG_SCRAMBLER_ERROR	0x4000
     91   1.1     fvdl #define PLHR_SS_DOWNGRADE		0x8000
     92   1.1     fvdl 
     93   1.1     fvdl /* IGP01E1000 GMII FIFO Register */
     94   1.1     fvdl #define MII_IGGMII_FIFO			0x14
     95   1.1     fvdl #define GMII_FLEX_SPD			0x10 /* Enable flexible speed */
     96   1.1     fvdl #define GMII_SPD			0x20 /* Enable SPD */
     97   1.1     fvdl 
     98   1.1     fvdl /* IGP01E1000 Channel Quality Register */
     99  1.12  msaitoh #define IGPHY_CHANNEL_QUALITY		0x15
    100   1.8  msaitoh #define MSE_CHANNEL_A			0x000F
    101   1.8  msaitoh #define MSE_CHANNEL_B			0x00F0
    102   1.8  msaitoh #define MSE_CHANNEL_C			0x0F00
    103   1.8  msaitoh #define MSE_CHANNEL_D			0xF000
    104   1.8  msaitoh 
    105   1.8  msaitoh /* IGP01E1000 Power Management */
    106  1.12  msaitoh #define IGPHY_POWER_MGMT		0x19
    107   1.8  msaitoh #define PMR_SPD_EN			0x0001
    108   1.8  msaitoh #define PMR_D0_LPLU			0x0002
    109   1.8  msaitoh #define PMR_D3_LPLU			0x0004
    110   1.8  msaitoh #define PMR_DIS_1000			0x0040
    111   1.1     fvdl 
    112  1.12  msaitoh #define IGPHY_PAGE_SELECT		0x1F
    113   1.5  msaitoh #define IGPHY_MAXREGADDR		0x1F
    114   1.5  msaitoh #define IGPHY_PAGEMASK			(~IGPHY_MAXREGADDR)
    115   1.1     fvdl 
    116   1.1     fvdl /* IGP01E1000 AGC Registers - stores the cable length values*/
    117  1.12  msaitoh #define IGPHY_AGC_A			0x1172
    118  1.12  msaitoh #define IGPHY_AGC_PARAM_A		0x1171
    119  1.12  msaitoh #define IGPHY_AGC_B			0x1272
    120  1.12  msaitoh #define IGPHY_AGC_PARAM_B		0x1271
    121  1.12  msaitoh #define IGPHY_AGC_C			0x1472
    122  1.12  msaitoh #define IGPHY_AGC_PARAM_C		0x1471
    123  1.12  msaitoh #define IGPHY_AGC_D			0x1872
    124  1.12  msaitoh #define IGPHY_AGC_PARAM_D		0x1871
    125   1.1     fvdl #define AGC_LENGTH_SHIFT		7  /* Coarse - 13:11, Fine - 10:7 */
    126   1.1     fvdl #define AGC_LENGTH_TABLE_SIZE		128
    127   1.1     fvdl #define AGC_RANGE			10
    128   1.1     fvdl 
    129   1.1     fvdl /* IGP01E1000 DSP Reset Register */
    130  1.12  msaitoh #define IGPHY_DSP_RESET			0x1F33
    131  1.12  msaitoh #define IGPHY_DSP_SET			0x1F71
    132  1.12  msaitoh #define IGPHY_DSP_FFE			0x1F35
    133  1.12  msaitoh #define IGPHY_CHANNEL_NUM		4
    134  1.12  msaitoh #define IGPHY_EDAC_MU_INDEX		0xC000
    135  1.12  msaitoh #define IGPHY_EDAC_SIGN_EXT_9_BITS	0x8000
    136  1.12  msaitoh #define IGPHY_ANALOG_TX_STATE		0x2890
    137  1.12  msaitoh #define IGPHY_ANALOG_CLASS_A		0x2000
    138  1.12  msaitoh #define IGPHY_FORCE_ANALOG_ENABLE	0x0004
    139  1.12  msaitoh #define IGPHY_DSP_FFE_CM_CP		0x0069
    140  1.12  msaitoh #define IGPHY_DSP_FFE_DEFAULT		0x002A
    141   1.1     fvdl 
    142   1.1     fvdl /* IGP01E1000 PCS Initialization register - stores the polarity status */
    143  1.12  msaitoh #define IGPHY_PCS_INIT_REG		0x00B4
    144  1.12  msaitoh #define IGPHY_PCS_CTRL_REG		0x00B5
    145   1.1     fvdl 
    146  1.12  msaitoh #define IGPHY_ANALOG_REGS_PAGE		0x20C0
    147   1.1     fvdl #define PHY_POLARITY_MASK		0x0078
    148   1.1     fvdl 
    149   1.1     fvdl /* IGP01E1000 Analog Register */
    150  1.12  msaitoh #define IGPHY_ANALOG_SPARE_FUSE_STATUS	0x20D1
    151  1.12  msaitoh #define IGPHY_ANALOG_FUSE_STATUS	0x20D0
    152  1.12  msaitoh #define IGPHY_ANALOG_FUSE_CONTROL	0x20DC
    153  1.12  msaitoh #define IGPHY_ANALOG_FUSE_BYPASS	0x20DE
    154   1.1     fvdl #define ANALOG_FUSE_POLY_MASK		0xF000
    155   1.1     fvdl #define ANALOG_FUSE_FINE_MASK		0x0F80
    156   1.1     fvdl #define ANALOG_FUSE_COARSE_MASK		0x0070
    157   1.1     fvdl #define ANALOG_SPARE_FUSE_ENABLED	0x0100
    158   1.1     fvdl #define ANALOG_FUSE_ENABLE_SW_CONTROL	0x0002
    159   1.1     fvdl #define ANALOG_FUSE_COARSE_THRESH	0x0040
    160   1.1     fvdl #define ANALOG_FUSE_COARSE_10		0x0010
    161   1.1     fvdl #define ANALOG_FUSE_FINE_1		0x0080
    162   1.1     fvdl #define ANALOG_FUSE_FINE_10		0x0500
    163   1.1     fvdl 
    164   1.6  msaitoh /*
    165   1.6  msaitoh  * IGP3 regs
    166   1.6  msaitoh  */
    167   1.6  msaitoh #define IGP3_PAGE_SHIFT		5
    168   1.6  msaitoh #define IGP3_REG(page, reg) \
    169  1.10  msaitoh 	(((page) << IGP3_PAGE_SHIFT) | ((reg) & MII_ADDRMASK))
    170   1.6  msaitoh 
    171   1.6  msaitoh #define IGP3_VR_CTRL	IGP3_REG(776, 18)
    172   1.6  msaitoh #define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK	0x0300
    173   1.6  msaitoh #define IGP3_VR_CTRL_MODE_SHUTDOWN		0x0200
    174   1.6  msaitoh 
    175   1.6  msaitoh #define IGP3_PM_CTRL	IGP3_REG(769, 20)
    176   1.6  msaitoh #define IGP3_PM_CTRL_FORCE_PWR_DOWN		0x0020
    177   1.6  msaitoh 
    178  1.11  msaitoh static inline int
    179  1.11  msaitoh IGPHY_READ(struct mii_softc *sc, int reg, uint16_t *val)
    180  1.11  msaitoh {
    181  1.11  msaitoh 	int rv;
    182  1.11  msaitoh 
    183  1.12  msaitoh 	if ((rv = PHY_WRITE(sc, IGPHY_PAGE_SELECT, reg & ~0x1f)) != 0)
    184  1.11  msaitoh 		return rv;
    185  1.11  msaitoh 	return PHY_READ(sc, reg & 0x1f, val);
    186  1.11  msaitoh }
    187  1.11  msaitoh static inline int
    188  1.11  msaitoh IGPHY_WRITE(struct mii_softc *sc, int reg, uint16_t val)
    189  1.11  msaitoh {
    190  1.11  msaitoh 	int rv;
    191   1.6  msaitoh 
    192  1.12  msaitoh 	if ((rv = PHY_WRITE(sc, IGPHY_PAGE_SELECT, reg & ~0x1f)) != 0)
    193  1.11  msaitoh 		return rv;
    194  1.11  msaitoh 
    195  1.11  msaitoh 	return PHY_WRITE(sc, reg & 0x1f, val);
    196  1.11  msaitoh }
    197   1.1     fvdl 
    198   1.2  thorpej #define	IGPHY_TICK_DOWNSHIFT	3
    199   1.2  thorpej #define	IGPHY_TICK_MAX		15
    200