2010-09-08 21:46:36 +00:00
|
|
|
#include "headers.h"
|
|
|
|
|
|
|
|
static struct usb_device_id InterfaceUsbtable[] = {
|
2010-12-06 07:02:11 +00:00
|
|
|
{ USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3) },
|
2010-09-08 21:46:36 +00:00
|
|
|
{ USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3B) },
|
|
|
|
{ USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3L) },
|
2010-12-06 07:02:11 +00:00
|
|
|
{ USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_SM250) },
|
|
|
|
{ USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_226) },
|
2010-09-08 21:46:36 +00:00
|
|
|
{ USB_DEVICE(BCM_USB_VENDOR_ID_FOXCONN, BCM_USB_PRODUCT_ID_1901) },
|
2010-12-06 07:02:11 +00:00
|
|
|
{ USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_ZTE_TU25) },
|
|
|
|
{ }
|
2010-09-08 21:46:36 +00:00
|
|
|
};
|
2010-10-29 14:44:45 +00:00
|
|
|
MODULE_DEVICE_TABLE(usb, InterfaceUsbtable);
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-11-01 18:06:24 +00:00
|
|
|
static int debug = -1;
|
|
|
|
module_param(debug, uint, 0600);
|
|
|
|
MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
|
|
|
|
|
|
|
|
static const u32 default_msg =
|
2010-12-06 07:02:11 +00:00
|
|
|
NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK
|
|
|
|
| NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR
|
|
|
|
| NETIF_MSG_IFUP | NETIF_MSG_IFDOWN;
|
2010-11-01 18:06:24 +00:00
|
|
|
|
2010-12-06 07:01:41 +00:00
|
|
|
static int InterfaceAdapterInit(PS_INTERFACE_ADAPTER Adapter);
|
2010-11-01 16:24:00 +00:00
|
|
|
|
2010-12-06 07:01:41 +00:00
|
|
|
static void InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter)
|
2010-09-08 21:46:36 +00:00
|
|
|
{
|
2010-12-06 07:01:41 +00:00
|
|
|
int i = 0;
|
2010-12-06 07:02:11 +00:00
|
|
|
|
|
|
|
/* Wake up the wait_queue... */
|
|
|
|
if (psIntfAdapter->psAdapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
|
2010-09-08 21:46:36 +00:00
|
|
|
psIntfAdapter->psAdapter->DriverState = DRIVER_HALT;
|
|
|
|
wake_up(&psIntfAdapter->psAdapter->LEDInfo.notify_led_event);
|
|
|
|
}
|
|
|
|
reset_card_proc(psIntfAdapter->psAdapter);
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
/*
|
|
|
|
* worst case time taken by the RDM/WRM will be 5 sec. will check after every 100 ms
|
|
|
|
* to accertain the device is not being accessed. After this No RDM/WRM should be made.
|
|
|
|
*/
|
|
|
|
while (psIntfAdapter->psAdapter->DeviceAccess) {
|
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
2010-12-06 07:03:13 +00:00
|
|
|
"Device is being accessed.\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
msleep(100);
|
|
|
|
}
|
|
|
|
/* Free interrupt URB */
|
2010-12-06 07:02:11 +00:00
|
|
|
/* psIntfAdapter->psAdapter->device_removed = TRUE; */
|
2010-12-06 07:03:38 +00:00
|
|
|
usb_free_urb(psIntfAdapter->psInterruptUrb);
|
2010-09-08 21:46:36 +00:00
|
|
|
|
|
|
|
/* Free transmit URBs */
|
2010-12-06 07:02:11 +00:00
|
|
|
for (i = 0; i < MAXIMUM_USB_TCB; i++) {
|
|
|
|
if (psIntfAdapter->asUsbTcb[i].urb != NULL) {
|
2010-09-08 21:46:36 +00:00
|
|
|
usb_free_urb(psIntfAdapter->asUsbTcb[i].urb);
|
|
|
|
psIntfAdapter->asUsbTcb[i].urb = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Free receive URB and buffers */
|
2010-12-06 07:02:11 +00:00
|
|
|
for (i = 0; i < MAXIMUM_USB_RCB; i++) {
|
|
|
|
if (psIntfAdapter->asUsbRcb[i].urb != NULL) {
|
2010-11-01 13:35:21 +00:00
|
|
|
kfree(psIntfAdapter->asUsbRcb[i].urb->transfer_buffer);
|
2010-09-08 21:46:36 +00:00
|
|
|
usb_free_urb(psIntfAdapter->asUsbRcb[i].urb);
|
|
|
|
psIntfAdapter->asUsbRcb[i].urb = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AdapterFree(psIntfAdapter->psAdapter);
|
|
|
|
}
|
|
|
|
|
2010-12-06 07:01:41 +00:00
|
|
|
static void ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter)
|
2010-09-08 21:46:36 +00:00
|
|
|
{
|
2010-12-06 07:01:41 +00:00
|
|
|
unsigned long ulReg = 0;
|
2011-11-06 14:40:11 +00:00
|
|
|
int bytes;
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
/* Program EP2 MAX_PKT_SIZE */
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg = ntohl(EP2_MPS_REG);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x128, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg = ntohl(EP2_MPS);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x12C, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
|
|
|
|
ulReg = ntohl(EP2_CFG_REG);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x132, 4, TRUE);
|
|
|
|
if (((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter))->bHighSpeedDevice == TRUE) {
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg = ntohl(EP2_CFG_INT);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x136, 4, TRUE);
|
|
|
|
} else {
|
|
|
|
/* USE BULK EP as TX in FS mode. */
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg = ntohl(EP2_CFG_BULK);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x136, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
/* Program EP4 MAX_PKT_SIZE. */
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg = ntohl(EP4_MPS_REG);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x13C, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg = ntohl(EP4_MPS);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x140, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
/* Program TX EP as interrupt(Alternate Setting) */
|
2011-11-06 14:40:11 +00:00
|
|
|
bytes = rdmalt(Adapter, 0x0F0110F8, (u32 *)&ulReg, sizeof(u32));
|
|
|
|
if (bytes < 0) {
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"reading of Tx EP failed\n");
|
2010-12-06 07:02:11 +00:00
|
|
|
return;
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
ulReg |= 0x6;
|
|
|
|
|
|
|
|
ulReg = ntohl(ulReg);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1CC, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
|
|
|
|
ulReg = ntohl(EP4_CFG_REG);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1C8, 4, TRUE);
|
|
|
|
/* Program ISOCHRONOUS EP size to zero. */
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg = ntohl(ISO_MPS_REG);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1D2, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg = ntohl(ISO_MPS);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1D6, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
/*
|
|
|
|
* Update EEPROM Version.
|
|
|
|
* Read 4 bytes from 508 and modify 511 and 510.
|
|
|
|
*/
|
|
|
|
ReadBeceemEEPROM(Adapter, 0x1FC, (PUINT)&ulReg);
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg &= 0x0101FFFF;
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1FC, 4, TRUE);
|
|
|
|
|
|
|
|
/* Update length field if required. Also make the string NULL terminated. */
|
|
|
|
|
|
|
|
ReadBeceemEEPROM(Adapter, 0xA8, (PUINT)&ulReg);
|
|
|
|
if ((ulReg&0x00FF0000)>>16 > 0x30) {
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg = (ulReg&0xFF00FFFF)|(0x30<<16);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0xA8, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
2010-12-06 07:02:11 +00:00
|
|
|
ReadBeceemEEPROM(Adapter, 0x148, (PUINT)&ulReg);
|
|
|
|
if ((ulReg&0x00FF0000)>>16 > 0x30) {
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg = (ulReg&0xFF00FFFF)|(0x30<<16);
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x148, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
ulReg = 0;
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x122, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
ulReg = 0;
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&ulReg, 0x1C2, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
2011-10-11 01:01:48 +00:00
|
|
|
static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
2010-09-08 21:46:36 +00:00
|
|
|
{
|
2010-12-06 07:02:11 +00:00
|
|
|
struct usb_device *udev = interface_to_usbdev(intf);
|
2010-11-01 13:52:14 +00:00
|
|
|
int retval;
|
|
|
|
PMINI_ADAPTER psAdapter;
|
|
|
|
PS_INTERFACE_ADAPTER psIntfAdapter;
|
|
|
|
struct net_device *ndev;
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-11-01 04:04:52 +00:00
|
|
|
/* Reserve one extra queue for the bit-bucket */
|
|
|
|
ndev = alloc_etherdev_mq(sizeof(MINI_ADAPTER), NO_OF_QUEUES+1);
|
2010-12-06 07:02:11 +00:00
|
|
|
if (ndev == NULL) {
|
2010-11-01 13:52:14 +00:00
|
|
|
dev_err(&udev->dev, DRV_NAME ": no memory for device\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2010-11-01 13:52:14 +00:00
|
|
|
SET_NETDEV_DEV(ndev, &intf->dev);
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-11-01 13:52:14 +00:00
|
|
|
psAdapter = netdev_priv(ndev);
|
|
|
|
psAdapter->dev = ndev;
|
2010-11-01 18:06:24 +00:00
|
|
|
psAdapter->msg_enable = netif_msg_init(debug, default_msg);
|
2010-11-01 13:52:14 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
/* Init default driver debug state */
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-11-01 16:12:31 +00:00
|
|
|
psAdapter->stDebugState.debug_level = DBG_LVL_CURR;
|
2010-09-08 21:46:36 +00:00
|
|
|
psAdapter->stDebugState.type = DBG_TYPE_INITEXIT;
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
/*
|
|
|
|
* Technically, one can start using BCM_DEBUG_PRINT after this point.
|
2010-09-08 21:46:36 +00:00
|
|
|
* However, realize that by default the Type/Subtype bitmaps are all zero now;
|
|
|
|
* so no prints will actually appear until the TestApp turns on debug paths via
|
|
|
|
* the ioctl(); so practically speaking, in early init, no logging happens.
|
|
|
|
*
|
|
|
|
* A solution (used below): we explicitly set the bitmaps to 1 for Type=DBG_TYPE_INITEXIT
|
|
|
|
* and ALL subtype's of the same. Now all bcm debug statements get logged, enabling debug
|
|
|
|
* during early init.
|
|
|
|
* Further, we turn this OFF once init_module() completes.
|
|
|
|
*/
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xff;
|
2010-09-08 21:46:36 +00:00
|
|
|
BCM_SHOW_DEBUG_BITMAP(psAdapter);
|
|
|
|
|
|
|
|
retval = InitAdapter(psAdapter);
|
2010-12-06 07:02:11 +00:00
|
|
|
if (retval) {
|
2010-11-01 13:52:14 +00:00
|
|
|
dev_err(&udev->dev, DRV_NAME ": InitAdapter Failed\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
AdapterFree(psAdapter);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate interface adapter structure */
|
2010-11-01 13:52:14 +00:00
|
|
|
psIntfAdapter = kzalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL);
|
2010-12-06 07:02:11 +00:00
|
|
|
if (psIntfAdapter == NULL) {
|
2010-11-01 13:52:14 +00:00
|
|
|
dev_err(&udev->dev, DRV_NAME ": no memory for Interface adapter\n");
|
2010-12-06 07:02:11 +00:00
|
|
|
AdapterFree(psAdapter);
|
2010-09-08 21:46:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2010-11-01 13:52:14 +00:00
|
|
|
psAdapter->pvInterfaceAdapter = psIntfAdapter;
|
2010-09-08 21:46:36 +00:00
|
|
|
psIntfAdapter->psAdapter = psAdapter;
|
|
|
|
|
|
|
|
/* Store usb interface in Interface Adapter */
|
|
|
|
psIntfAdapter->interface = intf;
|
|
|
|
usb_set_intfdata(intf, psIntfAdapter);
|
|
|
|
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"psIntfAdapter 0x%p\n", psIntfAdapter);
|
2010-09-08 21:46:36 +00:00
|
|
|
retval = InterfaceAdapterInit(psIntfAdapter);
|
2010-12-06 07:02:11 +00:00
|
|
|
if (retval) {
|
2010-09-08 21:46:36 +00:00
|
|
|
/* If the Firmware/Cfg File is not present
|
2010-12-06 07:02:11 +00:00
|
|
|
* then return success, let the application
|
|
|
|
* download the files.
|
|
|
|
*/
|
|
|
|
if (-ENOENT == retval) {
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"File Not Found. Use app to download.\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"InterfaceAdapterInit failed.\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
usb_set_intfdata(intf, NULL);
|
2010-12-06 07:02:11 +00:00
|
|
|
udev = interface_to_usbdev(intf);
|
2010-09-08 21:46:36 +00:00
|
|
|
usb_put_dev(udev);
|
|
|
|
InterfaceAdapterFree(psIntfAdapter);
|
2010-12-06 07:02:11 +00:00
|
|
|
return retval;
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
2010-12-06 07:02:11 +00:00
|
|
|
if (psAdapter->chip_id > T3) {
|
|
|
|
uint32_t uiNackZeroLengthInt = 4;
|
|
|
|
|
2010-12-06 07:03:38 +00:00
|
|
|
retval = wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, &uiNackZeroLengthInt, sizeof(uiNackZeroLengthInt));
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check whether the USB-Device Supports remote Wake-Up */
|
2010-12-06 07:02:11 +00:00
|
|
|
if (USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes) {
|
2010-09-08 21:46:36 +00:00
|
|
|
/* If Suspend then only support dynamic suspend */
|
2010-12-06 07:02:11 +00:00
|
|
|
if (psAdapter->bDoSuspend) {
|
2010-09-14 22:39:50 +00:00
|
|
|
#ifdef CONFIG_PM
|
2010-11-17 15:56:01 +00:00
|
|
|
pm_runtime_set_autosuspend_delay(&udev->dev, 0);
|
2010-09-08 21:46:36 +00:00
|
|
|
intf->needs_remote_wakeup = 1;
|
|
|
|
usb_enable_autosuspend(udev);
|
2010-12-06 07:02:11 +00:00
|
|
|
device_init_wakeup(&intf->dev, 1);
|
2010-09-08 21:46:36 +00:00
|
|
|
INIT_WORK(&psIntfAdapter->usbSuspendWork, putUsbSuspend);
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"Enabling USB Auto-Suspend\n");
|
2010-09-14 22:39:50 +00:00
|
|
|
#endif
|
2010-12-06 07:02:11 +00:00
|
|
|
} else {
|
2010-09-08 21:46:36 +00:00
|
|
|
intf->needs_remote_wakeup = 0;
|
|
|
|
usb_disable_autosuspend(udev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0x0;
|
|
|
|
return retval;
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
static void usbbcm_disconnect(struct usb_interface *intf)
|
2010-09-08 21:46:36 +00:00
|
|
|
{
|
2010-11-01 18:06:24 +00:00
|
|
|
PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf);
|
|
|
|
PMINI_ADAPTER psAdapter;
|
2010-12-06 07:02:11 +00:00
|
|
|
struct usb_device *udev = interface_to_usbdev(intf);
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (psIntfAdapter == NULL)
|
2010-09-08 21:46:36 +00:00
|
|
|
return;
|
2010-11-01 18:06:24 +00:00
|
|
|
|
2010-09-08 21:46:36 +00:00
|
|
|
psAdapter = psIntfAdapter->psAdapter;
|
2010-11-01 18:06:24 +00:00
|
|
|
netif_device_detach(psAdapter->dev);
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (psAdapter->bDoSuspend)
|
2010-09-08 21:46:36 +00:00
|
|
|
intf->needs_remote_wakeup = 0;
|
|
|
|
|
|
|
|
psAdapter->device_removed = TRUE ;
|
|
|
|
usb_set_intfdata(intf, NULL);
|
|
|
|
InterfaceAdapterFree(psIntfAdapter);
|
|
|
|
usb_put_dev(udev);
|
|
|
|
}
|
|
|
|
|
2010-11-01 03:52:36 +00:00
|
|
|
static int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter)
|
2010-09-08 21:46:36 +00:00
|
|
|
{
|
|
|
|
int i = 0;
|
2010-12-06 07:02:11 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAXIMUM_USB_TCB; i++) {
|
2011-10-11 01:01:49 +00:00
|
|
|
psIntfAdapter->asUsbTcb[i].urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
|
|
|
|
if (psIntfAdapter->asUsbTcb[i].urb == NULL) {
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0,
|
|
|
|
"Can't allocate Tx urb for index %d\n", i);
|
2010-09-08 21:46:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
for (i = 0; i < MAXIMUM_USB_RCB; i++) {
|
2011-10-11 01:01:49 +00:00
|
|
|
psIntfAdapter->asUsbRcb[i].urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
|
|
|
|
if (psIntfAdapter->asUsbRcb[i].urb == NULL) {
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0,
|
|
|
|
"Can't allocate Rx urb for index %d\n", i);
|
2010-09-08 21:46:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2011-10-11 01:01:49 +00:00
|
|
|
|
|
|
|
psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL);
|
|
|
|
|
|
|
|
if (psIntfAdapter->asUsbRcb[i].urb->transfer_buffer == NULL) {
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0,
|
|
|
|
"Can't allocate Rx buffer for index %d\n", i);
|
2010-09-08 21:46:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length = MAX_DATA_BUFFER_SIZE;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int device_run(PS_INTERFACE_ADAPTER psIntfAdapter)
|
|
|
|
{
|
2010-12-06 07:01:41 +00:00
|
|
|
int value = 0;
|
2010-09-08 21:46:36 +00:00
|
|
|
UINT status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
status = InitCardAndDownloadFirmware(psIntfAdapter->psAdapter);
|
2010-12-06 07:02:11 +00:00
|
|
|
if (status != STATUS_SUCCESS) {
|
2010-11-01 16:14:01 +00:00
|
|
|
pr_err(DRV_NAME "InitCardAndDownloadFirmware failed.\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
return status;
|
|
|
|
}
|
2010-12-06 07:02:11 +00:00
|
|
|
if (TRUE == psIntfAdapter->psAdapter->fw_download_done) {
|
|
|
|
if (StartInterruptUrb(psIntfAdapter)) {
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"Cannot send interrupt in URB\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
/*
|
|
|
|
* now register the cntrl interface.
|
|
|
|
* after downloading the f/w waiting for 5 sec to get the mailbox interrupt.
|
|
|
|
*/
|
2010-09-08 21:46:36 +00:00
|
|
|
psIntfAdapter->psAdapter->waiting_to_fw_download_done = FALSE;
|
|
|
|
value = wait_event_timeout(psIntfAdapter->psAdapter->ioctl_fw_dnld_wait_queue,
|
|
|
|
psIntfAdapter->psAdapter->waiting_to_fw_download_done, 5*HZ);
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (value == 0)
|
2010-12-06 07:03:13 +00:00
|
|
|
pr_err(DRV_NAME ": Timeout waiting for mailbox interrupt.\n");
|
2010-11-01 16:14:01 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (register_control_device_interface(psIntfAdapter->psAdapter) < 0) {
|
2010-12-06 07:03:13 +00:00
|
|
|
pr_err(DRV_NAME ": Register Control Device failed.\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
|
|
|
return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
|
|
|
return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
|
|
|
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
|
|
|
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
|
|
|
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
|
|
|
USB_ENDPOINT_XFER_BULK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_xfer_control(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
|
|
|
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
|
|
|
USB_ENDPOINT_XFER_CONTROL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
|
|
|
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
|
|
|
USB_ENDPOINT_XFER_INT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
|
|
|
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
|
|
|
|
USB_ENDPOINT_XFER_ISOC);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2011-10-11 01:01:48 +00:00
|
|
|
return bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_in(epd);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2011-10-11 01:01:48 +00:00
|
|
|
return bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_out(epd);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2011-10-11 01:01:48 +00:00
|
|
|
return bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_in(epd);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2011-10-11 01:01:48 +00:00
|
|
|
return bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_out(epd);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2011-10-11 01:01:48 +00:00
|
|
|
return bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_in(epd);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int bcm_usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2011-10-11 01:01:48 +00:00
|
|
|
return bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_out(epd);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 07:01:41 +00:00
|
|
|
static int InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter)
|
2010-09-08 21:46:36 +00:00
|
|
|
{
|
|
|
|
struct usb_host_interface *iface_desc;
|
|
|
|
struct usb_endpoint_descriptor *endpoint;
|
|
|
|
size_t buffer_size;
|
2010-12-06 07:01:41 +00:00
|
|
|
unsigned long value;
|
|
|
|
int retval = 0;
|
|
|
|
int usedIntOutForBulkTransfer = 0 ;
|
2010-09-08 21:46:36 +00:00
|
|
|
BOOLEAN bBcm16 = FALSE;
|
|
|
|
UINT uiData = 0;
|
2011-11-06 14:40:11 +00:00
|
|
|
int bytes;
|
2010-09-08 21:46:36 +00:00
|
|
|
|
|
|
|
/* Store the usb dev into interface adapter */
|
2010-11-01 16:14:01 +00:00
|
|
|
psIntfAdapter->udev = usb_get_dev(interface_to_usbdev(psIntfAdapter->interface));
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-11-01 16:14:01 +00:00
|
|
|
psIntfAdapter->bHighSpeedDevice = (psIntfAdapter->udev->speed == USB_SPEED_HIGH);
|
2010-09-08 21:46:36 +00:00
|
|
|
psIntfAdapter->psAdapter->interface_rdm = BcmRDM;
|
|
|
|
psIntfAdapter->psAdapter->interface_wrm = BcmWRM;
|
|
|
|
|
2011-11-06 14:40:11 +00:00
|
|
|
bytes = rdmalt(psIntfAdapter->psAdapter, CHIP_ID_REG,
|
2010-12-06 07:03:38 +00:00
|
|
|
(u32 *)&(psIntfAdapter->psAdapter->chip_id), sizeof(u32));
|
2011-11-06 14:40:11 +00:00
|
|
|
if (bytes < 0) {
|
|
|
|
retval = bytes;
|
2010-12-06 07:02:11 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0, "CHIP ID Read Failed\n");
|
2010-12-06 07:03:38 +00:00
|
|
|
return retval;
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (0xbece3200 == (psIntfAdapter->psAdapter->chip_id & ~(0xF0)))
|
2010-11-01 16:14:01 +00:00
|
|
|
psIntfAdapter->psAdapter->chip_id &= ~0xF0;
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-11-01 16:14:01 +00:00
|
|
|
dev_info(&psIntfAdapter->udev->dev, "RDM Chip ID 0x%lx\n",
|
|
|
|
psIntfAdapter->psAdapter->chip_id);
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-11-01 16:14:01 +00:00
|
|
|
iface_desc = psIntfAdapter->interface->cur_altsetting;
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (psIntfAdapter->psAdapter->chip_id == T3B) {
|
|
|
|
/* T3B device will have EEPROM, check if EEPROM is proper and BCM16 can be done or not. */
|
|
|
|
BeceemEEPROMBulkRead(psIntfAdapter->psAdapter, &uiData, 0x0, 4);
|
|
|
|
if (uiData == BECM)
|
2010-09-08 21:46:36 +00:00
|
|
|
bBcm16 = TRUE;
|
2010-11-01 16:14:01 +00:00
|
|
|
|
|
|
|
dev_info(&psIntfAdapter->udev->dev, "number of alternate setting %d\n",
|
|
|
|
psIntfAdapter->interface->num_altsetting);
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (bBcm16 == TRUE) {
|
|
|
|
/* selecting alternate setting one as a default setting for High Speed modem. */
|
|
|
|
if (psIntfAdapter->bHighSpeedDevice)
|
2011-10-11 01:01:48 +00:00
|
|
|
retval = usb_set_interface(psIntfAdapter->udev, DEFAULT_SETTING_0, ALTERNATE_SETTING_1);
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"BCM16 is applicable on this dongle\n");
|
2010-12-06 07:02:11 +00:00
|
|
|
if (retval || (psIntfAdapter->bHighSpeedDevice == FALSE)) {
|
2010-09-08 21:46:36 +00:00
|
|
|
usedIntOutForBulkTransfer = EP2 ;
|
|
|
|
endpoint = &iface_desc->endpoint[EP2].desc;
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"Interface altsetting failed or modem is configured to Full Speed, hence will work on default setting 0\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
/*
|
2010-12-06 07:02:11 +00:00
|
|
|
* If Modem is high speed device EP2 should be INT OUT End point
|
|
|
|
* If Mode is FS then EP2 should be bulk end point
|
|
|
|
*/
|
|
|
|
if (((psIntfAdapter->bHighSpeedDevice == TRUE) && (bcm_usb_endpoint_is_int_out(endpoint) == FALSE))
|
|
|
|
|| ((psIntfAdapter->bHighSpeedDevice == FALSE) && (bcm_usb_endpoint_is_bulk_out(endpoint) == FALSE))) {
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"Configuring the EEPROM\n");
|
2010-12-06 07:02:11 +00:00
|
|
|
/* change the EP2, EP4 to INT OUT end point */
|
2010-09-08 21:46:36 +00:00
|
|
|
ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter);
|
|
|
|
|
|
|
|
/*
|
2010-12-06 07:02:11 +00:00
|
|
|
* It resets the device and if any thing gets changed
|
|
|
|
* in USB descriptor it will show fail and re-enumerate
|
|
|
|
* the device
|
|
|
|
*/
|
2010-09-08 21:46:36 +00:00
|
|
|
retval = usb_reset_device(psIntfAdapter->udev);
|
2010-12-06 07:02:11 +00:00
|
|
|
if (retval) {
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"reset failed. Re-enumerating the device.\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
return retval ;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-12-06 07:02:11 +00:00
|
|
|
if ((psIntfAdapter->bHighSpeedDevice == FALSE) && bcm_usb_endpoint_is_bulk_out(endpoint)) {
|
|
|
|
/* Once BULK is selected in FS mode. Revert it back to INT. Else USB_IF will fail. */
|
2010-09-30 08:24:12 +00:00
|
|
|
UINT _uiData = ntohl(EP2_CFG_INT);
|
2011-10-11 01:01:48 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
2010-12-06 07:03:13 +00:00
|
|
|
"Reverting Bulk to INT as it is in Full Speed mode.\n");
|
2010-12-06 07:02:11 +00:00
|
|
|
BeceemEEPROMBulkWrite(psIntfAdapter->psAdapter, (PUCHAR)&_uiData, 0x136, 4, TRUE);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
2010-12-06 07:02:11 +00:00
|
|
|
} else {
|
2010-09-08 21:46:36 +00:00
|
|
|
usedIntOutForBulkTransfer = EP4 ;
|
|
|
|
endpoint = &iface_desc->endpoint[EP4].desc;
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"Choosing AltSetting as a default setting.\n");
|
2010-12-06 07:02:11 +00:00
|
|
|
if (bcm_usb_endpoint_is_int_out(endpoint) == FALSE) {
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"Dongle does not have BCM16 Fix.\n");
|
2010-12-06 07:02:11 +00:00
|
|
|
/* change the EP2, EP4 to INT OUT end point and use EP4 in altsetting */
|
2010-09-08 21:46:36 +00:00
|
|
|
ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter);
|
|
|
|
|
|
|
|
/*
|
2010-12-06 07:02:11 +00:00
|
|
|
* It resets the device and if any thing gets changed in
|
|
|
|
* USB descriptor it will show fail and re-enumerate the
|
|
|
|
* device
|
|
|
|
*/
|
2010-09-08 21:46:36 +00:00
|
|
|
retval = usb_reset_device(psIntfAdapter->udev);
|
2010-12-06 07:02:11 +00:00
|
|
|
if (retval) {
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"reset failed. Re-enumerating the device.\n");
|
2010-12-06 07:02:11 +00:00
|
|
|
return retval;
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
iface_desc = psIntfAdapter->interface->cur_altsetting;
|
2010-11-01 16:14:01 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value) {
|
2010-11-01 16:14:01 +00:00
|
|
|
endpoint = &iface_desc->endpoint[value].desc;
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && bcm_usb_endpoint_is_bulk_in(endpoint)) {
|
|
|
|
buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
|
|
|
|
psIntfAdapter->sBulkIn.bulk_in_size = buffer_size;
|
|
|
|
psIntfAdapter->sBulkIn.bulk_in_endpointAddr = endpoint->bEndpointAddress;
|
|
|
|
psIntfAdapter->sBulkIn.bulk_in_pipe =
|
2010-09-08 21:46:36 +00:00
|
|
|
usb_rcvbulkpipe(psIntfAdapter->udev,
|
|
|
|
psIntfAdapter->sBulkIn.bulk_in_endpointAddr);
|
2010-12-06 07:02:11 +00:00
|
|
|
}
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && bcm_usb_endpoint_is_bulk_out(endpoint)) {
|
|
|
|
psIntfAdapter->sBulkOut.bulk_out_endpointAddr = endpoint->bEndpointAddress;
|
|
|
|
psIntfAdapter->sBulkOut.bulk_out_pipe =
|
|
|
|
usb_sndbulkpipe(psIntfAdapter->udev,
|
2010-09-08 21:46:36 +00:00
|
|
|
psIntfAdapter->sBulkOut.bulk_out_endpointAddr);
|
2010-12-06 07:02:11 +00:00
|
|
|
}
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && bcm_usb_endpoint_is_int_in(endpoint)) {
|
|
|
|
buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
|
|
|
|
psIntfAdapter->sIntrIn.int_in_size = buffer_size;
|
|
|
|
psIntfAdapter->sIntrIn.int_in_endpointAddr = endpoint->bEndpointAddress;
|
|
|
|
psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval;
|
|
|
|
psIntfAdapter->sIntrIn.int_in_buffer =
|
2010-09-08 21:46:36 +00:00
|
|
|
kmalloc(buffer_size, GFP_KERNEL);
|
2010-12-06 07:02:11 +00:00
|
|
|
if (!psIntfAdapter->sIntrIn.int_in_buffer) {
|
2010-11-01 16:14:01 +00:00
|
|
|
dev_err(&psIntfAdapter->udev->dev,
|
2010-12-06 07:02:11 +00:00
|
|
|
"could not allocate interrupt_in_buffer\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint)) {
|
|
|
|
if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr &&
|
|
|
|
(psIntfAdapter->psAdapter->chip_id == T3B) && (value == usedIntOutForBulkTransfer)) {
|
|
|
|
/* use first intout end point as a bulk out end point */
|
|
|
|
buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
|
|
|
|
psIntfAdapter->sBulkOut.bulk_out_size = buffer_size;
|
|
|
|
psIntfAdapter->sBulkOut.bulk_out_endpointAddr = endpoint->bEndpointAddress;
|
|
|
|
psIntfAdapter->sBulkOut.bulk_out_pipe = usb_sndintpipe(psIntfAdapter->udev,
|
|
|
|
psIntfAdapter->sBulkOut.bulk_out_endpointAddr);
|
|
|
|
psIntfAdapter->sBulkOut.int_out_interval = endpoint->bInterval;
|
|
|
|
} else if (value == EP6) {
|
|
|
|
buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
|
|
|
|
psIntfAdapter->sIntrOut.int_out_size = buffer_size;
|
|
|
|
psIntfAdapter->sIntrOut.int_out_endpointAddr = endpoint->bEndpointAddress;
|
|
|
|
psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval;
|
2011-10-11 01:01:48 +00:00
|
|
|
psIntfAdapter->sIntrOut.int_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
|
2010-12-06 07:02:11 +00:00
|
|
|
if (!psIntfAdapter->sIntrOut.int_out_buffer) {
|
|
|
|
dev_err(&psIntfAdapter->udev->dev,
|
|
|
|
"could not allocate interrupt_out_buffer\n");
|
2010-11-01 16:14:01 +00:00
|
|
|
return -EINVAL;
|
2010-12-06 07:02:11 +00:00
|
|
|
}
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
2010-12-06 07:02:11 +00:00
|
|
|
}
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
usb_set_intfdata(psIntfAdapter->interface, psIntfAdapter);
|
2010-09-08 21:46:36 +00:00
|
|
|
|
|
|
|
psIntfAdapter->psAdapter->bcm_file_download = InterfaceFileDownload;
|
|
|
|
psIntfAdapter->psAdapter->bcm_file_readback_from_chip =
|
|
|
|
InterfaceFileReadbackFromChip;
|
|
|
|
psIntfAdapter->psAdapter->interface_transmit = InterfaceTransmitPacket;
|
|
|
|
|
|
|
|
retval = CreateInterruptUrb(psIntfAdapter);
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (retval) {
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_PRINTK, 0, 0,
|
|
|
|
"Cannot create interrupt urb\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = AllocUsbCb(psIntfAdapter);
|
2010-12-06 07:03:38 +00:00
|
|
|
if (retval)
|
2010-09-08 21:46:36 +00:00
|
|
|
return retval;
|
|
|
|
|
2010-11-01 14:03:29 +00:00
|
|
|
return device_run(psIntfAdapter);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
2010-09-30 08:24:12 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
static int InterfaceSuspend(struct usb_interface *intf, pm_message_t message)
|
2010-09-08 21:46:36 +00:00
|
|
|
{
|
|
|
|
PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf);
|
2010-11-01 16:14:01 +00:00
|
|
|
|
2010-09-08 21:46:36 +00:00
|
|
|
psIntfAdapter->bSuspended = TRUE;
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (TRUE == psIntfAdapter->bPreparingForBusSuspend) {
|
2010-09-08 21:46:36 +00:00
|
|
|
psIntfAdapter->bPreparingForBusSuspend = FALSE;
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
if (psIntfAdapter->psAdapter->LinkStatus == LINKUP_DONE) {
|
2010-09-08 21:46:36 +00:00
|
|
|
psIntfAdapter->psAdapter->IdleMode = TRUE ;
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"Host Entered in PMU Idle Mode.\n");
|
2010-12-06 07:02:11 +00:00
|
|
|
} else {
|
2010-09-08 21:46:36 +00:00
|
|
|
psIntfAdapter->psAdapter->bShutStatus = TRUE;
|
2010-12-06 07:03:13 +00:00
|
|
|
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,
|
|
|
|
"Host Entered in PMU Shutdown Mode.\n");
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
psIntfAdapter->psAdapter->bPreparingForLowPowerMode = FALSE;
|
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
/* Signaling the control pkt path */
|
2010-09-08 21:46:36 +00:00
|
|
|
wake_up(&psIntfAdapter->psAdapter->lowpower_mode_wait_queue);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2010-09-30 08:24:12 +00:00
|
|
|
|
2010-12-06 07:02:11 +00:00
|
|
|
static int InterfaceResume(struct usb_interface *intf)
|
2010-09-08 21:46:36 +00:00
|
|
|
{
|
2010-12-06 07:02:11 +00:00
|
|
|
PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf);
|
2010-12-06 07:02:36 +00:00
|
|
|
|
2011-10-11 01:01:48 +00:00
|
|
|
mdelay(100);
|
2010-09-08 21:46:36 +00:00
|
|
|
psIntfAdapter->bSuspended = FALSE;
|
|
|
|
|
|
|
|
StartInterruptUrb(psIntfAdapter);
|
|
|
|
InterfaceRx(psIntfAdapter);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-09-30 08:24:12 +00:00
|
|
|
|
2010-09-08 21:46:36 +00:00
|
|
|
static struct usb_driver usbbcm_driver = {
|
2010-12-06 07:02:11 +00:00
|
|
|
.name = "usbbcm",
|
|
|
|
.probe = usbbcm_device_probe,
|
|
|
|
.disconnect = usbbcm_disconnect,
|
|
|
|
.suspend = InterfaceSuspend,
|
|
|
|
.resume = InterfaceResume,
|
|
|
|
.id_table = InterfaceUsbtable,
|
|
|
|
.supports_autosuspend = 1,
|
2010-09-08 21:46:36 +00:00
|
|
|
};
|
|
|
|
|
2010-11-01 14:17:54 +00:00
|
|
|
struct class *bcm_class;
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-11-01 16:14:01 +00:00
|
|
|
static __init int bcm_init(void)
|
2010-09-08 21:46:36 +00:00
|
|
|
{
|
2010-11-01 16:14:01 +00:00
|
|
|
printk(KERN_INFO "%s: %s, %s\n", DRV_NAME, DRV_DESCRIPTION, DRV_VERSION);
|
|
|
|
printk(KERN_INFO "%s\n", DRV_COPYRIGHT);
|
2010-09-08 21:46:36 +00:00
|
|
|
|
2010-11-01 14:17:54 +00:00
|
|
|
bcm_class = class_create(THIS_MODULE, DRV_NAME);
|
|
|
|
if (IS_ERR(bcm_class)) {
|
|
|
|
printk(KERN_ERR DRV_NAME ": could not create class\n");
|
|
|
|
return PTR_ERR(bcm_class);
|
|
|
|
}
|
2010-09-08 21:46:36 +00:00
|
|
|
|
|
|
|
return usb_register(&usbbcm_driver);
|
|
|
|
}
|
|
|
|
|
2010-11-01 16:14:01 +00:00
|
|
|
static __exit void bcm_exit(void)
|
2010-09-08 21:46:36 +00:00
|
|
|
{
|
|
|
|
usb_deregister(&usbbcm_driver);
|
2010-12-06 07:02:55 +00:00
|
|
|
class_destroy(bcm_class);
|
2010-09-08 21:46:36 +00:00
|
|
|
}
|
2010-11-01 16:14:01 +00:00
|
|
|
|
|
|
|
module_init(bcm_init);
|
|
|
|
module_exit(bcm_exit);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION(DRV_DESCRIPTION);
|
|
|
|
MODULE_VERSION(DRV_VERSION);
|
2010-12-06 07:02:11 +00:00
|
|
|
MODULE_LICENSE("GPL");
|