| 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
| 2 | /* |
| 3 | * linux/mdio.h: definitions for MDIO (clause 45) transceivers |
| 4 | * Copyright 2006-2009 Solarflare Communications Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published |
| 8 | * by the Free Software Foundation, incorporated herein by reference. |
| 9 | */ |
| 10 | |
| 11 | #ifndef __LINUX_MDIO_H__ |
| 12 | #define __LINUX_MDIO_H__ |
| 13 | |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/mii.h> |
| 16 | |
| 17 | /* MDIO Manageable Devices (MMDs). */ |
| 18 | #define MDIO_MMD_PMAPMD		1	/* Physical Medium Attachment/ |
| 19 | 					 * Physical Medium Dependent */ |
| 20 | #define MDIO_MMD_WIS		2	/* WAN Interface Sublayer */ |
| 21 | #define MDIO_MMD_PCS		3	/* Physical Coding Sublayer */ |
| 22 | #define MDIO_MMD_PHYXS		4	/* PHY Extender Sublayer */ |
| 23 | #define MDIO_MMD_DTEXS		5	/* DTE Extender Sublayer */ |
| 24 | #define MDIO_MMD_TC		6	/* Transmission Convergence */ |
| 25 | #define MDIO_MMD_AN		7	/* Auto-Negotiation */ |
| 26 | #define MDIO_MMD_SEP_PMA1	8	/* Separated PMA (1) */ |
| 27 | #define MDIO_MMD_SEP_PMA2	9	/* Separated PMA (2) */ |
| 28 | #define MDIO_MMD_SEP_PMA3	10	/* Separated PMA (3) */ |
| 29 | #define MDIO_MMD_SEP_PMA4	11	/* Separated PMA (4) */ |
| 30 | #define MDIO_MMD_POWER_UNIT	13	/* PHY Power Unit */ |
| 31 | #define MDIO_MMD_C22EXT		29	/* Clause 22 extension */ |
| 32 | #define MDIO_MMD_VEND1		30	/* Vendor specific 1 */ |
| 33 | #define MDIO_MMD_VEND2		31	/* Vendor specific 2 */ |
| 34 | |
| 35 | /* Generic MDIO registers. */ |
| 36 | #define MDIO_CTRL1		MII_BMCR |
| 37 | #define MDIO_STAT1		MII_BMSR |
| 38 | #define MDIO_DEVID1		MII_PHYSID1 |
| 39 | #define MDIO_DEVID2		MII_PHYSID2 |
| 40 | #define MDIO_SPEED		4	/* Speed ability */ |
| 41 | #define MDIO_DEVS1		5	/* Devices in package */ |
| 42 | #define MDIO_DEVS2		6 |
| 43 | #define MDIO_CTRL2		7	/* 10G control 2 */ |
| 44 | #define MDIO_STAT2		8	/* 10G status 2 */ |
| 45 | #define MDIO_PMA_TXDIS		9	/* 10G PMA/PMD transmit disable */ |
| 46 | #define MDIO_PMA_RXDET		10	/* 10G PMA/PMD receive signal detect */ |
| 47 | #define MDIO_PMA_EXTABLE	11	/* 10G PMA/PMD extended ability */ |
| 48 | #define MDIO_PKGID1		14	/* Package identifier */ |
| 49 | #define MDIO_PKGID2		15 |
| 50 | #define MDIO_AN_ADVERTISE	16	/* AN advertising (base page) */ |
| 51 | #define MDIO_AN_LPA		19	/* AN LP abilities (base page) */ |
| 52 | #define MDIO_PCS_EEE_ABLE	20	/* EEE Capability register */ |
| 53 | #define MDIO_PCS_EEE_ABLE2	21	/* EEE Capability register 2 */ |
| 54 | #define MDIO_PMA_NG_EXTABLE	21	/* 2.5G/5G PMA/PMD extended ability */ |
| 55 | #define MDIO_PCS_EEE_WK_ERR	22	/* EEE wake error counter */ |
| 56 | #define MDIO_PHYXS_LNSTAT	24	/* PHY XGXS lane state */ |
| 57 | #define MDIO_AN_EEE_ADV		60	/* EEE advertisement */ |
| 58 | #define MDIO_AN_EEE_LPABLE	61	/* EEE link partner ability */ |
| 59 | #define MDIO_AN_EEE_ADV2	62	/* EEE advertisement 2 */ |
| 60 | #define MDIO_AN_EEE_LPABLE2	63	/* EEE link partner ability 2 */ |
| 61 | #define MDIO_AN_CTRL2		64	/* AN THP bypass request control */ |
| 62 | |
| 63 | /* Media-dependent registers. */ |
| 64 | #define MDIO_PMA_10GBT_SWAPPOL	130	/* 10GBASE-T pair swap & polarity */ |
| 65 | #define MDIO_PMA_10GBT_TXPWR	131	/* 10GBASE-T TX power control */ |
| 66 | #define MDIO_PMA_10GBT_SNR	133	/* 10GBASE-T SNR margin, lane A. |
| 67 | 					 * Lanes B-D are numbered 134-136. */ |
| 68 | #define MDIO_PMA_10GBR_FSRT_CSR	147	/* 10GBASE-R fast retrain status and control */ |
| 69 | #define MDIO_PMA_10GBR_FECABLE	170	/* 10GBASE-R FEC ability */ |
| 70 | #define MDIO_PMA_RSFEC_CTRL	200	/* RSFEC control */ |
| 71 | #define MDIO_PMA_RSFEC_LANE_MAP	206	/* RSFEC lane mapping */ |
| 72 | #define MDIO_PCS_10GBX_STAT1	24	/* 10GBASE-X PCS status 1 */ |
| 73 | #define MDIO_PCS_10GBRT_STAT1	32	/* 10GBASE-R/-T PCS status 1 */ |
| 74 | #define MDIO_PCS_10GBRT_STAT2	33	/* 10GBASE-R/-T PCS status 2 */ |
| 75 | #define MDIO_AN_10GBT_CTRL	32	/* 10GBASE-T auto-negotiation control */ |
| 76 | #define MDIO_AN_10GBT_STAT	33	/* 10GBASE-T auto-negotiation status */ |
| 77 | #define MDIO_B10L_PMA_CTRL	2294	/* 10BASE-T1L PMA control */ |
| 78 | #define MDIO_PMA_10T1L_STAT	2295	/* 10BASE-T1L PMA status */ |
| 79 | #define MDIO_PCS_10T1L_CTRL	2278	/* 10BASE-T1L PCS control */ |
| 80 | #define MDIO_PMA_PMD_BT1	18	/* BASE-T1 PMA/PMD extended ability */ |
| 81 | #define MDIO_AN_T1_CTRL		512	/* BASE-T1 AN control */ |
| 82 | #define MDIO_AN_T1_STAT		513	/* BASE-T1 AN status */ |
| 83 | #define MDIO_AN_T1_ADV_L	514	/* BASE-T1 AN advertisement register [15:0] */ |
| 84 | #define MDIO_AN_T1_ADV_M	515	/* BASE-T1 AN advertisement register [31:16] */ |
| 85 | #define MDIO_AN_T1_ADV_H	516	/* BASE-T1 AN advertisement register [47:32] */ |
| 86 | #define MDIO_AN_T1_LP_L		517	/* BASE-T1 AN LP Base Page ability register [15:0] */ |
| 87 | #define MDIO_AN_T1_LP_M		518	/* BASE-T1 AN LP Base Page ability register [31:16] */ |
| 88 | #define MDIO_AN_T1_LP_H		519	/* BASE-T1 AN LP Base Page ability register [47:32] */ |
| 89 | #define MDIO_AN_10BT1_AN_CTRL	526	/* 10BASE-T1 AN control register */ |
| 90 | #define MDIO_AN_10BT1_AN_STAT	527	/* 10BASE-T1 AN status register */ |
| 91 | #define MDIO_PMA_PMD_BT1_CTRL	2100	/* BASE-T1 PMA/PMD control register */ |
| 92 | #define MDIO_PCS_1000BT1_CTRL	2304	/* 1000BASE-T1 PCS control register */ |
| 93 | #define MDIO_PCS_1000BT1_STAT	2305	/* 1000BASE-T1 PCS status register */ |
| 94 | |
| 95 | /* LASI (Link Alarm Status Interrupt) registers, defined by XENPAK MSA. */ |
| 96 | #define MDIO_PMA_LASI_RXCTRL	0x9000	/* RX_ALARM control */ |
| 97 | #define MDIO_PMA_LASI_TXCTRL	0x9001	/* TX_ALARM control */ |
| 98 | #define MDIO_PMA_LASI_CTRL	0x9002	/* LASI control */ |
| 99 | #define MDIO_PMA_LASI_RXSTAT	0x9003	/* RX_ALARM status */ |
| 100 | #define MDIO_PMA_LASI_TXSTAT	0x9004	/* TX_ALARM status */ |
| 101 | #define MDIO_PMA_LASI_STAT	0x9005	/* LASI status */ |
| 102 | |
| 103 | /* Control register 1. */ |
| 104 | /* Enable extended speed selection */ |
| 105 | #define MDIO_CTRL1_SPEEDSELEXT		(BMCR_SPEED1000 | BMCR_SPEED100) |
| 106 | /* All speed selection bits */ |
| 107 | #define MDIO_CTRL1_SPEEDSEL		(MDIO_CTRL1_SPEEDSELEXT | 0x003c) |
| 108 | #define MDIO_CTRL1_FULLDPLX		BMCR_FULLDPLX |
| 109 | #define MDIO_CTRL1_LPOWER		BMCR_PDOWN |
| 110 | #define MDIO_CTRL1_RESET		BMCR_RESET |
| 111 | #define MDIO_PMA_CTRL1_LOOPBACK		0x0001 |
| 112 | #define MDIO_PMA_CTRL1_SPEED1000	BMCR_SPEED1000 |
| 113 | #define MDIO_PMA_CTRL1_SPEED100		BMCR_SPEED100 |
| 114 | #define MDIO_PCS_CTRL1_LOOPBACK		BMCR_LOOPBACK |
| 115 | #define MDIO_PHYXS_CTRL1_LOOPBACK	BMCR_LOOPBACK |
| 116 | #define MDIO_AN_CTRL1_RESTART		BMCR_ANRESTART |
| 117 | #define MDIO_AN_CTRL1_ENABLE		BMCR_ANENABLE |
| 118 | #define MDIO_AN_CTRL1_XNP		0x2000	/* Enable extended next page */ |
| 119 | #define MDIO_PCS_CTRL1_CLKSTOP_EN	0x400	/* Stop the clock during LPI */ |
| 120 | |
| 121 | /* 10 Gb/s */ |
| 122 | #define MDIO_CTRL1_SPEED10G		(MDIO_CTRL1_SPEEDSELEXT | 0x00) |
| 123 | /* 10PASS-TS/2BASE-TL */ |
| 124 | #define MDIO_CTRL1_SPEED10P2B		(MDIO_CTRL1_SPEEDSELEXT | 0x04) |
| 125 | /* Note: the MDIO_CTRL1_SPEED_XXX values for everything past 10PASS-TS/2BASE-TL |
| 126 | * do not match between the PCS and PMA values. Any additions past this point |
| 127 | * should be PMA or PCS specific. The following 2 defines are workarounds for |
| 128 | * values added before this was caught. They should be considered deprecated. |
| 129 | */ |
| 130 | #define MDIO_CTRL1_SPEED2_5G		MDIO_PMA_CTRL1_SPEED2_5G |
| 131 | #define MDIO_CTRL1_SPEED5G		MDIO_PMA_CTRL1_SPEED5G |
| 132 | /* 100 Gb/s */ |
| 133 | #define MDIO_PCS_CTRL1_SPEED100G	(MDIO_CTRL1_SPEEDSELEXT | 0x10) |
| 134 | /* 25 Gb/s */ |
| 135 | #define MDIO_PCS_CTRL1_SPEED25G		(MDIO_CTRL1_SPEEDSELEXT | 0x14) |
| 136 | /* 50 Gb/s */ |
| 137 | #define MDIO_PCS_CTRL1_SPEED50G		(MDIO_CTRL1_SPEEDSELEXT | 0x18) |
| 138 | /* 2.5 Gb/s */ |
| 139 | #define MDIO_PMA_CTRL1_SPEED2_5G	(MDIO_CTRL1_SPEEDSELEXT | 0x18) |
| 140 | /* 5 Gb/s */ |
| 141 | #define MDIO_PMA_CTRL1_SPEED5G		(MDIO_CTRL1_SPEEDSELEXT | 0x1c) |
| 142 | |
| 143 | |
| 144 | /* Status register 1. */ |
| 145 | #define MDIO_STAT1_LPOWERABLE		0x0002	/* Low-power ability */ |
| 146 | #define MDIO_STAT1_LSTATUS		BMSR_LSTATUS |
| 147 | #define MDIO_STAT1_FAULT		0x0080	/* Fault */ |
| 148 | #define MDIO_PCS_STAT1_CLKSTOP_CAP	0x0040 |
| 149 | #define MDIO_AN_STAT1_LPABLE		0x0001	/* Link partner AN ability */ |
| 150 | #define MDIO_AN_STAT1_ABLE		BMSR_ANEGCAPABLE |
| 151 | #define MDIO_AN_STAT1_RFAULT		BMSR_RFAULT |
| 152 | #define MDIO_AN_STAT1_COMPLETE		BMSR_ANEGCOMPLETE |
| 153 | #define MDIO_AN_STAT1_PAGE		0x0040	/* Page received */ |
| 154 | #define MDIO_AN_STAT1_XNP		0x0080	/* Extended next page status */ |
| 155 | |
| 156 | /* Device Identifier 2 */ |
| 157 | #define MDIO_DEVID2_OUI			0xfc00	/* OUI Portion of PHY ID */ |
| 158 | #define MDIO_DEVID2_MODEL_NUM		0x03f0	/* Manufacturer's Model Number */ |
| 159 | #define MDIO_DEVID2_REV_NUM		0x000f	/* Revision Number */ |
| 160 | |
| 161 | /* Speed register. */ |
| 162 | #define MDIO_SPEED_10G			0x0001	/* 10G capable */ |
| 163 | #define MDIO_PMA_SPEED_2B		0x0002	/* 2BASE-TL capable */ |
| 164 | #define MDIO_PMA_SPEED_10P		0x0004	/* 10PASS-TS capable */ |
| 165 | #define MDIO_PMA_SPEED_1000		0x0010	/* 1000M capable */ |
| 166 | #define MDIO_PMA_SPEED_100		0x0020	/* 100M capable */ |
| 167 | #define MDIO_PMA_SPEED_10		0x0040	/* 10M capable */ |
| 168 | #define MDIO_PMA_SPEED_2_5G		0x2000	/* 2.5G capable */ |
| 169 | #define MDIO_PMA_SPEED_5G		0x4000	/* 5G capable */ |
| 170 | #define MDIO_PCS_SPEED_10P2B		0x0002	/* 10PASS-TS/2BASE-TL capable */ |
| 171 | #define MDIO_PCS_SPEED_2_5G		0x0040	/* 2.5G capable */ |
| 172 | #define MDIO_PCS_SPEED_5G		0x0080	/* 5G capable */ |
| 173 | |
| 174 | /* Device present registers. */ |
| 175 | #define MDIO_DEVS_PRESENT(devad)	(1 << (devad)) |
| 176 | #define MDIO_DEVS_C22PRESENT		MDIO_DEVS_PRESENT(0) |
| 177 | #define MDIO_DEVS_PMAPMD		MDIO_DEVS_PRESENT(MDIO_MMD_PMAPMD) |
| 178 | #define MDIO_DEVS_WIS			MDIO_DEVS_PRESENT(MDIO_MMD_WIS) |
| 179 | #define MDIO_DEVS_PCS			MDIO_DEVS_PRESENT(MDIO_MMD_PCS) |
| 180 | #define MDIO_DEVS_PHYXS			MDIO_DEVS_PRESENT(MDIO_MMD_PHYXS) |
| 181 | #define MDIO_DEVS_DTEXS			MDIO_DEVS_PRESENT(MDIO_MMD_DTEXS) |
| 182 | #define MDIO_DEVS_TC			MDIO_DEVS_PRESENT(MDIO_MMD_TC) |
| 183 | #define MDIO_DEVS_AN			MDIO_DEVS_PRESENT(MDIO_MMD_AN) |
| 184 | #define MDIO_DEVS_SEP_PMA1		MDIO_DEVS_PRESENT(MDIO_MMD_SEP_PMA1) |
| 185 | #define MDIO_DEVS_SEP_PMA2		MDIO_DEVS_PRESENT(MDIO_MMD_SEP_PMA2) |
| 186 | #define MDIO_DEVS_SEP_PMA3		MDIO_DEVS_PRESENT(MDIO_MMD_SEP_PMA3) |
| 187 | #define MDIO_DEVS_SEP_PMA4		MDIO_DEVS_PRESENT(MDIO_MMD_SEP_PMA4) |
| 188 | #define MDIO_DEVS_C22EXT		MDIO_DEVS_PRESENT(MDIO_MMD_C22EXT) |
| 189 | #define MDIO_DEVS_VEND1			MDIO_DEVS_PRESENT(MDIO_MMD_VEND1) |
| 190 | #define MDIO_DEVS_VEND2			MDIO_DEVS_PRESENT(MDIO_MMD_VEND2) |
| 191 | |
| 192 | /* Control register 2. */ |
| 193 | #define MDIO_PMA_CTRL2_TYPE		0x000f	/* PMA/PMD type selection */ |
| 194 | #define MDIO_PMA_CTRL2_10GBCX4		0x0000	/* 10GBASE-CX4 type */ |
| 195 | #define MDIO_PMA_CTRL2_10GBEW		0x0001	/* 10GBASE-EW type */ |
| 196 | #define MDIO_PMA_CTRL2_10GBLW		0x0002	/* 10GBASE-LW type */ |
| 197 | #define MDIO_PMA_CTRL2_10GBSW		0x0003	/* 10GBASE-SW type */ |
| 198 | #define MDIO_PMA_CTRL2_10GBLX4		0x0004	/* 10GBASE-LX4 type */ |
| 199 | #define MDIO_PMA_CTRL2_10GBER		0x0005	/* 10GBASE-ER type */ |
| 200 | #define MDIO_PMA_CTRL2_10GBLR		0x0006	/* 10GBASE-LR type */ |
| 201 | #define MDIO_PMA_CTRL2_10GBSR		0x0007	/* 10GBASE-SR type */ |
| 202 | #define MDIO_PMA_CTRL2_10GBLRM		0x0008	/* 10GBASE-LRM type */ |
| 203 | #define MDIO_PMA_CTRL2_10GBT		0x0009	/* 10GBASE-T type */ |
| 204 | #define MDIO_PMA_CTRL2_10GBKX4		0x000a	/* 10GBASE-KX4 type */ |
| 205 | #define MDIO_PMA_CTRL2_10GBKR		0x000b	/* 10GBASE-KR type */ |
| 206 | #define MDIO_PMA_CTRL2_1000BT		0x000c	/* 1000BASE-T type */ |
| 207 | #define MDIO_PMA_CTRL2_1000BKX		0x000d	/* 1000BASE-KX type */ |
| 208 | #define MDIO_PMA_CTRL2_100BTX		0x000e	/* 100BASE-TX type */ |
| 209 | #define MDIO_PMA_CTRL2_10BT		0x000f	/* 10BASE-T type */ |
| 210 | #define MDIO_PMA_CTRL2_2_5GBT		0x0030 /* 2.5GBaseT type */ |
| 211 | #define MDIO_PMA_CTRL2_5GBT		0x0031 /* 5GBaseT type */ |
| 212 | #define MDIO_PMA_CTRL2_BASET1		0x003D /* BASE-T1 type */ |
| 213 | #define MDIO_PCS_CTRL2_TYPE		0x0003	/* PCS type selection */ |
| 214 | #define MDIO_PCS_CTRL2_10GBR		0x0000	/* 10GBASE-R type */ |
| 215 | #define MDIO_PCS_CTRL2_10GBX		0x0001	/* 10GBASE-X type */ |
| 216 | #define MDIO_PCS_CTRL2_10GBW		0x0002	/* 10GBASE-W type */ |
| 217 | #define MDIO_PCS_CTRL2_10GBT		0x0003	/* 10GBASE-T type */ |
| 218 | |
| 219 | /* Status register 2. */ |
| 220 | #define MDIO_STAT2_RXFAULT		0x0400	/* Receive fault */ |
| 221 | #define MDIO_STAT2_TXFAULT		0x0800	/* Transmit fault */ |
| 222 | #define MDIO_STAT2_DEVPRST		0xc000	/* Device present */ |
| 223 | #define MDIO_STAT2_DEVPRST_VAL		0x8000	/* Device present value */ |
| 224 | #define MDIO_PMA_STAT2_LBABLE		0x0001	/* PMA loopback ability */ |
| 225 | #define MDIO_PMA_STAT2_10GBEW		0x0002	/* 10GBASE-EW ability */ |
| 226 | #define MDIO_PMA_STAT2_10GBLW		0x0004	/* 10GBASE-LW ability */ |
| 227 | #define MDIO_PMA_STAT2_10GBSW		0x0008	/* 10GBASE-SW ability */ |
| 228 | #define MDIO_PMA_STAT2_10GBLX4		0x0010	/* 10GBASE-LX4 ability */ |
| 229 | #define MDIO_PMA_STAT2_10GBER		0x0020	/* 10GBASE-ER ability */ |
| 230 | #define MDIO_PMA_STAT2_10GBLR		0x0040	/* 10GBASE-LR ability */ |
| 231 | #define MDIO_PMA_STAT2_10GBSR		0x0080	/* 10GBASE-SR ability */ |
| 232 | #define MDIO_PMD_STAT2_TXDISAB		0x0100	/* PMD TX disable ability */ |
| 233 | #define MDIO_PMA_STAT2_EXTABLE		0x0200	/* Extended abilities */ |
| 234 | #define MDIO_PMA_STAT2_RXFLTABLE	0x1000	/* Receive fault ability */ |
| 235 | #define MDIO_PMA_STAT2_TXFLTABLE	0x2000	/* Transmit fault ability */ |
| 236 | #define MDIO_PCS_STAT2_10GBR		0x0001	/* 10GBASE-R capable */ |
| 237 | #define MDIO_PCS_STAT2_10GBX		0x0002	/* 10GBASE-X capable */ |
| 238 | #define MDIO_PCS_STAT2_10GBW		0x0004	/* 10GBASE-W capable */ |
| 239 | #define MDIO_PCS_STAT2_RXFLTABLE	0x1000	/* Receive fault ability */ |
| 240 | #define MDIO_PCS_STAT2_TXFLTABLE	0x2000	/* Transmit fault ability */ |
| 241 | |
| 242 | /* Transmit disable register. */ |
| 243 | #define MDIO_PMD_TXDIS_GLOBAL		0x0001	/* Global PMD TX disable */ |
| 244 | #define MDIO_PMD_TXDIS_0		0x0002	/* PMD TX disable 0 */ |
| 245 | #define MDIO_PMD_TXDIS_1		0x0004	/* PMD TX disable 1 */ |
| 246 | #define MDIO_PMD_TXDIS_2		0x0008	/* PMD TX disable 2 */ |
| 247 | #define MDIO_PMD_TXDIS_3		0x0010	/* PMD TX disable 3 */ |
| 248 | |
| 249 | /* Receive signal detect register. */ |
| 250 | #define MDIO_PMD_RXDET_GLOBAL		0x0001	/* Global PMD RX signal detect */ |
| 251 | #define MDIO_PMD_RXDET_0		0x0002	/* PMD RX signal detect 0 */ |
| 252 | #define MDIO_PMD_RXDET_1		0x0004	/* PMD RX signal detect 1 */ |
| 253 | #define MDIO_PMD_RXDET_2		0x0008	/* PMD RX signal detect 2 */ |
| 254 | #define MDIO_PMD_RXDET_3		0x0010	/* PMD RX signal detect 3 */ |
| 255 | |
| 256 | /* Extended abilities register. */ |
| 257 | #define MDIO_PMA_EXTABLE_10GCX4		0x0001	/* 10GBASE-CX4 ability */ |
| 258 | #define MDIO_PMA_EXTABLE_10GBLRM	0x0002	/* 10GBASE-LRM ability */ |
| 259 | #define MDIO_PMA_EXTABLE_10GBT		0x0004	/* 10GBASE-T ability */ |
| 260 | #define MDIO_PMA_EXTABLE_10GBKX4	0x0008	/* 10GBASE-KX4 ability */ |
| 261 | #define MDIO_PMA_EXTABLE_10GBKR		0x0010	/* 10GBASE-KR ability */ |
| 262 | #define MDIO_PMA_EXTABLE_1000BT		0x0020	/* 1000BASE-T ability */ |
| 263 | #define MDIO_PMA_EXTABLE_1000BKX	0x0040	/* 1000BASE-KX ability */ |
| 264 | #define MDIO_PMA_EXTABLE_100BTX		0x0080	/* 100BASE-TX ability */ |
| 265 | #define MDIO_PMA_EXTABLE_10BT		0x0100	/* 10BASE-T ability */ |
| 266 | #define MDIO_PMA_EXTABLE_BT1		0x0800	/* BASE-T1 ability */ |
| 267 | #define MDIO_PMA_EXTABLE_NBT		0x4000 /* 2.5/5GBASE-T ability */ |
| 268 | |
| 269 | /* AN Clause 73 linkword */ |
| 270 | #define MDIO_AN_C73_0_S_MASK		GENMASK(4, 0) |
| 271 | #define MDIO_AN_C73_0_E_MASK		GENMASK(9, 5) |
| 272 | #define MDIO_AN_C73_0_PAUSE		BIT(10) |
| 273 | #define MDIO_AN_C73_0_ASM_DIR		BIT(11) |
| 274 | #define MDIO_AN_C73_0_C2		BIT(12) |
| 275 | #define MDIO_AN_C73_0_RF		BIT(13) |
| 276 | #define MDIO_AN_C73_0_ACK		BIT(14) |
| 277 | #define MDIO_AN_C73_0_NP		BIT(15) |
| 278 | #define MDIO_AN_C73_1_T_MASK		GENMASK(4, 0) |
| 279 | #define MDIO_AN_C73_1_1000BASE_KX	BIT(5) |
| 280 | #define MDIO_AN_C73_1_10GBASE_KX4	BIT(6) |
| 281 | #define MDIO_AN_C73_1_10GBASE_KR	BIT(7) |
| 282 | #define MDIO_AN_C73_1_40GBASE_KR4	BIT(8) |
| 283 | #define MDIO_AN_C73_1_40GBASE_CR4	BIT(9) |
| 284 | #define MDIO_AN_C73_1_100GBASE_CR10	BIT(10) |
| 285 | #define MDIO_AN_C73_1_100GBASE_KP4	BIT(11) |
| 286 | #define MDIO_AN_C73_1_100GBASE_KR4	BIT(12) |
| 287 | #define MDIO_AN_C73_1_100GBASE_CR4	BIT(13) |
| 288 | #define MDIO_AN_C73_1_25GBASE_R_S	BIT(14) |
| 289 | #define MDIO_AN_C73_1_25GBASE_R		BIT(15) |
| 290 | #define MDIO_AN_C73_2_2500BASE_KX	BIT(0) |
| 291 | #define MDIO_AN_C73_2_5GBASE_KR		BIT(1) |
| 292 | |
| 293 | /* PHY XGXS lane state register. */ |
| 294 | #define MDIO_PHYXS_LNSTAT_SYNC0		0x0001 |
| 295 | #define MDIO_PHYXS_LNSTAT_SYNC1		0x0002 |
| 296 | #define MDIO_PHYXS_LNSTAT_SYNC2		0x0004 |
| 297 | #define MDIO_PHYXS_LNSTAT_SYNC3		0x0008 |
| 298 | #define MDIO_PHYXS_LNSTAT_ALIGN		0x1000 |
| 299 | |
| 300 | /* PMA 10GBASE-T pair swap & polarity */ |
| 301 | #define MDIO_PMA_10GBT_SWAPPOL_ABNX	0x0001	/* Pair A/B uncrossed */ |
| 302 | #define MDIO_PMA_10GBT_SWAPPOL_CDNX	0x0002	/* Pair C/D uncrossed */ |
| 303 | #define MDIO_PMA_10GBT_SWAPPOL_AREV	0x0100	/* Pair A polarity reversed */ |
| 304 | #define MDIO_PMA_10GBT_SWAPPOL_BREV	0x0200	/* Pair B polarity reversed */ |
| 305 | #define MDIO_PMA_10GBT_SWAPPOL_CREV	0x0400	/* Pair C polarity reversed */ |
| 306 | #define MDIO_PMA_10GBT_SWAPPOL_DREV	0x0800	/* Pair D polarity reversed */ |
| 307 | |
| 308 | /* PMA 10GBASE-T TX power register. */ |
| 309 | #define MDIO_PMA_10GBT_TXPWR_SHORT	0x0001	/* Short-reach mode */ |
| 310 | |
| 311 | /* PMA 10GBASE-T SNR registers. */ |
| 312 | /* Value is SNR margin in dB, clamped to range [-127, 127], plus 0x8000. */ |
| 313 | #define MDIO_PMA_10GBT_SNR_BIAS		0x8000 |
| 314 | #define MDIO_PMA_10GBT_SNR_MAX		127 |
| 315 | |
| 316 | /* PMA 10GBASE-R FEC ability register. */ |
| 317 | #define MDIO_PMA_10GBR_FECABLE_ABLE	0x0001	/* FEC ability */ |
| 318 | #define MDIO_PMA_10GBR_FECABLE_ERRABLE	0x0002	/* FEC error indic. ability */ |
| 319 | |
| 320 | /* PMA 10GBASE-R Fast Retrain status and control register. */ |
| 321 | #define MDIO_PMA_10GBR_FSRT_ENABLE	0x0001	/* Fast retrain enable */ |
| 322 | |
| 323 | /* PCS 10GBASE-R/-T status register 1. */ |
| 324 | #define MDIO_PCS_10GBRT_STAT1_BLKLK	0x0001	/* Block lock attained */ |
| 325 | |
| 326 | /* PCS 10GBASE-R/-T status register 2. */ |
| 327 | #define MDIO_PCS_10GBRT_STAT2_ERR	0x00ff |
| 328 | #define MDIO_PCS_10GBRT_STAT2_BER	0x3f00 |
| 329 | |
| 330 | /* AN 10GBASE-T control register. */ |
| 331 | #define MDIO_AN_10GBT_CTRL_ADVFSRT2_5G	0x0020	/* Advertise 2.5GBASE-T fast retrain */ |
| 332 | #define MDIO_AN_10GBT_CTRL_ADV2_5G	0x0080	/* Advertise 2.5GBASE-T */ |
| 333 | #define MDIO_AN_10GBT_CTRL_ADV5G	0x0100	/* Advertise 5GBASE-T */ |
| 334 | #define MDIO_AN_10GBT_CTRL_ADV10G	0x1000	/* Advertise 10GBASE-T */ |
| 335 | |
| 336 | /* AN 10GBASE-T status register. */ |
| 337 | #define MDIO_AN_10GBT_STAT_LP2_5G	0x0020 /* LP is 2.5GBT capable */ |
| 338 | #define MDIO_AN_10GBT_STAT_LP5G		0x0040 /* LP is 5GBT capable */ |
| 339 | #define MDIO_AN_10GBT_STAT_LPTRR	0x0200	/* LP training reset req. */ |
| 340 | #define MDIO_AN_10GBT_STAT_LPLTABLE	0x0400	/* LP loop timing ability */ |
| 341 | #define MDIO_AN_10GBT_STAT_LP10G	0x0800	/* LP is 10GBT capable */ |
| 342 | #define MDIO_AN_10GBT_STAT_REMOK	0x1000	/* Remote OK */ |
| 343 | #define MDIO_AN_10GBT_STAT_LOCOK	0x2000	/* Local OK */ |
| 344 | #define MDIO_AN_10GBT_STAT_MS		0x4000	/* Master/slave config */ |
| 345 | #define MDIO_AN_10GBT_STAT_MSFLT	0x8000	/* Master/slave config fault */ |
| 346 | |
| 347 | /* 10BASE-T1L PMA control */ |
| 348 | #define MDIO_PMA_10T1L_CTRL_LB_EN	0x0001	/* Enable loopback mode */ |
| 349 | #define MDIO_PMA_10T1L_CTRL_EEE_EN	0x0400	/* Enable EEE mode */ |
| 350 | #define MDIO_PMA_10T1L_CTRL_LOW_POWER	0x0800	/* Low-power mode */ |
| 351 | #define MDIO_PMA_10T1L_CTRL_2V4_EN	0x1000	/* Enable 2.4 Vpp operating mode */ |
| 352 | #define MDIO_PMA_10T1L_CTRL_TX_DIS	0x4000	/* Transmit disable */ |
| 353 | #define MDIO_PMA_10T1L_CTRL_PMA_RST	0x8000	/* MA reset */ |
| 354 | |
| 355 | /* 10BASE-T1L PMA status register. */ |
| 356 | #define MDIO_PMA_10T1L_STAT_LINK	0x0001	/* PMA receive link up */ |
| 357 | #define MDIO_PMA_10T1L_STAT_FAULT	0x0002	/* Fault condition detected */ |
| 358 | #define MDIO_PMA_10T1L_STAT_POLARITY	0x0004	/* Receive polarity is reversed */ |
| 359 | #define MDIO_PMA_10T1L_STAT_RECV_FAULT	0x0200	/* Able to detect fault on receive path */ |
| 360 | #define MDIO_PMA_10T1L_STAT_EEE		0x0400	/* PHY has EEE ability */ |
| 361 | #define MDIO_PMA_10T1L_STAT_LOW_POWER	0x0800	/* PMA has low-power ability */ |
| 362 | #define MDIO_PMA_10T1L_STAT_2V4_ABLE	0x1000	/* PHY has 2.4 Vpp operating mode ability */ |
| 363 | #define MDIO_PMA_10T1L_STAT_LB_ABLE	0x2000	/* PHY has loopback ability */ |
| 364 | |
| 365 | /* 10BASE-T1L PCS control register. */ |
| 366 | #define MDIO_PCS_10T1L_CTRL_LB		0x4000	/* Enable PCS level loopback mode */ |
| 367 | #define MDIO_PCS_10T1L_CTRL_RESET	0x8000	/* PCS reset */ |
| 368 | |
| 369 | /* BASE-T1 PMA/PMD extended ability register. */ |
| 370 | #define MDIO_PMA_PMD_BT1_B100_ABLE	0x0001	/* 100BASE-T1 Ability */ |
| 371 | #define MDIO_PMA_PMD_BT1_B1000_ABLE	0x0002	/* 1000BASE-T1 Ability */ |
| 372 | #define MDIO_PMA_PMD_BT1_B10L_ABLE	0x0004	/* 10BASE-T1L Ability */ |
| 373 | |
| 374 | /* BASE-T1 auto-negotiation advertisement register [15:0] */ |
| 375 | #define MDIO_AN_T1_ADV_L_PAUSE_CAP	ADVERTISE_PAUSE_CAP |
| 376 | #define MDIO_AN_T1_ADV_L_PAUSE_ASYM	ADVERTISE_PAUSE_ASYM |
| 377 | #define MDIO_AN_T1_ADV_L_FORCE_MS	0x1000	/* Force Master/slave Configuration */ |
| 378 | #define MDIO_AN_T1_ADV_L_REMOTE_FAULT	ADVERTISE_RFAULT |
| 379 | #define MDIO_AN_T1_ADV_L_ACK		ADVERTISE_LPACK |
| 380 | #define MDIO_AN_T1_ADV_L_NEXT_PAGE_REQ	ADVERTISE_NPAGE |
| 381 | |
| 382 | /* BASE-T1 auto-negotiation advertisement register [31:16] */ |
| 383 | #define MDIO_AN_T1_ADV_M_B10L		0x4000	/* device is compatible with 10BASE-T1L */ |
| 384 | #define MDIO_AN_T1_ADV_M_1000BT1	0x0080	/* advertise 1000BASE-T1 */ |
| 385 | #define MDIO_AN_T1_ADV_M_100BT1		0x0020	/* advertise 100BASE-T1 */ |
| 386 | #define MDIO_AN_T1_ADV_M_MST		0x0010	/* advertise master preference */ |
| 387 | |
| 388 | /* BASE-T1 auto-negotiation advertisement register [47:32] */ |
| 389 | #define MDIO_AN_T1_ADV_H_10L_TX_HI_REQ	0x1000	/* 10BASE-T1L High Level Transmit Request */ |
| 390 | #define MDIO_AN_T1_ADV_H_10L_TX_HI	0x2000	/* 10BASE-T1L High Level Transmit Ability */ |
| 391 | |
| 392 | /* BASE-T1 AN LP Base Page ability register [15:0] */ |
| 393 | #define MDIO_AN_T1_LP_L_PAUSE_CAP	LPA_PAUSE_CAP |
| 394 | #define MDIO_AN_T1_LP_L_PAUSE_ASYM	LPA_PAUSE_ASYM |
| 395 | #define MDIO_AN_T1_LP_L_FORCE_MS	0x1000	/* LP Force Master/slave Configuration */ |
| 396 | #define MDIO_AN_T1_LP_L_REMOTE_FAULT	LPA_RFAULT |
| 397 | #define MDIO_AN_T1_LP_L_ACK		LPA_LPACK |
| 398 | #define MDIO_AN_T1_LP_L_NEXT_PAGE_REQ	LPA_NPAGE |
| 399 | |
| 400 | /* BASE-T1 AN LP Base Page ability register [31:16] */ |
| 401 | #define MDIO_AN_T1_LP_M_MST		0x0010	/* LP master preference */ |
| 402 | #define MDIO_AN_T1_LP_M_B10L		0x4000	/* LP is compatible with 10BASE-T1L */ |
| 403 | |
| 404 | /* BASE-T1 AN LP Base Page ability register [47:32] */ |
| 405 | #define MDIO_AN_T1_LP_H_10L_TX_HI_REQ	0x1000	/* 10BASE-T1L High Level LP Transmit Request */ |
| 406 | #define MDIO_AN_T1_LP_H_10L_TX_HI	0x2000	/* 10BASE-T1L High Level LP Transmit Ability */ |
| 407 | |
| 408 | /* 10BASE-T1 AN control register */ |
| 409 | #define MDIO_AN_10BT1_AN_CTRL_ADV_EEE_T1L	0x4000 /* 10BASE-T1L EEE ability advertisement */ |
| 410 | |
| 411 | /* 10BASE-T1 AN status register */ |
| 412 | #define MDIO_AN_10BT1_AN_STAT_LPA_EEE_T1L	0x4000 /* 10BASE-T1L LP EEE ability advertisement */ |
| 413 | |
| 414 | /* BASE-T1 PMA/PMD control register */ |
| 415 | #define MDIO_PMA_PMD_BT1_CTRL_STRAP		0x000F /* Type selection (Strap) */ |
| 416 | #define MDIO_PMA_PMD_BT1_CTRL_STRAP_B1000	0x0001 /* Select 1000BASE-T1 */ |
| 417 | #define MDIO_PMA_PMD_BT1_CTRL_CFG_MST		0x4000 /* MASTER-SLAVE config value */ |
| 418 | |
| 419 | /* 1000BASE-T1 PCS control register */ |
| 420 | #define MDIO_PCS_1000BT1_CTRL_LOW_POWER		0x0800 /* Low power mode */ |
| 421 | #define MDIO_PCS_1000BT1_CTRL_DISABLE_TX	0x4000 /* Global PMA transmit disable */ |
| 422 | #define MDIO_PCS_1000BT1_CTRL_RESET		0x8000 /* Software reset value */ |
| 423 | |
| 424 | /* 1000BASE-T1 PCS status register */ |
| 425 | #define MDIO_PCS_1000BT1_STAT_LINK	0x0004 /* PCS Link is up */ |
| 426 | #define MDIO_PCS_1000BT1_STAT_FAULT	0x0080 /* There is a fault condition */ |
| 427 | |
| 428 | |
| 429 | /* EEE Supported/Advertisement/LP Advertisement registers. |
| 430 | * |
| 431 | * EEE capability Register (3.20), Advertisement (7.60) and |
| 432 | * Link partner ability (7.61) registers have and can use the same identical |
| 433 | * bit masks. |
| 434 | */ |
| 435 | #define MDIO_AN_EEE_ADV_100TX	0x0002	/* Advertise 100TX EEE cap */ |
| 436 | #define MDIO_AN_EEE_ADV_1000T	0x0004	/* Advertise 1000T EEE cap */ |
| 437 | /* Note: the two defines above can be potentially used by the user-land |
| 438 | * and cannot remove them now. |
| 439 | * So, we define the new generic MDIO_EEE_100TX and MDIO_EEE_1000T macros |
| 440 | * using the previous ones (that can be considered obsolete). |
| 441 | */ |
| 442 | #define MDIO_EEE_100TX		MDIO_AN_EEE_ADV_100TX	/* 100TX EEE cap */ |
| 443 | #define MDIO_EEE_1000T		MDIO_AN_EEE_ADV_1000T	/* 1000T EEE cap */ |
| 444 | #define MDIO_EEE_10GT		0x0008	/* 10GT EEE cap */ |
| 445 | #define MDIO_EEE_1000KX		0x0010	/* 1000KX EEE cap */ |
| 446 | #define MDIO_EEE_10GKX4		0x0020	/* 10G KX4 EEE cap */ |
| 447 | #define MDIO_EEE_10GKR		0x0040	/* 10G KR EEE cap */ |
| 448 | #define MDIO_EEE_40GR_FW	0x0100	/* 40G R fast wake */ |
| 449 | #define MDIO_EEE_40GR_DS	0x0200	/* 40G R deep sleep */ |
| 450 | #define MDIO_EEE_100GR_FW	0x1000	/* 100G R fast wake */ |
| 451 | #define MDIO_EEE_100GR_DS	0x2000	/* 100G R deep sleep */ |
| 452 | |
| 453 | #define MDIO_EEE_2_5GT		0x0001	/* 2.5GT EEE cap */ |
| 454 | #define MDIO_EEE_5GT		0x0002	/* 5GT EEE cap */ |
| 455 | |
| 456 | /* AN MultiGBASE-T AN control 2 */ |
| 457 | #define MDIO_AN_THP_BP2_5GT	0x0008	/* 2.5GT THP bypass request */ |
| 458 | |
| 459 | /* 2.5G/5G Extended abilities register. */ |
| 460 | #define MDIO_PMA_NG_EXTABLE_2_5GBT	0x0001	/* 2.5GBASET ability */ |
| 461 | #define MDIO_PMA_NG_EXTABLE_5GBT	0x0002	/* 5GBASET ability */ |
| 462 | |
| 463 | /* LASI RX_ALARM control/status registers. */ |
| 464 | #define MDIO_PMA_LASI_RX_PHYXSLFLT	0x0001	/* PHY XS RX local fault */ |
| 465 | #define MDIO_PMA_LASI_RX_PCSLFLT	0x0008	/* PCS RX local fault */ |
| 466 | #define MDIO_PMA_LASI_RX_PMALFLT	0x0010	/* PMA/PMD RX local fault */ |
| 467 | #define MDIO_PMA_LASI_RX_OPTICPOWERFLT	0x0020	/* RX optical power fault */ |
| 468 | #define MDIO_PMA_LASI_RX_WISLFLT	0x0200	/* WIS local fault */ |
| 469 | |
| 470 | /* LASI TX_ALARM control/status registers. */ |
| 471 | #define MDIO_PMA_LASI_TX_PHYXSLFLT	0x0001	/* PHY XS TX local fault */ |
| 472 | #define MDIO_PMA_LASI_TX_PCSLFLT	0x0008	/* PCS TX local fault */ |
| 473 | #define MDIO_PMA_LASI_TX_PMALFLT	0x0010	/* PMA/PMD TX local fault */ |
| 474 | #define MDIO_PMA_LASI_TX_LASERPOWERFLT	0x0080	/* Laser output power fault */ |
| 475 | #define MDIO_PMA_LASI_TX_LASERTEMPFLT	0x0100	/* Laser temperature fault */ |
| 476 | #define MDIO_PMA_LASI_TX_LASERBICURRFLT	0x0200	/* Laser bias current fault */ |
| 477 | |
| 478 | /* LASI control/status registers. */ |
| 479 | #define MDIO_PMA_LASI_LSALARM		0x0001	/* LS_ALARM enable/status */ |
| 480 | #define MDIO_PMA_LASI_TXALARM		0x0002	/* TX_ALARM enable/status */ |
| 481 | #define MDIO_PMA_LASI_RXALARM		0x0004	/* RX_ALARM enable/status */ |
| 482 | |
| 483 | /* Mapping between MDIO PRTAD/DEVAD and mii_ioctl_data::phy_id */ |
| 484 | |
| 485 | #define MDIO_PHY_ID_C45			0x8000 |
| 486 | #define MDIO_PHY_ID_PRTAD		0x03e0 |
| 487 | #define MDIO_PHY_ID_DEVAD		0x001f |
| 488 | #define MDIO_PHY_ID_C45_MASK						\ |
| 489 | 	(MDIO_PHY_ID_C45 | MDIO_PHY_ID_PRTAD | MDIO_PHY_ID_DEVAD) |
| 490 | |
| 491 | static __inline__ __u16 mdio_phy_id_c45(int prtad, int devad) |
| 492 | { |
| 493 | 	return MDIO_PHY_ID_C45 | (prtad << 5) | devad; |
| 494 | } |
| 495 | |
| 496 | /* UsxgmiiChannelInfo[15:0] for USXGMII in-band auto-negotiation.*/ |
| 497 | #define MDIO_USXGMII_EEE_CLK_STP	0x0080	/* EEE clock stop supported */ |
| 498 | #define MDIO_USXGMII_EEE		0x0100	/* EEE supported */ |
| 499 | #define MDIO_USXGMII_SPD_MASK		0x0e00	/* USXGMII speed mask */ |
| 500 | #define MDIO_USXGMII_FULL_DUPLEX	0x1000	/* USXGMII full duplex */ |
| 501 | #define MDIO_USXGMII_DPX_SPD_MASK	0x1e00	/* USXGMII duplex and speed bits */ |
| 502 | #define MDIO_USXGMII_10			0x0000	/* 10Mbps */ |
| 503 | #define MDIO_USXGMII_10HALF		0x0000	/* 10Mbps half-duplex */ |
| 504 | #define MDIO_USXGMII_10FULL		0x1000	/* 10Mbps full-duplex */ |
| 505 | #define MDIO_USXGMII_100		0x0200	/* 100Mbps */ |
| 506 | #define MDIO_USXGMII_100HALF		0x0200	/* 100Mbps half-duplex */ |
| 507 | #define MDIO_USXGMII_100FULL		0x1200	/* 100Mbps full-duplex */ |
| 508 | #define MDIO_USXGMII_1000		0x0400	/* 1000Mbps */ |
| 509 | #define MDIO_USXGMII_1000HALF		0x0400	/* 1000Mbps half-duplex */ |
| 510 | #define MDIO_USXGMII_1000FULL		0x1400	/* 1000Mbps full-duplex */ |
| 511 | #define MDIO_USXGMII_10G		0x0600	/* 10Gbps */ |
| 512 | #define MDIO_USXGMII_10GHALF		0x0600	/* 10Gbps half-duplex */ |
| 513 | #define MDIO_USXGMII_10GFULL		0x1600	/* 10Gbps full-duplex */ |
| 514 | #define MDIO_USXGMII_2500		0x0800	/* 2500Mbps */ |
| 515 | #define MDIO_USXGMII_2500HALF		0x0800	/* 2500Mbps half-duplex */ |
| 516 | #define MDIO_USXGMII_2500FULL		0x1800	/* 2500Mbps full-duplex */ |
| 517 | #define MDIO_USXGMII_5000		0x0a00	/* 5000Mbps */ |
| 518 | #define MDIO_USXGMII_5000HALF		0x0a00	/* 5000Mbps half-duplex */ |
| 519 | #define MDIO_USXGMII_5000FULL		0x1a00	/* 5000Mbps full-duplex */ |
| 520 | #define MDIO_USXGMII_LINK		0x8000	/* PHY link with copper-side partner */ |
| 521 | |
| 522 | #endif /* __LINUX_MDIO_H__ */ |