The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/ax88190.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: ax88190.c,v 1.7 2006/11/16 01:32:51 christos Exp $     */
    2 
    3 /*-
    4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Enami Tsugutomo.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *      This product includes software developed by the NetBSD
   21  *      Foundation, Inc. and its contributors.
   22  * 4. Neither the name of The NetBSD Foundation nor the names of its
   23  *    contributors may be used to endorse or promote products derived
   24  *    from this software without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36  * POSSIBILITY OF SUCH DAMAGE.
   37  */
   38 
   39 #include <sys/cdefs.h>
   40 __KERNEL_RCSID(0, "$NetBSD: ax88190.c,v 1.7 2006/11/16 01:32:51 christos Exp $");
   41 
   42 #include <sys/param.h>
   43 #include <sys/systm.h>
   44 #include <sys/device.h>
   45 #include <sys/socket.h>
   46 
   47 #include <net/if.h>
   48 #include <net/if_dl.h>
   49 #include <net/if_types.h>
   50 #include <net/if_media.h>
   51 #include <net/if_ether.h>
   52 
   53 #include <machine/bus.h>
   54 
   55 #include <dev/mii/miivar.h>
   56 #include <dev/mii/mii.h>
   57 #include <dev/mii/mii_bitbang.h>
   58 
   59 #include <dev/ic/dp8390reg.h>
   60 #include <dev/ic/dp8390var.h>
   61 
   62 #include <dev/ic/ne2000reg.h>
   63 #include <dev/ic/ne2000var.h>
   64 
   65 #include <dev/ic/ax88190reg.h>
   66 #include <dev/ic/ax88190var.h>
   67 
   68 static int      ax88190_mii_readreg(struct device *, int, int);
   69 static void     ax88190_mii_writereg(struct device *, int, int, int);
   70 static void     ax88190_mii_statchg(struct device *);
   71 
   72 /*
   73  * MII bit-bang glue.
   74  */
   75 static u_int32_t        ax88190_mii_bitbang_read(struct device *);
   76 static void             ax88190_mii_bitbang_write(struct device *, u_int32_t);
   77 
   78 static const struct mii_bitbang_ops ax88190_mii_bitbang_ops = {
   79         ax88190_mii_bitbang_read,
   80         ax88190_mii_bitbang_write,
   81         {
   82                 AX88190_MEMR_MDO,       /* MII_BIT_MDO */
   83                 AX88190_MEMR_MDI,       /* MII_BIT_MDI */
   84                 AX88190_MEMR_MDC,       /* MII_BIT_MDC */
   85                 0,                      /* MII_BIT_DIR_HOST_PHY */
   86                 AX88190_MEMR_MDIR,      /* MII_BIT_DIR_PHY_HOST */
   87         }
   88 };
   89 
   90 void
   91 ax88190_media_init(struct dp8390_softc *sc)
   92 {
   93         struct ifnet *ifp = &sc->sc_ec.ec_if;
   94 
   95         sc->sc_mii.mii_ifp = ifp;
   96         sc->sc_mii.mii_readreg = ax88190_mii_readreg;
   97         sc->sc_mii.mii_writereg = ax88190_mii_writereg;
   98         sc->sc_mii.mii_statchg = ax88190_mii_statchg;
   99         ifmedia_init(&sc->sc_mii.mii_media, IFM_IMASK, dp8390_mediachange,
  100             dp8390_mediastatus);
  101 
  102         mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
  103             MII_OFFSET_ANY, 0);
  104 
  105         if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
  106                 ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0,
  107                     NULL);
  108                 ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
  109         } else
  110                 ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
  111 }
  112 
  113 void
  114 ax88190_media_fini(struct dp8390_softc *sc)
  115 {
  116 
  117         mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
  118 }
  119 
  120 int
  121 ax88190_mediachange(struct dp8390_softc *sc)
  122 {
  123 
  124         mii_mediachg(&sc->sc_mii);
  125         return (0);
  126 }
  127 
  128 void
  129 ax88190_mediastatus(struct dp8390_softc *sc, struct ifmediareq *ifmr)
  130 {
  131 
  132         mii_pollstat(&sc->sc_mii);
  133         ifmr->ifm_status = sc->sc_mii.mii_media_status;
  134         ifmr->ifm_active = sc->sc_mii.mii_media_active;
  135 }
  136 
  137 void
  138 ax88190_init_card(struct dp8390_softc *sc)
  139 {
  140 
  141         mii_mediachg(&sc->sc_mii);
  142 }
  143 
  144 void
  145 ax88190_stop_card(struct dp8390_softc *sc)
  146 {
  147 
  148         mii_down(&sc->sc_mii);
  149 }
  150 
  151 static u_int32_t
  152 ax88190_mii_bitbang_read(self)
  153         struct device *self;
  154 {
  155         struct ne2000_softc *sc = (void *)self;
  156 
  157         return (bus_space_read_1(sc->sc_asict, sc->sc_asich, AX88190_MEMR));
  158 }
  159 
  160 static void
  161 ax88190_mii_bitbang_write(self, val)
  162         struct device *self;
  163         u_int32_t val;
  164 {
  165         struct ne2000_softc *sc = (void *)self;
  166 
  167         bus_space_write_1(sc->sc_asict, sc->sc_asich, AX88190_MEMR, val);
  168 }
  169 
  170 static int
  171 ax88190_mii_readreg(self, phy, reg)
  172         struct device *self;
  173         int phy, reg;
  174 {
  175 
  176         return (mii_bitbang_readreg(self, &ax88190_mii_bitbang_ops, phy, reg));
  177 }
  178 
  179 static void
  180 ax88190_mii_writereg(self, phy, reg, val)
  181         struct device *self;
  182         int phy, reg, val;
  183 {
  184 
  185         mii_bitbang_writereg(self, &ax88190_mii_bitbang_ops, phy, reg, val);
  186 }
  187 
  188 static void
  189 ax88190_mii_statchg(struct device *self)
  190 {
  191 
  192         /* XXX */
  193 }

Cache object: 3052a9cc8d7828d1ef690b2114ac3821


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.