1 /*- matcd_isa.c---------------------------------------------------------------
3 Matsushita(Panasonic) / Creative CD-ROM Driver (matcd)
4 Authored by Frank Durda IV
6 Copyright 1994, 1995, 2002, 2003 Frank Durda IV. All rights reserved.
7 "FDIV" is a trademark of Frank Durda IV.
9 ------------------------------------------------------------------------------
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions
14 1. Redistributions of source code must retain the above copyright
15 notice, this list of conditions and the following disclaimer.
16 2. Redistributions in binary form must reproduce the above copyright
17 notice, this list of conditions and the following disclaimer in the
18 documentation and/or other materials provided with the distribution.
19 3. Neither the name of the author nor the names of their contributors
20 may be used to endorse or promote products derived from this software
21 without specific prior written permission.
23 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 -----------------------------------------------------------------------------*/
37 #include <sys/cdefs.h>
38 __FBSDID("$FreeBSD$");
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/kernel.h>
43 #include <sys/module.h>
45 #include <sys/fcntl.h>
48 #include <sys/disklabel.h>
52 #include <sys/mutex.h>
54 #include <machine/bus_pio.h>
55 #include <machine/bus.h>
56 #include <machine/resource.h>
59 #include <isa/isavar.h>
61 #include <dev/matcd/options.h>
62 #include <dev/matcd/matcd_data.h>
64 extern int matcd_probe(struct matcd_softc *sc);
65 extern int matcd_attach(struct matcd_softc *sc);
67 static int matcd_isa_probe (device_t);
68 static int matcd_isa_attach (device_t);
69 static int matcd_isa_detach (device_t);
71 static int matcd_alloc_resources (device_t);
72 static void matcd_release_resources (device_t);
75 static int matcd_isa_probe (device_t dev)
77 struct matcd_softc * sc;
80 /*Any Plug aNd Pray Support?*/
81 if (isa_get_vendorid(dev)) {
85 if (bus_get_resource_start(dev,SYS_RES_IOPORT,0)==0) {
89 sc = device_get_softc(dev);
92 sc->port_type=SYS_RES_IOPORT;
94 error=matcd_alloc_resources(dev);
96 error = matcd_probe(sc);
99 device_set_desc(dev, "Matsushita CR-562/CR-563");
103 matcd_release_resources(dev);
108 static int matcd_isa_attach (device_t dev)
110 struct matcd_softc * sc;
113 sc=device_get_softc(dev);
118 sc->port_type=SYS_RES_IOPORT;
120 error=matcd_alloc_resources(dev);
122 error=matcd_probe(sc); /*Redundant Probe*/
124 error=matcd_attach(sc);
130 matcd_release_resources(dev);
135 static int matcd_isa_detach (device_t dev)
137 struct matcd_softc * sc;
139 sc=device_get_softc(dev);
140 destroy_dev(sc->matcd_dev_t);
141 matcd_release_resources(dev);
146 static int matcd_alloc_resources (device_t dev)
148 struct matcd_softc * sc;
150 sc = device_get_softc(dev);
152 sc->port=bus_alloc_resource(dev, sc->port_type, &sc->port_rid,
153 0, ~0, 1, RF_ACTIVE);
154 if (sc->port == NULL) {
156 "Port resource not available.\n");
159 sc->port_bst = rman_get_bustag(sc->port);
160 sc->port_bsh = rman_get_bushandle(sc->port);
166 static void matcd_release_resources (device_t dev)
168 struct matcd_softc * sc;
170 sc = device_get_softc(dev);
172 bus_release_resource(dev, sc->port_type, sc->port_rid,
181 static device_method_t matcd_isa_methods[] = {
182 DEVMETHOD(device_probe, matcd_isa_probe),
183 DEVMETHOD(device_attach, matcd_isa_attach),
184 DEVMETHOD(device_detach, matcd_isa_detach),
188 static driver_t matcd_isa_driver = {
191 sizeof(struct matcd_softc)
194 static devclass_t matcd_devclass;
196 DRIVER_MODULE(matcd, isa, matcd_isa_driver, matcd_devclass, NULL, 0);
198 /*End of matcd_isa.c*/