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$"); 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 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, 99166901Spiso NULL, 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