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/pci/cy_pci.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 /*
    2  * Copyright (c) 1996, David Greenman
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice unmodified, this list of conditions, and the following
   10  *    disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   25  * SUCH DAMAGE.
   26  *
   27  * $FreeBSD$
   28  */
   29 
   30 /*
   31  * Cyclades Y PCI serial interface driver
   32  */
   33 
   34 #include "opt_cy_pci_fastintr.h"
   35 
   36 #include <sys/param.h>
   37 #include <sys/systm.h>
   38 #include <sys/kernel.h>
   39 #include <vm/vm.h>
   40 #include <vm/pmap.h>
   41 
   42 #include <pci/pcivar.h>
   43 
   44 #include <pci/cy_pcireg.h>
   45 
   46 #ifdef CY_PCI_FASTINTR
   47 #include <i386/isa/intr_machdep.h>
   48 #endif
   49 
   50 static const char *cy_probe             __P((pcici_t, pcidi_t));
   51 static void cy_attach           __P((pcici_t, int));
   52 
   53 extern int cyattach_common(void *, int); /* Not exactly correct */
   54 extern void cyintr(int);
   55 
   56 static u_long cy_count;
   57 
   58 static struct pci_device cy_device = {
   59         "cy",
   60         cy_probe,
   61         cy_attach,
   62         &cy_count,
   63         NULL
   64 };
   65 COMPAT_PCI_DRIVER(cy_pci, cy_device);
   66 
   67 static const char *
   68 cy_probe(config_id, device_id)
   69         pcici_t config_id;
   70         pcidi_t device_id;
   71 {
   72         device_id &= ~0x00060000;
   73         if (device_id == 0x0100120e || device_id == 0x0101120e)
   74                 return ("Cyclades Cyclom-Y Serial Adapter");
   75         return (NULL);
   76 }
   77 
   78 static void
   79 cy_attach(config_id, unit)
   80         pcici_t config_id;
   81         int unit;
   82 {
   83         vm_offset_t paddr;
   84         void *vaddr;
   85         u_int32_t ioport;
   86         int adapter;
   87         u_char plx_ver;
   88 
   89         ioport = (u_int32_t) pci_conf_read(config_id, CY_PCI_BASE_ADDR1) & ~0x3;
   90         paddr = pci_conf_read(config_id, CY_PCI_BASE_ADDR2) & ~0xf;
   91 #if 0
   92         if (!pci_map_mem(config_id, CY_PCI_BASE_ADDR2, &vaddr, &paddr)) {
   93                 printf("cy%d: couldn't map shared memory\n", unit);
   94                 return;
   95         };
   96 #endif
   97         vaddr = pmap_mapdev(paddr, 0x4000);
   98 
   99         adapter = cyattach_common(vaddr, 1);
  100         if (adapter < 0) {
  101                 /*
  102                  * No ports found. Release resources and punt.
  103                  */
  104                 printf("cy%d: no ports found!\n", unit);
  105                 goto fail;
  106         }
  107 
  108         /*
  109          * Allocate our interrupt.
  110          * XXX  Using the ISA interrupt handler directly is a bit of a violation
  111          *      since it doesn't actually take the same argument. For PCI, the
  112          *      argument is a void * token, but for ISA it is a unit. Since
  113          *      there is no overlap in PCI/ISA unit numbers for this driver, and
  114          *      since the ISA driver must handle the interrupt anyway, we use
  115          *      the unit number as the token even for PCI.
  116          */
  117         if (
  118 #ifdef CY_PCI_FASTINTR
  119             !pci_map_int_right(config_id, (pci_inthand_t *)cyintr,
  120                                (void *)adapter, &tty_imask,
  121                                INTR_EXCL | INTR_FAST) &&
  122 #endif
  123             !pci_map_int_right(config_id, (pci_inthand_t *)cyintr,
  124                                (void *)adapter, &tty_imask, 0)) {
  125                 printf("cy%d: couldn't map interrupt\n", unit);
  126                 goto fail;
  127         }
  128 
  129         /*
  130          * Enable the "local" interrupt input to generate a
  131          * PCI interrupt.
  132          */
  133         plx_ver = *((u_char *)vaddr + PLX_VER) & 0x0f;
  134         switch (plx_ver) {
  135         case PLX_9050:
  136                 outw(ioport + CY_PLX_9050_ICS,
  137                     CY_PLX_9050_ICS_IENABLE | CY_PLX_9050_ICS_LOCAL_IENABLE |
  138                     CY_PLX_9050_ICS_LOCAL_IPOLARITY);
  139                 break;
  140         case PLX_9060:
  141         case PLX_9080:
  142         default:                /* Old board, use PLX_9060 values. */
  143                 outw(ioport + CY_PLX_9060_ICS,
  144                     inw(ioport + CY_PLX_9060_ICS) | CY_PLX_9060_ICS_IENABLE |
  145                     CY_PLX_9060_ICS_LOCAL_IENABLE);
  146                 break;
  147         }
  148 
  149         return;
  150 
  151 fail:
  152         /* XXX should release any allocated virtual memory */
  153         return;
  154 }

Cache object: 52640f80a31b131f4f9256457d549d59


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