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/isapnp/i82365_isapnp.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: i82365_isapnp.c,v 1.15 2002/10/02 16:33:58 thorpej Exp $       */
    2 
    3 /*
    4  * Copyright (c) 1998 Bill Sommerfeld.  All rights reserved.
    5  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. All advertising materials mentioning features or use of this software
   16  *    must display the following acknowledgement:
   17  *      This product includes software developed by Marc Horowitz.
   18  * 4. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission.
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 #include <sys/cdefs.h>
   34 __KERNEL_RCSID(0, "$NetBSD: i82365_isapnp.c,v 1.15 2002/10/02 16:33:58 thorpej Exp $");
   35 
   36 #include <sys/param.h>
   37 #include <sys/systm.h>
   38 #include <sys/device.h>
   39 #include <sys/extent.h>
   40 #include <sys/malloc.h>
   41 
   42 #include <machine/bus.h>
   43 #include <machine/intr.h>
   44 
   45 #include <dev/isa/isareg.h>
   46 #include <dev/isa/isavar.h>
   47 
   48 #include <dev/isapnp/isapnpreg.h>
   49 #include <dev/isapnp/isapnpvar.h>
   50 #include <dev/isapnp/isapnpdevs.h>
   51 
   52 #include <dev/pcmcia/pcmciareg.h>
   53 #include <dev/pcmcia/pcmciavar.h>
   54 #include <dev/pcmcia/pcmciachip.h>
   55 
   56 #include <dev/ic/i82365reg.h>
   57 #include <dev/ic/i82365var.h>
   58 #include <dev/isa/i82365_isavar.h>
   59 
   60 #undef DPRINTF
   61 #ifdef PCICISADEBUG
   62 int     pcicisapnp_debug = 0 /* XXX */ ;
   63 #define DPRINTF(arg) if (pcicisapnp_debug) printf arg;
   64 #else
   65 #define DPRINTF(arg)
   66 #endif
   67 
   68 int pcic_isapnp_match __P((struct device *, struct cfdata *, void *));
   69 void    pcic_isapnp_attach __P((struct device *, struct device *, void *));
   70 
   71 CFATTACH_DECL(pcic_isapnp, sizeof(struct pcic_isa_softc),
   72     pcic_isapnp_match, pcic_isapnp_attach, NULL, NULL);
   73 
   74 static struct pcmcia_chip_functions pcic_isa_functions = {
   75         pcic_chip_mem_alloc,
   76         pcic_chip_mem_free,
   77         pcic_chip_mem_map,
   78         pcic_chip_mem_unmap,
   79 
   80         pcic_chip_io_alloc,
   81         pcic_chip_io_free,
   82         pcic_chip_io_map,
   83         pcic_chip_io_unmap,
   84 
   85         pcic_isa_chip_intr_establish,
   86         pcic_isa_chip_intr_disestablish,
   87 
   88         pcic_chip_socket_enable,
   89         pcic_chip_socket_disable,
   90 };
   91 
   92 int
   93 pcic_isapnp_match(parent, match, aux)
   94         struct device *parent;
   95         struct cfdata *match;
   96         void *aux;
   97 {
   98         int pri, variant;
   99 
  100         pri = isapnp_devmatch(aux, &isapnp_pcic_devinfo, &variant);
  101         if (pri && variant > 0)
  102                 pri = 0;
  103         return (pri);
  104 }
  105 
  106 void
  107 pcic_isapnp_attach(parent, self, aux)
  108         struct device *parent, *self;
  109         void *aux;
  110 {
  111         struct pcic_softc *sc = (void *) self;
  112         struct pcic_isa_softc *isc = (void *) self;
  113         struct isapnp_attach_args *ipa = aux;
  114         isa_chipset_tag_t ic = ipa->ipa_ic;
  115         bus_space_tag_t iot = ipa->ipa_iot;
  116         bus_space_tag_t memt = ipa->ipa_memt;
  117         bus_space_handle_t ioh;
  118         bus_space_handle_t memh;
  119         bus_addr_t maddr;
  120         int msize;
  121         int tmp1;
  122 
  123         printf("\n");
  124 
  125         if (isapnp_config(iot, memt, ipa)) {
  126                 printf("%s: error in region allocation\n", sc->dev.dv_xname);
  127                 return;
  128         }
  129 
  130         printf("%s: %s %s", sc->dev.dv_xname, ipa->ipa_devident,
  131             ipa->ipa_devclass);
  132 
  133         /* sanity check that we get at least one hunk of IO space.. */
  134         if (ipa->ipa_nio < 1) {
  135                 printf("%s: failed to get one chunk of i/o space\n",
  136                        sc->dev.dv_xname);
  137                 return;
  138         }
  139 
  140         /* Find i/o space. */
  141         ioh = ipa->ipa_io[0].h;
  142 
  143         /* sanity check to make sure we have a real PCIC there.. */
  144         bus_space_write_1(iot, ioh, PCIC_REG_INDEX, C0SA + PCIC_IDENT);
  145         tmp1 = bus_space_read_1(iot, ioh, PCIC_REG_DATA);
  146         printf("(ident 0x%x", tmp1);
  147         if (pcic_ident_ok(tmp1)) {
  148                 printf(" OK)");
  149         } else {
  150                 printf(" Not OK)\n");
  151                 return;
  152         }
  153 
  154         msize =  0x4000;
  155         if (isa_mem_alloc (memt, msize, msize, 0, 0,
  156                            &maddr, &memh)) {
  157                 printf(": can't alloc mem space\n");
  158                 return;
  159         }
  160         printf(": using iomem 0x%lx iosiz 0x%x", maddr, msize);
  161         sc->membase = maddr;
  162         sc->subregionmask = (1 << (msize / PCIC_MEM_PAGESIZE)) - 1;
  163 
  164         isc->sc_ic = ic;
  165         sc->pct = (pcmcia_chipset_tag_t) & pcic_isa_functions;
  166 
  167         sc->iot = iot;
  168         sc->ioh = ioh;
  169         sc->memt = memt;
  170         sc->memh = memh;
  171 
  172         /*
  173          * allocate an irq.  it will be used by both controllers.  I could
  174          * use two different interrupts, but interrupts are relatively
  175          * scarce, shareable, and for PCIC controllers, very infrequent.
  176          */
  177 
  178         if (ipa->ipa_nirq > 0)
  179                 sc->irq = ipa->ipa_irq[0].num;
  180         else
  181                 sc->irq = ISACF_IRQ_DEFAULT;
  182 
  183         printf("\n");
  184 
  185         pcic_attach(sc);
  186         pcic_isa_bus_width_probe(sc, iot, ioh, ipa->ipa_io[0].base,
  187             ipa->ipa_io[0].length);
  188         pcic_attach_sockets(sc);
  189         config_interrupts(self, pcic_isa_config_interrupts);
  190 }

Cache object: b6d8a5432be39abdb024172d3294af91


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