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/eisa/if_ep_eisa.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: if_ep_eisa.c,v 1.42 2010/01/18 19:00:58 pooka Exp $    */
    2 
    3 /*-
    4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
    9  * NASA Ames Research Center.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   30  * POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 /*
   34  * Copyright (c) 1997 Jonathan Stone <jonathan@NetBSD.org>
   35  * Copyright (c) 1994 Herb Peyerl <hpeyerl@beer.org>
   36  * All rights reserved.
   37  *
   38  * Redistribution and use in source and binary forms, with or without
   39  * modification, are permitted provided that the following conditions
   40  * are met:
   41  * 1. Redistributions of source code must retain the above copyright
   42  *    notice, this list of conditions and the following disclaimer.
   43  * 2. Redistributions in binary form must reproduce the above copyright
   44  *    notice, this list of conditions and the following disclaimer in the
   45  *    documentation and/or other materials provided with the distribution.
   46  * 3. All advertising materials mentioning features or use of this software
   47  *    must display the following acknowledgement:
   48  *      This product includes software developed by Herb Peyerl.
   49  *      This product includes software developed by Jonathan Stone.
   50  * 4. The name of Herb Peyerl or Jonathan Stone may not be used to endorse
   51  *    or promote products derived from this software without specific
   52  *    prior written permission.
   53  *
   54  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   55  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   56  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   57  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   58  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   59  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   60  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   61  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   62  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   63  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   64  */
   65 
   66 #include <sys/cdefs.h>
   67 __KERNEL_RCSID(0, "$NetBSD: if_ep_eisa.c,v 1.42 2010/01/18 19:00:58 pooka Exp $");
   68 
   69 #include "opt_inet.h"
   70 
   71 #include <sys/param.h>
   72 #include <sys/systm.h>
   73 #include <sys/mbuf.h>
   74 #include <sys/socket.h>
   75 #include <sys/ioctl.h>
   76 #include <sys/errno.h>
   77 #include <sys/syslog.h>
   78 #include <sys/select.h>
   79 #include <sys/device.h>
   80 
   81 #include <net/if.h>
   82 #include <net/if_dl.h>
   83 #include <net/if_ether.h>
   84 #include <net/if_media.h>
   85 
   86 #ifdef INET
   87 #include <netinet/in.h>
   88 #include <netinet/in_systm.h>
   89 #include <netinet/in_var.h>
   90 #include <netinet/ip.h>
   91 #include <netinet/if_inarp.h>
   92 #endif
   93 
   94 #include <sys/cpu.h>
   95 #include <sys/bus.h>
   96 #include <sys/intr.h>
   97 
   98 #include <dev/mii/miivar.h>
   99 
  100 #include <dev/ic/elink3var.h>
  101 #include <dev/ic/elink3reg.h>
  102 
  103 #include <dev/eisa/eisareg.h>
  104 #include <dev/eisa/eisavar.h>
  105 #include <dev/eisa/eisadevs.h>
  106 
  107 static int      ep_eisa_match(device_t , cfdata_t , void *);
  108 static void     ep_eisa_attach(device_t , device_t , void *);
  109 
  110 CFATTACH_DECL_NEW(ep_eisa, sizeof(struct ep_softc),
  111     ep_eisa_match, ep_eisa_attach, NULL, NULL);
  112 
  113 /* XXX move these somewhere else */
  114 /* While attaching we need a few special EISA registers of the card,
  115    these are mapped at slotbase+EP_EISA_CFG_BASE with len EP_EISA_CFG_SIZE */
  116 #define EP_EISA_CFG_BASE        0x0c80
  117 #define EP_EISA_CFG_CONTROL     0x0004  /* 1 byte */
  118 #define EP_EISA_CFG_RESOURCE    0x0008  /* 2 byte */
  119 #define EP_EISA_CFG_SIZE        0x000a
  120 
  121 /* The generic driver backend only needs access to the standard ports,
  122    mapped at the beginning of the eisa slot space */
  123 #define EP_IOPORT_OFFSET        0x0000
  124 #define EP_IOPORT_SIZE          0x0020
  125 
  126 /* Bits for the eisa control register */
  127 #define EISA_RESET      0x04
  128 #define EISA_ERROR      0x02
  129 #define EISA_ENABLE     0x01
  130 
  131 static const struct ep_eisa_product {
  132         const char      *eep_eisaid;    /* EISA ID */
  133         u_short         eep_chipset;    /* 3Com chipset used */
  134         int             eep_flags;      /* initial softc flags */
  135         const char      *eep_name;      /* device name */
  136 } ep_eisa_products[] = {
  137         { "TCM5090",                    ELINK_CHIPSET_3C509,
  138           0,                            EISA_PRODUCT_TCM5090 },
  139         { "TCM5091",                    ELINK_CHIPSET_3C509,
  140           0,                            EISA_PRODUCT_TCM5091 },
  141         { "TCM5092",                    ELINK_CHIPSET_3C509,
  142           0,                            EISA_PRODUCT_TCM5092 },
  143         { "TCM5093",                    ELINK_CHIPSET_3C509,
  144           0,                            EISA_PRODUCT_TCM5093 },
  145         { "TCM5094",                    ELINK_CHIPSET_3C509,
  146           0,                            EISA_PRODUCT_TCM5094 },
  147         { "TCM5095",                    ELINK_CHIPSET_3C509,
  148           0,                            EISA_PRODUCT_TCM5095 },
  149         { "TCM5098",                    ELINK_CHIPSET_3C509,
  150           0,                            EISA_PRODUCT_TCM5098 },
  151 
  152         /*
  153          * Note: The 3c597 Fast Etherlink MII (TCM5972) is an
  154          * MII connector for an external PHY.  We treat it as
  155          * `manual' in the core driver.
  156          */
  157         { "TCM5920",                    ELINK_CHIPSET_VORTEX,
  158           0,                            EISA_PRODUCT_TCM5920 },
  159         { "TCM5970",                    ELINK_CHIPSET_VORTEX,
  160           0,                            EISA_PRODUCT_TCM5970 },
  161         { "TCM5971",                    ELINK_CHIPSET_VORTEX,
  162           0,                            EISA_PRODUCT_TCM5971 },
  163         { "TCM5972",                    ELINK_CHIPSET_VORTEX,
  164           0,                            EISA_PRODUCT_TCM5972 },
  165 
  166         { NULL,                         0,
  167           0,                            NULL },
  168 };
  169 
  170 static const struct ep_eisa_product *
  171 ep_eisa_lookup(const struct eisa_attach_args *ea)
  172 {
  173         const struct ep_eisa_product *eep;
  174 
  175         for (eep = ep_eisa_products; eep->eep_name != NULL; eep++)
  176                 if (strcmp(ea->ea_idstring, eep->eep_eisaid) == 0)
  177                         return (eep);
  178 
  179         return (NULL);
  180 }
  181 
  182 static int
  183 ep_eisa_match(device_t parent, cfdata_t match, void *aux)
  184 {
  185         struct eisa_attach_args *ea = aux;
  186 
  187         /* must match one of our known ID strings */
  188         if (ep_eisa_lookup(ea) != NULL)
  189                 return (1);
  190 
  191         return (0);
  192 }
  193 
  194 static void
  195 ep_eisa_attach(device_t parent, device_t self, void *aux)
  196 {
  197         struct ep_softc *sc = device_private(self);
  198         struct eisa_attach_args *ea = aux;
  199         bus_space_tag_t iot = ea->ea_iot;
  200         bus_space_handle_t ioh, ioh_cfg;
  201         eisa_chipset_tag_t ec = ea->ea_ec;
  202         eisa_intr_handle_t ih;
  203         const char *intrstr;
  204         const struct ep_eisa_product *eep;
  205         u_int irq;
  206 
  207         /* Map i/o space. */
  208         if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + EP_EISA_CFG_BASE,
  209             EP_EISA_CFG_SIZE, 0, &ioh_cfg)) {
  210                 printf("\n");
  211                 panic("ep_eisa_attach: can't map eisa cfg i/o space");
  212         }
  213         if (bus_space_map(iot, EISA_SLOT_ADDR(ea->ea_slot) + EP_IOPORT_OFFSET,
  214             EP_IOPORT_SIZE, 0, &ioh)) {
  215                 printf("\n");
  216                 panic("ep_eisa_attach: can't map i/o space");
  217         }
  218 
  219         sc->sc_dev = self;
  220         sc->sc_ioh = ioh;
  221         sc->sc_iot = iot;
  222 
  223         bus_space_write_1(iot, ioh_cfg, EP_EISA_CFG_CONTROL, EISA_ENABLE);
  224         delay(4000);
  225 
  226         /* Read the IRQ from the card. */
  227         irq = bus_space_read_2(iot, ioh_cfg, EP_EISA_CFG_RESOURCE) >> 12;
  228 
  229         eep = ep_eisa_lookup(ea);
  230         if (eep == NULL) {
  231                 printf("\n");
  232                 panic("ep_eisa_attach: impossible");
  233         }
  234 
  235         /* we don't need access to the config registers any more, but
  236            noone else should be able to map this space, so keep it
  237            reserved? */
  238 #if 0
  239         bus_space_unmap(iot, ioh_cfg, EP_EISA_CFG_SIZE);
  240 #endif
  241 
  242         printf(": %s\n", eep->eep_name);
  243 
  244         sc->enable = NULL;
  245         sc->disable = NULL;
  246         sc->enabled = 1;
  247 
  248         sc->bustype = ELINK_BUS_EISA;
  249         sc->ep_flags = eep->eep_flags;
  250 
  251         if (eisa_intr_map(ec, irq, &ih)) {
  252                 aprint_error_dev(sc->sc_dev, "couldn't map interrupt (%u)\n",
  253                     irq);
  254                 return;
  255         }
  256         intrstr = eisa_intr_string(ec, ih);
  257         sc->sc_ih = eisa_intr_establish(ec, ih, IST_EDGE, IPL_NET,
  258             epintr, sc);
  259         if (sc->sc_ih == NULL) {
  260                 aprint_error_dev(sc->sc_dev, "couldn't establish interrupt");
  261                 if (intrstr != NULL)
  262                         aprint_error(" at %s", intrstr);
  263                 aprint_error("\n");
  264                 return;
  265         }
  266         if (intrstr != NULL)
  267                 aprint_normal_dev(sc->sc_dev, "interrupting at %s\n", intrstr);
  268 
  269         epconfig(sc, eep->eep_chipset, NULL);
  270 }

Cache object: e9019cefe8e109c656e46a424dd1902d


[ 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.