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