/*---------------------------------------------------------------- * prism2sta_probe_usb * * Probe routine called by the USB subsystem. * * Arguments: * dev ptr to the usb_device struct * ifnum interface number being offered * * Returns: * NULL - we're not claiming the device+interface * non-NULL - we are claiming the device+interface and * this is a ptr to the data we want back * when disconnect is called. * * Side effects: * * Call context: * I'm not sure, assume it's interrupt. * ----------------------------------------------------------------*/ static int prism2sta_probe_usb(struct usb_interface *interface, const struct usb_device_id *id) { struct usb_device *dev; wlandevice_t *wlandev = NULL; hfa384x_t *hw = NULL; int result = 0; dev = interface_to_usbdev(interface); wlandev = create_wlan(); if (wlandev == NULL) { printk(KERN_ERR "%s: Memory allocation failure.\n", dev_info); result = -EIO; goto failed; } hw = wlandev->priv; <<<<<<< HEAD
/*---------------------------------------------------------------- * prism2sta_attach * * Half of the attach/detach pair. Creates and registers a device * instance with Card Services. In this case, it also creates the * wlandev structure and device private structure. These are * linked to the device instance via its priv member. * * Arguments: * none * * Returns: * A valid ptr to dev_link_t on success, NULL otherwise * * Side effects: * * * Call context: * process thread (insmod/init_module/register_pccard_driver) ----------------------------------------------------------------*/ dev_link_t *prism2sta_attach(void) { client_reg_t client_reg; int result; dev_link_t *link = NULL; wlandevice_t *wlandev = NULL; hfa384x_t *hw = NULL; DBFENTER; /* Alloc our structures */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link || ((wlandev = create_wlan()) == NULL)) { WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info); result = -EIO; goto failed; } hw = wlandev->priv; /* Clear all the structs */ memset(link, 0, sizeof(struct dev_link_t)); if ( wlan_setup(wlandev) != 0 ) { WLAN_LOG_ERROR("%s: wlan_setup() failed.\n", dev_info); result = -EIO; goto failed; } /* Initialize the hw struct for now */ hfa384x_create(hw, 0, 0, NULL); hw->wlandev = wlandev; /* Initialize the PC card device object. */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) init_timer(&link->release); link->release.function = &prism2sta_release; link->release.data = (u_long)link; #endif link->conf.IntType = INT_MEMORY_AND_IO; link->priv = wlandev; #if (defined(CS_RELEASE_CODE) && (CS_RELEASE_CODE < 0x2911)) link->irq.Instance = wlandev; #endif /* Link in to the list of devices managed by this driver */ link->next = dev_list; dev_list = link; /* Register with Card Services */ client_reg.dev_info = &dev_info; #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) ) client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE; #endif #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) ) client_reg.EventMask = CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | CS_EVENT_RESET_REQUEST | CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET | CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME; client_reg.event_handler = &prism2sta_event; #endif client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; result = pcmcia_register_client(&link->handle, &client_reg); if (result != 0) { cs_error(link->handle, RegisterClient, result); prism2sta_detach(link); return NULL; } goto done; failed: if (link) kfree(link); if (wlandev) kfree(wlandev); if (hw) kfree(hw); link = NULL; done: DBFEXIT; return link; }
static int prism2_cs_probe(struct pcmcia_device *pdev) { int rval = 0; struct wlandevice *wlandev = NULL; hfa384x_t *hw = NULL; config_info_t socketconf; cisparse_t *parse = NULL; tuple_t tuple; uint8_t buf[64]; int last_fn, last_ret; cistpl_cftable_entry_t dflt = { 0 }; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) dev_link_t *link; #endif DBFENTER; #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) /* Set up interrupt type */ pdev->conf.IntType = INT_MEMORY_AND_IO; #else link = kmalloc(sizeof(dev_link_t), GFP_KERNEL); if (link == NULL) return -ENOMEM; memset(link, 0, sizeof(dev_link_t)); link->conf.Vcc = 33; link->conf.IntType = INT_MEMORY_AND_IO; link->handle = pdev; pdev->instance = link; link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; #endif // VCC crap? parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL); wlandev = create_wlan(); if (!wlandev || !parse) { WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info); rval = -EIO; goto failed; } hw = wlandev->priv; if ( wlan_setup(wlandev) != 0 ) { WLAN_LOG_ERROR("%s: wlan_setup() failed.\n", dev_info); rval = -EIO; goto failed; } /* Initialize the hw struct for now */ hfa384x_create(hw, 0, 0, NULL); hw->wlandev = wlandev; #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) hw->pdev = pdev; pdev->priv = wlandev; #else hw->link = link; link->priv = wlandev; #endif tuple.DesiredTuple = CISTPL_CONFIG; tuple.Attributes = 0; tuple.TupleData = buf; tuple.TupleDataMax = sizeof(buf); tuple.TupleOffset = 0; CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple)); CS_CHECK(GetTupleData, pcmcia_get_tuple_data(pdev, &tuple)); CS_CHECK(ParseTuple, pcmcia_parse_tuple(pdev, &tuple, parse)); #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) pdev->conf.ConfigBase = parse->config.base; pdev->conf.Present = parse->config.rmask[0]; #else link->conf.ConfigBase = parse->config.base; link->conf.Present = parse->config.rmask[0]; link->conf.Vcc = socketconf.Vcc; #endif CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &socketconf)); tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple)); for (;;) { cistpl_cftable_entry_t *cfg = &(parse->cftable_entry); CFG_CHECK(GetTupleData, pcmcia_get_tuple_data(pdev, &tuple)); CFG_CHECK(ParseTuple, pcmcia_parse_tuple(pdev, &tuple, parse)); if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; if (cfg->index == 0) goto next_entry; #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) pdev->conf.ConfigIndex = cfg->index; #else link->conf.ConfigIndex = cfg->index; #endif /* Does this card need audio output? */ if (cfg->flags & CISTPL_CFTABLE_AUDIO) { #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) pdev->conf.Attributes |= CONF_ENABLE_SPKR; pdev->conf.Status = CCSR_AUDIO_ENA; #else link->conf.Attributes |= CONF_ENABLE_SPKR; link->conf.Status = CCSR_AUDIO_ENA; #endif } /* Use power settings for Vcc and Vpp if present */ /* Note that the CIS values need to be rescaled */ if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { if (socketconf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000 && !prism2_ignorevcc) { WLAN_LOG_DEBUG(1, " Vcc mismatch - skipping" " this entry\n"); goto next_entry; } } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { if (socketconf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / 10000 && !prism2_ignorevcc) { WLAN_LOG_DEBUG(1, " Vcc (default) mismatch " "- skipping this entry\n"); goto next_entry; } } if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; #else link->conf.Vpp1 = link->conf.Vpp2 = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; #endif } else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) { #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) pdev->conf.Vpp = dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; #else link->conf.Vpp1 = link->conf.Vpp2 = dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; #endif } /* Do we need to allocate an interrupt? */ /* HACK: due to a bad CIS....we ALWAYS need an interrupt */ /* if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) */ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) pdev->conf.Attributes |= CONF_ENABLE_IRQ; #else link->conf.Attributes |= CONF_ENABLE_IRQ; #endif /* IO window settings */ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) pdev->io.NumPorts1 = pdev->io.NumPorts2 = 0; if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; if (!(io->flags & CISTPL_IO_8BIT)) pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; if (!(io->flags & CISTPL_IO_16BIT)) pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; pdev->io.BasePort1 = io->win[0].base; if ( pdev->io.BasePort1 != 0 ) { WLAN_LOG_WARNING( "Brain damaged CIS: hard coded iobase=" "0x%x, try letting pcmcia_cs decide...\n", pdev->io.BasePort1 ); pdev->io.BasePort1 = 0; } pdev->io.NumPorts1 = io->win[0].len; if (io->nwin > 1) { pdev->io.Attributes2 = pdev->io.Attributes1; pdev->io.BasePort2 = io->win[1].base; pdev->io.NumPorts2 = io->win[1].len; } } /* This reserves IO space but doesn't actually enable it */ CFG_CHECK(RequestIO, pcmcia_request_io(pdev, &pdev->io)); #else link->io.NumPorts1 = link->io.NumPorts2 = 0; if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; if (!(io->flags & CISTPL_IO_8BIT)) link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; if (!(io->flags & CISTPL_IO_16BIT)) link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; link->io.BasePort1 = io->win[0].base; if ( link->io.BasePort1 != 0 ) { WLAN_LOG_WARNING( "Brain damaged CIS: hard coded iobase=" "0x%x, try letting pcmcia_cs decide...\n", link->io.BasePort1 ); link->io.BasePort1 = 0; } link->io.NumPorts1 = io->win[0].len; if (io->nwin > 1) { link->io.Attributes2 = link->io.Attributes1; link->io.BasePort2 = io->win[1].base; link->io.NumPorts2 = io->win[1].len; } } /* This reserves IO space but doesn't actually enable it */ CFG_CHECK(RequestIO, pcmcia_request_io(pdev, &link->io)); #endif /* If we got this far, we're cool! */ break; next_entry: if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(pdev, &tuple)); } /* Let pcmcia know the device name */ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) pdev->dev_node = &hw->node; #else link->dev = &hw->node; #endif /* Register the network device and get assigned a name */ SET_MODULE_OWNER(wlandev->netdev); SET_NETDEV_DEV(wlandev->netdev, &handle_to_dev(pdev)); if (register_wlandev(wlandev) != 0) { WLAN_LOG_NOTICE("prism2sta_cs: register_wlandev() failed.\n"); goto failed; } strcpy(hw->node.dev_name, wlandev->name); /* Allocate an interrupt line. Note that this does not assign a */ /* handler to the interrupt, unless the 'Handler' member of the */ /* irq structure is initialized. */ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) if (pdev->conf.Attributes & CONF_ENABLE_IRQ) { pdev->irq.IRQInfo1 = IRQ_LEVEL_ID; pdev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; pdev->irq.Handler = hfa384x_interrupt; pdev->irq.Instance = wlandev; CS_CHECK(RequestIRQ, pcmcia_request_irq(pdev, &pdev->irq)); } #else if (link->conf.Attributes & CONF_ENABLE_IRQ) { link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; link->irq.Handler = hfa384x_interrupt; link->irq.Instance = wlandev; CS_CHECK(RequestIRQ, pcmcia_request_irq(pdev, &link->irq)); } #endif /* This actually configures the PCMCIA socket -- setting up */ /* the I/O windows and the interrupt mapping, and putting the */ /* card and host interface into "Memory and IO" mode. */ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) CS_CHECK(RequestConfiguration, pcmcia_request_configuration(pdev, &pdev->conf)); #else CS_CHECK(RequestConfiguration, pcmcia_request_configuration(pdev, &link->conf)); #endif /* Fill the netdevice with this info */ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) wlandev->netdev->irq = pdev->irq.AssignedIRQ; wlandev->netdev->base_addr = pdev->io.BasePort1; #else wlandev->netdev->irq = link->irq.AssignedIRQ; wlandev->netdev->base_addr = link->io.BasePort1; #endif /* And the rest of the hw structure */ hw->irq = wlandev->netdev->irq; hw->iobase = wlandev->netdev->base_addr; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) link->state |= DEV_CONFIG; link->state &= ~DEV_CONFIG_PENDING; #endif /* And now we're done! */ wlandev->msdstate = WLAN_MSD_HWPRESENT; goto done; cs_failed: cs_error(pdev, last_fn, last_ret); failed: // wlandev, hw, etc etc.. #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16) pdev->priv = NULL; #else pdev->instance = NULL; if (link) { link->priv = NULL; kfree(link); } #endif if (wlandev) { wlan_unsetup(wlandev); if (wlandev->priv) { hw = wlandev->priv; wlandev->priv = NULL; if (hw) { hfa384x_destroy(hw); kfree(hw); } } kfree(wlandev); } done: if (parse) kfree(parse); DBFEXIT; return rval; }
/** * commit new values. * * At this point, you should have done everything you can to ensure that * this commit will not fail. * * Should you need different behavior depending on which columns were * set, rowreq_ctx->column_set_flags will indicate which writeable columns were * set. The definitions for the COLUMN_*_FLAG bits can be found in * dot11CreateWlanTable_oids.h. * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. * * @param dot11CreateWlanTable_rowreq_ctx * Pointer to the users context. * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error */ int dot11CreateWlanTable_commit( dot11CreateWlanTable_rowreq_ctx *rowreq_ctx) { int rc = MFD_SUCCESS; int save_flags; DEBUGMSGTL(("verbose:dot11CreateWlanTable:dot11CreateWlanTable_commit","called\n")); /** we should have a non-NULL pointer */ netsnmp_assert( NULL != rowreq_ctx ); /* * save flags, then clear until we actually do something */ save_flags = rowreq_ctx->column_set_flags; rowreq_ctx->column_set_flags = 0; if(RS_NOTREADY == rowreq_ctx->data.wlanRowStatus && MFD_SUCCESS == check_create_ready(rowreq_ctx)) { rowreq_ctx->data.wlanRowStatus = RS_NOTINSERVICE; } /* * commit dot11CreateWlanTable data * 1) check the column's flag in save_flags to see if it was set. * 2) clear the flag when you handle that column * 3) set the column's flag in column_set_flags if it needs undo * processing in case of a failure. */ if (save_flags & COLUMN_WLANNAME_FLAG) { save_flags &= ~COLUMN_WLANNAME_FLAG; /* clear wlanName */ /* * TODO:482:o: |-> commit column wlanName. */ rc = MFD_SUCCESS; if(-1 == rc) { snmp_log(LOG_ERR,"dot11CreateWlanTable column wlanName commit failed\n"); } else { /* * set flag, in case we need to undo wlanName */ rowreq_ctx->column_set_flags |= COLUMN_WLANNAME_FLAG; } } if (save_flags & COLUMN_WLANESSID_FLAG) { save_flags &= ~COLUMN_WLANESSID_FLAG; /* clear wlanESSID */ /* * TODO:482:o: |-> commit column wlanESSID. */ rc = MFD_SUCCESS; if(-1 == rc) { snmp_log(LOG_ERR,"dot11CreateWlanTable column wlanESSID commit failed\n"); } else { /* * set flag, in case we need to undo wlanESSID */ rowreq_ctx->column_set_flags |= COLUMN_WLANESSID_FLAG; } } if (save_flags & COLUMN_WLANROWSTATUS_FLAG) { save_flags &= ~COLUMN_WLANROWSTATUS_FLAG; /* clear wlanRowStatus */ switch(rowreq_ctx->data.wlanRowStatus) { case RS_ACTIVE: { char id[10] = { 0 }; memset(id,0,10); snprintf(id, sizeof(id)-1, "%d", rowreq_ctx->data.localWlanID); int ret = 0; void *connection = NULL; if(SNMPD_DBUS_SUCCESS == get_instance_dbus_connection(rowreq_ctx->data.parameter, &connection, SNMPD_INSTANCE_MASTER_V3)) { ret = create_wlan(rowreq_ctx->data.parameter, connection,id, rowreq_ctx->data.wlanName, rowreq_ctx->data.wlanESSID); snmp_log(LOG_DEBUG, "dot11CreateWlanTable_commit: create_wlan: ret = %d\n", ret); if(1 == ret) { rowreq_ctx->data.is_modify = 1; rc = MFD_SUCCESS; break; } else if(SNMPD_CONNECTION_ERROR == ret) { rowreq_ctx->data.is_modify = 0; close_slot_dbus_connection(rowreq_ctx->data.parameter.slot_id); } } } rc = -1; break; case RS_CREATEANDWAIT: rowreq_ctx->data.wlanRowStatus = RS_NOTREADY; rc = MFD_SUCCESS; break; case RS_DESTROY: { int ret = 0; void *connection = NULL; if(SNMPD_DBUS_SUCCESS == get_instance_dbus_connection(rowreq_ctx->data.parameter, &connection, SNMPD_INSTANCE_MASTER_V3)) { ret = delete_wlan(rowreq_ctx->data.parameter, connection, rowreq_ctx->data.localWlanID); snmp_log(LOG_DEBUG, "dot11CreateWlanTable_commit: delete_wlan: ret = %d\n", ret); if(1 == ret) { rc = MFD_SUCCESS; break; } else if(SNMPD_CONNECTION_ERROR == ret) { close_slot_dbus_connection(rowreq_ctx->data.parameter.slot_id); } } } rowreq_ctx->rowreq_flags &= ~MFD_ROW_DELETED; rc = -1; break; default: break; } /* * TODO:482:o: |-> commit column wlanRowStatus. */ if(-1 == rc) { snmp_log(LOG_ERR,"dot11CreateWlanTable column wlanRowStatus commit failed\n"); } else { /* * set flag, in case we need to undo wlanRowStatus */ rowreq_ctx->column_set_flags |= COLUMN_WLANROWSTATUS_FLAG; } } /* * if we successfully commited this row, set the dirty flag. */ if (MFD_SUCCESS == rc) { rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY; } if (save_flags) { snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", save_flags); return MFD_ERROR; } return rc; } /* dot11CreateWlanTable_commit */
/*---------------------------------------------------------------- * prism2sta_probe_plx * * Probe routine called when a PCI device w/ matching ID is found. * This PLX implementation uses the following map: * BAR0: Unused * BAR1: ???? * BAR2: PCMCIA attribute memory * BAR3: PCMCIA i/o space * Here's the sequence: * - Allocate the PCI resources. * - Read the PCMCIA attribute memory to make sure we have a WLAN card * - Reset the MAC using the PCMCIA COR * - Initialize the netdev and wlan data * - Initialize the MAC * * Arguments: * pdev ptr to pci device structure containing info about * pci configuration. * id ptr to the device id entry that matched this device. * * Returns: * zero - success * negative - failed * * Side effects: * * * Call context: * process thread * ----------------------------------------------------------------*/ static int __devinit prism2sta_probe_plx( struct pci_dev *pdev, const struct pci_device_id *id) { int result; phys_t pccard_ioaddr; phys_t pccard_attr_mem; unsigned int pccard_attr_len; void __iomem *attr_mem = NULL; UINT32 plx_addr; wlandevice_t *wlandev = NULL; hfa384x_t *hw = NULL; int reg; u32 regic; if (pci_enable_device(pdev)) return -EIO; /* TMC7160 boards are special */ if ((pdev->vendor == PCIVENDOR_NDC) && (pdev->device == PCIDEVICE_NCP130_ASIC)) { unsigned long delay; pccard_attr_mem = 0; pccard_ioaddr = pci_resource_start(pdev, 1); outb(0x45, pccard_ioaddr); delay = jiffies + 1*HZ; while (time_before(jiffies, delay)); if (inb(pccard_ioaddr) != 0x45) { WLAN_LOG_ERROR("Initialize the TMC7160 failed. (0x%x)\n", inb(pccard_ioaddr)); return -EIO; } pccard_ioaddr = pci_resource_start(pdev, 2); prism2_doreset = 0; WLAN_LOG_INFO("NDC NCP130 with TMC716(ASIC) PCI interface device found at io:0x%x, irq:%d\n", pccard_ioaddr, pdev->irq); goto init; } /* Collect the resource requirements */ pccard_attr_mem = pci_resource_start(pdev, 2); pccard_attr_len = pci_resource_len(pdev, 2); if (pccard_attr_len < PLX_MIN_ATTR_LEN) return -EIO; pccard_ioaddr = pci_resource_start(pdev, 3); /* bjoern: We need to tell the card to enable interrupts, in * case the serial eprom didn't do this already. See the * PLX9052 data book, p8-1 and 8-24 for reference. * [MSM]: This bit of code came from the orinoco_cs driver. */ plx_addr = pci_resource_start(pdev, 1); regic = 0; regic = inl(plx_addr+PLX_INTCSR); if(regic & PLX_INTCSR_INTEN) { WLAN_LOG_DEBUG(1, "%s: Local Interrupt already enabled\n", dev_info); } else { regic |= PLX_INTCSR_INTEN; outl(regic, plx_addr+PLX_INTCSR); regic = inl(plx_addr+PLX_INTCSR); if(!(regic & PLX_INTCSR_INTEN)) { WLAN_LOG_ERROR( "%s: Couldn't enable Local Interrupts\n", dev_info); return -EIO; } } /* These assignments are here in case of future mappings for * io space and irq that might be similar to ioremap */ if (!request_mem_region(pccard_attr_mem, pci_resource_len(pdev, 2), "Prism2")) { WLAN_LOG_ERROR("%s: Couldn't reserve PCI memory region\n", dev_info); return -EIO; } attr_mem = ioremap(pccard_attr_mem, pccard_attr_len); WLAN_LOG_INFO("A PLX PCI/PCMCIA interface device found, " "phymem:0x%llx, phyio=0x%x, irq:%d, " "mem: 0x%lx\n", (unsigned long long)pccard_attr_mem, pccard_ioaddr, pdev->irq, (unsigned long)attr_mem); /* Verify whether PC card is present. * [MSM] This needs improvement, the right thing to do is * probably to walk the CIS looking for the vendor and product * IDs. It would be nice if this could be tied in with the * etc/pcmcia/wlan-ng.conf file. Any volunteers? ;-) */ if ( readb(attr_mem + 0) != 0x01 || readb(attr_mem + 2) != 0x03 || readb(attr_mem + 4) != 0x00 || readb(attr_mem + 6) != 0x00 || readb(attr_mem + 8) != 0xFF || readb(attr_mem + 10) != 0x17 || readb(attr_mem + 12) != 0x04 || readb(attr_mem + 14) != 0x67) { WLAN_LOG_ERROR("Prism2 PC card CIS is invalid.\n"); return -EIO; } WLAN_LOG_INFO("A PCMCIA WLAN adapter was found.\n"); /* Write COR to enable PC card */ writeb(COR_VALUE, attr_mem + COR_OFFSET); reg = readb(attr_mem + COR_OFFSET); init: /* * Now do everything the same as a PCI device * [MSM] TODO: We could probably factor this out of pcmcia/pci/plx * and perhaps usb. Perhaps a task for another day....... */ if ((wlandev = create_wlan()) == NULL) { WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info); result = -EIO; goto failed; } hw = wlandev->priv; if ( wlan_setup(wlandev) != 0 ) { WLAN_LOG_ERROR("%s: wlan_setup() failed.\n", dev_info); result = -EIO; goto failed; } /* Setup netdevice's ability to report resources * Note: the netdevice was allocated by wlan_setup() */ wlandev->netdev->irq = pdev->irq; wlandev->netdev->base_addr = pccard_ioaddr; wlandev->netdev->mem_start = (unsigned long)attr_mem; wlandev->netdev->mem_end = (unsigned long)attr_mem + pci_resource_len(pdev, 0); /* Initialize the hw data */ hfa384x_create(hw, wlandev->netdev->irq, pccard_ioaddr, attr_mem); hw->wlandev = wlandev; /* Register the wlandev, this gets us a name and registers the * linux netdevice. */ SET_MODULE_OWNER(wlandev->netdev); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) SET_NETDEV_DEV(wlandev->netdev, &(pdev->dev)); #endif if ( register_wlandev(wlandev) != 0 ) { WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info); result = -EIO; goto failed; } #if 0 /* TODO: Move this and an irq test into an hfa384x_testif() routine. */ outw(PRISM2STA_MAGIC, HFA384x_SWSUPPORT(wlandev->netdev->base_addr)); reg=inw( HFA384x_SWSUPPORT(wlandev->netdev->base_addr)); if ( reg != PRISM2STA_MAGIC ) { WLAN_LOG_ERROR("MAC register access test failed!\n"); result = -EIO; goto failed; } #endif /* Do a chip-level reset on the MAC */ if (prism2_doreset) { result = hfa384x_corereset(hw, prism2_reset_holdtime, prism2_reset_settletime, 0); if (result != 0) { unregister_wlandev(wlandev); hfa384x_destroy(hw); WLAN_LOG_ERROR( "%s: hfa384x_corereset() failed.\n", dev_info); result = -EIO; goto failed; } } pci_set_drvdata(pdev, wlandev); /* Shouldn't actually hook up the IRQ until we * _know_ things are alright. A test routine would help. */ request_irq(wlandev->netdev->irq, hfa384x_interrupt, SA_SHIRQ, wlandev->name, wlandev); wlandev->msdstate = WLAN_MSD_HWPRESENT; result = 0; goto done; failed: pci_set_drvdata(pdev, NULL); if (wlandev) kfree(wlandev); if (hw) kfree(hw); if (attr_mem) iounmap(attr_mem); pci_release_regions(pdev); pci_disable_device(pdev); done: DBFEXIT; return result; }
static int prism2sta_probe_usb(struct usb_interface *interface, const struct usb_device_id *id) { struct usb_device *dev; wlandevice_t *wlandev = NULL; hfa384x_t *hw = NULL; int result = 0; dev = interface_to_usbdev(interface); wlandev = create_wlan(); if (!wlandev) { dev_err(&interface->dev, "Memory allocation failure.\n"); result = -EIO; goto failed; } hw = wlandev->priv; if (wlan_setup(wlandev, &(interface->dev)) != 0) { dev_err(&interface->dev, "wlan_setup() failed.\n"); result = -EIO; goto failed; } /* Initialize the hw data */ hfa384x_create(hw, dev); hw->wlandev = wlandev; /* Register the wlandev, this gets us a name and registers the * linux netdevice. */ SET_NETDEV_DEV(wlandev->netdev, &(interface->dev)); /* Do a chip-level reset on the MAC */ if (prism2_doreset) { result = hfa384x_corereset(hw, prism2_reset_holdtime, prism2_reset_settletime, 0); if (result != 0) { result = -EIO; dev_err(&interface->dev, "hfa384x_corereset() failed.\n"); goto failed_reset; } } usb_get_dev(dev); wlandev->msdstate = WLAN_MSD_HWPRESENT; /* Try and load firmware, then enable card before we register */ prism2_fwtry(dev, wlandev); prism2sta_ifstate(wlandev, P80211ENUM_ifstate_enable); if (register_wlandev(wlandev) != 0) { dev_err(&interface->dev, "register_wlandev() failed.\n"); result = -EIO; goto failed_register; } goto done; failed_register: usb_put_dev(dev); failed_reset: wlan_unsetup(wlandev); failed: kfree(wlandev); kfree(hw); wlandev = NULL; done: usb_set_intfdata(interface, wlandev); return result; }
/*---------------------------------------------------------------- * prism2sta_probe_pci * * Probe routine called when a PCI device w/ matching ID is found. * The ISL3874 implementation uses the following map: * BAR0: Prism2.x registers memory mapped, size=4k * Here's the sequence: * - Allocate the PCI resources. * - Read the PCMCIA attribute memory to make sure we have a WLAN card * - Reset the MAC * - Initialize the netdev and wlan data * - Initialize the MAC * * Arguments: * pdev ptr to pci device structure containing info about * pci configuration. * id ptr to the device id entry that matched this device. * * Returns: * zero - success * negative - failed * * Side effects: * * * Call context: * process thread * ----------------------------------------------------------------*/ static int __devinit prism2sta_probe_pci( struct pci_dev *pdev, const struct pci_device_id *id) { int result; phys_t phymem = 0; void *mem = NULL; wlandevice_t *wlandev = NULL; hfa384x_t *hw = NULL; DBFENTER; /* Enable the pci device */ if (pci_enable_device(pdev)) { WLAN_LOG_ERROR("%s: pci_enable_device() failed.\n", dev_info); result = -EIO; goto fail; } /* Figure out our resources */ 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"); result = -EIO; goto fail; } mem = ioremap(phymem, PCI_SIZE); if ( mem == 0 ) { WLAN_LOG_ERROR("%s: ioremap() failed.\n", dev_info); result = -EIO; goto fail; } /* Log the device */ WLAN_LOG_INFO("A Prism2.5 PCI device found, " "phymem:0x%llx, irq:%d, mem:0x%p\n", (unsigned long long)phymem, pdev->irq, mem); if ((wlandev = create_wlan()) == NULL) { WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info); result = -EIO; goto fail; } hw = wlandev->priv; if ( wlan_setup(wlandev) != 0 ) { WLAN_LOG_ERROR("%s: wlan_setup() failed.\n", dev_info); result = -EIO; goto fail; } /* Setup netdevice's ability to report resources * Note: the netdevice was allocated by wlan_setup() */ wlandev->netdev->irq = pdev->irq; wlandev->netdev->mem_start = (unsigned long) mem; wlandev->netdev->mem_end = wlandev->netdev->mem_start + pci_resource_len(pdev, 0); /* Register the wlandev, this gets us a name and registers the * linux netdevice. */ SET_MODULE_OWNER(wlandev->netdev); if ( register_wlandev(wlandev) != 0 ) { WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info); result = -EIO; goto fail; } #if 0 /* TODO: Move this and an irq test into an hfa384x_testif() routine. */ outw(PRISM2STA_MAGIC, HFA384x_SWSUPPORT(wlandev->netdev->base_addr)); reg=inw( HFA384x_SWSUPPORT(wlandev->netdev->base_addr)); if ( reg != PRISM2STA_MAGIC ) { WLAN_LOG_ERROR("MAC register access test failed!\n"); result = -EIO; goto fail; } #endif /* Initialize the hw data */ hfa384x_create(hw, wlandev->netdev->irq, 0, mem); hw->wlandev = wlandev; /* Do a chip-level reset on the MAC */ if (prism2_doreset) { result = hfa384x_corereset(hw, prism2_reset_holdtime, prism2_reset_settletime, 0); if (result != 0) { WLAN_LOG_ERROR( "%s: hfa384x_corereset() failed.\n", dev_info); unregister_wlandev(wlandev); hfa384x_destroy(hw); result = -EIO; goto fail; } } pci_set_drvdata(pdev, wlandev); /* Shouldn't actually hook up the IRQ until we * _know_ things are alright. A test routine would help. */ request_irq(wlandev->netdev->irq, hfa384x_interrupt, SA_SHIRQ, wlandev->name, wlandev); wlandev->msdstate = WLAN_MSD_HWPRESENT; result = 0; goto done; fail: pci_set_drvdata(pdev, NULL); if (wlandev) kfree(wlandev); if (hw) kfree(hw); if (mem) iounmap((void *) mem); pci_release_regions(pdev); pci_disable_device(pdev); done: DBFEXIT; return result; }