Module Name: src
Committed By: msaitoh
Date: Mon Jun 3 15:39:35 UTC 2019
Modified Files:
src/sys/dev/pci: if_sk.c
Log Message:
Make new sk_unreset_{xmac,yukon}() and use them in sk_attach().
Fixes PR kern/54267 reported by martin.
To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/pci/if_sk.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/if_sk.c
diff -u src/sys/dev/pci/if_sk.c:1.98 src/sys/dev/pci/if_sk.c:1.99
--- src/sys/dev/pci/if_sk.c:1.98 Thu May 30 02:32:18 2019
+++ src/sys/dev/pci/if_sk.c Mon Jun 3 15:39:35 2019
@@ -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 @@ int sk_encap(struct sk_if_softc *, struc
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 @@ sk_attach(device_t parent, device_t self
*/
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 @@ sk_intr(void *xsc)
}
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 @@ sk_init_xmac(struct sk_if_softc *sc_if)
}
}
}
+}
+
+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 @@ sk_init_xmac(struct sk_if_softc *sc_if)
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 @@ void sk_init_yukon(struct sk_if_softc *s
(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 @@ void sk_init_yukon(struct sk_if_softc *s
DPRINTFN(3, ("sk_init_yukon: gmac_ctrl=%#x\n",
SK_IF_READ_4(sc_if, 0, SK_GMAC_CTRL)));
+}
+
+void
+sk_init_yukon(struct sk_if_softc *sc_if)
+{
+ uint16_t reg;
+ int i;
- DPRINTFN(6, ("sk_init_yukon: 3\n"));
+ 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"));