Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic - Print chip revision. From OpenBSD.



details:   https://anonhg.NetBSD.org/src/rev/fd370e971d9a
branches:  trunk
changeset: 955137:fd370e971d9a
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Sep 21 06:57:00 2020 +0000

description:
- Print chip revision. From OpenBSD.
- Rename RTK_HWREV_8168_SPIN[123] to RTK_HWREV_8168'B'_SPIN[123].
  Same as other *BSDs.
- Rename RTK_HWREV_8168G_SPIN4 to RTK_HWREV_8411B. Same as other *BSDs.
- Add definition of RTK_HWREV_8169_8110SCE.

diffstat:

 sys/dev/ic/rtl8169.c    |  86 +++++++++++++++++++++++++++++++++++++++++-------
 sys/dev/ic/rtl81x9reg.h |  11 +++--
 sys/dev/ic/rtl81x9var.h |   3 +-
 3 files changed, 81 insertions(+), 19 deletions(-)

diffs (205 lines):

diff -r b5fcbf1c6158 -r fd370e971d9a sys/dev/ic/rtl8169.c
--- a/sys/dev/ic/rtl8169.c      Mon Sep 21 06:48:48 2020 +0000
+++ b/sys/dev/ic/rtl8169.c      Mon Sep 21 06:57:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtl8169.c,v 1.166 2020/03/13 04:08:07 thorpej Exp $    */
+/*     $NetBSD: rtl8169.c,v 1.167 2020/09/21 06:57:00 msaitoh Exp $    */
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.166 2020/03/13 04:08:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.167 2020/09/21 06:57:00 msaitoh Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -172,6 +172,54 @@
 
 static void re_reset(struct rtk_softc *);
 
