tmc18c30_isa.c revision 139749
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 139749 2005-01-06 01:43:34Z imp $");
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_pio.h>
5367468Snon#include <machine/bus.h>
5467468Snon#include <machine/resource.h>
5567468Snon#include <sys/rman.h>
5667468Snon
5767468Snon#include <cam/scsi/scsi_low.h>
5867468Snon#include <cam/scsi/scsi_low_pisa.h>
5967468Snon
6067468Snon#include <dev/stg/tmc18c30reg.h>
6167468Snon#include <dev/stg/tmc18c30var.h>
62113205Smdodd#include <dev/stg/tmc18c30.h>
6367468Snon
6467468Snonstatic int
65113205Smdoddstg_isa_probe(device_t dev)
6667468Snon{
6767468Snon	struct stg_softc	*sc = device_get_softc(dev);
6867468Snon	int			error;
6967468Snon
7067468Snon	sc->port_rid = 0;
7167468Snon	sc->irq_rid = 0;
7267468Snon	error = stg_alloc_resource(dev);
7367468Snon	if (error) {
7467468Snon		return(error);
7567468Snon	}
7667468Snon
77113205Smdodd	if (stg_probe(dev) == 0) {
7867468Snon		stg_release_resource(dev);
7967468Snon		return(ENXIO);
8067468Snon	}
8167468Snon
8267468Snon	stg_release_resource(dev);
8367468Snon
8467468Snon	return(0);
8567468Snon}
8667468Snon
8767468Snonstatic int
8867468Snonstg_isa_attach(device_t dev)
8967468Snon{
9067468Snon	struct stg_softc	*sc = device_get_softc(dev);
9167468Snon	int			error;
9267468Snon
93113205Smdodd	sc->port_rid = 0;
94113205Smdodd	sc->irq_rid = 0;
9567468Snon	error = stg_alloc_resource(dev);
9667468Snon	if (error) {
9767468Snon		return(error);
9867468Snon	}
9967468Snon
10073280Smarkm	error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_CAM | INTR_ENTROPY,
101113205Smdodd			       stg_intr, (void *)sc, &sc->stg_intrhand);
10267468Snon	if (error) {
10367468Snon		stg_release_resource(dev);
10467468Snon		return(error);
10567468Snon	}
10667468Snon
107113205Smdodd	if (stg_attach(dev) == 0) {
10867468Snon		stg_release_resource(dev);
10967468Snon		return(ENXIO);
11067468Snon	}
11167468Snon
11267468Snon	return(0);
11367468Snon}
11467468Snon
11567468Snonstatic device_method_t stg_isa_methods[] = {
11667468Snon	/* Device interface */
11767468Snon	DEVMETHOD(device_probe,		stg_isa_probe),
11867468Snon	DEVMETHOD(device_attach,	stg_isa_attach),
119113205Smdodd	DEVMETHOD(device_detach,	stg_detach),
12067468Snon
12167468Snon	{ 0, 0 }
12267468Snon};
12367468Snon
12467468Snonstatic driver_t stg_isa_driver = {
12567468Snon	"stg",
12667468Snon	stg_isa_methods,
12767468Snon	sizeof(struct stg_softc),
12867468Snon};
12967468Snon
13067468SnonDRIVER_MODULE(stg, isa, stg_isa_driver, stg_devclass, 0, 0);
131113205SmdoddMODULE_DEPEND(stg, scsi_low, 1, 1, 1);
132