Merge from vendor branch LESS:
[dragonfly.git] / sys / bus / cam / scsi / scsi_low_pisa.c
1 /*      $FreeBSD: src/sys/cam/scsi/scsi_low_pisa.c,v 1.2.2.4 2001/12/17 13:30:20 non Exp $      */
2 /*      $DragonFly: src/sys/bus/cam/scsi/scsi_low_pisa.c,v 1.4 2004/02/11 17:46:33 joerg Exp $  */
3 /*      $NecBSD: scsi_low_pisa.c,v 1.13 1998/11/26 14:26:11 honda Exp $ */
4 /*      $NetBSD$        */
5
6 /*
7  * [NetBSD for NEC PC-98 series]
8  *  Copyright (c) 1995, 1996, 1997, 1998
9  *      NetBSD/pc98 porting staff. All rights reserved.
10  *  Copyright (c) 1995, 1996, 1997, 1998
11  *      Naofumi HONDA. All rights reserved.
12  * 
13  *  Redistribution and use in source and binary forms, with or without
14  *  modification, are permitted provided that the following conditions
15  *  are met:
16  *  1. Redistributions of source code must retain the above copyright
17  *     notice, this list of conditions and the following disclaimer.
18  *  2. Redistributions in binary form must reproduce the above copyright
19  *     notice, this list of conditions and the following disclaimer in the
20  *     documentation and/or other materials provided with the distribution.
21  *  3. The name of the author may not be used to endorse or promote products
22  *     derived from this software without specific prior written permission.
23  * 
24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
28  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36
37 #ifdef  __NetBSD__
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/kernel.h>
41 #include <sys/device.h>
42 #include <sys/errno.h>
43
44 #include <machine/bus.h>
45 #include <machine/intr.h>
46
47 #include <dev/isa/isareg.h>
48 #include <dev/isa/isavar.h>
49
50 #include <dev/isa/pisaif.h>
51
52 #include <machine/dvcfg.h>
53
54 #include <dev/scsipi/scsi_all.h>
55 #include <dev/scsipi/scsipi_all.h>
56 #include <dev/scsipi/scsiconf.h>
57 #include <dev/scsipi/scsi_disk.h>
58
59 #include <i386/Cbus/dev/scsi_low.h>
60 #include <i386/Cbus/dev/scsi_low_pisa.h>
61
62 #define SCSIBUS_RESCAN
63
64 int
65 scsi_low_deactivate_pisa(dh)
66         pisa_device_handle_t dh;
67 {
68         struct scsi_low_softc *sc = PISA_DEV_SOFTC(dh);
69
70         if (scsi_low_deactivate(sc) != 0)
71                 return EBUSY;
72         return 0;
73 }
74
75 int
76 scsi_low_activate_pisa(dh)
77         pisa_device_handle_t dh;
78 {
79         struct scsi_low_softc *sc = PISA_DEV_SOFTC(dh);
80         slot_device_res_t dr = PISA_RES_DR(dh);
81
82         sc->sl_cfgflags = DVCFG_MKCFG(DVCFG_MAJOR(sc->sl_cfgflags), \
83                                       DVCFG_MINOR(PISA_DR_DVCFG(dr)));
84         sc->sl_irq = PISA_DR_IRQ(dr);
85
86         if (scsi_low_activate(sc) != 0)
87                 return EBUSY;
88
89         /* rescan the scsi bus */
90 #ifdef  SCSIBUS_RESCAN
91         if (scsi_low_is_busy(sc) == 0 &&
92             PISA_RES_EVENT(dh) == PISA_EVENT_INSERT)
93                 scsi_probe_busses((int) sc->sl_si.si_splp->scsipi_scsi.scsibus,
94                                   -1, -1);
95 #endif
96         return 0;
97 }
98
99 int
100 scsi_low_notify_pisa(dh, ev)
101         pisa_device_handle_t dh;
102         pisa_event_t ev;
103 {
104         struct scsi_low_softc *sc = PISA_DEV_SOFTC(dh);
105
106         switch(ev)
107         {
108         case PISA_EVENT_QUERY_SUSPEND:
109                 if (scsi_low_is_busy(sc) != 0)
110                         return SD_EVENT_STATUS_BUSY;
111                 break;
112
113         default:
114                 break;
115         }
116         return 0;
117 }
118 #endif  /* __NetBSD__ */
119
120 #ifdef  __DragonFly__ 
121 #include <sys/param.h>
122 #include <sys/systm.h>
123 #include <sys/kernel.h>
124 #include <sys/buf.h>
125 #include <sys/queue.h>
126 #include <sys/device_port.h>
127 #include <sys/module.h>
128
129 #include "scsi_low.h"
130 #include "scsi_low_pisa.h"
131
132 int
133 scsi_low_deactivate_pisa(sc)
134         struct scsi_low_softc *sc;
135 {
136
137         if (scsi_low_deactivate(sc) != 0)
138                 return EBUSY;
139         return 0;
140 }
141
142 int
143 scsi_low_activate_pisa(sc, flags)
144         struct scsi_low_softc *sc;
145         int flags;
146 {
147
148         sc->sl_cfgflags = ((sc->sl_cfgflags & 0xffff0000) |
149                            (flags & 0x00ff));
150
151         if (scsi_low_activate(sc) != 0)
152                 return EBUSY;
153         return 0;
154 }
155
156 static moduledata_t scsi_low_moduledata = {
157         "scsi_low",
158         NULL,
159         NULL
160 };
161
162 DECLARE_MODULE(scsi_low, scsi_low_moduledata, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
163 MODULE_VERSION(scsi_low, 1);
164 MODULE_DEPEND(scsi_low, cam, 1, 1, 1);
165 #endif  /* __DragonFly__ */