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