Date: Wed, 27 Oct 1999 16:06:31 -0700 (PDT) From: Doug Ambrisko <ambrisko@whistle.com> To: mobile@FreeBSD.ORG, sos@freebsd.dk Subject: Patches to ata driver for PCCard Message-ID: <199910272306.QAA28249@whistle.com>
next in thread | raw e-mail | index | archive | help
I have added PCCard attachment to the new ata driver. My changes are based on Warner's changes to sio for PCCard. Removal is not supported. I have to look at that more. Here is the pccard.conf entry: card "SHUTTLE TECHNOLOGY LTD." "PCCARD-IDE/ATAPI Adapter" config 0x2 "ata2" 9 insert echo Shuttle IDE inserted remove echo Shuttle IDE removed I'm using a Microtec PCMCIA adapter, others should work. I currently have an IDE hard drive & CD-RW attached with it and there Zip drive worked http://www.microtech-pc.com/products_usb.shtml I added a "probed" field to ensure that devices were not re-probed. Please send me any comments. The following patch is based on -current. Doug A. Index: ata-all.c =================================================================== RCS file: /cvs/freebsd/src/sys/dev/ata/ata-all.c,v retrieving revision 1.28 diff -c -r1.28 ata-all.c *** ata-all.c 1999/10/16 09:00:49 1.28 --- ata-all.c 1999/10/27 22:50:59 *************** *** 70,75 **** --- 70,84 ---- #include <dev/ata/ata-disk.h> #include <dev/ata/atapi-all.h> + #include "card.h" + #if NCARD > 0 + /* XXX should die XXX */ + #include <sys/select.h> + #include <sys/module.h> + #include <pccard/cardinfo.h> + #include <pccard/slot.h> + #endif + /* misc defines */ #if SMP == 0 #define isa_apic_irq(x) x *************** *** 80,85 **** --- 89,102 ---- static void ataintr(void *); static int8_t *active2str(int32_t); + #if NCARD > 0 + static int ata_pccard_attach __P((device_t dev)); + static void ata_pccard_detach __P((device_t dev)); + static int ata_pccard_probe __P((device_t dev)); + extern void ad_drvinit(void); + extern void atapi_init(void); + #endif /* NCARD > 0 */ + /* local vars */ static int32_t atanlun = 2; struct ata_softc *atadevices[MAXATA]; *************** *** 104,115 **** int32_t lun; /* Check isapnp ids */ if (ISA_PNP_PROBE(device_get_parent(dev), dev, ata_ids) == ENXIO) return (ENXIO); ! /* Allocate the port range */ rid = 0; port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE); if (!port) return (ENOMEM); --- 121,134 ---- int32_t lun; /* Check isapnp ids */ + if (ISA_PNP_PROBE(device_get_parent(dev), dev, ata_ids) == ENXIO) return (ENXIO); ! /* Allocate the port range */ rid = 0; port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE); + if (!port) return (ENOMEM); *************** *** 177,182 **** --- 196,285 ---- DRIVER_MODULE(ata, isa, ata_isa_driver, ata_devclass, 0, 0); #endif + #if NCARD > 0 + static int + ata_pccard_probe(dev) + device_t dev; + { + struct resource *port; + int rid; + int32_t res; + int32_t lun; + const char *name; + + name = pccard_get_name(dev); + printf("ata_pccard_probe: Does %s match?\n", name); + if (strcmp(name, "ata")) + return ENXIO; + + /* Allocate the port range */ + rid = 0; + port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE); + + if (!port) + return (ENOMEM); + + /* don't worry about conflict since PCCard code should have checked + already */ + + lun = 0; + res = ata_probe(rman_get_start(port), rman_get_start(port) + ATA_ALTPORT, + 0, dev, &lun); + + bus_release_resource(dev, SYS_RES_IOPORT, 0, port); + + if (res) { + isa_set_portsize(dev, res); + *(int *)device_get_softc(dev) = lun; + return 0; + } + return ENXIO; + } + + static int + ata_pccard_attach(dev) + device_t dev; + { + int status; + + status = ata_isaattach(dev); + if (status == 0){ + printf("ata_pccard: scan drives\n"); + ad_drvinit(); + printf("ata_pccard: scan ATAPI bus\n"); + atapi_init(); + } + return status; + } + + + static void + ata_pccard_detach(dev) + device_t dev; + { + + printf("I can't be dettached ata\n"); + } + + + static device_method_t ata_pccard_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ata_pccard_probe), + DEVMETHOD(device_attach, ata_pccard_attach), + DEVMETHOD(device_detach, ata_pccard_detach), + + { 0, 0 } + }; + + static driver_t ata_pccard_driver = { + "ata", + ata_pccard_methods, + sizeof(int), + }; + + DRIVER_MODULE(ata, pccard, ata_pccard_driver, ata_devclass, 0, 0); + #endif (NCARD > 0) + #if NPCI > 0 static const char * ata_pcimatch(device_t dev) *************** *** 416,421 **** --- 519,525 ---- scp->lun = lun; scp->unit = *unit; scp->active = ATA_IDLE; + scp->probed = 0; if (bootverbose) printf("ata%d: iobase=0x%04x altiobase=0x%04x\n", Index: ata-all.h =================================================================== RCS file: /cvs/freebsd/src/sys/dev/ata/ata-all.h,v retrieving revision 1.12 diff -c -r1.12 ata-all.h *** ata-all.h 1999/10/09 19:57:11 1.12 --- ata-all.h 1999/10/27 22:50:59 *************** *** 159,164 **** --- 159,167 ---- #define ATA_ACTIVE_ATA 0x3 #define ATA_ACTIVE_ATAPI 0x4 #define ATA_REINITING 0x5 + int32_t probed; /* already probed */ + #define ATA_PROBE 0x1 + #define ATAPI_PROBE 0x2 TAILQ_HEAD(, ad_request) ata_queue; /* head of ATA queue */ TAILQ_HEAD(, atapi_request) atapi_queue; /* head of ATAPI queue */ Index: ata-disk.c =================================================================== RCS file: /cvs/freebsd/src/sys/dev/ata/ata-disk.c,v retrieving revision 1.32 diff -c -r1.32 ata-disk.c *** ata-disk.c 1999/10/18 17:55:38 1.32 --- ata-disk.c 1999/10/27 22:50:59 *************** *** 84,90 **** static void ad_timeout(struct ad_request *); static void ad_sleep(struct ad_softc *, int8_t *); static int8_t ad_version(u_int16_t); ! static void ad_drvinit(void); /* internal vars */ static struct intr_config_hook *ad_attach_hook; --- 84,90 ---- static void ad_timeout(struct ad_request *); static void ad_sleep(struct ad_softc *, int8_t *); static int8_t ad_version(u_int16_t); ! void ad_drvinit(void); /* internal vars */ static struct intr_config_hook *ad_attach_hook; *************** *** 140,145 **** --- 140,147 ---- /* now, run through atadevices and look for ATA disks */ for (ctlr=0; ctlr<MAXATA; ctlr++) { if (!atadevices[ctlr]) continue; + if (atadevices[ctlr]->probed & ATA_PROBE) continue; + atadevices[ctlr]->probed|=ATA_PROBE; for (dev=0; dev<2; dev++) { if (atadevices[ctlr]->devices & (dev ? ATA_ATA_SLAVE : ATA_ATA_MASTER)) { *************** *** 662,668 **** return '?'; } ! static void ad_drvinit(void) { fakewd_cdevsw = ad_cdevsw; --- 664,670 ---- return '?'; } ! void ad_drvinit(void) { fakewd_cdevsw = ad_cdevsw; Index: atapi-all.c =================================================================== RCS file: /cvs/freebsd/src/sys/dev/ata/atapi-all.c,v retrieving revision 1.19 diff -c -r1.19 atapi-all.c *** atapi-all.c 1999/10/10 18:08:38 1.19 --- atapi-all.c 1999/10/27 22:50:59 *************** *** 54,60 **** static int8_t *atapi_cmd2str(u_int8_t); static int8_t *atapi_skey2str(u_int8_t); static int32_t atapi_wait(struct atapi_softc *, u_int8_t); ! static void atapi_init(void); /* extern references */ int32_t acdattach(struct atapi_softc *); --- 54,60 ---- static int8_t *atapi_cmd2str(u_int8_t); static int8_t *atapi_skey2str(u_int8_t); static int32_t atapi_wait(struct atapi_softc *, u_int8_t); ! void atapi_init(void); /* extern references */ int32_t acdattach(struct atapi_softc *); *************** *** 111,116 **** --- 111,118 ---- /* now, run through atadevices and look for ATAPI devices */ for (ctlr=0; ctlr<MAXATA; ctlr++) { if (!atadevices[ctlr]) continue; + if (atadevices[ctlr]->probed & ATAPI_PROBE) continue; + atadevices[ctlr]->probed|=ATAPI_PROBE; for (dev=0; dev<2; dev++) { if (atadevices[ctlr]->devices & (dev ? ATA_ATAPI_SLAVE : ATA_ATAPI_MASTER)) { *************** *** 744,750 **** return -1; } ! static void atapi_init(void) { /* register callback for when interrupts are enabled */ --- 746,752 ---- return -1; } ! void atapi_init(void) { /* register callback for when interrupts are enabled */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199910272306.QAA28249>