tmc18c30_isa.c revision 113205
167468Snon/* $FreeBSD: head/sys/dev/stg/tmc18c30_isa.c 113205 2003-04-07 10:13:25Z mdodd $ */ 267468Snon/* $NecBSD: tmc18c30_pisa.c,v 1.22 1998/11/26 01:59:21 honda Exp $ */ 367468Snon/* $NetBSD$ */ 467468Snon 567468Snon/* 667468Snon * [Ported for FreeBSD] 767468Snon * Copyright (c) 2000 867468Snon * Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe. 967468Snon * All rights reserved. 1067468Snon * [NetBSD for NEC PC-98 series] 1167468Snon * Copyright (c) 1996, 1997, 1998 1267468Snon * NetBSD/pc98 porting staff. All rights reserved. 1367468Snon * Copyright (c) 1996, 1997, 1998 1467468Snon * Naofumi HONDA. All rights reserved. 1567468Snon * Copyright (c) 1996, 1997, 1998 1667468Snon * Kouichi Matsuda. All rights reserved. 1767468Snon * 1867468Snon * Redistribution and use in source and binary forms, with or without 1967468Snon * modification, are permitted provided that the following conditions 2067468Snon * are met: 2167468Snon * 1. Redistributions of source code must retain the above copyright 2267468Snon * notice, this list of conditions and the following disclaimer. 2367468Snon * 2. Redistributions in binary form must reproduce the above copyright 2467468Snon * notice, this list of conditions and the following disclaimer in the 2567468Snon * documentation and/or other materials provided with the distribution. 2667468Snon * 3. The name of the author may not be used to endorse or promote products 2767468Snon * derived from this software without specific prior written permission. 2867468Snon * 2967468Snon * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 3067468Snon * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 3167468Snon * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 3267468Snon * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 3367468Snon * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 3467468Snon * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 3567468Snon * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3667468Snon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3767468Snon * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 3867468Snon * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3967468Snon * POSSIBILITY OF SUCH DAMAGE. 4067468Snon */ 4167468Snon 4267468Snon#include <sys/param.h> 4367468Snon#include <sys/systm.h> 4467468Snon#include <sys/kernel.h> 4567468Snon#include <sys/module.h> 4667468Snon#include <sys/bus.h> 4767468Snon#include <sys/malloc.h> 4867468Snon#include <sys/errno.h> 4967468Snon 5067468Snon#include <machine/bus_pio.h> 5167468Snon#include <machine/bus.h> 5267468Snon#include <machine/resource.h> 5367468Snon#include <sys/rman.h> 5467468Snon 5567468Snon#include <cam/scsi/scsi_low.h> 5667468Snon#include <cam/scsi/scsi_low_pisa.h> 5767468Snon 5867468Snon#include <dev/stg/tmc18c30reg.h> 5967468Snon#include <dev/stg/tmc18c30var.h> 60113205Smdodd#include <dev/stg/tmc18c30.h> 6167468Snon 6267468Snonstatic int 63113205Smdoddstg_isa_probe(device_t dev) 6467468Snon{ 6567468Snon struct stg_softc *sc = device_get_softc(dev); 6667468Snon int error; 6767468Snon 6867468Snon sc->port_rid = 0; 6967468Snon sc->irq_rid = 0; 7067468Snon error = stg_alloc_resource(dev); 7167468Snon if (error) { 7267468Snon return(error); 7367468Snon } 7467468Snon 75113205Smdodd if (stg_probe(dev) == 0) { 7667468Snon stg_release_resource(dev); 7767468Snon return(ENXIO); 7867468Snon } 7967468Snon 8067468Snon stg_release_resource(dev); 8167468Snon 8267468Snon return(0); 8367468Snon} 8467468Snon 8567468Snonstatic int 8667468Snonstg_isa_attach(device_t dev) 8767468Snon{ 8867468Snon struct stg_softc *sc = device_get_softc(dev); 8967468Snon int error; 9067468Snon 91113205Smdodd sc->port_rid = 0; 92113205Smdodd sc->irq_rid = 0; 9367468Snon error = stg_alloc_resource(dev); 9467468Snon if (error) { 9567468Snon return(error); 9667468Snon } 9767468Snon 9873280Smarkm error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_CAM | INTR_ENTROPY, 99113205Smdodd stg_intr, (void *)sc, &sc->stg_intrhand); 10067468Snon if (error) { 10167468Snon stg_release_resource(dev); 10267468Snon return(error); 10367468Snon } 10467468Snon 105113205Smdodd if (stg_attach(dev) == 0) { 10667468Snon stg_release_resource(dev); 10767468Snon return(ENXIO); 10867468Snon } 10967468Snon 11067468Snon return(0); 11167468Snon} 11267468Snon 11367468Snonstatic device_method_t stg_isa_methods[] = { 11467468Snon /* Device interface */ 11567468Snon DEVMETHOD(device_probe, stg_isa_probe), 11667468Snon DEVMETHOD(device_attach, stg_isa_attach), 117113205Smdodd DEVMETHOD(device_detach, stg_detach), 11867468Snon 11967468Snon { 0, 0 } 12067468Snon}; 12167468Snon 12267468Snonstatic driver_t stg_isa_driver = { 12367468Snon "stg", 12467468Snon stg_isa_methods, 12567468Snon sizeof(struct stg_softc), 12667468Snon}; 12767468Snon 12867468SnonDRIVER_MODULE(stg, isa, stg_isa_driver, stg_devclass, 0, 0); 129113205SmdoddMODULE_DEPEND(stg, scsi_low, 1, 1, 1); 130