1 /* Pci/pcmcia code for wavelan.c */
4 #include "../port/lib.h"
9 #include "../port/error.h"
10 #include "../port/netif.h"
11 #include "../port/etherif.h"
16 wavelanpcmciareset(Ether *ether)
22 if((ctlr = malloc(sizeof(Ctlr))) == nil)
26 ctlr->ctlrno = ether->ctlrno;
30 ctlr->iob = ether->port;
35 if (ioalloc(ether->port,WIOLen,0,"wavelan")<0){
36 // print("#l%d: port 0x%lx in use\n",
37 // ether->ctlrno, ether->port);
42 * If id= is specified, card must match. Otherwise try generic.
45 for(i=0; i<ether->nopt; i++){
46 if(cistrncmp(ether->opt[i], "id=", 3) == 0){
47 if((ctlr->slot = pcmspecial(ðer->opt[i][3], ether)) < 0)
53 for (i=0; wavenames[i]; i++)
54 if((ctlr->slot = pcmspecial(wavenames[i], ether))>=0)
57 DEBUG("no wavelan found\n");
62 // DEBUG("#l%d: port=0x%lx irq=%ld\n",
63 // ether->ctlrno, ether->port, ether->irq);
65 if(wavelanreset(ether, ctlr) < 0){
75 for(i = 0; i < ether->nopt; i++){
76 if(p = strchr(ether->opt[i], '='))
78 w_option(ctlr, ether->opt[i], strlen(ether->opt[i]));
89 0x1260, 0x3873, /* Intersil Prism2.5 */
90 0x1737, 0x0019, /* Linksys WPC-11 untested */
93 static Ctlr *ctlrhead, *ctlrtail;
104 while(p = pcimatch(p, 0, 0)){
105 for(i=0; i<nelem(wavelanpci); i++)
106 if(p->vid == wavelanpci[i].vid && p->did == wavelanpci[i].did)
108 if(i==nelem(wavelanpci))
112 * On the Prism, bar[0] is the memory-mapped register address (4KB),
114 if(p->mem[0].size != 4096){
115 print("wavelanpci: %.4ux %.4ux: unlikely mmio size\n", p->vid, p->did);
119 ctlr = malloc(sizeof(Ctlr));
121 print("wavelanpci: can't allocate memory\n");
125 mem = vmap(p->mem[0].bar&~0xF, p->mem[0].size);
127 print("wavelanpci: %.4ux %.4ux: vmap 0x%.8lux %d failed\n", p->vid, p->did, p->mem[0].bar&~0xF, p->mem[0].size);
133 ctlrtail->next = ctlr;
141 wavelanpcireset(Ether *ether)
151 * Allow plan9.ini to set vid, did?
153 for(ctlr=ctlrhead; ctlr!=nil; ctlr=ctlr->next)
154 if(ctlr->active == 0)
162 pcienable(ctlr->pcidev);
163 ether->irq = ctlr->pcidev->intl;
164 ether->tbdf = ctlr->pcidev->tbdf;
169 csr_outs(ctlr, WR_PciCor, 0x0080);
171 csr_outs(ctlr, WR_PciCor, 0x0000);
173 for(i=0; i<2*10; i++){
174 if(!(csr_ins(ctlr, WR_Cmd)&WCmdBusy))
179 print("wavelan pci %.4ux %.4ux: reset timeout %.4ux\n",
180 ctlr->pcidev->vid, ctlr->pcidev->did, csr_ins(ctlr, WR_Cmd));
182 if(wavelanreset(ether, ctlr) < 0){
188 for(i = 0; i < ether->nopt; i++){
189 if(p = strchr(ether->opt[i], '='))
191 w_option(ctlr, ether->opt[i], strlen(ether->opt[i]));
193 pcisetbme(ctlr->pcidev);
199 etherwavelanlink(void)
201 addethercard("wavelan", wavelanpcmciareset);
202 addethercard("wavelanpci", wavelanpcireset);