Module Name: src Committed By: jmcneill Date: Thu Jun 1 16:59:20 UTC 2017
Modified Files: src/sys/dev/ic: lan9118.c lan9118var.h Log Message: Add flags to control IRQ polarity and buffer type. These can be set by the bus glue to switch to active high and/or push-pull configurations. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/dev/ic/lan9118.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ic/lan9118var.h 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/ic/lan9118.c diff -u src/sys/dev/ic/lan9118.c:1.24 src/sys/dev/ic/lan9118.c:1.25 --- src/sys/dev/ic/lan9118.c:1.24 Mon Feb 20 07:43:29 2017 +++ src/sys/dev/ic/lan9118.c Thu Jun 1 16:59:20 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: lan9118.c,v 1.24 2017/02/20 07:43:29 ozaki-r Exp $ */ +/* $NetBSD: lan9118.c,v 1.25 2017/06/01 16:59:20 jmcneill Exp $ */ /* * Copyright (c) 2008 KIYOHARA Takashi * All rights reserved. @@ -25,7 +25,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lan9118.c,v 1.24 2017/02/20 07:43:29 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lan9118.c,v 1.25 2017/06/01 16:59:20 jmcneill Exp $"); /* * The LAN9118 Family @@ -156,7 +156,7 @@ int lan9118_attach(struct lan9118_softc *sc) { struct ifnet *ifp = &sc->sc_ec.ec_if; - uint32_t val; + uint32_t val, irq_cfg; int timo, i; if (sc->sc_flags & LAN9118_FLAGS_SWAP) @@ -206,6 +206,14 @@ lan9118_attach(struct lan9118_softc *sc) aprint_normal_dev(sc->sc_dev, "MAC address %s\n", ether_sprintf(sc->sc_enaddr)); + /* Set IRQ config */ + irq_cfg = 0; + if (sc->sc_flags & LAN9118_FLAGS_IRQ_ACTHI) + irq_cfg |= LAN9118_IRQ_CFG_IRQ_POL; + if (sc->sc_flags & LAN9118_FLAGS_IRQ_PP) + irq_cfg |= LAN9118_IRQ_CFG_IRQ_TYPE; + bus_space_write_4(sc->sc_iot, sc->sc_ioh, LAN9118_IRQ_CFG, irq_cfg); + KASSERT(LAN9118_TX_FIF_SZ >= 2 && LAN9118_TX_FIF_SZ < 15); sc->sc_afc_cfg = afc_cfg[LAN9118_TX_FIF_SZ]; @@ -514,7 +522,7 @@ lan9118_init(struct ifnet *ifp) { struct lan9118_softc *sc = ifp->if_softc; struct ifmedia *ifm = &sc->sc_mii.mii_media; - uint32_t reg, hw_cfg, mac_cr; + uint32_t reg, hw_cfg, mac_cr, irq_cfg; int timo, s; DPRINTFN(2, ("%s\n", __func__)); @@ -588,8 +596,10 @@ lan9118_init(struct ifnet *ifp) LAN9118_GPIO_CFG_GPIOBUFN(1) | LAN9118_GPIO_CFG_GPIOBUFN(0)); - bus_space_write_4(sc->sc_iot, sc->sc_ioh, LAN9118_IRQ_CFG, - LAN9118_IRQ_CFG_IRQ_EN); + irq_cfg = bus_space_read_4(sc->sc_iot, sc->sc_ioh, LAN9118_IRQ_CFG); + irq_cfg |= LAN9118_IRQ_CFG_IRQ_EN; + bus_space_write_4(sc->sc_iot, sc->sc_ioh, LAN9118_IRQ_CFG, irq_cfg); + bus_space_write_4(sc->sc_iot, sc->sc_ioh, LAN9118_INT_STS, bus_space_read_4(sc->sc_iot, sc->sc_ioh, LAN9118_INT_STS)); bus_space_write_4(sc->sc_iot, sc->sc_ioh, LAN9118_FIFO_INT, Index: src/sys/dev/ic/lan9118var.h diff -u src/sys/dev/ic/lan9118var.h:1.5 src/sys/dev/ic/lan9118var.h:1.6 --- src/sys/dev/ic/lan9118var.h:1.5 Mon Apr 13 16:33:24 2015 +++ src/sys/dev/ic/lan9118var.h Thu Jun 1 16:59:20 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: lan9118var.h,v 1.5 2015/04/13 16:33:24 riastradh Exp $ */ +/* $NetBSD: lan9118var.h,v 1.6 2017/06/01 16:59:20 jmcneill Exp $ */ /* * Copyright (c) 2008 KIYOHARA Takashi * All rights reserved. @@ -70,6 +70,8 @@ struct lan9118_softc { int sc_flags; #define LAN9118_FLAGS_SWAP 0x00000001 #define LAN9118_FLAGS_NO_EEPROM 0x00000002 +#define LAN9118_FLAGS_IRQ_ACTHI 0x00000004 +#define LAN9118_FLAGS_IRQ_PP 0x00000008 krndsource_t rnd_source; };