Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Restore original MDC speed control register valu...



details:   https://anonhg.NetBSD.org/src/rev/464977456f7b
branches:  trunk
changeset: 1023246:464977456f7b
user:      andvar <andvar%NetBSD.org@localhost>
date:      Mon Aug 30 20:09:22 2021 +0000

description:
Restore original MDC speed control register value after MAC reset, if it wasn't default. Fixes PR port-i386/53494.
ok riastradh

diffstat:

 sys/dev/pci/if_vte.c |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r 063cc7fc689b -r 464977456f7b sys/dev/pci/if_vte.c
--- a/sys/dev/pci/if_vte.c      Mon Aug 30 19:48:21 2021 +0000
+++ b/sys/dev/pci/if_vte.c      Mon Aug 30 20:09:22 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vte.c,v 1.31 2020/02/07 00:04:28 thorpej Exp $      */
+/*     $NetBSD: if_vte.c,v 1.32 2021/08/30 20:09:22 andvar Exp $       */
 
 /*
  * Copyright (c) 2011 Manuel Bouyer.  All rights reserved.
@@ -55,7 +55,7 @@
 /* Driver for DM&P Electronics, Inc, Vortex86 RDC R6040 FastEthernet. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vte.c,v 1.31 2020/02/07 00:04:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vte.c,v 1.32 2021/08/30 20:09:22 andvar Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1211,9 +1211,10 @@
 static void
 vte_reset(struct vte_softc *sc)
 {
-       uint16_t mcr;
+       uint16_t mcr, mdcsc;
        int i;
 
+       mdcsc = CSR_READ_2(sc, VTE_MDCSC);
        mcr = CSR_READ_2(sc, VTE_MCR1);
        CSR_WRITE_2(sc, VTE_MCR1, mcr | MCR1_MAC_RESET);
        for (i = VTE_RESET_TIMEOUT; i > 0; i--) {
@@ -1231,6 +1232,14 @@
        CSR_WRITE_2(sc, VTE_MACSM, 0x0002);
        CSR_WRITE_2(sc, VTE_MACSM, 0);
        DELAY(5000);
+
+       /*
+        * On some SoCs (like Vortex86DX3) MDC speed control register value
+        * needs to be restored to original value instead of default one,
+        * otherwise some PHY registers may fail to be read.
+        */
+       if (mdcsc != MDCSC_DEFAULT)
+               CSR_WRITE_2(sc, VTE_MDCSC, mdcsc);
 }
 
 



Home | Main Index | Thread Index | Old Index