From owner-freebsd-mobile Wed Jan 26 18:17:24 2000 Delivered-To: freebsd-mobile@freebsd.org Received: from onoe2.sm.sony.co.jp (onoe2.sm.sony.co.jp [133.138.10.2]) by hub.freebsd.org (Postfix) with ESMTP id 0560C154F4 for ; Wed, 26 Jan 2000 18:17:09 -0800 (PST) (envelope-from onoe@sm.sony.co.jp) Received: from duplo.sm.sony.co.jp (onoe@localhost) by onoe2.sm.sony.co.jp (8.9.0/3.7W) with ESMTP id LAA22061 for ; Thu, 27 Jan 2000 11:17:08 +0900 (JST) Received: (from onoe@localhost) by duplo.sm.sony.co.jp (8.9.3/8.9.3) id LAA02198; Thu, 27 Jan 2000 11:17:46 +0900 (JST) Date: Thu, 27 Jan 2000 11:17:46 +0900 (JST) From: Atsushi Onoe Message-Id: <200001270217.LAA02198@duplo.sm.sony.co.jp> To: mobile@freebsd.org Subject: Re: pccardd patch [Auto select config index] In-Reply-To: Your message of "Tue, 25 Jan 2000 05:42:29 +0900" <200001242042.FAA02072@tasogare.imasy.or.jp> References: <200001242042.FAA02072@tasogare.imasy.or.jp> X-Mailer: Cue version 0.6 (991220-1713/onoe) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="NextPart-20000127095539-0080901" Sender: owner-freebsd-mobile@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org --NextPart-20000127095539-0080901 Content-Type: Text/Plain; charset=us-ascii I've tested the pccardd patch with several cards, and found no problems by chainging config index to "auto" for most of all cards. Only for ata flash (not supported in -current yet), I must specify appropriate index. > Attached patch allow you to specify config index something like > config auto "sio3" ? > or > config default "ed0" ? > in your pccard.conf like PAO configuration. > > There are a lot of sio (sio1, 2, 3, 4 are mixed) entries in > pccard.conf.sample, but it seems we don't have guidelines for new > entry registration. Once we get guideline, we just rewrite > pccard.conf.sample. But it is not easy to survey again to get suitable > config index for many cards... > > Then I made following patch, we don't need to survey again, just put > `auto' as config index and "sio3" (or sio4) as driver name in usual cases. > > Specifying `auto', pccardd try to find cis_config entry which have > available i/o port dynamically. > > Would this be one of the 4.0-RELEASE candidates? Summary: test environment FreeBSD-current as of Jan 26 0800 JST GENERIC kernel (with awi driver, ata-flash patch) VAIO PCG-N505 only sio0 is visible as serial (infrared, modem are disabled) pccard.conf add "irq 10" "io" description is left unmodified * works fine with "config auto" card "NCR" "WaveLAN/IEEE" card "ACCTON" "EN2216-PCMCIA-ETHERNET" card "3Com Corporation" "3C589D" card "AD PC_CARD" "RC288ACL" card "3Com" "Megahertz 589E" * works fine with "config auto", though it has no entry in -current card "NTT DoCoMo" "PCMCIA DATA/FAX ADAPTER 9600 Mark2" card "MEGAHERTZ" "CC/XJEM3336" * works fine with "config auto", though it has no driver in current:-) card "Bay Networks" "BayStack 650 Wireless LAN" card "Icom" "SL-200" - awi driver will be found in ftp://onoe2.sm.sony.co.jp/pub/awi/ * only works with "config 0x01", failed with "config auto" card "SONY" "MEMORYSTICK( 4M)" card "SONY" "MEMORYSTICK( 32M)" card "SONY" "MEMORYSTICK( 64M)" auto chooses io port from config index 3 (0x170 == ata1) since GENERIC kernel has static configuration for ata1, alloc_unit slides it to ata2. io port 0x170 is already used for ata1, and fails to probe. - attached patch (originally posted to -mobile by Warner) enables to attach ATA flash only once during boot... Atsushi Onoe --NextPart-20000127095539-0080901 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pccard.log" #### Listed in pccard.conf.sample, works fine with "auto" # NCR WaveLAN/IEEE card "NCR" "WaveLAN/IEEE" config auto "wi0" ? insert logger -t pccard:$device -s WaveLAN/IEEE inserted insert /etc/pccard_ether $device remove logger -t pccard:$device -s WaveLAN/IEEE removed remove /sbin/ifconfig $device delete pccardd: Using I/O addr 0x240, size 64 pccardd: Setting config reg at offs 0x3e0 to 0x41, Reset time = 50 ms pccardd: Assigning I/O window 0, start 0x240, size 0x40 flags 0x5 pccardd: Assign wi0, io 0x240-0x27f, mem 0x0, 0 bytes, irq 10, flags 0 /kernel: wi0: at port 0x240-0x27f irq 10 slot 0 on pccard0 /kernel: wi0: Ethernet address: 00:60:1d:04:e1:64 pccard:wi0: WaveLAN/IEEE inserted #Accton 2216 card "ACCTON" "EN2216-PCMCIA-ETHERNET" config auto "ed0" ? insert logger -t pccard:$device -s Accton 2216 inserted insert /etc/pccard_ether $device remove logger -t pccard:$device -s Accton 2216 removed remove /sbin/ifconfig $device delete pccardd: Using I/O addr 0x240, size 32 pccardd: Setting config reg at offs 0x3f8 to 0x60, Reset time = 50 ms pccardd: Assigning I/O window 0, start 0x240, size 0x20 flags 0x7 pccardd: Assign ed0, io 0x240-0x25f, mem 0x0, 0 bytes, irq 10, flags 0 /kernel: devclass_alloc_unit: ed0 already exists, using next available unit number /kernel: ed1 at port 0x240-0x25f irq 10 slot 0 on pccard0 /kernel: ed1: address 00:00:e8:3a:4d:aa, type NE2000 (16 bit) pccard:ed1: Accton 2216 inserted # 3Com Etherlink III 3C589D card "3Com Corporation" "3C589D" config auto "ep0" ? insert logger -t pccard:$device -s 3Com Etherlink III inserted insert /etc/pccard_ether $device remove logger -t pccard:$device -s 3Com Etherlink III removed remove /sbin/ifconfig $device delete pccardd: Using I/O addr 0x240, size 16 pccardd: Setting config reg at offs 0x10000 to 0x41, Reset time = 50 ms pccardd: Assigning I/O window 0, start 0x240, size 0x10 flags 0x7 pccardd: Assign ep0, io 0x240-0x24f, mem 0x0, 0 bytes, irq 10, flags 0 /kernel: ep0: <3Com Etherlink III 3C589> at port 0x240-0x24f irq 10 slot 0 on pccard0 /kernel: ep0: Ethernet address 00:60:08:b2:56:4f pccard:ep0: 3Com Etherlink III inserted # Apex Data 28.8 PC Card "MOBILE PLUS Cellular" modem. card "AD PC_CARD" "RC288ACL" config auto "sio2" ? insert logger -t pccard:$device -s Apex Data Mobile Plus 28.8 Modem inserted remove logger -t pccard:$device -s Apex Data Mobile Plus 28.8 Modem removed pccardd: Using I/O addr 0x2f8, size 8 pccardd: Setting config reg at offs 0x200 to 0x61, Reset time = 50 ms pccardd: Assigning I/O window 0, start 0x2f8, size 0x8 flags 0x1 pccardd: Assign sio2, io 0x2f8-0x2ff, mem 0x0, 0 bytes, irq 10, flags 0 /kernel: devclass_alloc_unit: sio2 already exists, using next available unit number /kernel: sio4 at port 0x2f8-0x2ff irq 10 slot 0 on pccard0 /kernel: sio4: type 16550A pccard:sio4: Apex Data Mobile Plus 28.8 Modem inserted # 3Com Megahertz 3CCE589E* 10 Mbps LAN PC Card card "3Com" "Megahertz 589E" config auto "ep0" ? insert logger -t pccard:$device -s 3Com Megahertz Ethernet card inserted insert /etc/pccard_ether $device remove logger -t pccard:$device -s 3Com Megahertz Ethernet card removed remove /sbin/ifconfig $device delete pccardd: Using I/O addr 0x240, size 16 pccardd: Setting config reg at offs 0x10000 to 0x41, Reset time = 50 ms pccardd: Assigning I/O window 0, start 0x240, size 0x10 flags 0x7 pccardd: Assign ep0, io 0x240-0x24f, mem 0x0, 0 bytes, irq 10, flags 0 /kernel: ep0: <3Com Etherlink III 3C589> at port 0x240-0x24f irq 10 slot 0 on pccard0 /kernel: ep0: Ethernet address 00:00:86:31:c4:85 pccard:ep0: 3Com Megahertz Ethernet card inserted #### Not Listed in pccard.conf.sample, works fine with "auto" # NTT DoCoMo DATA/FAX Adapter card "NTT DoCoMo" "PCMCIA DATA/FAX ADAPTER 9600 Mark2" config auto "sio3" ? insert logger -t pccard:$device -s NTT DoCoMo DATA/FAX Adapter inserted remove logger -t pccard:$device -s NTT DoCoMo DATA/FAX Adapter removed pccardd: Using I/O addr 0x2f8, size 8 pccardd: Setting config reg at offs 0x300 to 0x61, Reset time = 50 ms pccardd: Assigning I/O window 0, start 0x2f8, size 0x8 flags 0x1 pccardd: Assign sio3, io 0x2f8-0x2ff, mem 0x0, 0 bytes, irq 10, flags 0 /kernel: devclass_alloc_unit: sio3 already exists, using next available unit number /kernel: sio4 at port 0x2f8-0x2ff irq 10 slot 0 on pccard0 /kernel: sio4: type 16550A pccard:sio4: NTT DoCoMo DATA/FAX Adapter inserted # Megahertz XJEM1336 (as modem) card "MEGAHERTZ" "CC/XJEM3336" config auto "sio2" ? insert logger -t pccard:$device -s Megahertz CC/XJEM3336 inserted remove logger -t pccard:$device -s Megahertz CC/XJEM3336 removed pccardd: Using I/O addr 0x2f8, size 8 pccardd: Setting config reg at offs 0x100 to 0x61, Reset time = 50 ms pccardd: Assigning I/O window 0, start 0x2f8, size 0x8 flags 0x1 pccardd: Assign sio2, io 0x2f8-0x2ff, mem 0x0, 0 bytes, irq 10, flags 0 /kernel: devclass_alloc_unit: sio2 already exists, using next available unit number /kernel: sio4 at port 0x2f8-0x2ff irq 10 slot 0 on pccard0 /kernel: sio4: type 16550A pccard:sio4: Megahertz CC/XJEM3336 inserted #### No drivers in -current yet, works fine with "auto" card "Bay Networks" "BayStack 650 Wireless LAN" config auto "awi0" ? insert logger -t pccard:$device -s Bay Networks BayStack 650 inserted remove logger -t pccard:$device -s Bay Networks BayStack 650 removed pccardd: Using I/O addr 0x300, size 16 pccardd: Setting config reg at offs 0x800 to 0x43, Reset time = 50 ms pccardd: Assigning I/O window 0, start 0x300, size 0x10 flags 0x1 pccardd: Assign awi0, io 0x300-0x30f, mem 0x0, 0 bytes, irq 10, flags 0 /kernel: awi0: at port 0x300-0x30f irq 10 slot 0 on pccard0 pccard:awi0: Bay Networks BayStack 650 inserted /kernel: awi0: IEEE802.11 (FH 1Mbps) address 00:20:d8:01:07:23 card "Icom" "SL-200" config auto "awi0" ? insert logger -t pccard:$device -s Icom SL-200 inserted remove logger -t pccard:$device -s Icom SL-200 removed pccardd: Using I/O addr 0x240, size 16 pccardd: Setting config reg at offs 0x800 to 0x42, Reset time = 50 ms pccardd: Assigning I/O window 0, start 0x240, size 0x10 flags 0x1 pccardd: Assign awi0, io 0x240-0x24f, mem 0x0, 0 bytes, irq 10, flags 0 /kernel: awi0: at port 0x240-0x24f irq 10 slot 0 on pccard0 pccard:awi0: Icom SL-200 inserted /kernel: awi0: IEEE802.11 (DS 2Mbps) address 00:90:c7:07:04:ef #### No drivers in -current yet, do not works with "auto" card "SONY" "MEMORYSTICK( 64M)" config 0x01 "ata1" ? insert logger -t pccard:$device -s Sony Memorystick inserted remove logger -t pccard:$device -s Sony Memorystick removed pccardd: Using I/O addr 0x240, size 16 pccardd: Setting config reg at offs 0x200 to 0x41, Reset time = 50 ms pccardd: Assigning I/O window 0, start 0x240, size 0x10 flags 0x7 pccardd: Assign ata1, io 0x240-0x24f, mem 0x0, 0 bytes, irq 10, flags 0 /kernel: devclass_alloc_unit: ata1 already exists, using next available unit number /kernel: ata2 at port 0x240-0x24f irq 10 slot 0 on pccard0 /kernel: ad4: 61MB [990/8/16] at ata2-master using PIO1 pccard:ata2: Sony Memorystick inserted --NextPart-20000127095539-0080901 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ata.000126.patch" Index: ata-all.c =================================================================== RCS file: /export/FBSDC/src/sys/dev/ata/ata-all.c,v retrieving revision 1.44 diff -c -r1.44 ata-all.c *** ata-all.c 2000/01/25 20:14:48 1.44 --- ata-all.c 2000/01/26 14:40:52 *************** *** 30,35 **** --- 30,36 ---- #include "ata.h" #include "apm.h" + #include "card.h" #include "isa.h" #include "pci.h" #include "atadisk.h" *************** *** 87,92 **** --- 88,99 ---- static void btrim(int8_t *, int32_t); static void bpack(int8_t *, int8_t *, int32_t); + #if NCARD > 0 + static int ata_pccard_attach __P((device_t dev)); + static int ata_pccard_detach __P((device_t dev)); + static int ata_pccard_probe __P((device_t dev)); + #endif /* NCARD > 0 */ + /* local vars */ static int32_t atanlun = 2; static struct intr_config_hook *ata_attach_hook = NULL; *************** *** 135,141 **** 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); --- 142,148 ---- res = ata_probe(rman_get_start(port), rman_get_start(port) + ATA_ALTPORT, 0, dev, &lun); ! bus_release_resource(dev, SYS_RES_IOPORT, rid, port); if (res) { isa_set_portsize(dev, res); *************** *** 152,169 **** struct resource *port; struct resource *irq; void *ih; ! int rid; /* Allocate the port range and interrupt */ ! rid = 0; ! port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE); if (!port) return (ENOMEM); ! rid = 0; ! irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, RF_ACTIVE); if (!irq) { ! bus_release_resource(dev, SYS_RES_IOPORT, 0, port); return (ENOMEM); } return bus_setup_intr(dev, irq, INTR_TYPE_BIO, ataintr, --- 159,176 ---- struct resource *port; struct resource *irq; void *ih; ! int prid, irqrid; /* Allocate the port range and interrupt */ ! prid = 0; ! port = bus_alloc_resource(dev, SYS_RES_IOPORT, &prid, 0, ~0, 1, RF_ACTIVE); if (!port) return (ENOMEM); ! irqrid = 0; ! irq = bus_alloc_resource(dev, SYS_RES_IRQ, &irqrid, 0, ~0, 1, RF_ACTIVE); if (!irq) { ! bus_release_resource(dev, SYS_RES_IOPORT, prid, port); return (ENOMEM); } return bus_setup_intr(dev, irq, INTR_TYPE_BIO, ataintr, *************** *** 186,191 **** --- 193,330 ---- 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; + struct intr_config_hook *ata_attach_hook_save; + + /* Allocate the port range */ + rid = 0; + port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 16, RF_ACTIVE); + /* XXX 16 shouldn't be hard coded */ + + if (!port) + return (ENOMEM); + + /* don't worry about conflict since PCCard code should have checked + already */ + /* + * XXX ALTPORT not used in pccard XXX + * Here's the i/o map for isa vs pccard + * Offset isa pccard + * DATA 0 0 + * ERROR 1 1 R + * FEATURE 1 1 W + * COUNT 2 2 W + * IREASON 2 2 R + * SECTOR 3 3 + * CYL_LSB 4 4 + * CYL_MSB 5 5 + * DRIVE 6 6 + * CMD 7 7 + * STATUS 7 7 + * ALTSTATUS 206 8 R + * CTLR 206 8 W + * wd_digin 207 9 + */ + lun = 0; + /* do not callback intrhook */ + ata_attach_hook_save = ata_attach_hook; + ata_attach_hook = (struct intr_config_hook *)-1; + res = ata_probe(rman_get_start(port), + rman_get_start(port) + ATA_ALTPORT_ONE_WINDOW, 0, dev, &lun); + ata_attach_hook = ata_attach_hook_save; + + bus_release_resource(dev, SYS_RES_IOPORT, rid, port); + + if (res) { + *(int *)device_get_softc(dev) = lun; + return 0; + } + return ENXIO; + } + + static int + ata_pccard_attach(dev) + device_t dev; + { + struct ata_softc *scp; + int lun; + int status; + + lun = *(int *)device_get_softc(dev); + scp = atadevices[lun]; + scp->flags |= ATA_USE_16BIT; + /* Allocate the port range and interrupt */ + scp->port_rid = 0; + scp->port = bus_alloc_resource(dev, SYS_RES_IOPORT, &scp->port_rid, 0, ~0, + 1, RF_ACTIVE); + if (!scp->port) { + /* XXX Need to free things ? */ + return (ENOMEM); + } + + scp->irq_rid = 0; + scp->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &scp->irq_rid, 0, ~0, 1, + RF_ACTIVE); + if (!scp->irq) { + /* XXX Need to free things ? */ + bus_release_resource(dev, SYS_RES_IOPORT, scp->port_rid, scp->port); + return (ENOMEM); + } + status = bus_setup_intr(dev, scp->irq, INTR_TYPE_BIO, ataintr, scp, + &scp->ih); + /* XXX The following really should just scan *THIS* device XXX */ + if (status != 0) { + bus_release_resource(dev, SYS_RES_IRQ, scp->irq_rid, scp->irq); + bus_release_resource(dev, SYS_RES_IOPORT, scp->port_rid, scp->port); + return ENXIO; + } + ata_attach(NULL); + return 0; + } + + static int + ata_pccard_detach(dev) + device_t dev; + { + struct ata_softc *scp; + int lun; + + lun = *(int *)device_get_softc(dev); + scp = atadevices[lun]; + bus_teardown_intr(dev, scp->irq, scp->ih); + bus_release_resource(dev, SYS_RES_IRQ, scp->irq_rid, scp->irq); + bus_release_resource(dev, SYS_RES_IOPORT, scp->port_rid, scp->port); + printf("ata%d: I can't be dettached ata\n", lun); + return EIO; + } + + + 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) *************** *** 526,531 **** --- 665,671 ---- scp->lun = lun; scp->unit = *unit; scp->active = ATA_IDLE; + scp->probed = 0; if (bootverbose) ata_printf(scp, -1, "iobase=0x%04x altiobase=0x%04x bmaddr=0x%04x\n", *************** *** 641,646 **** --- 781,787 ---- */ for (ctlr=0; ctlrprobed & (ATA_PROBE|ATAPI_PROBE)) continue; if (atadevices[ctlr]->devices & ATA_ATA_SLAVE) if (ata_getparam(atadevices[ctlr], ATA_SLAVE, ATA_C_ATA_IDENTIFY)) atadevices[ctlr]->devices &= ~ATA_ATA_SLAVE; *************** *** 659,664 **** --- 800,807 ---- /* now we know whats there, do the real attach, first the ATA disks */ for (ctlr=0; ctlrprobed & ATA_PROBE) continue; + atadevices[ctlr]->probed |= ATA_PROBE; if (atadevices[ctlr]->devices & ATA_ATA_MASTER) ad_attach(atadevices[ctlr], ATA_MASTER); if (atadevices[ctlr]->devices & ATA_ATA_SLAVE) *************** *** 669,674 **** --- 812,819 ---- /* then the atapi devices */ for (ctlr=0; ctlrprobed & ATAPI_PROBE) continue; + atadevices[ctlr]->probed |= ATAPI_PROBE; if (atadevices[ctlr]->devices & ATA_ATAPI_MASTER) atapi_attach(atadevices[ctlr], ATA_MASTER); if (atadevices[ctlr]->devices & ATA_ATAPI_SLAVE) *************** *** 795,801 **** --- 940,948 ---- ata_start(struct ata_softc *scp) { struct ad_request *ad_request; + #if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0 struct atapi_request *atapi_request; + #endif if (scp->active != ATA_IDLE) return; Index: ata-all.h =================================================================== RCS file: /export/FBSDC/src/sys/dev/ata/ata-all.h,v retrieving revision 1.21 diff -c -r1.21 ata-all.h *************** *** 87,92 **** --- 87,93 ---- #define ATA_S_BUSY 0x80 /* busy */ #define ATA_ALTPORT 0x206 /* alternate Status register */ + #define ATA_ALTPORT_ONE_WINDOW 0x08 /* Alternate port for pccard */ #define ATA_A_IDS 0x02 /* disable interrupts */ #define ATA_A_RESET 0x04 /* RESET controller */ #define ATA_A_4BIT 0x08 /* 4 head bits */ *************** *** 291,296 **** --- 292,305 ---- #define ATA_ACTIVE_ATA 0x4 #define ATA_ACTIVE_ATAPI 0x5 #define ATA_REINITING 0x6 + int32_t probed; /* already probed */ + #define ATA_PROBE 0x1 + #define ATAPI_PROBE 0x2 + struct resource * port; + struct resource * irq; + int port_rid; + int irq_rid; + void *ih; TAILQ_HEAD(, ad_request) ata_queue; /* head of ATA queue */ TAILQ_HEAD(, atapi_request) atapi_queue; /* head of ATAPI queue */ Index: ata-dma.c =================================================================== RCS file: /export/FBSDC/src/sys/dev/ata/ata-dma.c,v retrieving revision 1.27 diff -c -r1.27 ata-dma.c *** ata-dma.c 2000/01/24 20:45:24 1.27 --- ata-dma.c 2000/01/26 14:40:53 *************** *** 67,72 **** --- 67,73 ---- int32_t devno = (scp->unit << 1) + ATA_DEV(device); int32_t error; + scp->mode[ATA_DEV(device)] = ata_pio2mode(apiomode); if (!scp->bmaddr) return -1; *************** *** 657,662 **** --- 658,664 ---- ata_dmainit(struct ata_softc *scp, int32_t device, int32_t piomode, int32_t wdmamode, int32_t udmamode) { + scp->mode[ATA_DEV(device)] = ata_pio2mode(apiomode); return -1; } --NextPart-20000127095539-0080901-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message