Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Add flags to control IRQ polarity and buffer type...



details:   https://anonhg.NetBSD.org/src/rev/7258f7365f5a
branches:  trunk
changeset: 354025:7258f7365f5a
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Jun 01 16:59:20 2017 +0000

description:
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.

diffstat:

 sys/dev/ic/lan9118.c    |  22 ++++++++++++++++------
 sys/dev/ic/lan9118var.h |   4 +++-
 2 files changed, 19 insertions(+), 7 deletions(-)

diffs (82 lines):

diff -r bb7cce585ea4 -r 7258f7365f5a sys/dev/ic/lan9118.c
--- a/sys/dev/ic/lan9118.c      Thu Jun 01 16:57:12 2017 +0000
+++ b/sys/dev/ic/lan9118.c      Thu Jun 01 16:59:20 2017 +0000
@@ -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 @@
 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 @@
        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 @@
 {
        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_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,
diff -r bb7cce585ea4 -r 7258f7365f5a sys/dev/ic/lan9118var.h
--- a/sys/dev/ic/lan9118var.h   Thu Jun 01 16:57:12 2017 +0000
+++ b/sys/dev/ic/lan9118var.h   Thu Jun 01 16:59:20 2017 +0000
@@ -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 @@
        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;
 };



Home | Main Index | Thread Index | Old Index