aic_pccard.c (69960) | aic_pccard.c (70782) |
---|---|
1/*- 2 * Copyright (c) 1999 Luoqi Chen. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1999 Luoqi Chen. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/dev/aic/aic_pccard.c 69960 2000-12-13 05:46:23Z imp $ | 26 * $FreeBSD: head/sys/dev/aic/aic_pccard.c 70782 2001-01-08 01:59:15Z imp $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/kernel.h> 31#include <sys/module.h> 32#include <sys/bus.h> 33 34#include <machine/bus_pio.h> 35#include <machine/bus.h> 36#include <machine/resource.h> 37#include <sys/rman.h> 38 39#include <dev/aic/aicvar.h> | 27 */ 28 29#include <sys/param.h> 30#include <sys/kernel.h> 31#include <sys/module.h> 32#include <sys/bus.h> 33 34#include <machine/bus_pio.h> 35#include <machine/bus.h> 36#include <machine/resource.h> 37#include <sys/rman.h> 38 39#include <dev/aic/aicvar.h> |
40#include <dev/pccard/pccardvar.h> 41#include <dev/pccard/pccarddevs.h> |
|
40 | 42 |
43#include "card_if.h" 44 |
|
41struct aic_pccard_softc { 42 struct aic_softc sc_aic; 43 struct resource *sc_port; 44 struct resource *sc_irq; 45 void *sc_ih; 46}; 47 | 45struct aic_pccard_softc { 46 struct aic_softc sc_aic; 47 struct resource *sc_port; 48 struct resource *sc_irq; 49 void *sc_ih; 50}; 51 |
48static int aic_pccard_alloc_resources __P((device_t)); 49static void aic_pccard_release_resources __P((device_t)); 50static int aic_pccard_probe __P((device_t)); 51static int aic_pccard_attach __P((device_t)); | 52static int aic_pccard_alloc_resources(device_t); 53static void aic_pccard_release_resources(device_t); 54static int aic_pccard_match(device_t); 55static int aic_pccard_probe(device_t); 56static int aic_pccard_attach(device_t); |
52 | 57 |
58const struct pccard_product aic_pccard_products[] = { 59 { PCCARD_STR_ADAPTEC_APA1460, PCCARD_VENDOR_ADAPTEC, 60 PCCARD_PRODUCT_ADAPTEC_APA1460, 0, NULL, NULL }, 61 62 { PCCARD_STR_ADAPTEC_APA1460A, PCCARD_VENDOR_ADAPTEC, 63 PCCARD_PRODUCT_ADAPTEC_APA1460A, 0, NULL, NULL }, 64 65 { PCCARD_STR_NEWMEDIA_BUSTOASTER, PCCARD_VENDOR_NEWMEDIA, 66 PCCARD_PRODUCT_NEWMEDIA_BUSTOASTER, 0, NULL, NULL }, 67 68 { NULL } 69}; 70 |
|
53#define AIC_PCCARD_PORTSIZE 0x20 54 55static int 56aic_pccard_alloc_resources(device_t dev) 57{ 58 struct aic_pccard_softc *sc = device_get_softc(dev); 59 int rid; 60 --- 27 unchanged lines hidden (view full) --- 88 if (sc->sc_port) 89 bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->sc_port); 90 if (sc->sc_irq) 91 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq); 92 sc->sc_port = sc->sc_irq = 0; 93} 94 95static int | 71#define AIC_PCCARD_PORTSIZE 0x20 72 73static int 74aic_pccard_alloc_resources(device_t dev) 75{ 76 struct aic_pccard_softc *sc = device_get_softc(dev); 77 int rid; 78 --- 27 unchanged lines hidden (view full) --- 106 if (sc->sc_port) 107 bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->sc_port); 108 if (sc->sc_irq) 109 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq); 110 sc->sc_port = sc->sc_irq = 0; 111} 112 113static int |
114aic_pccard_match(device_t dev) 115{ 116 const struct pccard_product *pp; 117 118 if ((pp = pccard_product_lookup(dev, aic_pccard_products, 119 sizeof(aic_pccard_products[0]), NULL)) != NULL) { 120 device_set_desc(dev, pp->pp_name); 121 return 0; 122 } 123 return EIO; 124} 125 126static int |
|
96aic_pccard_probe(device_t dev) 97{ 98 struct aic_pccard_softc *sc = device_get_softc(dev); 99 struct aic_softc *aic = &sc->sc_aic; 100 101 if (aic_pccard_alloc_resources(dev)) 102 return (ENXIO); 103 if (aic_probe(aic)) { --- 55 unchanged lines hidden (view full) --- 159 } 160 161 aic_pccard_release_resources(dev); 162 return (0); 163} 164 165static device_method_t aic_pccard_methods[] = { 166 /* Device interface */ | 127aic_pccard_probe(device_t dev) 128{ 129 struct aic_pccard_softc *sc = device_get_softc(dev); 130 struct aic_softc *aic = &sc->sc_aic; 131 132 if (aic_pccard_alloc_resources(dev)) 133 return (ENXIO); 134 if (aic_probe(aic)) { --- 55 unchanged lines hidden (view full) --- 190 } 191 192 aic_pccard_release_resources(dev); 193 return (0); 194} 195 196static device_method_t aic_pccard_methods[] = { 197 /* Device interface */ |
167 DEVMETHOD(device_probe, aic_pccard_probe), 168 DEVMETHOD(device_attach, aic_pccard_attach), | 198 DEVMETHOD(device_probe, pccard_compat_probe), 199 DEVMETHOD(device_attach, pccard_compat_attach), |
169 DEVMETHOD(device_detach, aic_pccard_detach), | 200 DEVMETHOD(device_detach, aic_pccard_detach), |
201 202 /* Card interface */ 203 DEVMETHOD(card_compat_match, aic_pccard_match), 204 DEVMETHOD(card_compat_probe, aic_pccard_probe), 205 DEVMETHOD(card_compat_attach, aic_pccard_attach), 206 |
|
170 { 0, 0 } 171}; 172 173static driver_t aic_pccard_driver = { 174 "aic", 175 aic_pccard_methods, sizeof(struct aic_pccard_softc), 176}; 177 178extern devclass_t aic_devclass; 179 180MODULE_DEPEND(aic, cam, 1,1,1); 181DRIVER_MODULE(aic, pccard, aic_pccard_driver, aic_devclass, 0, 0); | 207 { 0, 0 } 208}; 209 210static driver_t aic_pccard_driver = { 211 "aic", 212 aic_pccard_methods, sizeof(struct aic_pccard_softc), 213}; 214 215extern devclass_t aic_devclass; 216 217MODULE_DEPEND(aic, cam, 1,1,1); 218DRIVER_MODULE(aic, pccard, aic_pccard_driver, aic_devclass, 0, 0); |