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: src/sys/pci/cy_pci.c,v 1.2.2.2 1999/09/05 08:20:56 peter Exp $
   28  */
   29 
   30 /*
   31  * Cyclades Y PCI serial interface driver
   32  */
   33 
   34 #include "pci.h"
   35 #if NPCI > 0
   36 
   37 #include <sys/param.h>
   38 #include <sys/systm.h>
   39 #include <sys/malloc.h>
   40 #include <sys/kernel.h>
   41 #include <vm/vm.h>
   42 #include <vm/pmap.h>
   43 
   44 #include <pci/pcivar.h>
   45 
   46 #include <pci/cy_pcireg.h>
   47 
   48 static char *cy_probe           __P((pcici_t, pcidi_t));
   49 static void cy_attach           __P((pcici_t, int));
   50 
   51 extern int cyattach_common(void *, int); /* Not exactly correct */
   52 extern void cyintr(int);
   53 
   54 static u_long cy_count;
   55 
   56 static struct pci_device cy_device = {
   57         "cy",
   58         cy_probe,
   59         cy_attach,
   60         &cy_count,
   61         NULL
   62 };
   63 DATA_SET(pcidevice_set, cy_device);
   64 
   65 static char *
   66 cy_probe(config_id, device_id)
   67         pcici_t config_id;
   68         pcidi_t device_id;
   69 {
   70         if ((device_id & 0xffff) == CY_VENDORID_CYCLADES &&
   71             ((device_id >> 16) == CY_DEVICEID_CYCLOM_Y_1 ||
   72              (device_id >> 16) == CY_DEVICEID_CYCLOM_Y_2))
   73                 return ("Cyclades Cyclom-Y Serial Adapter");
   74         return NULL;
   75 }
   76 
   77 static void
   78 cy_attach(config_id, unit)
   79         pcici_t config_id;
   80         int unit;
   81 {
   82         vm_offset_t paddr;
   83         void *vaddr;
   84         u_int32_t ioport;
   85         int adapter;
   86 
   87         ioport = (u_int32_t) pci_conf_read(config_id, CY_PCI_BASE_ADDR1) & ~0x3;
   88         paddr = pci_conf_read(config_id, CY_PCI_BASE_ADDR2) & ~0xf;
   89 #if 0
   90         if (!pci_map_mem(config_id, CY_PCI_BASE_ADDR2, &vaddr, &paddr)) {
   91                 printf("cy%d: couldn't map shared memory\n", unit);
   92                 return;
   93         };
   94 #endif
   95         vaddr = pmap_mapdev(paddr, 0x4000);
   96 
   97         adapter = cyattach_common(vaddr, 1);
   98         if (adapter < 0) {
   99                 /*
  100                  * No ports found. Release resources and punt.
  101                  */
  102                 printf("cy%d: no ports found!", unit);
  103                 goto fail;
  104         }
  105 
  106         /*
  107          * Allocate our interrupt.
  108          * XXX  Using the ISA interrupt handler directly is a bit of a violation
  109          *      since it doesn't actually take the same argument. For PCI, the
  110          *      argument is a void * token, but for ISA it is a unit. Since
  111          *      there is no overlap in PCI/ISA unit numbers for this driver, and
  112          *      since the ISA driver must handle the interrupt anyway, we use
  113          *      the unit number as the token even for PCI.
  114          */
  115         if (!pci_map_int(config_id, (pci_inthand_t *)cyintr, (void *)adapter, &tty_imask)) {
  116                 printf("cy%d: couldn't map interrupt\n", unit);
  117                 goto fail;
  118         }
  119         /*
  120          * Enable the "local" interrupt input to generate a
  121          * PCI interrupt.
  122          */
  123         outw(ioport + CY_PLX_ICS, inw(ioport + CY_PLX_ICS) |
  124             CY_PLX_ICS_IENABLE | CY_PLX_ICS_LOCAL_IENABLE);
  125 
  126         return;
  127 
  128 fail:
  129         /* XXX should release any allocated virtual memory */
  130         return;
  131 }
  132 
  133 #endif /* NPCI > 0 */

Cache object: 70fd6347cb19b8c4e4900e39a66602cf


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