static int prism2_config(struct pcmcia_device *link) { struct net_device *dev; struct hostap_interface *iface; local_info_t *local; int ret = 1; struct hostap_cs_priv *hw_priv; unsigned long flags; PDEBUG(DEBUG_FLOW, "prism2_config()\n"); hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); if (hw_priv == NULL) { ret = -ENOMEM; goto failed; } /* Look for an appropriate configuration table entry in the CIS */ link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO | CONF_AUTO_CHECK_VCC | CONF_AUTO_SET_IO | CONF_ENABLE_IRQ; if (ignore_cis_vcc) link->config_flags &= ~CONF_AUTO_CHECK_VCC; ret = pcmcia_loop_config(link, prism2_config_check, NULL); if (ret) { if (!ignore_cis_vcc) printk(KERN_ERR "GetNextTuple(): No matching " "CIS configuration. Maybe you need the " "ignore_cis_vcc=1 parameter.\n"); goto failed; } /* Need to allocate net_device before requesting IRQ handler */ dev = prism2_init_local_data(&prism2_pccard_funcs, 0, &link->dev); if (dev == NULL) goto failed; link->priv = dev; iface = netdev_priv(dev); local = iface->local; local->hw_priv = hw_priv; hw_priv->link = link; /* * We enable IRQ here, but IRQ handler will not proceed * until dev->base_addr is set below. This protect us from * receive interrupts when driver is not initialized. */ ret = pcmcia_request_irq(link, prism2_interrupt); if (ret) goto failed; ret = pcmcia_enable_device(link); if (ret) goto failed; spin_lock_irqsave(&local->irq_init_lock, flags); dev->irq = link->irq; dev->base_addr = link->resource[0]->start; spin_unlock_irqrestore(&local->irq_init_lock, flags); local->shutdown = 0; sandisk_enable_wireless(dev); ret = prism2_hw_config(dev, 1); if (!ret) ret = hostap_hw_ready(dev); return ret; failed: kfree(hw_priv); prism2_release((u_long)link); return ret; }
static int prism2_usb_probe(struct usb_interface *interface, const struct usb_device_id *id) { struct usb_device *usb; local_info_t *local = NULL; struct net_device *dev = NULL; static int cards_found /* = 0 */; struct hostap_interface *iface; struct hostap_usb_priv *hw_priv; hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); if (hw_priv == NULL) return -ENOMEM; usb = interface_to_usbdev(interface); hw_priv->endp_in = usb_rcvbulkpipe(usb, 1); hw_priv->endp_out = usb_sndbulkpipe(usb, 2); usb_init_urb(&hw_priv->tx_urb); usb_init_urb(&hw_priv->rx_urb); hw_priv->present = 1; skb_queue_head_init(&hw_priv->tx_queue); dev = prism2_init_local_data(&prism2_usb_funcs, cards_found, &interface->dev); if (dev == NULL) goto fail; iface = netdev_priv(dev); local = iface->local; local->hw_priv = hw_priv; cards_found++; hw_priv->usb = usb_get_dev(usb); prism2_usb_cor_sreset(local); usb_set_intfdata(interface, dev); if (!local->pri_only && prism2_hw_config(dev, 1)) { printk(KERN_DEBUG "%s: hardware initialization failed\n", dev_info); goto fail2; } printk(KERN_INFO "%s: Intersil Prism2/2.5/3 USB", dev->name); return hostap_hw_ready(dev); fail2: usb_put_dev(hw_priv->usb); fail: hw_priv->present = 0; prism2_free_local_data(dev); usb_kill_urb(&hw_priv->rx_urb); usb_kill_urb(&hw_priv->tx_urb); // err_out_free: kfree(hw_priv); return -ENODEV; }
static int prism2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { unsigned long phymem; void __iomem *mem = NULL; local_info_t *local = NULL; struct net_device *dev = NULL; static int cards_found ; int irq_registered = 0; struct hostap_interface *iface; struct hostap_pci_priv *hw_priv; hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); if (hw_priv == NULL) return -ENOMEM; if (pci_enable_device(pdev)) goto err_out_free; phymem = pci_resource_start(pdev, 0); if (!request_mem_region(phymem, pci_resource_len(pdev, 0), "Prism2")) { printk(KERN_ERR "prism2: Cannot reserve PCI memory region\n"); goto err_out_disable; } mem = pci_ioremap_bar(pdev, 0); if (mem == NULL) { printk(KERN_ERR "prism2: Cannot remap PCI memory region\n") ; goto fail; } dev = prism2_init_local_data(&prism2_pci_funcs, cards_found, &pdev->dev); if (dev == NULL) goto fail; iface = netdev_priv(dev); local = iface->local; local->hw_priv = hw_priv; cards_found++; dev->irq = pdev->irq; hw_priv->mem_start = mem; dev->base_addr = (unsigned long) mem; prism2_pci_cor_sreset(local); pci_set_drvdata(pdev, dev); if (request_irq(dev->irq, prism2_interrupt, IRQF_SHARED, dev->name, dev)) { printk(KERN_WARNING "%s: request_irq failed\n", dev->name); goto fail; } else irq_registered = 1; if (!local->pri_only && prism2_hw_config(dev, 1)) { printk(KERN_DEBUG "%s: hardware initialization failed\n", dev_info); goto fail; } printk(KERN_INFO "%s: Intersil Prism2.5 PCI: " "mem=0x%lx, irq=%d\n", dev->name, phymem, dev->irq); return hostap_hw_ready(dev); fail: if (irq_registered && dev) free_irq(dev->irq, dev); if (mem) iounmap(mem); release_mem_region(phymem, pci_resource_len(pdev, 0)); err_out_disable: pci_disable_device(pdev); prism2_free_local_data(dev); err_out_free: kfree(hw_priv); return -ENODEV; }
static int prism2_plx_probe(struct pci_dev *pdev, const struct pci_device_id *id) { unsigned int pccard_ioaddr, plx_ioaddr; unsigned long pccard_attr_mem; unsigned int pccard_attr_len; void __iomem *attr_mem = NULL; unsigned int cor_offset = 0, cor_index = 0; u32 reg; local_info_t *local = NULL; struct net_device *dev = NULL; struct hostap_interface *iface; static int cards_found /* = 0 */; int irq_registered = 0; int tmd7160; struct hostap_plx_priv *hw_priv; hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); if (hw_priv == NULL) return -ENOMEM; if (pci_enable_device(pdev)) goto err_out_free; /* National Datacomm NCP130 based on TMD7160, not PLX9052. */ tmd7160 = (pdev->vendor == 0x15e8) && (pdev->device == 0x0131); plx_ioaddr = pci_resource_start(pdev, 1); pccard_ioaddr = pci_resource_start(pdev, tmd7160 ? 2 : 3); if (tmd7160) { /* TMD7160 */ attr_mem = NULL; /* no access to PC Card attribute memory */ printk(KERN_INFO "TMD7160 PCI/PCMCIA adapter: io=0x%x, " "irq=%d, pccard_io=0x%x\n", plx_ioaddr, pdev->irq, pccard_ioaddr); cor_offset = plx_ioaddr; cor_index = 0x04; outb(cor_index | COR_LEVLREQ | COR_ENABLE_FUNC, plx_ioaddr); mdelay(1); reg = inb(plx_ioaddr); if (reg != (cor_index | COR_LEVLREQ | COR_ENABLE_FUNC)) { printk(KERN_ERR "%s: Error setting COR (expected=" "0x%02x, was=0x%02x)\n", dev_info, cor_index | COR_LEVLREQ | COR_ENABLE_FUNC, reg); goto fail; } } else { /* PLX9052 */ pccard_attr_mem = pci_resource_start(pdev, 2); pccard_attr_len = pci_resource_len(pdev, 2); if (pccard_attr_len < PLX_MIN_ATTR_LEN) goto fail; attr_mem = ioremap(pccard_attr_mem, pccard_attr_len); if (attr_mem == NULL) { printk(KERN_ERR "%s: cannot remap attr_mem\n", dev_info); goto fail; } printk(KERN_INFO "PLX9052 PCI/PCMCIA adapter: " "mem=0x%lx, plx_io=0x%x, irq=%d, pccard_io=0x%x\n", pccard_attr_mem, plx_ioaddr, pdev->irq, pccard_ioaddr); if (prism2_plx_check_cis(attr_mem, pccard_attr_len, &cor_offset, &cor_index)) { printk(KERN_INFO "Unknown PC Card CIS - not a " "Prism2/2.5 card?\n"); goto fail; } printk(KERN_DEBUG "Prism2/2.5 PC Card detected in PLX9052 " "adapter\n"); /* Write COR to enable PC Card */ writeb(cor_index | COR_LEVLREQ | COR_ENABLE_FUNC, attr_mem + cor_offset); /* Enable PCI interrupts if they are not already enabled */ reg = inl(plx_ioaddr + PLX_INTCSR); printk(KERN_DEBUG "PLX_INTCSR=0x%x\n", reg); if (!(reg & PLX_INTCSR_PCI_INTEN)) { outl(reg | PLX_INTCSR_PCI_INTEN, plx_ioaddr + PLX_INTCSR); if (!(inl(plx_ioaddr + PLX_INTCSR) & PLX_INTCSR_PCI_INTEN)) { printk(KERN_WARNING "%s: Could not enable " "Local Interrupts\n", dev_info); goto fail; } } reg = inl(plx_ioaddr + PLX_CNTRL); printk(KERN_DEBUG "PLX_CNTRL=0x%x (Serial EEPROM " "present=%d)\n", reg, (reg & PLX_CNTRL_SERIAL_EEPROM_PRESENT) != 0); /* should set PLX_PCIIPR to 0x01 (INTA#) if Serial EEPROM is * not present; but are there really such cards in use(?) */ } dev = prism2_init_local_data(&prism2_plx_funcs, cards_found, &pdev->dev); if (dev == NULL) goto fail; iface = netdev_priv(dev); local = iface->local; local->hw_priv = hw_priv; cards_found++; dev->irq = pdev->irq; dev->base_addr = pccard_ioaddr; hw_priv->attr_mem = attr_mem; hw_priv->cor_offset = cor_offset; pci_set_drvdata(pdev, dev); if (request_irq(dev->irq, prism2_interrupt, IRQF_SHARED, dev->name, dev)) { printk(KERN_WARNING "%s: request_irq failed\n", dev->name); goto fail; } else irq_registered = 1; if (prism2_hw_config(dev, 1)) { printk(KERN_DEBUG "%s: hardware initialization failed\n", dev_info); goto fail; } return hostap_hw_ready(dev); fail: if (irq_registered && dev) free_irq(dev->irq, dev); if (attr_mem) iounmap(attr_mem); pci_disable_device(pdev); prism2_free_local_data(dev); err_out_free: kfree(hw_priv); return -ENODEV; }