diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/if_vr.c | 40 | ||||
-rw-r--r-- | sys/dev/pci/if_vrreg.h | 17 |
2 files changed, 55 insertions, 2 deletions
diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c index e8ec0e4c093..7703a2a65cb 100644 --- a/sys/dev/pci/if_vr.c +++ b/sys/dev/pci/if_vr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vr.c,v 1.107 2011/01/13 11:28:14 kettenis Exp $ */ +/* $OpenBSD: if_vr.c,v 1.108 2011/03/13 15:38:50 stsp Exp $ */ /* * Copyright (c) 1997, 1998 @@ -137,6 +137,9 @@ void vr_reset(struct vr_softc *); int vr_list_rx_init(struct vr_softc *); void vr_fill_rx_ring(struct vr_softc *); int vr_list_tx_init(struct vr_softc *); +#ifndef SMALL_KERNEL +int vr_wol(struct ifnet *, int); +#endif int vr_alloc_mbuf(struct vr_softc *, struct vr_chain_onefrag *); @@ -643,6 +646,13 @@ vr_attach(struct device *parent, struct device *self, void *aux) if (sc->vr_quirks & VR_Q_CSUM) ifp->if_capabilities |= IFCAP_CSUM_IPv4|IFCAP_CSUM_TCPv4| IFCAP_CSUM_UDPv4; +#ifndef SMALL_KERNEL + if (sc->vr_revid >= REV_ID_VT3065_A) { + ifp->if_capabilities |= IFCAP_WOL; + ifp->if_wol = vr_wol; + vr_wol(ifp, 0); + } +#endif /* * Do MII setup. @@ -1529,6 +1539,34 @@ vr_stop(struct vr_softc *sc) sizeof(sc->vr_ldata->vr_tx_list)); } +#ifndef SMALL_KERNEL +int +vr_wol(struct ifnet *ifp, int enable) +{ + struct vr_softc *sc = ifp->if_softc; + + /* Clear WOL configuration */ + CSR_WRITE_1(sc, VR_WOLCRCLR, 0xFF); + + /* Clear event status bits. */ + CSR_WRITE_1(sc, VR_PWRCSRCLR, 0xFF); + + /* Disable PME# assertion upon wake event. */ + VR_CLRBIT(sc, VR_STICKHW, VR_STICKHW_WOL_ENB); + VR_SETBIT(sc, VR_WOLCFGCLR, VR_WOLCFG_PMEOVR); + + if (enable) { + VR_SETBIT(sc, VR_WOLCRSET, VR_WOLCR_MAGIC); + + /* Enable PME# assertion upon wake event. */ + VR_SETBIT(sc, VR_STICKHW, VR_STICKHW_WOL_ENB); + VR_SETBIT(sc, VR_WOLCFGSET, VR_WOLCFG_PMEOVR); + } + + return (0); +} +#endif + int vr_alloc_mbuf(struct vr_softc *sc, struct vr_chain_onefrag *r) { diff --git a/sys/dev/pci/if_vrreg.h b/sys/dev/pci/if_vrreg.h index 13f41ad9883..f4b620f8f38 100644 --- a/sys/dev/pci/if_vrreg.h +++ b/sys/dev/pci/if_vrreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vrreg.h,v 1.27 2009/06/18 17:48:15 claudio Exp $ */ +/* $OpenBSD: if_vrreg.h,v 1.28 2011/03/13 15:38:50 stsp Exp $ */ /* * Copyright (c) 1997, 1998 @@ -285,6 +285,21 @@ #define VR_STICKHW_WOL_STS 0x08 #define VR_STICKHW_LEGWOL_ENB 0x80 +/* Wake on Lan */ +#define VR_WOLCRSET 0xA0 +#define VR_PWRCFGSET 0xA1 +#define VR_WOLCFGSET 0xA3 +#define VR_WOLCRCLR 0xA4 +#define VR_PWRCFGCLR 0xA5 +#define VR_WOLCFGCLR 0xA7 +#define VR_PWRCSRSET 0xA8 +#define VR_PWRCSRCLR 0xAC +#define VR_WOLCR_UCAST 0x10 +#define VR_WOLCR_MAGIC 0x20 +#define VR_WOLCR_LINKON 0x40 +#define VR_WOLCR_LINKOFF 0x80 +#define VR_WOLCFG_PMEOVR 0x80 + /* * BCR0 register bits. (At least for the VT6102 chip.) */ |