tmc18c30_pccard.c revision 119420
12786Ssos/* $NecBSD: tmc18c30_pisa.c,v 1.22 1998/11/26 01:59:21 honda Exp $ */ 22786Ssos/* $NetBSD$ */ 32786Ssos 42786Ssos/* 52786Ssos * [Ported for FreeBSD] 62786Ssos * Copyright (c) 2000 72786Ssos * Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe. 86851Ssos * All rights reserved. 92786Ssos * [NetBSD for NEC PC-98 series] 1029826Sache * Copyright (c) 1996, 1997, 1998 112786Ssos * NetBSD/pc98 porting staff. All rights reserved. 122786Ssos * Copyright (c) 1996, 1997, 1998 132786Ssos * Naofumi HONDA. All rights reserved. 142786Ssos * Copyright (c) 1996, 1997, 1998 1528375Ssos * Kouichi Matsuda. All rights reserved. 162786Ssos * 172786Ssos * Redistribution and use in source and binary forms, with or without 182786Ssos * modification, are permitted provided that the following conditions 197420Ssos * are met: 202786Ssos * 1. Redistributions of source code must retain the above copyright 212786Ssos * notice, this list of conditions and the following disclaimer. 222786Ssos * 2. Redistributions in binary form must reproduce the above copyright 232786Ssos * notice, this list of conditions and the following disclaimer in the 242786Ssos * documentation and/or other materials provided with the distribution. 252786Ssos * 3. The name of the author may not be used to endorse or promote products 262786Ssos * derived from this software without specific prior written permission. 272786Ssos * 282786Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 292786Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 302786Ssos * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 312786Ssos * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 322786Ssos * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 332786Ssos * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 342786Ssos * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 352786Ssos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 362786Ssos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 372786Ssos * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 382786Ssos * POSSIBILITY OF SUCH DAMAGE. 392786Ssos */ 402786Ssos 412786Ssos#include <sys/cdefs.h> 422786Ssos__FBSDID("$FreeBSD: head/sys/dev/stg/tmc18c30_pccard.c 119420 2003-08-24 18:17:24Z obrien $"); 432786Ssos 442786Ssos#include <sys/param.h> 452786Ssos#include <sys/systm.h> 462786Ssos#include <sys/malloc.h> 472786Ssos#include <sys/errno.h> 482786Ssos 492786Ssos#include <machine/bus.h> 502786Ssos#include <machine/bus_pio.h> 512786Ssos#include <machine/dvcfg.h> 522786Ssos 532786Ssos#include <sys/device_port.h> 542786Ssos 552786Ssos#include <dev/pccard/pccarddevs.h> 562786Ssos#include <dev/pccard/pccardvar.h> 572786Ssos 582786Ssos#include <cam/scsi/scsi_low.h> 592786Ssos#include <cam/scsi/scsi_low_pisa.h> 602786Ssos 612786Ssos#include <dev/stg/tmc18c30reg.h> 626851Ssos#include <dev/stg/tmc18c30var.h> 632786Ssos#include <dev/stg/tmc18c30.h> 642786Ssos 652786Ssos#include <sys/kernel.h> 662786Ssos#include <sys/module.h> 672786Ssos#if !defined(__FreeBSD__) || __FreeBSD_version < 500014 682786Ssos#include <sys/select.h> 692786Ssos#endif 702786Ssos#include <pccard/cardinfo.h> 712786Ssos#include <pccard/slot.h> 722786Ssos 732786Ssosstatic const struct pccard_product stg_products[] = { 742786Ssos PCMCIA_CARD(FUTUREDOMAIN, SCSI2GO, 0), 752786Ssos PCMCIA_CARD(IBM, SCSICARD, 0), 762786Ssos PCMCIA_CARD(RATOC, REX5536, 0), 772786Ssos PCMCIA_CARD(RATOC, REX5536AM, 0), 782786Ssos PCMCIA_CARD(RATOC, REX5536M, 0), 792786Ssos { NULL } 802786Ssos}; 815994Ssos 822786Ssos/* 832786Ssos * Additional code for FreeBSD new-bus PCCard frontend 842786Ssos */ 852786Ssos 862786Ssosstatic int stg_pccard_match(device_t dev) 872786Ssos{ 886045Ssos const struct pccard_product *pp; 892786Ssos 902786Ssos if ((pp = pccard_product_lookup(dev, stg_products, 912786Ssos sizeof(stg_products[0]), NULL)) != NULL) { 922786Ssos if (pp->pp_name != NULL) 932786Ssos device_set_desc(dev, pp->pp_name); 9418194Ssos return(0); 952786Ssos } 962786Ssos return(EIO); 972786Ssos} 982786Ssos 992786Ssosstatic int 1002786Ssosstg_pccard_probe(DEVPORT_PDEVICE dev) 1012786Ssos{ 1022786Ssos struct stg_softc *sc = device_get_softc(dev); 1032786Ssos int error; 1042786Ssos 1052786Ssos sc->port_rid = 0; 1062786Ssos sc->irq_rid = 0; 1072786Ssos error = stg_alloc_resource(dev); 1086851Ssos if (error) { 1092786Ssos return(error); 1106851Ssos } 1116851Ssos 1126851Ssos if (stg_probe(dev) == 0) { 113 stg_release_resource(dev); 114 return(ENXIO); 115 } 116 117 stg_release_resource(dev); 118 119 return(0); 120} 121 122static int 123stg_pccard_attach(DEVPORT_PDEVICE dev) 124{ 125 struct stg_softc *sc = device_get_softc(dev); 126 int error; 127 128 sc->port_rid = 0; 129 sc->irq_rid = 0; 130 error = stg_alloc_resource(dev); 131 if (error) { 132 return(error); 133 } 134 135 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_CAM | INTR_ENTROPY, 136 stg_intr, (void *)sc, &sc->stg_intrhand); 137 if (error) { 138 stg_release_resource(dev); 139 return(error); 140 } 141 142 if (stg_attach(dev) == 0) { 143 stg_release_resource(dev); 144 return(ENXIO); 145 } 146 147 return(0); 148} 149 150static device_method_t stg_pccard_methods[] = { 151 /* Device interface */ 152 DEVMETHOD(device_probe, pccard_compat_probe), 153 DEVMETHOD(device_attach, pccard_compat_attach), 154 DEVMETHOD(device_detach, stg_detach), 155 156 /* Card interface */ 157 DEVMETHOD(card_compat_match, stg_pccard_match), 158 DEVMETHOD(card_compat_probe, stg_pccard_probe), 159 DEVMETHOD(card_compat_attach, stg_pccard_attach), 160 161 { 0, 0 } 162}; 163 164static driver_t stg_pccard_driver = { 165 "stg", 166 stg_pccard_methods, 167 sizeof(struct stg_softc), 168}; 169 170DRIVER_MODULE(stg, pccard, stg_pccard_driver, stg_devclass, 0, 0); 171MODULE_DEPEND(stg, scsi_low, 1, 1, 1); 172