static void prism2_pci_remove(struct pci_dev *pdev)
{
	struct net_device *dev;
	struct hostap_interface *iface;
	void __iomem *mem_start;
	struct hostap_pci_priv *hw_priv;

	dev = pci_get_drvdata(pdev);
	iface = netdev_priv(dev);
	hw_priv = iface->local->hw_priv;

	
	prism2_pci_cor_sreset(iface->local);
	hfa384x_disable_interrupts(dev);

	if (dev->irq)
		free_irq(dev->irq, dev);

	mem_start = hw_priv->mem_start;
	prism2_free_local_data(dev);
	kfree(hw_priv);

	iounmap(mem_start);

	release_mem_region(pci_resource_start(pdev, 0),
			   pci_resource_len(pdev, 0));
	pci_disable_device(pdev);
}
Ejemplo n.º 2
0
static void prism2_usb_disconnect(struct usb_interface *interface)
{
	struct net_device *dev;
	struct hostap_interface *iface;
	struct hostap_usb_priv *hw_priv;

	dev = usb_get_intfdata(interface);
	if (dev != NULL) {
		iface = netdev_priv(dev);
		hw_priv = iface->local->hw_priv;

		hw_priv->present = 0;
		usb_kill_urb(&hw_priv->rx_urb);
		usb_kill_urb(&hw_priv->tx_urb);

		/* Reset the hardware, and ensure interrupts are disabled. */
		prism2_usb_cor_sreset(iface->local);

		prism2_free_local_data(dev);
		/* FIXME: or before free_local_data ? */
		usb_put_dev(hw_priv->usb);

		kfree(hw_priv);
	}

	usb_set_intfdata(interface, NULL);
}
Ejemplo n.º 3
0
static void prism2_pci_remove(struct pci_dev *pdev)
{
    struct net_device *dev = pci_get_drvdata(pdev);
    struct hostap_interface *iface = dev->priv;
    unsigned long mem_start;

    /* Reset the hardware, and ensure interrupts are disabled. */
    prism2_pci_cor_sreset(iface->local);
    hfa384x_disable_interrupts(dev);

    if (dev->irq)
        free_irq(dev->irq, dev);

    mem_start = dev->mem_start;
    prism2_free_local_data(dev);

    iounmap((void *) mem_start);

    release_mem_region(pci_resource_start(pdev, 0),
                       pci_resource_len(pdev, 0));

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4))
    pci_disable_device(pdev);
#endif
}
Ejemplo n.º 4
0
static void prism2_detach(struct pcmcia_device *link)
{
	PDEBUG(DEBUG_FLOW, "prism2_detach\n");

	prism2_release((u_long)link);

	/* release net devices */
	if (link->priv) {
		struct hostap_cs_priv *hw_priv;
		struct net_device *dev;
		struct hostap_interface *iface;
		dev = link->priv;
		iface = netdev_priv(dev);
		hw_priv = iface->local->hw_priv;
		prism2_free_local_data(dev);
		kfree(hw_priv);
	}
}
Ejemplo n.º 5
0
static void prism2_detach(dev_link_t *link)
{
	dev_link_t **linkp;

	PDEBUG(DEBUG_FLOW, "prism2_detach\n");

	for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
		if (*linkp == link)
			break;
	if (*linkp == NULL) {
		printk(KERN_WARNING "%s: Attempt to detach non-existing "
		       "PCMCIA client\n", dev_info);
		return;
	}

#ifdef HOSTAP_USE_RELEASE_TIMER
	del_timer(&link->release);
#endif /* HOSTAP_USE_RELEASE_TIMER */
	if (link->state & DEV_CONFIG) {
		printk("%s: detach postponed, '%s' still locked\n",
		       dev_info, link->dev->dev_name);
		prism2_release((u_long)link);
		if (link->state & DEV_STALE_CONFIG) {
			link->state |= DEV_STALE_LINK;
			return;
		}
	}

	if (link->handle) {
		int res = CardServices(DeregisterClient, link->handle);
		if (res) {
			printk("CardService(DeregisterClient) => %d\n", res);
			cs_error(link->handle, DeregisterClient, res);
		}
	}

	*linkp = link->next;
	/* release net devices */
	if (link->priv) {
		prism2_free_local_data((struct net_device *) link->priv);

	}
	kfree(link);
}
Ejemplo n.º 6
0
static void prism2_plx_remove(struct pci_dev *pdev)
{
	struct net_device *dev = pci_get_drvdata(pdev);
	struct hostap_interface *iface = dev->priv;

	/* Reset the hardware, and ensure interrupts are disabled. */
	prism2_plx_cor_sreset(iface->local);
	hfa384x_disable_interrupts(dev);

	if (iface->local->attr_mem)
		iounmap((void *) iface->local->attr_mem);
	if (dev->irq)
		free_irq(dev->irq, dev);

	prism2_free_local_data(dev);

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4))
	pci_disable_device(pdev);
