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