Deleted Added
full compact
nsp_pccard.c (194023) nsp_pccard.c (240172)
1/* $NecBSD: nsp_pisa.c,v 1.4 1999/04/15 01:35:54 kmatsuda Exp $ */
2/* $NetBSD$ */
3
4/*-
5 * [Ported for FreeBSD]
6 * Copyright (c) 2000
7 * Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe.
8 * All rights reserved.

--- 21 unchanged lines hidden (view full) ---

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#include <sys/cdefs.h>
1/* $NecBSD: nsp_pisa.c,v 1.4 1999/04/15 01:35:54 kmatsuda Exp $ */
2/* $NetBSD$ */
3
4/*-
5 * [Ported for FreeBSD]
6 * Copyright (c) 2000
7 * Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe.
8 * All rights reserved.

--- 21 unchanged lines hidden (view full) ---

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#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/dev/nsp/nsp_pccard.c 194023 2009-06-11 17:14:28Z avg $");
38__FBSDID("$FreeBSD: head/sys/dev/nsp/nsp_pccard.c 240172 2012-09-06 18:53:33Z jhb $");
39
40#include <sys/param.h>
41#include <sys/bus.h>
42#include <sys/errno.h>
43#include <sys/kernel.h>
44#include <sys/malloc.h>
39
40#include <sys/param.h>
41#include <sys/bus.h>
42#include <sys/errno.h>
43#include <sys/kernel.h>
44#include <sys/malloc.h>
45#include <sys/module.h>
45#include <sys/systm.h>
46
47#include <machine/bus.h>
48#include <machine/resource.h>
49#include <sys/rman.h>
50#include <compat/netbsd/dvcfg.h>
51
46#include <sys/systm.h>
47
48#include <machine/bus.h>
49#include <machine/resource.h>
50#include <sys/rman.h>
51#include <compat/netbsd/dvcfg.h>
52
52#include <sys/device_port.h>
53#include <sys/bus.h>
53
54#include <dev/pccard/pccardvar.h>
55
56#include <cam/scsi/scsi_low.h>
57#include <cam/scsi/scsi_low_pisa.h>
58
59#include <dev/nsp/nspreg.h>
60#include <dev/nsp/nspvar.h>
61
62#define NSP_HOSTID 7
63
64#include "pccarddevs.h"
65
66#define PIO_MODE 0x100 /* pd_flags */
67
54
55#include <dev/pccard/pccardvar.h>
56
57#include <cam/scsi/scsi_low.h>
58#include <cam/scsi/scsi_low_pisa.h>
59
60#include <dev/nsp/nspreg.h>
61#include <dev/nsp/nspvar.h>
62
63#define NSP_HOSTID 7
64
65#include "pccarddevs.h"
66
67#define PIO_MODE 0x100 /* pd_flags */
68
68static int nspprobe(DEVPORT_PDEVICE devi);
69static int nspattach(DEVPORT_PDEVICE devi);
69static int nspprobe(device_t devi);
70static int nspattach(device_t devi);
70
71
71static void nsp_card_unload (DEVPORT_PDEVICE);
72static void nsp_card_unload (device_t);
72
73const struct pccard_product nsp_products[] = {
74 PCMCIA_CARD(IODATA3, CBSC16),
75 PCMCIA_CARD(PANASONIC, KME),
76 PCMCIA_CARD(WORKBIT2, NINJA_SCSI3),
77 PCMCIA_CARD(WORKBIT, ULTRA_NINJA_16),
78 { NULL }
79};

--- 54 unchanged lines hidden (view full) ---

