Tue Jan 28 09:34:29 2020 UTC ()
Pull up the following, requested by msaitoh in ticket #1493:

	sys/dev/mii/makphy.c			1.61, 1.63-1.64 via patch
	sys/dev/mii/makphyreg.h			1.10

- Remove ESSR_FIBER_LINK bit check in makphyattach(). This bit is
  valid only when the link is up, so it's not good to check in the
  attach function.
- There is an environment that both copper and fiber bits are set in
  EXTSR but it support copper only. To resolve this problem, check the
  ESSR register's HWCFG_MODE bit and drop unsupported bits.
- If the chip is in Fiber/Copper auto select mode, check which media is
  selected. Currently, the code supports 88E1011, 88E1111 and 88E1112
  only.
- Fix comment. KNF.


(martin)
diff -r1.42.8.3 -r1.42.8.4 src/sys/dev/mii/makphy.c
diff -r1.6.20.1 -r1.6.20.2 src/sys/dev/mii/makphyreg.h

cvs diff -r1.42.8.3 -r1.42.8.4 src/sys/dev/mii/makphy.c (expand / switch to unified diff)

--- src/sys/dev/mii/makphy.c 2019/08/01 14:27:30 1.42.8.3
+++ src/sys/dev/mii/makphy.c 2020/01/28 09:34:29 1.42.8.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: makphy.c,v 1.42.8.3 2019/08/01 14:27:30 martin Exp $ */ 1/* $NetBSD: makphy.c,v 1.42.8.4 2020/01/28 09:34:29 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -49,27 +49,27 @@ @@ -49,27 +49,27 @@
49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */ 55 */
56 56
57/* 57/*
58 * Driver for the Marvell 88E1000 ``Alaska'' 10/100/1000 PHY. 58 * Driver for the Marvell 88E1000 ``Alaska'' 10/100/1000 PHY.
59 */ 59 */
60 60
61#include <sys/cdefs.h> 61#include <sys/cdefs.h>
62__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.42.8.3 2019/08/01 14:27:30 martin Exp $"); 62__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.42.8.4 2020/01/28 09:34:29 martin Exp $");
63 63
64#include <sys/param.h> 64#include <sys/param.h>
65#include <sys/systm.h> 65#include <sys/systm.h>
66#include <sys/kernel.h> 66#include <sys/kernel.h>
67#include <sys/device.h> 67#include <sys/device.h>
68#include <sys/socket.h> 68#include <sys/socket.h>
69#include <sys/errno.h> 69#include <sys/errno.h>
70 70
71#include <net/if.h> 71#include <net/if.h>
72#include <net/if_media.h> 72#include <net/if_media.h>
73 73
74#include <dev/mii/mii.h> 74#include <dev/mii/mii.h>
75#include <dev/mii/miivar.h> 75#include <dev/mii/miivar.h>
@@ -194,27 +194,27 @@ makphymatch(device_t parent, cfdata_t ma @@ -194,27 +194,27 @@ makphymatch(device_t parent, cfdata_t ma
194 194
195 return 0; 195 return 0;
196} 196}
197 197
198static void 198static void
199makphyattach(device_t parent, device_t self, void *aux) 199makphyattach(device_t parent, device_t self, void *aux)
200{ 200{
201 struct mii_softc *sc = device_private(self); 201 struct mii_softc *sc = device_private(self);
202 struct mii_attach_args *ma = aux; 202 struct mii_attach_args *ma = aux;
203 struct mii_data *mii = ma->mii_data; 203 struct mii_data *mii = ma->mii_data;
204 const struct mii_phydesc *mpd; 204 const struct mii_phydesc *mpd;
205 struct makphy_softc *maksc = (struct makphy_softc *)sc; 205 struct makphy_softc *maksc = (struct makphy_softc *)sc;
206 const char *name; 206 const char *name;
207 int model, val; 207 int reg, model;
208 208
209 mpd = mii_phy_match(ma, makphys); 209 mpd = mii_phy_match(ma, makphys);
210 aprint_naive(": Media interface\n"); 210 aprint_naive(": Media interface\n");
211 if (mpd) 211 if (mpd)
212 name = mpd->mpd_name; 212 name = mpd->mpd_name;
213 else if (makphy_isi210(parent, ma)) { 213 else if (makphy_isi210(parent, ma)) {
214 name = MII_STR_xxMARVELL_I210; 214 name = MII_STR_xxMARVELL_I210;
215 maksc->sc_flags |= MAKPHY_F_I210; 215 maksc->sc_flags |= MAKPHY_F_I210;
216 } else 216 } else
217 panic("Unknown PHY"); 217 panic("Unknown PHY");
218 aprint_normal(": %s, rev. %d\n", name, MII_REV(ma->mii_id2)); 218 aprint_normal(": %s, rev. %d\n", name, MII_REV(ma->mii_id2));
219 219
220 sc->mii_dev = self; 220 sc->mii_dev = self;
@@ -235,64 +235,99 @@ makphyattach(device_t parent, device_t s @@ -235,64 +235,99 @@ makphyattach(device_t parent, device_t s
235 /* FALLTHROUGH */ 235 /* FALLTHROUGH */
236 case MII_MODEL_xxMARVELL_E1000_3: 236 case MII_MODEL_xxMARVELL_E1000_3:
237 case MII_MODEL_xxMARVELL_E1000S: 237 case MII_MODEL_xxMARVELL_E1000S:
238 case MII_MODEL_xxMARVELL_E1000_5: 238 case MII_MODEL_xxMARVELL_E1000_5:
239 /* 88E1000 series has no EADR */ 239 /* 88E1000 series has no EADR */
240 break; 240 break;
241 default: 241 default:
242page0: 242page0:
243 /* Make sure page 0 is selected. */ 243 /* Make sure page 0 is selected. */
244 PHY_WRITE(sc, MAKPHY_EADR, 0); 244 PHY_WRITE(sc, MAKPHY_EADR, 0);
245 break; 245 break;
246 } 246 }
247 247
248 switch (model) { 
249 case MII_MODEL_xxMARVELL_E1011: 
250 case MII_MODEL_xxMARVELL_E1112: 
251 val = PHY_READ(sc, MAKPHY_ESSR); 
252 if ((val != 0) && (((u_int)val & 0x0000ffffU) != 0x0000ffffU) 
253 && ((val & ESSR_FIBER_LINK) != 0)) 
254 sc->mii_flags |= MIIF_HAVEFIBER; 
255 break; 
256 default: 
257 break; 
258 } 
259 
260 PHY_RESET(sc); 248 PHY_RESET(sc);
261 249
262 sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; 250 sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
263 if (sc->mii_capabilities & BMSR_EXTSTAT) 251 if (sc->mii_capabilities & BMSR_EXTSTAT)
264 sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); 252 sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
265 253
 254 if (((sc->mii_extcapabilities & (EXTSR_1000TFDX | EXTSR_1000THDX))
 255 != 0)
 256 && ((sc->mii_extcapabilities & (EXTSR_1000XFDX | EXTSR_1000XHDX))
 257 != 0)) {
 258 bool fiberonly = false, copperonly = false;
 259
 260 /* Both copper and fiber are set. check MODE[] */
 261 switch (sc->mii_mpd_model) {
 262 case MII_MODEL_xxMARVELL_E1011:
 263 case MII_MODEL_xxMARVELL_E1111:
 264 /* These devices have ESSR register */
 265 reg = PHY_READ(sc, MAKPHY_ESSR);
 266 if ((reg & ESSR_AUTOSEL_DISABLE) != 0) {
 267 switch (reg & ESSR_HWCFG_MODE) {
 268 case ESSR_RTBI_FIBER:
 269 case ESSR_RGMII_FIBER:
 270 case ESSR_RGMII_SGMII: /* right? */
 271 case ESSR_TBI_FIBER:
 272 case ESSR_GMII_FIBER:
 273 fiberonly = true;
 274 break;
 275 case ESSR_SGMII_WC_COPPER:
 276 case ESSR_SGMII_WOC_COPPER:
 277 case ESSR_RTBI_COPPER:
 278 case ESSR_RGMII_COPPER:
 279 case ESSR_GMII_COPPER:
 280 copperonly = true;
 281 default:
 282 break;
 283 }
 284 }
 285 break;
 286 default:
 287 break;
 288 }
 289 if (fiberonly || copperonly)
 290 aprint_debug_dev(self, "both copper and fiber are set "
 291 "but MODE[] is %s only.\n",
 292 fiberonly ? "fiber" : "copper");
 293 if (fiberonly)
 294 sc->mii_extcapabilities
 295 &= ~(EXTSR_1000TFDX | EXTSR_1000THDX);
 296 else if (copperonly) {
 297 sc->mii_extcapabilities
 298 &= ~(EXTSR_1000XFDX | EXTSR_1000XHDX);
 299 sc->mii_flags &= ~MIIF_IS_1000X;
 300 }
 301 }
 302
266 aprint_normal_dev(self, ""); 303 aprint_normal_dev(self, "");
267 if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 && 304 if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 &&
268 (sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0) 305 (sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0)
269 aprint_error("no media present"); 306 aprint_error("no media present");
270 else 307 else
271 mii_phy_add_media(sc); 308 mii_phy_add_media(sc);
272 aprint_normal("\n"); 309 aprint_normal("\n");
273} 310}
274 311
275static void 312static void
276makphy_reset(struct mii_softc *sc) 313makphy_reset(struct mii_softc *sc)
277{ 314{
278 struct makphy_softc *maksc = (struct makphy_softc *)sc; 315 struct makphy_softc *maksc = (struct makphy_softc *)sc;
279 uint16_t reg; 316 uint16_t reg;
280 317
281 mii_phy_reset(sc); 318 mii_phy_reset(sc);
282 319
283 /* 320 /* Initialize PHY Specific Control Register. */
284 * Initialize PHY Specific Control Register. 
285 */ 
286 reg = PHY_READ(sc, MAKPHY_PSCR); 321 reg = PHY_READ(sc, MAKPHY_PSCR);
287 322
288 /* Assert CRS on transmit. */ 323 /* Assert CRS on transmit. */
289 switch (sc->mii_mpd_model) { 324 switch (sc->mii_mpd_model) {
290 case MII_MODEL_MARVELL_E1000_0: 325 case MII_MODEL_MARVELL_E1000_0:
291 if ((maksc->sc_flags & MAKPHY_F_I210) != 0) 326 if ((maksc->sc_flags & MAKPHY_F_I210) != 0)
292 break; 327 break;
293 /* FALLTHROUGH */ 328 /* FALLTHROUGH */
294 case MII_MODEL_MARVELL_E1000_3: 329 case MII_MODEL_MARVELL_E1000_3:
295 case MII_MODEL_MARVELL_E1000_5: 330 case MII_MODEL_MARVELL_E1000_5:
296 case MII_MODEL_MARVELL_E1000_6: 331 case MII_MODEL_MARVELL_E1000_6:
297 case MII_MODEL_xxMARVELL_E1000S: 332 case MII_MODEL_xxMARVELL_E1000S:
298 case MII_MODEL_xxMARVELL_E1011: 333 case MII_MODEL_xxMARVELL_E1011:
@@ -415,27 +450,27 @@ makphy_service(struct mii_softc *sc, str @@ -415,27 +450,27 @@ makphy_service(struct mii_softc *sc, str
415 450
416 /* Update the media status. */ 451 /* Update the media status. */
417 mii_phy_status(sc); 452 mii_phy_status(sc);
418 453
419 /* Callback if something changed. */ 454 /* Callback if something changed. */
420 mii_phy_update(sc, cmd); 455 mii_phy_update(sc, cmd);
421 return 0; 456 return 0;
422} 457}
423 458
424static void 459static void
425makphy_status(struct mii_softc *sc) 460makphy_status(struct mii_softc *sc)
426{ 461{
427 struct mii_data *mii = sc->mii_pdata; 462 struct mii_data *mii = sc->mii_pdata;
428 int bmcr, gsr, pssr; 463 int bmcr, gsr, pssr, essr;
429 464
430 mii->mii_media_status = IFM_AVALID; 465 mii->mii_media_status = IFM_AVALID;
431 mii->mii_media_active = IFM_ETHER; 466 mii->mii_media_active = IFM_ETHER;
432 467
433 bmcr = PHY_READ(sc, MII_BMCR); 468 bmcr = PHY_READ(sc, MII_BMCR);
434 /* XXX FIXME: Use different page for Fiber on newer chips */ 469 /* XXX FIXME: Use different page for Fiber on newer chips */
435 pssr = PHY_READ(sc, MAKPHY_PSSR); 470 pssr = PHY_READ(sc, MAKPHY_PSSR);
436 471
437 if (pssr & PSSR_LINK) 472 if (pssr & PSSR_LINK)
438 mii->mii_media_status |= IFM_ACTIVE; 473 mii->mii_media_status |= IFM_ACTIVE;
439 474
440 if (bmcr & BMCR_LOOP) 475 if (bmcr & BMCR_LOOP)
441 mii->mii_media_active |= IFM_LOOP; 476 mii->mii_media_active |= IFM_LOOP;
@@ -453,30 +488,65 @@ makphy_status(struct mii_softc *sc) @@ -453,30 +488,65 @@ makphy_status(struct mii_softc *sc)
453 */ 488 */
454 if (!(pssr & PSSR_RESOLVED)) { 489 if (!(pssr & PSSR_RESOLVED)) {
455 /* Erg, still trying, I guess... */ 490 /* Erg, still trying, I guess... */
456 mii->mii_media_active |= IFM_NONE; 491 mii->mii_media_active |= IFM_NONE;
457 return; 492 return;
458 } 493 }
459 } else { 494 } else {
460 if ((pssr & PSSR_LINK) == 0) { 495 if ((pssr & PSSR_LINK) == 0) {
461 mii->mii_media_active |= IFM_NONE; 496 mii->mii_media_active |= IFM_NONE;
462 return; 497 return;
463 } 498 }
464 } 499 }
465 500
466 /* XXX FIXME: Use different page for Fiber on newer chips */ 501 /*
 502 * XXX The following code support Fiber/Copper auto select mode
 503 * only for 88E1011, 88E1111 and 88E1112. For other chips, the document
 504 * is required.
 505 */
467 if (sc->mii_flags & MIIF_IS_1000X) { 506 if (sc->mii_flags & MIIF_IS_1000X) {
 507 /* Not in Fiber/Copper auto select mode */
 508 mii->mii_media_active |= IFM_1000_SX;
 509 } else if ((sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1011) ||
 510 (sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1111)) {
 511 /* Fiber/Copper auto select mode */
 512
 513 essr = PHY_READ(sc, MAKPHY_ESSR);
 514 if ((essr & ESSR_FIBER_LINK) == 0)
 515 goto copper;
 516
 517 /* XXX Assume 1000BASE-SX only */
468 mii->mii_media_active |= IFM_1000_SX; 518 mii->mii_media_active |= IFM_1000_SX;
 519 } else if (sc->mii_mpd_model == MII_MODEL_xxMARVELL_E1112) {
 520 /* Fiber/Copper auto select mode */
 521
 522 pssr = PHY_READ(sc, MAKPHY_PSSR);
 523 if ((pssr & PSSR_RESOLUTION_FIBER) == 0)
 524 goto copper;
 525
 526 switch (PSSR_SPEED_get(pssr)) {
 527 case SPEED_1000:
 528 mii->mii_media_active |= IFM_1000_SX;
 529 break;
 530 case SPEED_100:
 531 mii->mii_media_active |= IFM_100_FX;
 532 break;
 533 default: /* Undefined (reserved) value */
 534 mii->mii_media_active |= IFM_NONE;
 535 mii->mii_media_status = 0;
 536 return;
 537 }
469 } else { 538 } else {
 539copper:
470 switch (PSSR_SPEED_get(pssr)) { 540 switch (PSSR_SPEED_get(pssr)) {
471 case SPEED_1000: 541 case SPEED_1000:
472 mii->mii_media_active |= IFM_1000_T; 542 mii->mii_media_active |= IFM_1000_T;
473 break; 543 break;
474 case SPEED_100: 544 case SPEED_100:
475 mii->mii_media_active |= IFM_100_TX; 545 mii->mii_media_active |= IFM_100_TX;
476 break; 546 break;
477 case SPEED_10: 547 case SPEED_10:
478 mii->mii_media_active |= IFM_10_T; 548 mii->mii_media_active |= IFM_10_T;
479 break; 549 break;
480 default: /* Undefined (reserved) value */ 550 default: /* Undefined (reserved) value */
481 mii->mii_media_active |= IFM_NONE; 551 mii->mii_media_active |= IFM_NONE;
482 mii->mii_media_status = 0; 552 mii->mii_media_status = 0;

cvs diff -r1.6.20.1 -r1.6.20.2 src/sys/dev/mii/makphyreg.h (expand / switch to unified diff)

--- src/sys/dev/mii/makphyreg.h 2019/01/17 17:23:02 1.6.20.1
+++ src/sys/dev/mii/makphyreg.h 2020/01/28 09:34:29 1.6.20.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: makphyreg.h,v 1.6.20.1 2019/01/17 17:23:02 martin Exp $ */ 1/* $NetBSD: makphyreg.h,v 1.6.20.2 2020/01/28 09:34:29 martin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe. 8 * by Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -97,26 +97,32 @@ @@ -97,26 +97,32 @@
97#define PSSR_MDIX (1U << 6) /* 1 = MIDX, 0 = MDI */ 97#define PSSR_MDIX (1U << 6) /* 1 = MIDX, 0 = MDI */
98#define PSSR_CABLE_LENGTH_get(x) (((x) >> 7) & 0x3) 98#define PSSR_CABLE_LENGTH_get(x) (((x) >> 7) & 0x3)
99#define PSSR_LINK (1U << 10) /* link indication */ 99#define PSSR_LINK (1U << 10) /* link indication */
100#define PSSR_RESOLVED (1U << 11) /* speed and duplex resolved */ 100#define PSSR_RESOLVED (1U << 11) /* speed and duplex resolved */
101#define PSSR_PAGE_RECEIVED (1U << 12) /* page received */ 101#define PSSR_PAGE_RECEIVED (1U << 12) /* page received */
102#define PSSR_DUPLEX (1U << 13) /* 1 = FDX */ 102#define PSSR_DUPLEX (1U << 13) /* 1 = FDX */
103#define PSSR_SPEED_get(x) (((x) >> 14) & 0x3) 103#define PSSR_SPEED_get(x) (((x) >> 14) & 0x3)
104 104
105#define SPEED_10 0 105#define SPEED_10 0
106#define SPEED_100 1 106#define SPEED_100 1
107#define SPEED_1000 2 107#define SPEED_1000 2
108#define SPEED_reserved 3 108#define SPEED_reserved 3
109 109
 110/* For 88E1112 */
 111#define PSSR_RESOLUTION_FIBER (1U << 7) /*
 112 * Fiber/Copper resolution
 113 * 1 = Fiber, 0 = Copper
 114 */
 115
110#define MAKPHY_IE 0x12 /* Interrupt enable */ 116#define MAKPHY_IE 0x12 /* Interrupt enable */
111#define IE_JABBER (1U << 0) /* jabber indication */ 117#define IE_JABBER (1U << 0) /* jabber indication */
112#define IE_POL_CHANGED (1U << 1) /* polarity changed */ 118#define IE_POL_CHANGED (1U << 1) /* polarity changed */
113#define IE_MDI_XOVER_CHANGED (1U << 6) /* MDI/MDIX changed */ 119#define IE_MDI_XOVER_CHANGED (1U << 6) /* MDI/MDIX changed */
114#define IE_FIFO_OVER_UNDER (1U << 7) /* FIFO over/underflow */ 120#define IE_FIFO_OVER_UNDER (1U << 7) /* FIFO over/underflow */
115#define IE_FALSE_CARRIER (1U << 8) /* false carrier detected */ 121#define IE_FALSE_CARRIER (1U << 8) /* false carrier detected */
116#define IE_SYMBOL_ERROR (1U << 9) /* symbol error occurred */ 122#define IE_SYMBOL_ERROR (1U << 9) /* symbol error occurred */
117#define IE_LINK_CHANGED (1U << 10) /* link status changed */ 123#define IE_LINK_CHANGED (1U << 10) /* link status changed */
118#define IE_ANEG_COMPLETE (1U << 11) /* autonegotiation completed */ 124#define IE_ANEG_COMPLETE (1U << 11) /* autonegotiation completed */
119#define IE_PAGE_RECEIVED (1U << 12) /* page received */ 125#define IE_PAGE_RECEIVED (1U << 12) /* page received */
120#define IE_DUPLEX_CHANGED (1U << 13) /* duplex changed */ 126#define IE_DUPLEX_CHANGED (1U << 13) /* duplex changed */
121#define IE_SPEED_CHANGED (1U << 14) /* speed changed */ 127#define IE_SPEED_CHANGED (1U << 14) /* speed changed */
122#define IE_ANEG_ERROR (1U << 15) /* autonegotiation error occurred */ 128#define IE_ANEG_ERROR (1U << 15) /* autonegotiation error occurred */
@@ -133,33 +139,44 @@ @@ -133,33 +139,44 @@
133#define MAKPHY_REC 0x15 /* receive error counter */ 139#define MAKPHY_REC 0x15 /* receive error counter */
134 140
135#define MAKPHY_EADR 0x16 /* extended address register */ 141#define MAKPHY_EADR 0x16 /* extended address register */
136 142
137#define MAKPHY_LEDCTRL 0x18 /* LED control */ 143#define MAKPHY_LEDCTRL 0x18 /* LED control */
138#define LEDCTRL_LED_TX (1U << 0) /* 1 = activ/link, 0 = xmit */ 144#define LEDCTRL_LED_TX (1U << 0) /* 1 = activ/link, 0 = xmit */
139#define LEDCTRL_LED_RX (1U << 1) /* 1 = activ/link, 1 = recv */ 145#define LEDCTRL_LED_RX (1U << 1) /* 1 = activ/link, 1 = recv */
140#define LEDCTRL_LED_DUPLEX (1U << 2) /* 1 = duplex, 0 = dup/coll */ 146#define LEDCTRL_LED_DUPLEX (1U << 2) /* 1 = duplex, 0 = dup/coll */
141#define LEDCTRL_LED_LINK (1U << 3) /* 1 = spd/link, 0 = link */ 147#define LEDCTRL_LED_LINK (1U << 3) /* 1 = spd/link, 0 = link */
142#define LEDCTRL_BLINK_RATE(x) ((x) << 8) 148#define LEDCTRL_BLINK_RATE(x) ((x) << 8)
143#define LEDCTRL_PULSE_STRCH(x) ((x) << 12) 149#define LEDCTRL_PULSE_STRCH(x) ((x) << 12)
144#define LEDCTRL_DISABLE (1U << 15) /* disable LED */ 150#define LEDCTRL_DISABLE (1U << 15) /* disable LED */
145 151
 152/* For 88E1011, 88E1111 */
146#define MAKPHY_ESSR 0x1b /* Extended PHY specific status */ 153#define MAKPHY_ESSR 0x1b /* Extended PHY specific status */
147#define ESSR_AUTOSEL_DISABLE 0x8000 /* Fiber/Copper autoselect disable */ 154#define ESSR_AUTOSEL_DISABLE 0x8000 /* Fiber/Copper autoselect disable */
148#define ESSR_FIBER_LINK 0x2000 /* Fiber/Copper resolution */ 155#define ESSR_FIBER_LINK 0x2000 /* Fiber/Copper resolution */
149#define ESSR_SER_ANEG_BYPASS 0x1000 /* Serial Iface Aneg bypass enable */ 156#define ESSR_SER_ANEG_BYPASS 0x1000 /* Serial Iface Aneg bypass enable */
150#define ESSR_SER_ANEG_BYPASS_ST 0x0800 /* Serial Iface Aneg bypass status */ 157#define ESSR_SER_ANEG_BYPASS_ST 0x0800 /* Serial Iface Aneg bypass status */
151#define ESSR_INTR_POLARITY 0x0400 /* Interrupt Polarity */ 158#define ESSR_INTR_POLARITY 0x0400 /* Interrupt Polarity */
152#define ESSR_AUTO_MEDIAREG_SEL 0x0200 /* Auto Medium Register Selection */ 159#define ESSR_AUTO_MEDIAREG_SEL 0x0200 /* Auto Medium Register Selection */
153#define ESSR_DTE_DROP_HYST 0x01e0 /* DTE detect status drop hysteresis */ 160#define ESSR_DTE_DROP_HYST 0x01e0 /* DTE detect status drop hysteresis */
154#define ESSR_DTE_POWER 0x0010 161#define ESSR_DTE_POWER 0x0010
155#define ESSR_HWCFG_MODE 0x000f 162#define ESSR_HWCFG_MODE 0x000f
156#define ESSR_GMII_COPPER 0x000f 163#define ESSR_SGMII_WC_COPPER 0x0000 /* SGMII w/ Clock w/ SGMII AN Copper */
157#define ESSR_GMII_FIBER 0x0007 164#define ESSR_RTBI_FIBER 0x0001 /* RTBI to Fiber */
158#define ESSR_RGMII_COPPER 0x000b 165#define ESSR_RGMII_FIBER 0x0003 /* RGMII to Fiber */
159#define ESSR_RGMII_FIBER 0x0003 166#define ESSR_SGMII_WOC_COPPER 0x0004 /* SGMII w/o Clock w/ SGMII AN Copp. */
160#define ESSR_RGMII_SGMII 0x0006 167#define ESSR_TBI_FIBER 0x0005 /* TBI to Fiber */
161#define ESSR_TBI_COPPER 0x000d 168#define ESSR_RGMII_SGMII 0x0006 /* RGMII to SGMII */
162#define ESSR_TBI_FIBER 0x0005 169#define ESSR_GMII_FIBER 0x0007 /* GMII to Fiber */
163 170#define ESSR_SERIAL_WAN 0x0008 /* 88E1011: Serial w 1000KX AN */
 171#define ESSR_GBIC 0x0008 /* 88E1111: GBIC */
 172#define ESSR_RTBI_COPPER 0x0009 /* RTBI to Copper */
 173#define ESSR_RGMII_COPPER 0x000b /* RGMII to Copper */
 174#define ESSR_RGMII_AUTOSEL 0x000b /* RGMII with Auto-Selection */
 175#define ESSR_SERIAL_WOAN 0x000c /* 88E1011: Serial w/o 1000KX AN */
 176#define ESSR_1000X_WOAN 0x000c /* 88E1111: 1000X w/o AN Copper */
 177#define ESSR_TBI_COPPER 0x000d /* TBI to Copper */
 178#define ESSR_GMII_SGMII 0x000e /* GMII to SGMII */
 179#define ESSR_GMII_COPPER 0x000f /* GMII to Copper */
 180#define ESSR_GMII_AUTOSEL 0x000f /* GMII with Auto-Selection */
164 181
165#endif /* _DEV_MII_MAKPHYREG_H_ */ 182#endif /* _DEV_MII_MAKPHYREG_H_ */