summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormsaitoh <msaitoh@NetBSD.org>2019-06-03 15:39:35 +0000
committermsaitoh <msaitoh@NetBSD.org>2019-06-03 15:39:35 +0000
commit500bb015f88877afff2a2bc91f4b012c1c9cd1db (patch)
tree7897a44566d46ad6e172a72a6747e1fdeae6fad8 /sys/dev
parent9080eaf550242b9e48da2f9cffa603ba1394cd5c (diff)
Make new sk_unreset_{xmac,yukon}() and use them in sk_attach().
Fixes PR kern/54267 reported by martin.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_sk.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/sys/dev/pci/if_sk.c b/sys/dev/pci/if_sk.c
index c8f1f602d8a..e3336aedcde 100644
--- a/sys/dev/pci/if_sk.c
+++ b/sys/dev/pci/if_sk.c
@@ -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 *, struct mbuf *, uint32_t *);
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, void *aux)
*/
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 *sc_if)
(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 *sc_if)
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"));