134 }
135
136 error = bus_get_resource(dev, SYS_RES_MEMORY, 0, &maddr, &msize);
137 if (error)
138 return(0); /* XXX */
139
140 /* No need to allocate memory if not configured and it's in PIO mode */
141 if (maddr == 0 || msize == 0) {
73
74const struct pccard_product nsp_products[] = {
75 PCMCIA_CARD(IODATA3, CBSC16),
76 PCMCIA_CARD(PANASONIC, KME),
77 PCMCIA_CARD(WORKBIT2, NINJA_SCSI3),
78 PCMCIA_CARD(WORKBIT, ULTRA_NINJA_16),
79 { NULL }
80};

--- 54 unchanged lines hidden (view full) ---

135 }
136
137 error = bus_get_resource(dev, SYS_RES_MEMORY, 0, &maddr, &msize);
138 if (error)
139 return(0); /* XXX */
140
141 /* No need to allocate memory if not configured and it's in PIO mode */
142 if (maddr == 0 || msize == 0) {
142 if ((DEVPORT_PDEVFLAGS(dev) & PIO_MODE) == 0) {
143 if ((device_get_flags(dev) & PIO_MODE) == 0) {
143 printf("Memory window was not configured. Configure or use in PIO mode.");
144 nsp_release_resource(dev);
145 return(ENOMEM);
146 }
147 /* no need to allocate memory if PIO mode */
148 return(0);
149 }
150

--- 73 unchanged lines hidden (view full) ---

224};
225
226static devclass_t nsp_devclass;
227
228MODULE_DEPEND(nsp, scsi_low, 1, 1, 1);
229DRIVER_MODULE(nsp, pccard, nsp_pccard_driver, nsp_devclass, 0, 0);
230
231static void
144 printf("Memory window was not configured. Configure or use in PIO mode.");
145 nsp_release_resource(dev);
146 return(ENOMEM);
147 }
148 /* no need to allocate memory if PIO mode */
149 return(0);
150 }
151

--- 73 unchanged lines hidden (view full) ---

225};
226
227static devclass_t nsp_devclass;
228
229MODULE_DEPEND(nsp, scsi_low, 1, 1, 1);
230DRIVER_MODULE(nsp, pccard, nsp_pccard_driver, nsp_devclass, 0, 0);
231
232static void
232nsp_card_unload(DEVPORT_PDEVICE devi)
233nsp_card_unload(device_t devi)
233{
234{
234 struct nsp_softc *sc = DEVPORT_PDEVGET_SOFTC(devi);
235 struct nsp_softc *sc = device_get_softc(devi);
235 intrmask_t s;
236
237 s = splcam();
238 scsi_low_deactivate((struct scsi_low_softc *)sc);
239 scsi_low_dettach(&sc->sc_sclow);
240 splx(s);
241}
242
243static int
236 intrmask_t s;
237
238 s = splcam();
239 scsi_low_deactivate((struct scsi_low_softc *)sc);
240 scsi_low_dettach(&sc->sc_sclow);
241 splx(s);
242}
243
244static int
244nspprobe(DEVPORT_PDEVICE devi)
245nspprobe(device_t devi)
245{
246 int rv;
247 struct nsp_softc *sc = device_get_softc(devi);
248
249 rv = nspprobesubr(rman_get_bustag(sc->port_res),
250 rman_get_bushandle(sc->port_res),
246{
247 int rv;
248 struct nsp_softc *sc = device_get_softc(devi);
249
250 rv = nspprobesubr(rman_get_bustag(sc->port_res),
251 rman_get_bushandle(sc->port_res),
251 DEVPORT_PDEVFLAGS(devi));
252 device_get_flags(devi));
252
253 return rv;
254}
255
256static int
253
254 return rv;
255}
256
257static int
257nspattach(DEVPORT_PDEVICE devi)
258nspattach(device_t devi)
258{
259 struct nsp_softc *sc;
260 struct scsi_low_softc *slp;
259{
260 struct nsp_softc *sc;
261 struct scsi_low_softc *slp;
261 u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
262 u_int iobase = DEVPORT_PDEVIOBASE(devi);
262 u_int32_t flags = device_get_flags(devi);
263 u_int iobase = bus_get_resource_start(devi, SYS_RES_IOPORT, 0);
263 intrmask_t s;
264 char dvname[16];
265
266 strcpy(dvname,"nsp");
267
268 if (iobase == 0) {
269 printf("%s: no ioaddr is given\n", dvname);
270 return (0);
271 }
272
264 intrmask_t s;
265 char dvname[16];
266
267 strcpy(dvname,"nsp");
268
269 if (iobase == 0) {
270 printf("%s: no ioaddr is given\n", dvname);
271 return (0);
272 }
273
273 sc = DEVPORT_PDEVALLOC_SOFTC(devi);
274 sc = device_get_softc(devi);
274 if (sc == NULL)
275 return (0);
276
277 slp = &sc->sc_sclow;
278 slp->sl_dev = devi;
279 sc->sc_iot = rman_get_bustag(sc->port_res);
280 sc->sc_ioh = rman_get_bushandle(sc->port_res);
281

--- 24 unchanged lines hidden ---
275 if (sc == NULL)
276 return (0);
277
278 slp = &sc->sc_sclow;
279 slp->sl_dev = devi;
280 sc->sc_iot = rman_get_bustag(sc->port_res);
281 sc->sc_ioh = rman_get_bushandle(sc->port_res);
282

--- 24 unchanged lines hidden ---