+static const struct re_revision {
+       uint32_t                re_chipid;
+       const char              *re_name;
+} re_revisions[] = {
+       { RTK_HWREV_8100,       "RTL8100" },
+       { RTK_HWREV_8100E,      "RTL8100E" },
+       { RTK_HWREV_8100E_SPIN2, "RTL8100E 2" },
+       { RTK_HWREV_8101,       "RTL8101" },
+       { RTK_HWREV_8101E,      "RTL8101E" },
+       { RTK_HWREV_8102E,      "RTL8102E" },
+       { RTK_HWREV_8106E,      "RTL8106E" },
+       { RTK_HWREV_8401E,      "RTL8401E" },
+       { RTK_HWREV_8402,       "RTL8402" },
+       { RTK_HWREV_8411,       "RTL8411" },
+       { RTK_HWREV_8411B,      "RTL8411B" },
+       { RTK_HWREV_8102EL,     "RTL8102EL" },
+       { RTK_HWREV_8102EL_SPIN1, "RTL8102EL 1" },
+       { RTK_HWREV_8103E,       "RTL8103E" },
+       { RTK_HWREV_8110S,      "RTL8110S" },
+       { RTK_HWREV_8139CPLUS,  "RTL8139C+" },
+       { RTK_HWREV_8168B_SPIN1, "RTL8168 1" },
+       { RTK_HWREV_8168B_SPIN2, "RTL8168 2" },
+       { RTK_HWREV_8168B_SPIN3, "RTL8168 3" },
+       { RTK_HWREV_8168C,      "RTL8168C/8111C" },
+       { RTK_HWREV_8168C_SPIN2, "RTL8168C/8111C" },
+       { RTK_HWREV_8168CP,     "RTL8168CP/8111CP" },
+       { RTK_HWREV_8168F,      "RTL8168F/8111F" },
+       { RTK_HWREV_8168G,      "RTL8168G/8111G" },
+       { RTK_HWREV_8168GU,     "RTL8168GU/8111GU" },
+       { RTK_HWREV_8168H,      "RTL8168H/8111H" },
+       { RTK_HWREV_8105E,      "RTL8105E" },
+       { RTK_HWREV_8105E_SPIN1, "RTL8105E" },
+       { RTK_HWREV_8168D,      "RTL8168D/8111D" },
+       { RTK_HWREV_8168DP,     "RTL8168DP/8111DP" },
+       { RTK_HWREV_8168E,      "RTL8168E/8111E" },
+       { RTK_HWREV_8168E_VL,   "RTL8168E/8111E-VL" },
+       { RTK_HWREV_8168EP,     "RTL8168EP/8111EP" },
+       { RTK_HWREV_8168FP,     "RTL8168FP/8117" },
+       { RTK_HWREV_8169,       "RTL8169" },
+       { RTK_HWREV_8169_8110SB, "RTL8169/8110SB" },
+       { RTK_HWREV_8169_8110SBL, "RTL8169SBL" },
+       { RTK_HWREV_8169_8110SC, "RTL8169/8110SCd" },
+       { RTK_HWREV_8169_8110SCE, "RTL8169/8110SCe" },
+       { RTK_HWREV_8169S,      "RTL8169S" },
+
+       { 0, NULL }
+};
+
 static inline void
 re_set_bufaddr(struct re_desc *d, bus_addr_t addr)
 {
@@ -559,13 +607,26 @@
        struct ifnet *ifp;
        struct mii_data *mii = &sc->mii;
        int error = 0, i;
+       const struct re_revision *rr;
+       const char *re_name = NULL;
 
        if ((sc->sc_quirk & RTKQ_8139CPLUS) == 0) {
-               uint32_t hwrev;
+               /* Revision of 8169/8169S/8110s in bits 30..26, 23 */
+               sc->sc_hwrev = CSR_READ_4(sc, RTK_TXCFG) & RTK_TXCFG_HWREV;
+
+               for (rr = re_revisions; rr->re_name != NULL; rr++) {
+                       if (rr->re_chipid == sc->sc_hwrev)
+                               re_name = rr->re_name;
+               }
 
-               /* Revision of 8169/8169S/8110s in bits 30..26, 23 */
-               hwrev = CSR_READ_4(sc, RTK_TXCFG) & RTK_TXCFG_HWREV;
-               switch (hwrev) {
+               if (re_name == NULL)
+                       aprint_normal_dev(sc->sc_dev,
+                           "unknown ASIC (0x%04x)\n", sc->sc_hwrev >> 16);
+               else
+                       aprint_normal_dev(sc->sc_dev,
+                           "%s (0x%04x)\n", re_name, sc->sc_hwrev >> 16);
+
+               switch (sc->sc_hwrev) {
                case RTK_HWREV_8169:
                        sc->sc_quirk |= RTKQ_8169NONS;
                        break;
@@ -576,9 +637,9 @@
                case RTK_HWREV_8169_8110SC:
                        sc->sc_quirk |= RTKQ_MACLDPS;
                        break;
-               case RTK_HWREV_8168_SPIN1:
-               case RTK_HWREV_8168_SPIN2:
-               case RTK_HWREV_8168_SPIN3:
+               case RTK_HWREV_8168B_SPIN1:
+               case RTK_HWREV_8168B_SPIN2:
+               case RTK_HWREV_8168B_SPIN3:
                        sc->sc_quirk |= RTKQ_MACSTAT;
                        break;
                case RTK_HWREV_8168C:
@@ -625,7 +686,7 @@
                case RTK_HWREV_8168G:
                case RTK_HWREV_8168G_SPIN1:
                case RTK_HWREV_8168G_SPIN2:
-               case RTK_HWREV_8168G_SPIN4:
+               case RTK_HWREV_8411B:
                        sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
                            RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO | 
                            RTKQ_RXDV_GATED;
@@ -647,7 +708,7 @@
                        break;
                case RTK_HWREV_8401E:
                case RTK_HWREV_8105E:
-               case RTK_HWREV_8105E_SPIN1:
+               case RTK_HWREV_8105E_SPIN1: /* XXX */
                case RTK_HWREV_8106E:
                        sc->sc_quirk |= RTKQ_PHYWAKE_PM |
                            RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT |
@@ -659,8 +720,7 @@
                            RTKQ_CMDSTOP; /* CMDSTOP_WAIT_TXQ */
                        break;
                default:
-                       aprint_normal_dev(sc->sc_dev,
-                           "Unknown revision (0x%08x)\n", hwrev);
+                       aprint_normal_dev(sc->sc_dev, "Use default quirks\n");
                        /* assume the latest features */
                        sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD;
                        sc->sc_quirk |= RTKQ_NOJUMBO;
diff -r b5fcbf1c6158 -r fd370e971d9a sys/dev/ic/rtl81x9reg.h
--- a/sys/dev/ic/rtl81x9reg.h   Mon Sep 21 06:48:48 2020 +0000
+++ b/sys/dev/ic/rtl81x9reg.h   Mon Sep 21 06:57:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtl81x9reg.h,v 1.53 2020/03/13 04:08:07 thorpej Exp $  */
+/*     $NetBSD: rtl81x9reg.h,v 1.54 2020/09/21 06:57:00 msaitoh Exp $  */
 
 /*
  * Copyright (c) 1997, 1998
@@ -166,13 +166,13 @@
 #define RTK_HWREV_8168DP       0x28800000
 #define RTK_HWREV_8168E                0x2C000000
 #define RTK_HWREV_8168E_VL     0x2C800000
-#define RTK_HWREV_8168_SPIN1   0x30000000
+#define RTK_HWREV_8168B_SPIN1  0x30000000
 #define RTK_HWREV_8100E                0x30800000
 #define RTK_HWREV_8101E                0x34000000
 #define RTK_HWREV_8102E                0x34800000
 #define RTK_HWREV_8103E                0x34c00000
-#define RTK_HWREV_8168_SPIN2   0x38000000
-#define RTK_HWREV_8168_SPIN3   0x38400000
+#define RTK_HWREV_8168B_SPIN2  0x38000000
+#define RTK_HWREV_8168B_SPIN3  0x38400000
 #define RTK_HWREV_8100E_SPIN2  0x38800000
 #define RTK_HWREV_8168C                0x3C000000
 #define RTK_HWREV_8168C_SPIN2  0x3C400000
@@ -191,7 +191,7 @@
 #define RTK_HWREV_8168H                0x54000000
 #define RTK_HWREV_8168H_SPIN1  0x54100000
 #define RTK_HWREV_8168FP       0x54800000
-#define RTK_HWREV_8168G_SPIN4  0x5c800000
+#define RTK_HWREV_8411B                0x5c800000
 #define RTK_HWREV_8139         0x60000000
 #define RTK_HWREV_8139A                0x70000000
 #define RTK_HWREV_8139AG       0x70800000
@@ -203,6 +203,7 @@
 #define RTK_HWREV_8100         0x78800000
 #define RTK_HWREV_8130         0x7C000000
 #define RTK_HWREV_8169_8110SBL 0x7cc00000
+#define RTK_HWREV_8169_8110SCE 0x98000000
 
 #define RTK_TXDMA_16BYTES      0x00000000
 #define RTK_TXDMA_32BYTES      0x00000100
diff -r b5fcbf1c6158 -r fd370e971d9a sys/dev/ic/rtl81x9var.h
--- a/sys/dev/ic/rtl81x9var.h   Mon Sep 21 06:48:48 2020 +0000
+++ b/sys/dev/ic/rtl81x9var.h   Mon Sep 21 06:57:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtl81x9var.h,v 1.57 2019/09/22 16:41:19 ryo Exp $      */
+/*     $NetBSD: rtl81x9var.h,v 1.58 2020/09/21 06:57:00 msaitoh Exp $  */
 
 /*
  * Copyright (c) 1997, 1998
@@ -176,6 +176,7 @@
        device_t                sc_dev;
        struct ethercom         ethercom;       /* interface info */
        struct mii_data         mii;
+       uint32_t                sc_hwrev;
        struct callout          rtk_tick_ch;    /* tick callout */
        bus_space_tag_t         rtk_btag;       /* bus space tag */
        bus_space_handle_t      rtk_bhandle;    /* bus space handle */



Home | Main Index | Thread Index | Old Index