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/isa/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 /*      $OpenBSD: i82365_isapnp.c,v 1.11 2022/04/06 18:59:28 naddy Exp $ */
    2 /*      $NetBSD: i82365_isapnp.c,v 1.8 2000/02/23 17:22:11 soren Exp $  */
    3 
    4 /*
    5  * Copyright (c) 1998 Bill Sommerfeld.  All rights reserved.
    6  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. All advertising materials mentioning features or use of this software
   17  *    must display the following acknowledgement:
   18  *      This product includes software developed by Marc Horowitz.
   19  * 4. The name of the author may not be used to endorse or promote products
   20  *    derived from this software without specific prior written permission.
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   32  */
   33 
   34 
   35 #include <sys/param.h>
   36 #include <sys/systm.h>
   37 #include <sys/kernel.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/isa/isapnpreg.h>
   49 
   50 #include <dev/pcmcia/pcmciareg.h>
   51 #include <dev/pcmcia/pcmciavar.h>
   52 #include <dev/pcmcia/pcmciachip.h>
   53 
   54 #include <dev/ic/i82365reg.h>
   55 #include <dev/ic/i82365var.h>
   56 #include <dev/isa/i82365_isavar.h>
   57 
   58 #undef DPRINTF
   59 #ifdef PCICISADEBUG
   60 int     pcicisapnp_debug = 0 /* XXX */ ;
   61 #define DPRINTF(arg) if (pcicisapnp_debug) printf arg;
   62 #else
   63 #define DPRINTF(arg)
   64 #endif
   65 
   66 int     pcic_isapnp_match(struct device *, void *, void *);
   67 void    pcic_isapnp_attach(struct device *, struct device *, void *);
   68 
   69 const struct cfattach pcic_isapnp_ca = {
   70         sizeof(struct pcic_softc), pcic_isapnp_match, pcic_isapnp_attach
   71 };
   72 
   73 static struct pcmcia_chip_functions pcic_isa_functions = {
   74         pcic_chip_mem_alloc,
   75         pcic_chip_mem_free,
   76         pcic_chip_mem_map,
   77         pcic_chip_mem_unmap,
   78 
   79         pcic_chip_io_alloc,
   80         pcic_chip_io_free,
   81         pcic_chip_io_map,
   82         pcic_chip_io_unmap,
   83 
   84         pcic_isa_chip_intr_establish,
   85         pcic_isa_chip_intr_disestablish,
   86         pcic_isa_chip_intr_string,
   87 
   88         pcic_chip_socket_enable,
   89         pcic_chip_socket_disable,
   90 };
   91 
   92 int
   93 pcic_isapnp_match(struct device *parent, void *match, void *aux)
   94 {
   95         return (1);
   96 }
   97 
   98 void
   99 pcic_isapnp_attach(struct device *parent, struct device *self, void *aux)
  100 {
  101         struct pcic_softc *sc = (void *) self;
  102         struct pcic_handle *h;
  103         struct isa_attach_args *ipa = aux;
  104         isa_chipset_tag_t ic = ipa->ia_ic;
  105         bus_space_tag_t iot = ipa->ia_iot;
  106         bus_space_tag_t memt = ipa->ia_memt;
  107         bus_space_handle_t ioh;
  108         bus_space_handle_t memh;
  109         int tmp1, i;
  110 
  111         printf("\n");
  112 
  113         if (isapnp_config(iot, memt, ipa)) {
  114                 printf("%s: error in region allocation\n", sc->dev.dv_xname);
  115                 return;
  116         }
  117 
  118         printf("%s: %s %s", sc->dev.dv_xname, ipa->ipa_devident,
  119             ipa->ipa_devclass);
  120 
  121         /* sanity check that we get at least one hunk of IO space.. */
  122         if (ipa->ipa_nio < 1) {
  123                 printf("%s: failed to get one chunk of i/o space\n",
  124                        sc->dev.dv_xname);
  125                 return;
  126         }
  127 
  128         /* Find i/o space. */
  129         ioh = ipa->ipa_io[0].h;
  130 
  131         /* sanity check to make sure we have a real PCIC there.. */
  132         bus_space_write_1(iot, ioh, PCIC_REG_INDEX, C0SA + PCIC_IDENT);
  133         tmp1 = bus_space_read_1(iot, ioh, PCIC_REG_DATA);
  134         printf("(ident 0x%x", tmp1);
  135         if (pcic_ident_ok(tmp1)) {
  136                 printf(" OK)");
  137         } else {
  138                 printf(" Not OK)\n");
  139                 return;
  140         }
  141 
  142         if (bus_space_map(memt, ipa->ia_maddr, ipa->ia_msize, 0, &memh)) {
  143                 printf(": can't map mem space\n");
  144                 return;
  145         }
  146 
  147         sc->membase = ipa->ia_maddr;
  148         sc->subregionmask = (1 << (ipa->ia_msize / PCIC_MEM_PAGESIZE)) - 1;
  149 
  150         sc->intr_est = ic;
  151         sc->pct = (pcmcia_chipset_tag_t) & pcic_isa_functions;
  152 
  153         sc->iot = iot;
  154         sc->ioh = ioh;
  155         sc->memt = memt;
  156         sc->memh = memh;
  157 
  158         printf("\n");
  159 
  160         pcic_attach(sc);
  161         pcic_isa_bus_width_probe(sc, iot, ioh, ipa->ipa_io[0].base,
  162             ipa->ipa_io[0].length);
  163         pcic_attach_sockets(sc);
  164 
  165         /*
  166          * allocate an irq.  it will be used by both controllers.  I could
  167          * use two different interrupts, but interrupts are relatively
  168          * scarce, shareable, and for PCIC controllers, very infrequent.
  169          */
  170 
  171         if (ipa->ipa_nirq > 0)
  172                 sc->irq = ipa->ipa_irq[0].num;
  173         else
  174                 sc->irq = IRQUNK;
  175 
  176         if (sc->irq == IRQUNK)
  177                 sc->irq = pcic_intr_find(sc, IST_EDGE);
  178 
  179         if (sc->irq) {
  180                 sc->ih = isa_intr_establish(ic, sc->irq, IST_EDGE, IPL_TTY,
  181                     pcic_intr, sc, sc->dev.dv_xname);
  182                 if (!sc->ih)
  183                         sc->irq = 0;
  184         }
  185 
  186         if (sc->irq) {
  187                 printf("%s: irq %d, ", sc->dev.dv_xname, sc->irq);
  188 
  189                 /* Set up the pcic to interrupt on card detect. */
  190                 for (i = 0; i < PCIC_NSLOTS; i++) {
  191                         h = &sc->handle[i];
  192                         if (h->flags & PCIC_FLAG_SOCKETP) {
  193                                 pcic_write(h, PCIC_CSC_INTR,
  194                                     (sc->irq << PCIC_CSC_INTR_IRQ_SHIFT) |
  195                                     PCIC_CSC_INTR_CD_ENABLE);
  196                         }
  197                 }
  198         } else
  199                 printf("%s: no irq, ", sc->dev.dv_xname);
  200 
  201         printf("polling enabled\n");
  202         if (sc->poll_established == 0) {
  203                 timeout_set(&sc->poll_timeout, pcic_poll_intr, sc);
  204                 timeout_add_msec(&sc->poll_timeout, 500);
  205                 sc->poll_established = 1;
  206         }
  207 }

Cache object: b26a7e1be543eabb6676c70b66a45eb7


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