3 static struct usb_device_id InterfaceUsbtable[] = {
4 { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3) },
5 { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3B) },
6 { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3L) },
7 { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_226) },
8 { USB_DEVICE(BCM_USB_VENDOR_ID_FOXCONN, BCM_USB_PRODUCT_ID_1901) },
12 MODULE_DEVICE_TABLE(usb, InterfaceUsbtable);
14 static int debug = -1;
15 module_param(debug, uint, 0600);
16 MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
18 static const u32 default_msg =
19 NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK
20 | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR
21 | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN;
23 static INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER Adapter);
25 static VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter)
28 // Wake up the wait_queue...
29 if(psIntfAdapter->psAdapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
31 psIntfAdapter->psAdapter->DriverState = DRIVER_HALT;
32 wake_up(&psIntfAdapter->psAdapter->LEDInfo.notify_led_event);
34 reset_card_proc(psIntfAdapter->psAdapter);
36 //worst case time taken by the RDM/WRM will be 5 sec. will check after every 100 ms
37 //to accertain the device is not being accessed. After this No RDM/WRM should be made.
38 while(psIntfAdapter->psAdapter->DeviceAccess)
40 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Device is being Accessed \n");
43 /* Free interrupt URB */
44 //psIntfAdapter->psAdapter->device_removed = TRUE;
45 if(psIntfAdapter->psInterruptUrb)
47 usb_free_urb(psIntfAdapter->psInterruptUrb);
50 /* Free transmit URBs */
51 for(i = 0; i < MAXIMUM_USB_TCB; i++)
53 if(psIntfAdapter->asUsbTcb[i].urb != NULL)
55 usb_free_urb(psIntfAdapter->asUsbTcb[i].urb);
56 psIntfAdapter->asUsbTcb[i].urb = NULL;
59 /* Free receive URB and buffers */
60 for(i = 0; i < MAXIMUM_USB_RCB; i++)
62 if (psIntfAdapter->asUsbRcb[i].urb != NULL)
64 kfree(psIntfAdapter->asUsbRcb[i].urb->transfer_buffer);
65 usb_free_urb(psIntfAdapter->asUsbRcb[i].urb);
66 psIntfAdapter->asUsbRcb[i].urb = NULL;
69 AdapterFree(psIntfAdapter->psAdapter);
72 static VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter)
76 // Program EP2 MAX_PKT_SIZE
77 ulReg = ntohl(EP2_MPS_REG);
78 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x128,4,TRUE);
79 ulReg = ntohl(EP2_MPS);
80 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x12C,4,TRUE);
82 ulReg = ntohl(EP2_CFG_REG);
83 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x132,4,TRUE);
84 if(((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter))->bHighSpeedDevice == TRUE)
86 ulReg = ntohl(EP2_CFG_INT);
87 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x136,4,TRUE);
91 // USE BULK EP as TX in FS mode.
92 ulReg = ntohl(EP2_CFG_BULK);
93 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x136,4,TRUE);
97 // Program EP4 MAX_PKT_SIZE.
98 ulReg = ntohl(EP4_MPS_REG);
99 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x13C,4,TRUE);
100 ulReg = ntohl(EP4_MPS);
101 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x140,4,TRUE);
103 // Program TX EP as interrupt (Alternate Setting)
104 if( rdmalt(Adapter,0x0F0110F8, (PUINT)&ulReg,4))
106 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reading of Tx EP is failing");
111 ulReg = ntohl(ulReg);
112 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1CC,4,TRUE);
114 ulReg = ntohl(EP4_CFG_REG);
115 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1C8,4,TRUE);
116 // Program ISOCHRONOUS EP size to zero.
117 ulReg = ntohl(ISO_MPS_REG);
118 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1D2,4,TRUE);
119 ulReg = ntohl(ISO_MPS);
120 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1D6,4,TRUE);
122 // Update EEPROM Version.
123 // Read 4 bytes from 508 and modify 511 and 510.
125 ReadBeceemEEPROM(Adapter,0x1FC,(PUINT)&ulReg);
127 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1FC,4,TRUE);
129 //Update length field if required. Also make the string NULL terminated.
131 ReadBeceemEEPROM(Adapter,0xA8,(PUINT)&ulReg);
132 if((ulReg&0x00FF0000)>>16 > 0x30)
134 ulReg = (ulReg&0xFF00FFFF)|(0x30<<16);
135 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0xA8,4,TRUE);
137 ReadBeceemEEPROM(Adapter,0x148,(PUINT)&ulReg);
138 if((ulReg&0x00FF0000)>>16 > 0x30)
140 ulReg = (ulReg&0xFF00FFFF)|(0x30<<16);
141 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x148,4,TRUE);
144 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x122,4,TRUE);
146 BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1C2,4,TRUE);
151 usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
153 struct usb_device *udev = interface_to_usbdev (intf);
155 PMINI_ADAPTER psAdapter;
156 PS_INTERFACE_ADAPTER psIntfAdapter;
157 struct net_device *ndev;
159 /* Reserve one extra queue for the bit-bucket */
160 ndev = alloc_etherdev_mq(sizeof(MINI_ADAPTER), NO_OF_QUEUES+1);
162 dev_err(&udev->dev, DRV_NAME ": no memory for device\n");
166 SET_NETDEV_DEV(ndev, &intf->dev);
168 psAdapter = netdev_priv(ndev);
169 psAdapter->dev = ndev;
170 psAdapter->msg_enable = netif_msg_init(debug, default_msg);
172 /* Init default driver debug state */
174 psAdapter->stDebugState.debug_level = DBG_LVL_CURR;
175 psAdapter->stDebugState.type = DBG_TYPE_INITEXIT;
177 /* Technically, one can start using BCM_DEBUG_PRINT after this point.
178 * However, realize that by default the Type/Subtype bitmaps are all zero now;
179 * so no prints will actually appear until the TestApp turns on debug paths via
180 * the ioctl(); so practically speaking, in early init, no logging happens.
182 * A solution (used below): we explicitly set the bitmaps to 1 for Type=DBG_TYPE_INITEXIT
183 * and ALL subtype's of the same. Now all bcm debug statements get logged, enabling debug
185 * Further, we turn this OFF once init_module() completes.
188 psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xff;
189 BCM_SHOW_DEBUG_BITMAP(psAdapter);
191 retval = InitAdapter(psAdapter);
194 dev_err(&udev->dev, DRV_NAME ": InitAdapter Failed\n");
195 AdapterFree(psAdapter);
199 /* Allocate interface adapter structure */
200 psIntfAdapter = kzalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL);
201 if (psIntfAdapter == NULL)
203 dev_err(&udev->dev, DRV_NAME ": no memory for Interface adapter\n");
204 AdapterFree (psAdapter);
208 psAdapter->pvInterfaceAdapter = psIntfAdapter;
209 psIntfAdapter->psAdapter = psAdapter;
211 /* Store usb interface in Interface Adapter */
212 psIntfAdapter->interface = intf;
213 usb_set_intfdata(intf, psIntfAdapter);
215 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%p",psIntfAdapter);
216 retval = InterfaceAdapterInit(psIntfAdapter);
219 /* If the Firmware/Cfg File is not present
220 * then return success, let the application
221 * download the files.
223 if(-ENOENT == retval){
224 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "File Not Found, Use App to Download\n");
225 return STATUS_SUCCESS;
227 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapterInit Failed \n");
228 usb_set_intfdata(intf, NULL);
229 udev = interface_to_usbdev (intf);
231 InterfaceAdapterFree(psIntfAdapter);
234 if(psAdapter->chip_id > T3)
236 uint32_t uiNackZeroLengthInt=4;
237 if(wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, &uiNackZeroLengthInt, sizeof(uiNackZeroLengthInt)))
243 /* Check whether the USB-Device Supports remote Wake-Up */
244 if(USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes)
246 /* If Suspend then only support dynamic suspend */
247 if(psAdapter->bDoSuspend)
250 udev->autosuspend_delay = 0;
251 intf->needs_remote_wakeup = 1;
252 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
253 udev->autosuspend_disabled = 0;
255 usb_enable_autosuspend(udev);
257 device_init_wakeup(&intf->dev,1);
258 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
259 usb_autopm_disable(intf);
261 INIT_WORK(&psIntfAdapter->usbSuspendWork, putUsbSuspend);
262 BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Enabling USB Auto-Suspend\n");
267 intf->needs_remote_wakeup = 0;
268 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
269 udev->autosuspend_disabled = 1;
271 usb_disable_autosuspend(udev);
276 psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0x0;
280 static void usbbcm_disconnect (struct usb_interface *intf)
282 PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf);
283 PMINI_ADAPTER psAdapter;
284 struct usb_device *udev = interface_to_usbdev (intf);
286 if(psIntfAdapter == NULL)
289 psAdapter = psIntfAdapter->psAdapter;
290 netif_device_detach(psAdapter->dev);
292 if(psAdapter->bDoSuspend)
293 intf->needs_remote_wakeup = 0;
295 psAdapter->device_removed = TRUE ;
296 usb_set_intfdata(intf, NULL);
297 InterfaceAdapterFree(psIntfAdapter);
301 static int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter)
304 for(i = 0; i < MAXIMUM_USB_TCB; i++)
306 if((psIntfAdapter->asUsbTcb[i].urb =
307 usb_alloc_urb(0, GFP_KERNEL)) == NULL)
309 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Tx urb for index %d", i);
314 for(i = 0; i < MAXIMUM_USB_RCB; i++)
316 if ((psIntfAdapter->asUsbRcb[i].urb =
317 usb_alloc_urb(0, GFP_KERNEL)) == NULL)
319 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Rx urb for index %d", i);
322 if((psIntfAdapter->asUsbRcb[i].urb->transfer_buffer =
323 kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL)) == NULL)
325 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Rx buffer for index %d", i);
328 psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length = MAX_DATA_BUFFER_SIZE;
335 static int device_run(PS_INTERFACE_ADAPTER psIntfAdapter)
338 UINT status = STATUS_SUCCESS;
340 status = InitCardAndDownloadFirmware(psIntfAdapter->psAdapter);
341 if(status != STATUS_SUCCESS)
343 pr_err(DRV_NAME "InitCardAndDownloadFirmware failed.\n");
346 if(TRUE == psIntfAdapter->psAdapter->fw_download_done)
348 if(StartInterruptUrb(psIntfAdapter))
350 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Cannot send interrupt in URB");
352 //now register the cntrl interface.
353 //after downloading the f/w waiting for 5 sec to get the mailbox interrupt.
355 psIntfAdapter->psAdapter->waiting_to_fw_download_done = FALSE;
356 value = wait_event_timeout(psIntfAdapter->psAdapter->ioctl_fw_dnld_wait_queue,
357 psIntfAdapter->psAdapter->waiting_to_fw_download_done, 5*HZ);
360 pr_err(DRV_NAME ": Mailbox Interrupt has not reached to Driver..\n");
362 if(register_control_device_interface(psIntfAdapter->psAdapter) < 0)
364 pr_err(DRV_NAME ": Register Control Device failed...\n");
372 static inline int bcm_usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
374 return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
377 static inline int bcm_usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
379 return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
382 static inline int bcm_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
384 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
387 static inline int bcm_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
389 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
392 static inline int bcm_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
394 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
395 USB_ENDPOINT_XFER_BULK);
398 static inline int bcm_usb_endpoint_xfer_control(const struct usb_endpoint_descriptor *epd)
400 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
401 USB_ENDPOINT_XFER_CONTROL);
404 static inline int bcm_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
406 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
407 USB_ENDPOINT_XFER_INT);
410 static inline int bcm_usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
412 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
413 USB_ENDPOINT_XFER_ISOC);
416 static inline int bcm_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
418 return (bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_in(epd));
421 static inline int bcm_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
423 return (bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_out(epd));
426 static inline int bcm_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
428 return (bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_in(epd));
431 static inline int bcm_usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd)
433 return (bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_out(epd));
436 static inline int bcm_usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd)
438 return (bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_in(epd));
441 static inline int bcm_usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd)
443 return (bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_out(epd));
446 static INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter)
448 struct usb_host_interface *iface_desc;
449 struct usb_endpoint_descriptor *endpoint;
453 INT usedIntOutForBulkTransfer = 0 ;
454 BOOLEAN bBcm16 = FALSE;
457 /* Store the usb dev into interface adapter */
458 psIntfAdapter->udev = usb_get_dev(interface_to_usbdev(psIntfAdapter->interface));
460 psIntfAdapter->bHighSpeedDevice = (psIntfAdapter->udev->speed == USB_SPEED_HIGH);
461 psIntfAdapter->psAdapter->interface_rdm = BcmRDM;
462 psIntfAdapter->psAdapter->interface_wrm = BcmWRM;
464 if(rdmalt(psIntfAdapter->psAdapter, CHIP_ID_REG, (PUINT)&(psIntfAdapter->psAdapter->chip_id), sizeof(UINT)) < 0)
466 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "CHIP ID Read Failed\n");
467 return STATUS_FAILURE;
470 if(0xbece3200==(psIntfAdapter->psAdapter->chip_id&~(0xF0)))
471 psIntfAdapter->psAdapter->chip_id &= ~0xF0;
473 dev_info(&psIntfAdapter->udev->dev, "RDM Chip ID 0x%lx\n",
474 psIntfAdapter->psAdapter->chip_id);
476 iface_desc = psIntfAdapter->interface->cur_altsetting;
478 if(psIntfAdapter->psAdapter->chip_id == T3B)
481 //T3B device will have EEPROM,check if EEPROM is proper and BCM16 can be done or not.
483 BeceemEEPROMBulkRead(psIntfAdapter->psAdapter,&uiData,0x0,4);
487 dev_info(&psIntfAdapter->udev->dev, "number of alternate setting %d\n",
488 psIntfAdapter->interface->num_altsetting);
492 //selecting alternate setting one as a default setting for High Speed modem.
493 if(psIntfAdapter->bHighSpeedDevice)
494 retval= usb_set_interface(psIntfAdapter->udev,DEFAULT_SETTING_0,ALTERNATE_SETTING_1);
495 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM16 is Applicable on this dongle");
496 if(retval || (psIntfAdapter->bHighSpeedDevice == FALSE))
498 usedIntOutForBulkTransfer = EP2 ;
499 endpoint = &iface_desc->endpoint[EP2].desc;
500 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Interface altsetting got failed or Moemd is configured to FS.hence will work on default setting 0 \n");
502 If Modem is high speed device EP2 should be INT OUT End point
503 If Mode is FS then EP2 should be bulk end point
505 if(((psIntfAdapter->bHighSpeedDevice ==TRUE ) && (bcm_usb_endpoint_is_int_out(endpoint)== FALSE))
506 ||((psIntfAdapter->bHighSpeedDevice == FALSE)&& (bcm_usb_endpoint_is_bulk_out(endpoint)== FALSE)))
508 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Configuring the EEPROM ");
509 //change the EP2, EP4 to INT OUT end point
510 ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter);
513 It resets the device and if any thing gets changed in USB descriptor it will show fail and
514 re-enumerate the device
516 retval = usb_reset_device(psIntfAdapter->udev);
519 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reset got failed. hence Re-enumerating the device \n");
524 if((psIntfAdapter->bHighSpeedDevice == FALSE) && bcm_usb_endpoint_is_bulk_out(endpoint))
526 // Once BULK is selected in FS mode. Revert it back to INT. Else USB_IF will fail.
527 UINT _uiData = ntohl(EP2_CFG_INT);
528 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Reverting Bulk to INT as it is FS MODE");
529 BeceemEEPROMBulkWrite(psIntfAdapter->psAdapter,(PUCHAR)&_uiData,0x136,4,TRUE);
534 usedIntOutForBulkTransfer = EP4 ;
535 endpoint = &iface_desc->endpoint[EP4].desc;
536 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Choosing AltSetting as a default setting");
537 if( bcm_usb_endpoint_is_int_out(endpoint) == FALSE)
539 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, " Dongle does not have BCM16 Fix");
540 //change the EP2, EP4 to INT OUT end point and use EP4 in altsetting
541 ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter);
544 It resets the device and if any thing gets changed in USB descriptor it will show fail and
545 re-enumerate the device
547 retval = usb_reset_device(psIntfAdapter->udev);
550 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reset got failed. hence Re-enumerating the device \n");
559 iface_desc = psIntfAdapter->interface->cur_altsetting;
561 for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value)
563 endpoint = &iface_desc->endpoint[value].desc;
565 if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && bcm_usb_endpoint_is_bulk_in(endpoint))
567 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
568 psIntfAdapter->sBulkIn.bulk_in_size = buffer_size;
569 psIntfAdapter->sBulkIn.bulk_in_endpointAddr =
570 endpoint->bEndpointAddress;
571 psIntfAdapter->sBulkIn.bulk_in_pipe =
572 usb_rcvbulkpipe(psIntfAdapter->udev,
573 psIntfAdapter->sBulkIn.bulk_in_endpointAddr);
576 if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && bcm_usb_endpoint_is_bulk_out(endpoint))
579 psIntfAdapter->sBulkOut.bulk_out_endpointAddr =
580 endpoint->bEndpointAddress;
581 psIntfAdapter->sBulkOut.bulk_out_pipe =
582 usb_sndbulkpipe(psIntfAdapter->udev,
583 psIntfAdapter->sBulkOut.bulk_out_endpointAddr);
586 if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && bcm_usb_endpoint_is_int_in(endpoint))
588 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
589 psIntfAdapter->sIntrIn.int_in_size = buffer_size;
590 psIntfAdapter->sIntrIn.int_in_endpointAddr =
591 endpoint->bEndpointAddress;
592 psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval;
593 psIntfAdapter->sIntrIn.int_in_buffer =
594 kmalloc(buffer_size, GFP_KERNEL);
595 if (!psIntfAdapter->sIntrIn.int_in_buffer) {
596 dev_err(&psIntfAdapter->udev->dev,
597 "could not allocate interrupt_in_buffer\n");
602 if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint))
605 if( !psIntfAdapter->sBulkOut.bulk_out_endpointAddr &&
606 (psIntfAdapter->psAdapter->chip_id == T3B) && (value == usedIntOutForBulkTransfer))
608 //use first intout end point as a bulk out end point
609 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
610 psIntfAdapter->sBulkOut.bulk_out_size = buffer_size;
611 //printk("\nINT OUT Endpoing buffer size :%x endpoint :%x\n", buffer_size, value +1);
612 psIntfAdapter->sBulkOut.bulk_out_endpointAddr =
613 endpoint->bEndpointAddress;
614 psIntfAdapter->sBulkOut.bulk_out_pipe =
615 usb_sndintpipe(psIntfAdapter->udev,
616 psIntfAdapter->sBulkOut.bulk_out_endpointAddr);
617 psIntfAdapter->sBulkOut.int_out_interval = endpoint->bInterval;
620 else if(value == EP6)
622 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
623 psIntfAdapter->sIntrOut.int_out_size = buffer_size;
624 psIntfAdapter->sIntrOut.int_out_endpointAddr =
625 endpoint->bEndpointAddress;
626 psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval;
627 psIntfAdapter->sIntrOut.int_out_buffer= kmalloc(buffer_size,
629 if (!psIntfAdapter->sIntrOut.int_out_buffer)
631 dev_err(&psIntfAdapter->udev->dev,
632 "could not allocate interrupt_out_buffer\n");
638 usb_set_intfdata(psIntfAdapter->interface, psIntfAdapter);
640 psIntfAdapter->psAdapter->bcm_file_download = InterfaceFileDownload;
641 psIntfAdapter->psAdapter->bcm_file_readback_from_chip =
642 InterfaceFileReadbackFromChip;
643 psIntfAdapter->psAdapter->interface_transmit = InterfaceTransmitPacket;
645 retval = CreateInterruptUrb(psIntfAdapter);
649 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cannot create interrupt urb");
653 retval = AllocUsbCb(psIntfAdapter);
660 return device_run(psIntfAdapter);
663 static int InterfaceSuspend (struct usb_interface *intf, pm_message_t message)
665 PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf);
667 psIntfAdapter->bSuspended = TRUE;
669 if(TRUE == psIntfAdapter->bPreparingForBusSuspend)
671 psIntfAdapter->bPreparingForBusSuspend = FALSE;
673 if(psIntfAdapter->psAdapter->LinkStatus == LINKUP_DONE)
675 psIntfAdapter->psAdapter->IdleMode = TRUE ;
676 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Host Entered in PMU Idle Mode..");
680 psIntfAdapter->psAdapter->bShutStatus = TRUE;
681 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Host Entered in PMU Shutdown Mode..");
684 psIntfAdapter->psAdapter->bPreparingForLowPowerMode = FALSE;
686 //Signaling the control pkt path
687 wake_up(&psIntfAdapter->psAdapter->lowpower_mode_wait_queue);
692 static int InterfaceResume (struct usb_interface *intf)
694 PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf);
695 printk("=================================\n");
697 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
698 intf->pm_usage_cnt =1 ;
700 psIntfAdapter->bSuspended = FALSE;
702 StartInterruptUrb(psIntfAdapter);
703 InterfaceRx(psIntfAdapter);
707 static struct usb_driver usbbcm_driver = {
709 .probe = usbbcm_device_probe,
710 .disconnect = usbbcm_disconnect,
711 .suspend = InterfaceSuspend,
712 .resume = InterfaceResume,
713 .id_table = InterfaceUsbtable,
714 .supports_autosuspend = 1,
717 struct class *bcm_class;
720 static __init int bcm_init(void)
722 printk(KERN_INFO "%s: %s, %s\n", DRV_NAME, DRV_DESCRIPTION, DRV_VERSION);
723 printk(KERN_INFO "%s\n", DRV_COPYRIGHT);
725 bcm_class = class_create(THIS_MODULE, DRV_NAME);
726 if (IS_ERR(bcm_class)) {
727 printk(KERN_ERR DRV_NAME ": could not create class\n");
728 return PTR_ERR(bcm_class);
731 return usb_register(&usbbcm_driver);
734 static __exit void bcm_exit(void)
736 class_destroy (bcm_class);
738 usb_deregister(&usbbcm_driver);
741 module_init(bcm_init);
742 module_exit(bcm_exit);
744 MODULE_DESCRIPTION(DRV_DESCRIPTION);
745 MODULE_VERSION(DRV_VERSION);
746 MODULE_LICENSE ("GPL");