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/mips/rmi/xlr_pcmcia.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) 2003-2009 RMI Corporation
    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, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  * 3. Neither the name of RMI Corporation, nor the names of its contributors,
   14  *    may be used to endorse or promote products derived from this software
   15  *    without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * RMI_BSD */
   30 /*
   31  * ATA driver for the XLR_PCMCIA Host adapter on the RMI XLR/XLS/.
   32  */
   33 #include <sys/cdefs.h>
   34 __FBSDID("$FreeBSD: releng/8.2/sys/mips/rmi/xlr_pcmcia.c 215938 2010-11-27 12:26:40Z jchandra $");
   35 
   36 #include <sys/param.h>
   37 #include <sys/systm.h>
   38 #include <sys/kernel.h>
   39 #include <sys/module.h>
   40 #include <sys/bus.h> 
   41 #include <sys/rman.h>
   42 #include <vm/uma.h>
   43 #include <sys/ata.h>
   44 #include <sys/sema.h>
   45 #include <sys/taskqueue.h>
   46 #include <sys/bus_dma.h>
   47 
   48 #include <dev/ata/ata-all.h>
   49 #include <mips/rmi/pic.h>
   50 #include <mips/rmi/iomap.h>
   51 #include <mips/include/resource.h>
   52 #include <mips/rmi/interrupt.h>
   53 
   54 #define XLR_PCMCIA_DATA_REG             0x1f0
   55 #define XLR_PCMCIA_ERROR_REG            0x1f1
   56 #define XLR_PCMCIA_SECT_CNT_REG         0x1f2
   57 #define XLR_PCMCIA_SECT_NUM_REG         0x1f3
   58 #define XLR_PCMCIA_CYLINDER_LOW_REG     0x1f4
   59 #define XLR_PCMCIA_CYLINDER_HIGH_REG    0x1f5
   60 #define XLR_PCMCIA_SECT_DRIVE_HEAD_REG  0x1f6
   61 #define XLR_PCMCIA_CMD_STATUS_REG       0x1f7
   62 #define XLR_PCMCIA_ALT_STATUS_REG       0x3f6
   63 #define XLR_PCMCIA_CONTROL_REG          0x3f6
   64 
   65 /*
   66  * Device methods
   67  */
   68 static int xlr_pcmcia_probe(device_t);
   69 static int xlr_pcmcia_attach(device_t);
   70 static int xlr_pcmcia_detach(device_t);
   71 
   72 static int
   73 xlr_pcmcia_probe(device_t dev)
   74 {
   75         struct ata_channel *ch = device_get_softc(dev);
   76 
   77         ch->unit = 0;
   78         ch->flags |= ATA_USE_16BIT | ATA_NO_SLAVE ;
   79         device_set_desc(dev, "PCMCIA ATA controller");
   80 
   81         return (ata_probe(dev));
   82 }
   83 
   84 /*
   85  * We add all the devices which we know about.
   86  * The generic attach routine will attach them if they are alive.
   87  */
   88 static int
   89 xlr_pcmcia_attach(device_t dev)
   90 {
   91         struct ata_channel *ch = device_get_softc(dev);
   92         int i;
   93         int rid =0;
   94         struct resource *mem_res;
   95 
   96 
   97         mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,  RF_ACTIVE);
   98         for (i = 0; i < ATA_MAX_RES; i++)
   99                 ch->r_io[i].res = mem_res;
  100 
  101         /*
  102          * CF+ Specification.
  103          */
  104         ch->r_io[ATA_DATA].offset       = XLR_PCMCIA_DATA_REG;
  105         ch->r_io[ATA_FEATURE].offset    = XLR_PCMCIA_ERROR_REG;
  106         ch->r_io[ATA_COUNT].offset      = XLR_PCMCIA_SECT_CNT_REG;
  107         ch->r_io[ATA_SECTOR].offset     = XLR_PCMCIA_SECT_NUM_REG;
  108         ch->r_io[ATA_CYL_LSB].offset    = XLR_PCMCIA_CYLINDER_LOW_REG;
  109         ch->r_io[ATA_CYL_MSB].offset    = XLR_PCMCIA_CYLINDER_HIGH_REG;
  110         ch->r_io[ATA_DRIVE].offset      = XLR_PCMCIA_SECT_DRIVE_HEAD_REG;
  111         ch->r_io[ATA_COMMAND].offset    = XLR_PCMCIA_CMD_STATUS_REG;
  112         ch->r_io[ATA_ERROR].offset      = XLR_PCMCIA_ERROR_REG;
  113         ch->r_io[ATA_IREASON].offset    = XLR_PCMCIA_SECT_CNT_REG;
  114         ch->r_io[ATA_STATUS].offset     = XLR_PCMCIA_CMD_STATUS_REG;
  115         ch->r_io[ATA_ALTSTAT].offset    = XLR_PCMCIA_ALT_STATUS_REG;
  116         ch->r_io[ATA_CONTROL].offset    = XLR_PCMCIA_CONTROL_REG;
  117 
  118         /* Should point at the base of registers. */
  119         ch->r_io[ATA_IDX_ADDR].offset = XLR_PCMCIA_DATA_REG;
  120 
  121         ata_generic_hw(dev);
  122 
  123         return (ata_attach(dev)); 
  124 }
  125 
  126 static int
  127 xlr_pcmcia_detach(device_t dev)
  128 {
  129         bus_generic_detach(dev);
  130   
  131         return (0);
  132 }
  133 
  134 static device_method_t xlr_pcmcia_methods[] = {
  135     /* device interface */
  136     DEVMETHOD(device_probe,         xlr_pcmcia_probe),
  137     DEVMETHOD(device_attach,        xlr_pcmcia_attach),
  138     DEVMETHOD(device_detach,        xlr_pcmcia_detach),
  139 
  140     { 0, 0 }
  141 };
  142 
  143 static driver_t xlr_pcmcia_driver = {
  144         "ata",
  145         xlr_pcmcia_methods,
  146         sizeof(struct ata_channel),
  147 };
  148 
  149 DRIVER_MODULE(ata, iodi, xlr_pcmcia_driver, ata_devclass, 0, 0);

Cache object: 54a704712deb3aaf5efb126d5073d0c5


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