#endif
}
Ejemplo n.º 7
0
static void prism2_plx_remove(struct pci_dev *pdev)
{
	struct net_device *dev;
	struct hostap_interface *iface;
	struct hostap_plx_priv *hw_priv;

	dev = pci_get_drvdata(pdev);
	iface = netdev_priv(dev);
	hw_priv = iface->local->hw_priv;

	/* Reset the hardware, and ensure interrupts are disabled. */
	prism2_plx_cor_sreset(iface->local);
	hfa384x_disable_interrupts(dev);

	if (hw_priv->attr_mem)
		iounmap(hw_priv->attr_mem);
	if (dev->irq)
		free_irq(dev->irq, dev);

	prism2_free_local_data(dev);
	kfree(hw_priv);
	pci_disable_device(pdev);
}
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;
}
Ejemplo n.º 9
0
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;
	unsigned long attr_mem = 0;
	unsigned int cor_offset, cor_index;
	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;

	if (pci_enable_device(pdev))
		return -EIO;

	/* 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 = 0; /* 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 = (unsigned long) ioremap(pccard_attr_mem,
						   pccard_attr_len);
		if (!attr_mem) {
			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);
	if (dev == NULL)
		goto fail;
	iface = dev->priv;
	local = iface->local;
	cards_found++;

	dev->irq = pdev->irq;
	dev->base_addr = pccard_ioaddr;
	local->attr_mem = attr_mem;
	local->cor_offset = cor_offset;

	if (prism2_init_dev(local))
		goto fail;

	pci_set_drvdata(pdev, dev);

	if (request_irq(dev->irq, prism2_interrupt, SA_SHIRQ, 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 0;

 fail:
	prism2_free_local_data(dev);

	if (irq_registered && dev)
		free_irq(dev->irq, dev);

	if (attr_mem)
		iounmap((void *) attr_mem);

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4))
	pci_disable_device(pdev);
#endif

	return -ENODEV;
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
static int prism2_pci_probe(struct pci_dev *pdev,
                            const struct pci_device_id *id)
{
    unsigned long phymem;
    unsigned long mem = 0;
    local_info_t *local = NULL;
    struct net_device *dev = NULL;
    static int cards_found /* = 0 */;
    int irq_registered = 0;
    struct hostap_interface *iface;

    if (pci_enable_device(pdev))
        return -EIO;

    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 = (unsigned long) ioremap(phymem, pci_resource_len(pdev, 0));
    if (!mem) {
        printk(KERN_ERR "prism2: Cannot remap PCI memory region\n") ;
        goto fail;
    }

#ifdef PRISM2_BUS_MASTER
    pci_set_master(pdev);
#endif /* PRISM2_BUS_MASTER */

    dev = prism2_init_local_data(&prism2_pci_funcs, cards_found);
    if (dev == NULL)
        goto fail;
    iface = dev->priv;
    local = iface->local;
    cards_found++;

    dev->irq = pdev->irq;
    dev->mem_start = mem;
    dev->mem_end = mem + pci_resource_len(pdev, 0);

    if (prism2_init_dev(local))
        goto fail;

    prism2_pci_cor_sreset(local);

    pci_set_drvdata(pdev, dev);

    if (request_irq(dev->irq, prism2_interrupt, SA_SHIRQ, 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 0;

fail:
    if (irq_registered && dev)
        free_irq(dev->irq, dev);

    if (mem)
        iounmap((void *) mem);

    release_mem_region(phymem, pci_resource_len(pdev, 0));

err_out_disable:
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,4))
    pci_disable_device(pdev);
#endif

    prism2_free_local_data(dev);

    return -ENODEV;
}