tmc18c30_isa.c revision 146734
1/* $NecBSD: tmc18c30_pisa.c,v 1.22 1998/11/26 01:59:21 honda Exp $ */ 2/* $NetBSD$ */ 3 4/*- 5 * [Ported for FreeBSD] 6 * Copyright (c) 2000 7 * Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe. 8 * All rights reserved. 9 * [NetBSD for NEC PC-98 series] 10 * Copyright (c) 1996, 1997, 1998 11 * NetBSD/pc98 porting staff. All rights reserved. 12 * Copyright (c) 1996, 1997, 1998 13 * Naofumi HONDA. All rights reserved. 14 * Copyright (c) 1996, 1997, 1998 15 * Kouichi Matsuda. All rights reserved. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions 19 * are met: 20 * 1. Redistributions of source code must retain the above copyright 21 * notice, this list of conditions and the following disclaimer. 22 * 2. Redistributions in binary form must reproduce the above copyright 23 * notice, this list of conditions and the following disclaimer in the 24 * documentation and/or other materials provided with the distribution. 25 * 3. The name of the author may not be used to endorse or promote products 26 * derived from this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 30 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 32 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 33 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 * POSSIBILITY OF SUCH DAMAGE. 39 */ 40 41#include <sys/cdefs.h> 42__FBSDID("$FreeBSD: head/sys/dev/stg/tmc18c30_isa.c 146734 2005-05-29 04:42:30Z nyan $"); 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/kernel.h> 47#include <sys/module.h> 48#include <sys/bus.h> 49#include <sys/malloc.h> 50#include <sys/errno.h> 51 52#include <machine/bus.h> 53#include <machine/resource.h> 54#include <sys/rman.h> 55 56#include <cam/scsi/scsi_low.h> 57#include <cam/scsi/scsi_low_pisa.h> 58 59#include <dev/stg/tmc18c30reg.h> 60#include <dev/stg/tmc18c30var.h> 61#include <dev/stg/tmc18c30.h> 62 63static int 64stg_isa_probe(device_t dev) 65{ 66 struct stg_softc *sc = device_get_softc(dev); 67 int error; 68 69 sc->port_rid = 0; 70 sc->irq_rid = 0; 71 error = stg_alloc_resource(dev); 72 if (error) { 73 return(error); 74 } 75 76 if (stg_probe(dev) == 0) { 77 stg_release_resource(dev); 78 return(ENXIO); 79 } 80 81 stg_release_resource(dev); 82 83 return(0); 84} 85 86static int 87stg_isa_attach(device_t dev) 88{ 89 struct stg_softc *sc = device_get_softc(dev); 90 int error; 91 92 sc->port_rid = 0; 93 sc->irq_rid = 0; 94 error = stg_alloc_resource(dev); 95 if (error) { 96 return(error); 97 } 98 99 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_CAM | INTR_ENTROPY, 100 stg_intr, (void *)sc, &sc->stg_intrhand); 101 if (error) { 102 stg_release_resource(dev); 103 return(error); 104 } 105 106 if (stg_attach(dev) == 0) { 107 stg_release_resource(dev); 108 return(ENXIO); 109 } 110 111 return(0); 112} 113 114static device_method_t stg_isa_methods[] = { 115 /* Device interface */ 116 DEVMETHOD(device_probe, stg_isa_probe), 117 DEVMETHOD(device_attach, stg_isa_attach), 118 DEVMETHOD(device_detach, stg_detach), 119 120 { 0, 0 } 121}; 122 123static driver_t stg_isa_driver = { 124 "stg", 125 stg_isa_methods, 126 sizeof(struct stg_softc), 127}; 128 129DRIVER_MODULE(stg, isa, stg_isa_driver, stg_devclass, 0, 0); 130MODULE_DEPEND(stg, scsi_low, 1, 1, 1); 131