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