Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1 | #include "headers.h" |
| 2 | |
| 3 | static struct usb_device_id InterfaceUsbtable[] = { |
| 4 | { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3) }, |
Stephen Hemminger | 2e44f76 | 2010-10-29 07:44:45 -0700 | [diff] [blame] | 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) }, |
| 9 | |
| 10 | { } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 11 | }; |
Stephen Hemminger | 2e44f76 | 2010-10-29 07:44:45 -0700 | [diff] [blame] | 12 | MODULE_DEVICE_TABLE(usb, InterfaceUsbtable); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 13 | |
Stephen Hemminger | 2564a14 | 2010-10-29 08:11:12 -0700 | [diff] [blame] | 14 | static unsigned int debug_level = DBG_LVL_CURR; |
| 15 | module_param(debug_level, uint, 0644); |
| 16 | MODULE_PARM_DESC(debug_level, "Debug level (0=none,...,7=all)"); |
| 17 | |
| 18 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 19 | VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter) |
| 20 | { |
| 21 | INT i = 0; |
| 22 | // Wake up the wait_queue... |
| 23 | if(psIntfAdapter->psAdapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) |
| 24 | { |
| 25 | psIntfAdapter->psAdapter->DriverState = DRIVER_HALT; |
| 26 | wake_up(&psIntfAdapter->psAdapter->LEDInfo.notify_led_event); |
| 27 | } |
| 28 | reset_card_proc(psIntfAdapter->psAdapter); |
| 29 | |
| 30 | //worst case time taken by the RDM/WRM will be 5 sec. will check after every 100 ms |
| 31 | //to accertain the device is not being accessed. After this No RDM/WRM should be made. |
| 32 | while(psIntfAdapter->psAdapter->DeviceAccess) |
| 33 | { |
| 34 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Device is being Accessed \n"); |
| 35 | msleep(100); |
| 36 | } |
| 37 | /* Free interrupt URB */ |
| 38 | //psIntfAdapter->psAdapter->device_removed = TRUE; |
| 39 | if(psIntfAdapter->psInterruptUrb) |
| 40 | { |
| 41 | usb_free_urb(psIntfAdapter->psInterruptUrb); |
| 42 | } |
| 43 | |
| 44 | /* Free transmit URBs */ |
| 45 | for(i = 0; i < MAXIMUM_USB_TCB; i++) |
| 46 | { |
| 47 | if(psIntfAdapter->asUsbTcb[i].urb != NULL) |
| 48 | { |
| 49 | usb_free_urb(psIntfAdapter->asUsbTcb[i].urb); |
| 50 | psIntfAdapter->asUsbTcb[i].urb = NULL; |
| 51 | } |
| 52 | } |
| 53 | /* Free receive URB and buffers */ |
| 54 | for(i = 0; i < MAXIMUM_USB_RCB; i++) |
| 55 | { |
| 56 | if (psIntfAdapter->asUsbRcb[i].urb != NULL) |
| 57 | { |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 58 | kfree(psIntfAdapter->asUsbRcb[i].urb->transfer_buffer); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 59 | usb_free_urb(psIntfAdapter->asUsbRcb[i].urb); |
| 60 | psIntfAdapter->asUsbRcb[i].urb = NULL; |
| 61 | } |
| 62 | } |
| 63 | AdapterFree(psIntfAdapter->psAdapter); |
| 64 | } |
| 65 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 66 | VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter) |
| 67 | { |
| 68 | ULONG ulReg = 0; |
| 69 | |
| 70 | // Program EP2 MAX_PKT_SIZE |
| 71 | ulReg = ntohl(EP2_MPS_REG); |
| 72 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x128,4,TRUE); |
| 73 | ulReg = ntohl(EP2_MPS); |
| 74 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x12C,4,TRUE); |
| 75 | |
| 76 | ulReg = ntohl(EP2_CFG_REG); |
| 77 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x132,4,TRUE); |
| 78 | if(((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter))->bHighSpeedDevice == TRUE) |
| 79 | { |
| 80 | ulReg = ntohl(EP2_CFG_INT); |
| 81 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x136,4,TRUE); |
| 82 | } |
| 83 | else |
| 84 | { |
| 85 | // USE BULK EP as TX in FS mode. |
| 86 | ulReg = ntohl(EP2_CFG_BULK); |
| 87 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x136,4,TRUE); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | // Program EP4 MAX_PKT_SIZE. |
| 92 | ulReg = ntohl(EP4_MPS_REG); |
| 93 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x13C,4,TRUE); |
| 94 | ulReg = ntohl(EP4_MPS); |
| 95 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x140,4,TRUE); |
| 96 | |
| 97 | // Program TX EP as interrupt (Alternate Setting) |
| 98 | if( rdmalt(Adapter,0x0F0110F8, (PUINT)&ulReg,4)) |
| 99 | { |
| 100 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reading of Tx EP is failing"); |
| 101 | return ; |
| 102 | } |
| 103 | ulReg |= 0x6; |
| 104 | |
| 105 | ulReg = ntohl(ulReg); |
| 106 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1CC,4,TRUE); |
| 107 | |
| 108 | ulReg = ntohl(EP4_CFG_REG); |
| 109 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1C8,4,TRUE); |
| 110 | // Program ISOCHRONOUS EP size to zero. |
| 111 | ulReg = ntohl(ISO_MPS_REG); |
| 112 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1D2,4,TRUE); |
| 113 | ulReg = ntohl(ISO_MPS); |
| 114 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1D6,4,TRUE); |
| 115 | |
| 116 | // Update EEPROM Version. |
| 117 | // Read 4 bytes from 508 and modify 511 and 510. |
| 118 | // |
| 119 | ReadBeceemEEPROM(Adapter,0x1FC,(PUINT)&ulReg); |
| 120 | ulReg &= 0x0101FFFF; |
| 121 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1FC,4,TRUE); |
| 122 | // |
| 123 | //Update length field if required. Also make the string NULL terminated. |
| 124 | // |
| 125 | ReadBeceemEEPROM(Adapter,0xA8,(PUINT)&ulReg); |
| 126 | if((ulReg&0x00FF0000)>>16 > 0x30) |
| 127 | { |
| 128 | ulReg = (ulReg&0xFF00FFFF)|(0x30<<16); |
| 129 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0xA8,4,TRUE); |
| 130 | } |
| 131 | ReadBeceemEEPROM(Adapter,0x148,(PUINT)&ulReg); |
| 132 | if((ulReg&0x00FF0000)>>16 > 0x30) |
| 133 | { |
| 134 | ulReg = (ulReg&0xFF00FFFF)|(0x30<<16); |
| 135 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x148,4,TRUE); |
| 136 | } |
| 137 | ulReg = 0; |
| 138 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x122,4,TRUE); |
| 139 | ulReg = 0; |
| 140 | BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1C2,4,TRUE); |
| 141 | |
| 142 | } |
| 143 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 144 | static int |
| 145 | usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 146 | { |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 147 | struct usb_device *udev = interface_to_usbdev (intf); |
| 148 | int retval; |
| 149 | PMINI_ADAPTER psAdapter; |
| 150 | PS_INTERFACE_ADAPTER psIntfAdapter; |
| 151 | struct net_device *ndev; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 152 | |
Stephen Hemminger | 0980f2e | 2010-11-01 00:04:52 -0400 | [diff] [blame] | 153 | /* Reserve one extra queue for the bit-bucket */ |
| 154 | ndev = alloc_etherdev_mq(sizeof(MINI_ADAPTER), NO_OF_QUEUES+1); |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 155 | if(ndev == NULL) { |
| 156 | dev_err(&udev->dev, DRV_NAME ": no memory for device\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 157 | return -ENOMEM; |
| 158 | } |
| 159 | |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 160 | SET_NETDEV_DEV(ndev, &intf->dev); |
| 161 | |
| 162 | psAdapter = netdev_priv(ndev); |
| 163 | psAdapter->dev = ndev; |
| 164 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 165 | /* Init default driver debug state */ |
| 166 | |
Stephen Hemminger | 2564a14 | 2010-10-29 08:11:12 -0700 | [diff] [blame] | 167 | psAdapter->stDebugState.debug_level = debug_level; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 168 | psAdapter->stDebugState.type = DBG_TYPE_INITEXIT; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 169 | |
| 170 | /* Technically, one can start using BCM_DEBUG_PRINT after this point. |
| 171 | * However, realize that by default the Type/Subtype bitmaps are all zero now; |
| 172 | * so no prints will actually appear until the TestApp turns on debug paths via |
| 173 | * the ioctl(); so practically speaking, in early init, no logging happens. |
| 174 | * |
| 175 | * A solution (used below): we explicitly set the bitmaps to 1 for Type=DBG_TYPE_INITEXIT |
| 176 | * and ALL subtype's of the same. Now all bcm debug statements get logged, enabling debug |
| 177 | * during early init. |
| 178 | * Further, we turn this OFF once init_module() completes. |
| 179 | */ |
| 180 | |
| 181 | psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xff; |
| 182 | BCM_SHOW_DEBUG_BITMAP(psAdapter); |
| 183 | |
| 184 | retval = InitAdapter(psAdapter); |
| 185 | if(retval) |
| 186 | { |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 187 | dev_err(&udev->dev, DRV_NAME ": InitAdapter Failed\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 188 | AdapterFree(psAdapter); |
| 189 | return retval; |
| 190 | } |
| 191 | |
| 192 | /* Allocate interface adapter structure */ |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 193 | psIntfAdapter = kzalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL); |
| 194 | if (psIntfAdapter == NULL) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 195 | { |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 196 | dev_err(&udev->dev, DRV_NAME ": no memory for Interface adapter\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 197 | AdapterFree (psAdapter); |
| 198 | return -ENOMEM; |
| 199 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 200 | |
Stephen Hemminger | e614e28 | 2010-11-01 09:52:14 -0400 | [diff] [blame] | 201 | psAdapter->pvInterfaceAdapter = psIntfAdapter; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 202 | psIntfAdapter->psAdapter = psAdapter; |
| 203 | |
| 204 | /* Store usb interface in Interface Adapter */ |
| 205 | psIntfAdapter->interface = intf; |
| 206 | usb_set_intfdata(intf, psIntfAdapter); |
| 207 | |
Arnd Bergmann | 9f1c75a | 2010-09-30 10:24:11 +0200 | [diff] [blame] | 208 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%p",psIntfAdapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 209 | retval = InterfaceAdapterInit(psIntfAdapter); |
| 210 | if(retval) |
| 211 | { |
| 212 | /* If the Firmware/Cfg File is not present |
| 213 | * then return success, let the application |
| 214 | * download the files. |
| 215 | */ |
| 216 | if(-ENOENT == retval){ |
| 217 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "File Not Found, Use App to Download\n"); |
| 218 | return STATUS_SUCCESS; |
| 219 | } |
| 220 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapterInit Failed \n"); |
| 221 | usb_set_intfdata(intf, NULL); |
| 222 | udev = interface_to_usbdev (intf); |
| 223 | usb_put_dev(udev); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 224 | InterfaceAdapterFree(psIntfAdapter); |
| 225 | return retval ; |
| 226 | } |
| 227 | if(psAdapter->chip_id > T3) |
| 228 | { |
| 229 | uint32_t uiNackZeroLengthInt=4; |
| 230 | if(wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, &uiNackZeroLengthInt, sizeof(uiNackZeroLengthInt))) |
| 231 | { |
| 232 | return -EIO;; |
| 233 | } |
| 234 | } |
| 235 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 236 | /* Check whether the USB-Device Supports remote Wake-Up */ |
| 237 | if(USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes) |
| 238 | { |
| 239 | /* If Suspend then only support dynamic suspend */ |
| 240 | if(psAdapter->bDoSuspend) |
| 241 | { |
Randy Dunlap | 5fe1f1e | 2010-09-14 15:39:50 -0700 | [diff] [blame] | 242 | #ifdef CONFIG_PM |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 243 | udev->autosuspend_delay = 0; |
| 244 | intf->needs_remote_wakeup = 1; |
| 245 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) |
| 246 | udev->autosuspend_disabled = 0; |
| 247 | #else |
| 248 | usb_enable_autosuspend(udev); |
| 249 | #endif |
| 250 | device_init_wakeup(&intf->dev,1); |
| 251 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) |
| 252 | usb_autopm_disable(intf); |
| 253 | #endif |
| 254 | INIT_WORK(&psIntfAdapter->usbSuspendWork, putUsbSuspend); |
| 255 | BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Enabling USB Auto-Suspend\n"); |
Randy Dunlap | 5fe1f1e | 2010-09-14 15:39:50 -0700 | [diff] [blame] | 256 | #endif |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 257 | } |
| 258 | else |
| 259 | { |
| 260 | intf->needs_remote_wakeup = 0; |
| 261 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) |
| 262 | udev->autosuspend_disabled = 1; |
| 263 | #else |
| 264 | usb_disable_autosuspend(udev); |
| 265 | #endif |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0x0; |
| 270 | return retval; |
| 271 | } |
| 272 | |
| 273 | static void usbbcm_disconnect (struct usb_interface *intf) |
| 274 | { |
| 275 | PS_INTERFACE_ADAPTER psIntfAdapter = NULL; |
| 276 | PMINI_ADAPTER psAdapter = NULL; |
| 277 | struct usb_device *udev = NULL; |
| 278 | PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); |
| 279 | |
| 280 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usb disconnected"); |
| 281 | if(intf == NULL) |
| 282 | { |
| 283 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf pointer is NULL"); |
| 284 | return; |
| 285 | } |
| 286 | psIntfAdapter = usb_get_intfdata(intf); |
Arnd Bergmann | 9f1c75a | 2010-09-30 10:24:11 +0200 | [diff] [blame] | 287 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%p",psIntfAdapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 288 | if(psIntfAdapter == NULL) |
| 289 | { |
| 290 | BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapter pointer is NULL"); |
| 291 | return; |
| 292 | } |
| 293 | psAdapter = psIntfAdapter->psAdapter; |
| 294 | if(psAdapter->bDoSuspend) |
| 295 | intf->needs_remote_wakeup = 0; |
| 296 | |
| 297 | psAdapter->device_removed = TRUE ; |
| 298 | usb_set_intfdata(intf, NULL); |
| 299 | InterfaceAdapterFree(psIntfAdapter); |
| 300 | udev = interface_to_usbdev (intf); |
| 301 | usb_put_dev(udev); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Stephen Hemminger | 20f4865 | 2010-10-31 23:52:36 -0400 | [diff] [blame] | 304 | static int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 305 | { |
| 306 | int i = 0; |
| 307 | for(i = 0; i < MAXIMUM_USB_TCB; i++) |
| 308 | { |
| 309 | if((psIntfAdapter->asUsbTcb[i].urb = |
| 310 | usb_alloc_urb(0, GFP_KERNEL)) == NULL) |
| 311 | { |
| 312 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Tx urb for index %d", i); |
| 313 | return -ENOMEM; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | for(i = 0; i < MAXIMUM_USB_RCB; i++) |
| 318 | { |
| 319 | if ((psIntfAdapter->asUsbRcb[i].urb = |
| 320 | usb_alloc_urb(0, GFP_KERNEL)) == NULL) |
| 321 | { |
| 322 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Rx urb for index %d", i); |
| 323 | return -ENOMEM; |
| 324 | } |
| 325 | if((psIntfAdapter->asUsbRcb[i].urb->transfer_buffer = |
| 326 | kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL)) == NULL) |
| 327 | { |
| 328 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Rx buffer for index %d", i); |
| 329 | return -ENOMEM; |
| 330 | } |
| 331 | psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length = MAX_DATA_BUFFER_SIZE; |
| 332 | } |
| 333 | return 0; |
| 334 | } |
| 335 | |
| 336 | |
| 337 | |
| 338 | static int device_run(PS_INTERFACE_ADAPTER psIntfAdapter) |
| 339 | { |
| 340 | INT value = 0; |
| 341 | UINT status = STATUS_SUCCESS; |
| 342 | |
| 343 | status = InitCardAndDownloadFirmware(psIntfAdapter->psAdapter); |
| 344 | if(status != STATUS_SUCCESS) |
| 345 | { |
| 346 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "InitCardAndDownloadFirmware failed.\n"); |
| 347 | return status; |
| 348 | } |
| 349 | if(TRUE == psIntfAdapter->psAdapter->fw_download_done) |
| 350 | { |
| 351 | |
| 352 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Sending first interrupt URB down......"); |
| 353 | if(StartInterruptUrb(psIntfAdapter)) |
| 354 | { |
| 355 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Cannot send interrupt in URB"); |
| 356 | } |
| 357 | //now register the cntrl interface. |
| 358 | //after downloading the f/w waiting for 5 sec to get the mailbox interrupt. |
| 359 | |
| 360 | psIntfAdapter->psAdapter->waiting_to_fw_download_done = FALSE; |
| 361 | value = wait_event_timeout(psIntfAdapter->psAdapter->ioctl_fw_dnld_wait_queue, |
| 362 | psIntfAdapter->psAdapter->waiting_to_fw_download_done, 5*HZ); |
| 363 | |
| 364 | if(value == 0) |
| 365 | { |
| 366 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Mailbox Interrupt has not reached to Driver.."); |
| 367 | } |
| 368 | else |
| 369 | { |
| 370 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Got the mailbox interrupt ...Registering control interface...\n "); |
| 371 | } |
| 372 | if(register_control_device_interface(psIntfAdapter->psAdapter) < 0) |
| 373 | { |
| 374 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Register Control Device failed..."); |
| 375 | return -EIO; |
| 376 | } |
| 377 | } |
| 378 | return 0; |
| 379 | } |
| 380 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 381 | |
| 382 | static inline int bcm_usb_endpoint_num(const struct usb_endpoint_descriptor *epd) |
| 383 | { |
| 384 | return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; |
| 385 | } |
| 386 | |
| 387 | static inline int bcm_usb_endpoint_type(const struct usb_endpoint_descriptor *epd) |
| 388 | { |
| 389 | return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; |
| 390 | } |
| 391 | |
| 392 | static inline int bcm_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) |
| 393 | { |
| 394 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); |
| 395 | } |
| 396 | |
| 397 | static inline int bcm_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) |
| 398 | { |
| 399 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); |
| 400 | } |
| 401 | |
| 402 | static inline int bcm_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) |
| 403 | { |
| 404 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == |
| 405 | USB_ENDPOINT_XFER_BULK); |
| 406 | } |
| 407 | |
| 408 | static inline int bcm_usb_endpoint_xfer_control(const struct usb_endpoint_descriptor *epd) |
| 409 | { |
| 410 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == |
| 411 | USB_ENDPOINT_XFER_CONTROL); |
| 412 | } |
| 413 | |
| 414 | static inline int bcm_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) |
| 415 | { |
| 416 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == |
| 417 | USB_ENDPOINT_XFER_INT); |
| 418 | } |
| 419 | |
| 420 | static inline int bcm_usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) |
| 421 | { |
| 422 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == |
| 423 | USB_ENDPOINT_XFER_ISOC); |
| 424 | } |
| 425 | |
| 426 | static inline int bcm_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) |
| 427 | { |
| 428 | return (bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_in(epd)); |
| 429 | } |
| 430 | |
| 431 | static inline int bcm_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) |
| 432 | { |
| 433 | return (bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_out(epd)); |
| 434 | } |
| 435 | |
| 436 | static inline int bcm_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) |
| 437 | { |
| 438 | return (bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_in(epd)); |
| 439 | } |
| 440 | |
| 441 | static inline int bcm_usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) |
| 442 | { |
| 443 | return (bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_out(epd)); |
| 444 | } |
| 445 | |
| 446 | static inline int bcm_usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) |
| 447 | { |
| 448 | return (bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_in(epd)); |
| 449 | } |
| 450 | |
| 451 | static inline int bcm_usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) |
| 452 | { |
| 453 | return (bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_out(epd)); |
| 454 | } |
| 455 | |
| 456 | INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter) |
| 457 | { |
| 458 | struct usb_host_interface *iface_desc; |
| 459 | struct usb_endpoint_descriptor *endpoint; |
| 460 | size_t buffer_size; |
| 461 | ULONG value; |
| 462 | INT retval = 0; |
| 463 | INT usedIntOutForBulkTransfer = 0 ; |
| 464 | BOOLEAN bBcm16 = FALSE; |
| 465 | UINT uiData = 0; |
| 466 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 467 | /* Store the usb dev into interface adapter */ |
| 468 | psIntfAdapter->udev = usb_get_dev(interface_to_usbdev( |
| 469 | psIntfAdapter->interface)); |
| 470 | |
| 471 | if((psIntfAdapter->udev->speed == USB_SPEED_HIGH)) |
| 472 | { |
| 473 | psIntfAdapter->bHighSpeedDevice = TRUE ; |
| 474 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "MODEM IS CONFIGURED TO HIGH_SPEED "); |
| 475 | } |
| 476 | else |
| 477 | { |
| 478 | psIntfAdapter->bHighSpeedDevice = FALSE ; |
| 479 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "MODEM IS CONFIGURED TO FULL_SPEED "); |
| 480 | } |
| 481 | |
| 482 | psIntfAdapter->psAdapter->interface_rdm = BcmRDM; |
| 483 | psIntfAdapter->psAdapter->interface_wrm = BcmWRM; |
| 484 | |
| 485 | if(rdmalt(psIntfAdapter->psAdapter, CHIP_ID_REG, (PUINT)&(psIntfAdapter->psAdapter->chip_id), sizeof(UINT)) < 0) |
| 486 | { |
| 487 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "CHIP ID Read Failed\n"); |
| 488 | return STATUS_FAILURE; |
| 489 | } |
| 490 | if(0xbece3200==(psIntfAdapter->psAdapter->chip_id&~(0xF0))) |
| 491 | { |
| 492 | psIntfAdapter->psAdapter->chip_id=(psIntfAdapter->psAdapter->chip_id&~(0xF0)); |
| 493 | } |
| 494 | |
| 495 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "First RDM Chip ID 0x%lx\n", psIntfAdapter->psAdapter->chip_id); |
| 496 | |
| 497 | iface_desc = psIntfAdapter->interface->cur_altsetting; |
| 498 | //print_usb_interface_desc(&(iface_desc->desc)); |
| 499 | |
| 500 | if(psIntfAdapter->psAdapter->chip_id == T3B) |
| 501 | { |
| 502 | |
| 503 | // |
| 504 | //T3B device will have EEPROM,check if EEPROM is proper and BCM16 can be done or not. |
| 505 | // |
| 506 | BeceemEEPROMBulkRead(psIntfAdapter->psAdapter,&uiData,0x0,4); |
| 507 | if(uiData == BECM) |
| 508 | { |
| 509 | bBcm16 = TRUE; |
| 510 | } |
| 511 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Number of Altsetting aviailable for This Modem 0x%x\n", psIntfAdapter->interface->num_altsetting); |
| 512 | if(bBcm16 == TRUE) |
| 513 | { |
| 514 | //selecting alternate setting one as a default setting for High Speed modem. |
| 515 | if(psIntfAdapter->bHighSpeedDevice) |
| 516 | retval= usb_set_interface(psIntfAdapter->udev,DEFAULT_SETTING_0,ALTERNATE_SETTING_1); |
| 517 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM16 is Applicable on this dongle"); |
| 518 | if(retval || (psIntfAdapter->bHighSpeedDevice == FALSE)) |
| 519 | { |
| 520 | usedIntOutForBulkTransfer = EP2 ; |
| 521 | endpoint = &iface_desc->endpoint[EP2].desc; |
| 522 | 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"); |
| 523 | /* |
| 524 | If Modem is high speed device EP2 should be INT OUT End point |
| 525 | If Mode is FS then EP2 should be bulk end point |
| 526 | */ |
| 527 | if(((psIntfAdapter->bHighSpeedDevice ==TRUE ) && (bcm_usb_endpoint_is_int_out(endpoint)== FALSE)) |
| 528 | ||((psIntfAdapter->bHighSpeedDevice == FALSE)&& (bcm_usb_endpoint_is_bulk_out(endpoint)== FALSE))) |
| 529 | { |
| 530 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Configuring the EEPROM "); |
| 531 | //change the EP2, EP4 to INT OUT end point |
| 532 | ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter); |
| 533 | |
| 534 | /* |
| 535 | It resets the device and if any thing gets changed in USB descriptor it will show fail and |
| 536 | re-enumerate the device |
| 537 | */ |
| 538 | retval = usb_reset_device(psIntfAdapter->udev); |
| 539 | if(retval) |
| 540 | { |
| 541 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reset got failed. hence Re-enumerating the device \n"); |
| 542 | return retval ; |
| 543 | } |
| 544 | |
| 545 | } |
| 546 | if((psIntfAdapter->bHighSpeedDevice == FALSE) && bcm_usb_endpoint_is_bulk_out(endpoint)) |
| 547 | { |
| 548 | // Once BULK is selected in FS mode. Revert it back to INT. Else USB_IF will fail. |
Arnd Bergmann | 44a17eff | 2010-09-30 10:24:12 +0200 | [diff] [blame] | 549 | UINT _uiData = ntohl(EP2_CFG_INT); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 550 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Reverting Bulk to INT as it is FS MODE"); |
Arnd Bergmann | 44a17eff | 2010-09-30 10:24:12 +0200 | [diff] [blame] | 551 | BeceemEEPROMBulkWrite(psIntfAdapter->psAdapter,(PUCHAR)&_uiData,0x136,4,TRUE); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 552 | } |
| 553 | } |
| 554 | else |
| 555 | { |
| 556 | usedIntOutForBulkTransfer = EP4 ; |
| 557 | endpoint = &iface_desc->endpoint[EP4].desc; |
| 558 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Choosing AltSetting as a default setting"); |
| 559 | if( bcm_usb_endpoint_is_int_out(endpoint) == FALSE) |
| 560 | { |
| 561 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, " Dongle does not have BCM16 Fix"); |
| 562 | //change the EP2, EP4 to INT OUT end point and use EP4 in altsetting |
| 563 | ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter); |
| 564 | |
| 565 | /* |
| 566 | It resets the device and if any thing gets changed in USB descriptor it will show fail and |
| 567 | re-enumerate the device |
| 568 | */ |
| 569 | retval = usb_reset_device(psIntfAdapter->udev); |
| 570 | if(retval) |
| 571 | { |
| 572 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reset got failed. hence Re-enumerating the device \n"); |
| 573 | return retval ; |
| 574 | } |
| 575 | |
| 576 | } |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | iface_desc = psIntfAdapter->interface->cur_altsetting; |
| 582 | //print_usb_interface_desc(&(iface_desc->desc)); |
| 583 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Current number of endpoints :%x \n", iface_desc->desc.bNumEndpoints); |
| 584 | for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value) |
| 585 | { |
| 586 | endpoint = &iface_desc->endpoint[value].desc; |
| 587 | //print_usb_endpoint_descriptor(endpoint); |
| 588 | |
| 589 | if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && bcm_usb_endpoint_is_bulk_in(endpoint)) |
| 590 | { |
| 591 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); |
| 592 | psIntfAdapter->sBulkIn.bulk_in_size = buffer_size; |
| 593 | psIntfAdapter->sBulkIn.bulk_in_endpointAddr = |
| 594 | endpoint->bEndpointAddress; |
| 595 | psIntfAdapter->sBulkIn.bulk_in_pipe = |
| 596 | usb_rcvbulkpipe(psIntfAdapter->udev, |
| 597 | psIntfAdapter->sBulkIn.bulk_in_endpointAddr); |
| 598 | } |
| 599 | |
| 600 | if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && bcm_usb_endpoint_is_bulk_out(endpoint)) |
| 601 | { |
| 602 | |
| 603 | psIntfAdapter->sBulkOut.bulk_out_endpointAddr = |
| 604 | endpoint->bEndpointAddress; |
| 605 | psIntfAdapter->sBulkOut.bulk_out_pipe = |
| 606 | usb_sndbulkpipe(psIntfAdapter->udev, |
| 607 | psIntfAdapter->sBulkOut.bulk_out_endpointAddr); |
| 608 | } |
| 609 | |
| 610 | if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && bcm_usb_endpoint_is_int_in(endpoint)) |
| 611 | { |
| 612 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); |
| 613 | psIntfAdapter->sIntrIn.int_in_size = buffer_size; |
| 614 | psIntfAdapter->sIntrIn.int_in_endpointAddr = |
| 615 | endpoint->bEndpointAddress; |
| 616 | psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval; |
| 617 | psIntfAdapter->sIntrIn.int_in_buffer = |
| 618 | kmalloc(buffer_size, GFP_KERNEL); |
| 619 | if (!psIntfAdapter->sIntrIn.int_in_buffer) { |
| 620 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Could not allocate interrupt_in_buffer"); |
| 621 | return -EINVAL; |
| 622 | } |
| 623 | //psIntfAdapter->sIntrIn.int_in_pipe = |
| 624 | } |
| 625 | |
| 626 | if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint)) |
| 627 | { |
| 628 | |
| 629 | if( !psIntfAdapter->sBulkOut.bulk_out_endpointAddr && |
| 630 | (psIntfAdapter->psAdapter->chip_id == T3B) && (value == usedIntOutForBulkTransfer)) |
| 631 | { |
| 632 | //use first intout end point as a bulk out end point |
| 633 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); |
| 634 | psIntfAdapter->sBulkOut.bulk_out_size = buffer_size; |
| 635 | //printk("\nINT OUT Endpoing buffer size :%x endpoint :%x\n", buffer_size, value +1); |
| 636 | psIntfAdapter->sBulkOut.bulk_out_endpointAddr = |
| 637 | endpoint->bEndpointAddress; |
| 638 | psIntfAdapter->sBulkOut.bulk_out_pipe = |
| 639 | usb_sndintpipe(psIntfAdapter->udev, |
| 640 | psIntfAdapter->sBulkOut.bulk_out_endpointAddr); |
| 641 | psIntfAdapter->sBulkOut.int_out_interval = endpoint->bInterval; |
| 642 | |
| 643 | } |
| 644 | else if(value == EP6) |
| 645 | { |
| 646 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); |
| 647 | psIntfAdapter->sIntrOut.int_out_size = buffer_size; |
| 648 | psIntfAdapter->sIntrOut.int_out_endpointAddr = |
| 649 | endpoint->bEndpointAddress; |
| 650 | psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval; |
| 651 | psIntfAdapter->sIntrOut.int_out_buffer= kmalloc(buffer_size, |
| 652 | GFP_KERNEL); |
| 653 | if (!psIntfAdapter->sIntrOut.int_out_buffer) |
| 654 | { |
| 655 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Could not allocate interrupt_out_buffer"); |
| 656 | return -EINVAL; |
| 657 | } |
| 658 | } |
| 659 | } |
| 660 | } |
| 661 | usb_set_intfdata(psIntfAdapter->interface, psIntfAdapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 662 | |
| 663 | psIntfAdapter->psAdapter->bcm_file_download = InterfaceFileDownload; |
| 664 | psIntfAdapter->psAdapter->bcm_file_readback_from_chip = |
| 665 | InterfaceFileReadbackFromChip; |
| 666 | psIntfAdapter->psAdapter->interface_transmit = InterfaceTransmitPacket; |
| 667 | |
| 668 | retval = CreateInterruptUrb(psIntfAdapter); |
| 669 | |
| 670 | if(retval) |
| 671 | { |
| 672 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cannot create interrupt urb"); |
| 673 | return retval; |
| 674 | } |
| 675 | |
| 676 | retval = AllocUsbCb(psIntfAdapter); |
| 677 | if(retval) |
| 678 | { |
| 679 | return retval; |
| 680 | } |
| 681 | |
| 682 | |
Stephen Hemminger | 032100f | 2010-11-01 10:03:29 -0400 | [diff] [blame^] | 683 | return device_run(psIntfAdapter); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 684 | } |
Arnd Bergmann | 44a17eff | 2010-09-30 10:24:12 +0200 | [diff] [blame] | 685 | |
| 686 | static int InterfaceSuspend (struct usb_interface *intf, pm_message_t message) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 687 | { |
| 688 | PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); |
| 689 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "=================================\n"); |
| 690 | //Bcm_kill_all_URBs(psIntfAdapter); |
| 691 | psIntfAdapter->bSuspended = TRUE; |
| 692 | |
| 693 | if(TRUE == psIntfAdapter->bPreparingForBusSuspend) |
| 694 | { |
| 695 | psIntfAdapter->bPreparingForBusSuspend = FALSE; |
| 696 | |
| 697 | if(psIntfAdapter->psAdapter->LinkStatus == LINKUP_DONE) |
| 698 | { |
| 699 | psIntfAdapter->psAdapter->IdleMode = TRUE ; |
| 700 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Host Entered in PMU Idle Mode.."); |
| 701 | } |
| 702 | else |
| 703 | { |
| 704 | psIntfAdapter->psAdapter->bShutStatus = TRUE; |
| 705 | BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Host Entered in PMU Shutdown Mode.."); |
| 706 | } |
| 707 | } |
| 708 | psIntfAdapter->psAdapter->bPreparingForLowPowerMode = FALSE; |
| 709 | |
| 710 | //Signaling the control pkt path |
| 711 | wake_up(&psIntfAdapter->psAdapter->lowpower_mode_wait_queue); |
| 712 | |
| 713 | return 0; |
| 714 | } |
Arnd Bergmann | 44a17eff | 2010-09-30 10:24:12 +0200 | [diff] [blame] | 715 | |
| 716 | static int InterfaceResume (struct usb_interface *intf) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 717 | { |
| 718 | PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); |
| 719 | printk("=================================\n"); |
| 720 | mdelay(100); |
| 721 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) |
| 722 | intf->pm_usage_cnt =1 ; |
| 723 | #endif |
| 724 | psIntfAdapter->bSuspended = FALSE; |
| 725 | |
| 726 | StartInterruptUrb(psIntfAdapter); |
| 727 | InterfaceRx(psIntfAdapter); |
| 728 | return 0; |
| 729 | } |
Arnd Bergmann | 44a17eff | 2010-09-30 10:24:12 +0200 | [diff] [blame] | 730 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 731 | static struct usb_driver usbbcm_driver = { |
| 732 | .name = "usbbcm", |
| 733 | .probe = usbbcm_device_probe, |
| 734 | .disconnect = usbbcm_disconnect, |
| 735 | .suspend = InterfaceSuspend, |
| 736 | .resume = InterfaceResume, |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 737 | .id_table = InterfaceUsbtable, |
| 738 | .supports_autosuspend = 1, |
| 739 | }; |
| 740 | |
| 741 | |
| 742 | /* |
| 743 | Function: InterfaceInitialize |
| 744 | |
| 745 | Description: This is the hardware specific initialization Function. |
| 746 | Registering the driver with NDIS , other device specific NDIS |
| 747 | and hardware initializations are done here. |
| 748 | |
| 749 | Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context |
| 750 | |
| 751 | |
| 752 | Return: BCM_STATUS_SUCCESS - If Initialization of the |
| 753 | HW Interface was successful. |
| 754 | Other - If an error occured. |
| 755 | */ |
| 756 | INT InterfaceInitialize(void) |
| 757 | { |
| 758 | // BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Registering Usb driver!!"); |
| 759 | return usb_register(&usbbcm_driver); |
| 760 | } |
| 761 | |
| 762 | INT InterfaceExit(void) |
| 763 | { |
| 764 | //PMINI_ADAPTER psAdapter = NULL; |
| 765 | int status = 0; |
| 766 | |
| 767 | //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Deregistering Usb driver!!"); |
| 768 | usb_deregister(&usbbcm_driver); |
| 769 | return status; |
| 770 | } |