Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Make new sk_unreset_{xmac,yukon}() and use them ...



details:   https://anonhg.NetBSD.org/src/rev/18010b186341
branches:  trunk
changeset: 999463:18010b186341
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Jun 03 15:39:35 2019 +0000

description:
Make new sk_unreset_{xmac,yukon}() and use them in sk_attach().
Fixes PR kern/54267 reported by martin.

diffstat:

 sys/dev/pci/if_sk.c |  46 +++++++++++++++++++++++++++++++---------------
 1 files changed, 31 insertions(+), 15 deletions(-)

diffs (125 lines):

diff -r a7eb333bfee0 -r 18010b186341 sys/dev/pci/if_sk.c
--- a/sys/dev/pci/if_sk.c       Mon Jun 03 09:58:31 2019 +0000
+++ b/sys/dev/pci/if_sk.c       Mon Jun 03 15:39:35 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sk.c,v 1.98 2019/05/30 02:32:18 msaitoh Exp $       */
+/*     $NetBSD: if_sk.c,v 1.99 2019/06/03 15:39:35 msaitoh Exp $       */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -115,7 +115,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.98 2019/05/30 02:32:18 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.99 2019/06/03 15:39:35 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -168,7 +168,9 @@
 void sk_start(struct ifnet *);
 int sk_ioctl(struct ifnet *, u_long, void *);
 int sk_init(struct ifnet *);
+void sk_unreset_xmac(struct sk_if_softc *);
 void sk_init_xmac(struct sk_if_softc *);
+void sk_unreset_yukon(struct sk_if_softc *);
 void sk_init_yukon(struct sk_if_softc *);
 void sk_stop(struct ifnet *, int);
 void sk_watchdog(struct ifnet *);
@@ -1420,12 +1422,12 @@
         */
        switch (sc->sk_type) {
        case SK_GENESIS:
-               sk_init_xmac(sc_if);
+               sk_unreset_xmac(sc_if);
                break;
        case SK_YUKON:
        case SK_YUKON_LITE:
        case SK_YUKON_LP:
-               sk_init_yukon(sc_if);
+               sk_unreset_yukon(sc_if);
                break;
        default:
                aprint_error_dev(sc->sk_dev, "unknown device type %d\n",
@@ -2429,17 +2431,16 @@
 }
 
 void
-sk_init_xmac(struct sk_if_softc        *sc_if)
+sk_unreset_xmac(struct sk_if_softc *sc_if)
 {
        struct sk_softc         *sc = sc_if->sk_softc;
-       struct ifnet            *ifp = &sc_if->sk_ethercom.ec_if;
        static const struct sk_bcom_hack     bhack[] = {
        { 0x18, 0x0c20 }, { 0x17, 0x0012 }, { 0x15, 0x1104 }, { 0x17, 0x0013 },
        { 0x15, 0x0404 }, { 0x17, 0x8006 }, { 0x15, 0x0132 }, { 0x17, 0x8006 },
        { 0x15, 0x0232 }, { 0x17, 0x800D }, { 0x15, 0x000F }, { 0x18, 0x0420 },
        { 0, 0 } };
 
-       DPRINTFN(1, ("sk_init_xmac\n"));
+       DPRINTFN(1, ("sk_unreset_xmac\n"));
 
        /* Unreset the XMAC. */
        SK_IF_WRITE_2(sc_if, 0, SK_TXF1_MACCTL, SK_TXMACCTL_XMAC_UNRESET);
@@ -2495,6 +2496,15 @@
                        }
                }
        }
+}
+
+void
+sk_init_xmac(struct sk_if_softc *sc_if)
+{
+       struct sk_softc         *sc = sc_if->sk_softc;
+       struct ifnet            *ifp = &sc_if->sk_ethercom.ec_if;
+
+       sk_unreset_xmac(sc_if);
 
        /* Set station address */
        SK_XM_WRITE_2(sc_if, XM_PAR0,
@@ -2593,14 +2603,13 @@
        sc_if->sk_link = 1;
 }
 
-void sk_init_yukon(struct sk_if_softc *sc_if)
+void
+sk_unreset_yukon(struct sk_if_softc *sc_if)
 {
        uint32_t                /*mac, */phy;
-       uint16_t                reg;
        struct sk_softc         *sc;
-       int                     i;
-
-       DPRINTFN(1, ("sk_init_yukon: start: sk_csr=%#x\n",
+
+       DPRINTFN(1, ("sk_unreset_yukon: start: sk_csr=%#x\n",
                     CSR_READ_4(sc_if->sk_softc, SK_CSR)));
 
        sc = sc_if->sk_softc;
@@ -2611,7 +2620,6 @@
                        (sk_win_read_4(sc, SK_GPIO) | SK_GPIO_DIR9) & ~SK_GPIO_DAT9);
        }
 
-
        /* GMAC and GPHY Reset */
        SK_IF_WRITE_4(sc_if, 0, SK_GPHY_CTRL, SK_GPHY_RESET_SET);
 
@@ -2651,8 +2659,16 @@
 
        DPRINTFN(3, ("sk_init_yukon: gmac_ctrl=%#x\n",
                     SK_IF_READ_4(sc_if, 0, SK_GMAC_CTRL)));
-
-       DPRINTFN(6, ("sk_init_yukon: 3\n"));
+}
+
+void
+sk_init_yukon(struct sk_if_softc *sc_if)
+{
+       uint16_t                reg;
+       int                     i;
+
+       DPRINTFN(1, ("sk_init_yukon: start\n"));
+       sk_unreset_yukon(sc_if);
 
        /* unused read of the interrupt source register */
        DPRINTFN(6, ("sk_init_yukon: 4\n"));



Home | Main Index | Thread Index | Old Index