diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-10-07 22:28:21 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-10-07 22:28:21 +0200 |
commit | 9fec0e736081cd155afb6a413b7641b93faed519 (patch) | |
tree | a91f5bb3e967e97ddd00c727e0d2bfd65669f93d /sys/src/9/pc/etheriwl.c | |
parent | 4d7c195804991b9c762f9a859679282c7014bbbb (diff) |
pc drivers: use pcienable() to handle device power up and missing initialization
Diffstat (limited to 'sys/src/9/pc/etheriwl.c')
-rw-r--r-- | sys/src/9/pc/etheriwl.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/sys/src/9/pc/etheriwl.c b/sys/src/9/pc/etheriwl.c index bdd35b86f..666863da5 100644 --- a/sys/src/9/pc/etheriwl.c +++ b/sys/src/9/pc/etheriwl.c @@ -821,6 +821,23 @@ iwlinit(Ether *edev) uint u, caloff, regoff; ctlr = edev->ctlr; + + /* Clear device-specific "PCI retry timeout" register (41h). */ + if(pcicfgr8(ctlr->pdev, 0x41) != 0) + pcicfgw8(ctlr->pdev, 0x41, 0); + + /* Clear interrupt disable bit. Hardware bug workaround. */ + if(ctlr->pdev->pcr & 0x400){ + ctlr->pdev->pcr &= ~0x400; + pcicfgw16(ctlr->pdev, PciPCR, ctlr->pdev->pcr); + } + + ctlr->type = (csr32r(ctlr, Rev) >> 4) & 0x1F; + if(fwname[ctlr->type] == nil){ + print("iwl: unsupported controller type %d\n", ctlr->type); + return -1; + } + if((err = handover(ctlr)) != nil) goto Err; if((err = poweron(ctlr)) != nil) @@ -2465,19 +2482,6 @@ iwlpci(void) break; } - /* Clear device-specific "PCI retry timeout" register (41h). */ - if(pcicfgr8(pdev, 0x41) != 0) - pcicfgw8(pdev, 0x41, 0); - - /* Clear interrupt disable bit. Hardware bug workaround. */ - if(pdev->pcr & 0x400){ - pdev->pcr &= ~0x400; - pcicfgw16(pdev, PciPCR, pdev->pcr); - } - - pcisetbme(pdev); - pcisetpms(pdev, 0); - ctlr = malloc(sizeof(Ctlr)); if(ctlr == nil) { print("iwl: unable to alloc Ctlr\n"); @@ -2492,14 +2496,6 @@ iwlpci(void) } ctlr->nic = mem; ctlr->pdev = pdev; - ctlr->type = (csr32r(ctlr, Rev) >> 4) & 0x1F; - - if(fwname[ctlr->type] == nil){ - print("iwl: unsupported controller type %d\n", ctlr->type); - vunmap(mem, pdev->mem[0].size); - free(ctlr); - continue; - } if(iwlhead != nil) iwltail->link = ctlr; @@ -2542,11 +2538,14 @@ again: edev->multicast = iwlmulticast; edev->mbps = 54; + pcienable(ctlr->pdev); if(iwlinit(edev) < 0){ + pcidisable(ctlr->pdev); edev->ctlr = nil; goto again; } + pcisetbme(ctlr->pdev); intrenable(edev->irq, iwlinterrupt, edev, edev->tbdf, edev->name); return 0; |