old mode 100644new mode 100755| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Dongle BUS interface |
|---|
| 3 | 4 | * USB Linux Implementation |
|---|
| .. | .. |
|---|
| 511 | 512 | struct usb_interface *intf; |
|---|
| 512 | 513 | } probe_info_t; |
|---|
| 513 | 514 | |
|---|
| 514 | | -/* driver info, initialized when bcmsdh_register is called */ |
|---|
| 515 | | -static dbus_driver_t drvinfo = {NULL, NULL, NULL, NULL}; |
|---|
| 516 | | - |
|---|
| 517 | 515 | /* |
|---|
| 518 | 516 | * USB Linux dbus_intf_t |
|---|
| 519 | 517 | */ |
|---|
| .. | .. |
|---|
| 591 | 589 | }; |
|---|
| 592 | 590 | |
|---|
| 593 | 591 | static probe_info_t g_probe_info; |
|---|
| 592 | +static probe_cb_t probe_cb = NULL; |
|---|
| 593 | +static disconnect_cb_t disconnect_cb = NULL; |
|---|
| 594 | +static void *probe_arg = NULL; |
|---|
| 594 | 595 | static void *disc_arg = NULL; |
|---|
| 595 | 596 | |
|---|
| 596 | 597 | |
|---|
| .. | .. |
|---|
| 1232 | 1233 | dbus_usbos_suspend(struct usb_interface *intf, |
|---|
| 1233 | 1234 | pm_message_t message) |
|---|
| 1234 | 1235 | { |
|---|
| 1235 | | - usbos_info_t *usbos_info = (usbos_info_t *) g_probe_info.usbos_info; |
|---|
| 1236 | | - int err = 0; |
|---|
| 1237 | | - |
|---|
| 1238 | | - printf("%s Enter\n", __FUNCTION__); |
|---|
| 1239 | | - |
|---|
| 1236 | + DBUSERR(("%s suspend state: %d\n", __FUNCTION__, g_probe_info.suspend_state)); |
|---|
| 1240 | 1237 | /* DHD for full dongle model */ |
|---|
| 1241 | 1238 | g_probe_info.suspend_state = USBOS_SUSPEND_STATE_SUSPEND_PENDING; |
|---|
| 1242 | | - if (drvinfo.suspend && disc_arg) |
|---|
| 1243 | | - err = drvinfo.suspend(disc_arg); |
|---|
| 1244 | | - if (err) { |
|---|
| 1245 | | - printf("%s: err=%d\n", __FUNCTION__, err); |
|---|
| 1246 | | -// g_probe_info.suspend_state = USBOS_SUSPEND_STATE_DEVICE_ACTIVE; |
|---|
| 1247 | | -// return err; |
|---|
| 1248 | | - } |
|---|
| 1249 | | - usbos_info->pub->busstate = DBUS_STATE_SLEEP; |
|---|
| 1250 | | - |
|---|
| 1239 | + dbus_usbos_state_change((usbos_info_t*)g_probe_info.usbos_info, DBUS_STATE_SLEEP); |
|---|
| 1251 | 1240 | dbus_usbos_cancel_all_urbs((usbos_info_t*)g_probe_info.usbos_info); |
|---|
| 1252 | 1241 | g_probe_info.suspend_state = USBOS_SUSPEND_STATE_SUSPENDED; |
|---|
| 1253 | 1242 | |
|---|
| 1254 | | - printf("%s Exit err=%d\n", __FUNCTION__, err); |
|---|
| 1255 | | - return err; |
|---|
| 1243 | + return 0; |
|---|
| 1256 | 1244 | } |
|---|
| 1257 | 1245 | |
|---|
| 1258 | 1246 | /** |
|---|
| 1259 | 1247 | * The resume method is called to tell the driver that the device has been resumed and the driver |
|---|
| 1260 | 1248 | * can return to normal operation. URBs may once more be submitted. |
|---|
| 1261 | 1249 | */ |
|---|
| 1262 | | -static int |
|---|
| 1263 | | -dbus_usbos_resume(struct usb_interface *intf) |
|---|
| 1250 | +static int dbus_usbos_resume(struct usb_interface *intf) |
|---|
| 1264 | 1251 | { |
|---|
| 1265 | | - usbos_info_t *usbos_info = (usbos_info_t *) g_probe_info.usbos_info; |
|---|
| 1252 | + DBUSERR(("%s Device resumed\n", __FUNCTION__)); |
|---|
| 1266 | 1253 | |
|---|
| 1267 | | - printf("%s Enter\n", __FUNCTION__); |
|---|
| 1268 | | - |
|---|
| 1254 | + dbus_usbos_state_change((usbos_info_t*)g_probe_info.usbos_info, DBUS_STATE_UP); |
|---|
| 1269 | 1255 | g_probe_info.suspend_state = USBOS_SUSPEND_STATE_DEVICE_ACTIVE; |
|---|
| 1270 | | - if (drvinfo.resume && disc_arg) |
|---|
| 1271 | | - drvinfo.resume(disc_arg); |
|---|
| 1272 | | - usbos_info->pub->busstate = DBUS_STATE_UP; |
|---|
| 1273 | | - |
|---|
| 1274 | | - printf("%s Exit\n", __FUNCTION__); |
|---|
| 1275 | 1256 | return 0; |
|---|
| 1276 | 1257 | } |
|---|
| 1277 | 1258 | |
|---|
| .. | .. |
|---|
| 1279 | 1260 | * This function is directly called by the Linux kernel, when the suspended device has been reset |
|---|
| 1280 | 1261 | * instead of being resumed |
|---|
| 1281 | 1262 | */ |
|---|
| 1282 | | -static int |
|---|
| 1283 | | -dbus_usbos_reset_resume(struct usb_interface *intf) |
|---|
| 1263 | +static int dbus_usbos_reset_resume(struct usb_interface *intf) |
|---|
| 1284 | 1264 | { |
|---|
| 1285 | | - printf("%s Enter\n", __FUNCTION__); |
|---|
| 1265 | + DBUSERR(("%s Device reset resumed\n", __FUNCTION__)); |
|---|
| 1286 | 1266 | |
|---|
| 1267 | + /* The device may have lost power, so a firmware download may be required */ |
|---|
| 1268 | + dbus_usbos_state_change((usbos_info_t*)g_probe_info.usbos_info, DBUS_STATE_DL_NEEDED); |
|---|
| 1287 | 1269 | g_probe_info.suspend_state = USBOS_SUSPEND_STATE_DEVICE_ACTIVE; |
|---|
| 1288 | | - if (drvinfo.resume && disc_arg) |
|---|
| 1289 | | - drvinfo.resume(disc_arg); |
|---|
| 1290 | | - |
|---|
| 1291 | | - printf("%s Exit\n", __FUNCTION__); |
|---|
| 1292 | 1270 | return 0; |
|---|
| 1293 | 1271 | } |
|---|
| 1294 | 1272 | |
|---|
| .. | .. |
|---|
| 1577 | 1555 | g_probe_info.device_speed = FULL_SPEED; |
|---|
| 1578 | 1556 | DBUSERR(("full speed device detected\n")); |
|---|
| 1579 | 1557 | } |
|---|
| 1580 | | - if (g_probe_info.dereged == FALSE && drvinfo.probe) { |
|---|
| 1581 | | - disc_arg = drvinfo.probe(usb->bus->busnum, usb->portnum, 0); |
|---|
| 1558 | + if (g_probe_info.dereged == FALSE && probe_cb) { |
|---|
| 1559 | + disc_arg = probe_cb(probe_arg, "", USB_BUS, usb->bus->busnum, usb->portnum, 0); |
|---|
| 1582 | 1560 | } |
|---|
| 1583 | 1561 | |
|---|
| 1584 | 1562 | g_probe_info.disc_cb_done = FALSE; |
|---|
| .. | .. |
|---|
| 1639 | 1617 | if (probe_usb_init_data) { |
|---|
| 1640 | 1618 | usbos_info = (usbos_info_t *) probe_usb_init_data->usbos_info; |
|---|
| 1641 | 1619 | if (usbos_info) { |
|---|
| 1642 | | - if ((probe_usb_init_data->dereged == FALSE) && drvinfo.remove && disc_arg) { |
|---|
| 1643 | | - drvinfo.remove(disc_arg); |
|---|
| 1620 | + if ((probe_usb_init_data->dereged == FALSE) && disconnect_cb && disc_arg) { |
|---|
| 1621 | + disconnect_cb(disc_arg); |
|---|
| 1644 | 1622 | disc_arg = NULL; |
|---|
| 1645 | 1623 | probe_usb_init_data->disc_cb_done = TRUE; |
|---|
| 1646 | 1624 | } |
|---|
| .. | .. |
|---|
| 2577 | 2555 | } |
|---|
| 2578 | 2556 | |
|---|
| 2579 | 2557 | int |
|---|
| 2580 | | -dbus_bus_osl_register(dbus_driver_t *driver, dbus_intf_t **intf) |
|---|
| 2558 | +dbus_bus_osl_register(int vid, int pid, probe_cb_t prcb, |
|---|
| 2559 | + disconnect_cb_t discb, void *prarg, dbus_intf_t **intf, void *param1, void *param2) |
|---|
| 2581 | 2560 | { |
|---|
| 2582 | 2561 | bzero(&g_probe_info, sizeof(probe_info_t)); |
|---|
| 2583 | 2562 | |
|---|
| 2584 | | - drvinfo = *driver; |
|---|
| 2563 | + probe_cb = prcb; |
|---|
| 2564 | + disconnect_cb = discb; |
|---|
| 2565 | + probe_arg = prarg; |
|---|
| 2566 | + |
|---|
| 2567 | + devid_table[0].idVendor = vid; |
|---|
| 2568 | + devid_table[0].idProduct = pid; |
|---|
| 2569 | + |
|---|
| 2585 | 2570 | *intf = &dbus_usbos_intf; |
|---|
| 2586 | 2571 | |
|---|
| 2587 | 2572 | USB_REGISTER(); |
|---|
| .. | .. |
|---|
| 2595 | 2580 | g_probe_info.dereged = TRUE; |
|---|
| 2596 | 2581 | |
|---|
| 2597 | 2582 | DHD_MUTEX_LOCK(); |
|---|
| 2598 | | - if (drvinfo.remove && disc_arg && (g_probe_info.disc_cb_done == FALSE)) { |
|---|
| 2599 | | - drvinfo.remove(disc_arg); |
|---|
| 2583 | + if (disconnect_cb && disc_arg && (g_probe_info.disc_cb_done == FALSE)) { |
|---|
| 2584 | + disconnect_cb(disc_arg); |
|---|
| 2600 | 2585 | disc_arg = NULL; |
|---|
| 2601 | 2586 | } |
|---|
| 2602 | 2587 | DHD_MUTEX_UNLOCK(); |
|---|
| .. | .. |
|---|
| 3198 | 3183 | return *firmware != NULL ? 0 : -ENOENT; |
|---|
| 3199 | 3184 | } |
|---|
| 3200 | 3185 | |
|---|
| 3201 | | -#ifndef DHD_LINUX_STD_FW_API |
|---|
| 3202 | 3186 | static void * |
|---|
| 3203 | | -dbus_get_fwfile(int devid, int chiprev, uint8 **fw, int *fwlen, |
|---|
| 3204 | | - uint16 boardtype, uint16 boardrev, char *path) |
|---|
| 3187 | +dbus_get_fwfile(int devid, int chiprev, uint8 **fw, int *fwlen, uint16 boardtype, uint16 boardrev) |
|---|
| 3205 | 3188 | { |
|---|
| 3206 | 3189 | const struct firmware *firmware = NULL; |
|---|
| 3207 | 3190 | #ifndef OEM_ANDROID |
|---|
| .. | .. |
|---|
| 3264 | 3247 | snprintf(file_name, sizeof(file_name), "%s", CONFIG_ANDROID_BCMDHD_FW_PATH); |
|---|
| 3265 | 3248 | #endif /* OEM_ANDROID */ |
|---|
| 3266 | 3249 | |
|---|
| 3267 | | - ret = dbus_request_firmware(path, &firmware); |
|---|
| 3250 | + ret = dbus_request_firmware(file_name, &firmware); |
|---|
| 3268 | 3251 | if (ret) { |
|---|
| 3269 | | - DBUSERR(("fail to request firmware %s\n", path)); |
|---|
| 3252 | + DBUSERR(("fail to request firmware %s\n", file_name)); |
|---|
| 3270 | 3253 | return NULL; |
|---|
| 3271 | | - } else |
|---|
| 3272 | | - DBUSERR(("%s: %s (%zu bytes) open success\n", __FUNCTION__, path, firmware->size)); |
|---|
| 3254 | + } |
|---|
| 3273 | 3255 | |
|---|
| 3274 | 3256 | *fwlen = firmware->size; |
|---|
| 3275 | 3257 | *fw = (uint8 *)firmware->data; |
|---|
| .. | .. |
|---|
| 3278 | 3260 | } |
|---|
| 3279 | 3261 | |
|---|
| 3280 | 3262 | static void * |
|---|
| 3281 | | -dbus_get_nvfile(int devid, int chiprev, uint8 **fw, int *fwlen, |
|---|
| 3282 | | - uint16 boardtype, uint16 boardrev, char *path) |
|---|
| 3263 | +dbus_get_nvfile(int devid, int chiprev, uint8 **fw, int *fwlen, uint16 boardtype, uint16 boardrev) |
|---|
| 3283 | 3264 | { |
|---|
| 3284 | 3265 | const struct firmware *firmware = NULL; |
|---|
| 3285 | 3266 | #ifndef OEM_ANDROID |
|---|
| .. | .. |
|---|
| 3347 | 3328 | snprintf(file_name, sizeof(file_name), "%s", CONFIG_ANDROID_BCMDHD_NVRAM_PATH); |
|---|
| 3348 | 3329 | #endif /* OEM_ANDROID */ |
|---|
| 3349 | 3330 | |
|---|
| 3350 | | - ret = dbus_request_firmware(path, &firmware); |
|---|
| 3331 | + ret = dbus_request_firmware(file_name, &firmware); |
|---|
| 3351 | 3332 | if (ret) { |
|---|
| 3352 | | - DBUSERR(("fail to request nvram %s\n", path)); |
|---|
| 3333 | + DBUSERR(("fail to request nvram %s\n", file_name)); |
|---|
| 3353 | 3334 | |
|---|
| 3354 | 3335 | #ifndef OEM_ANDROID |
|---|
| 3355 | 3336 | /* Load generic nvram file */ |
|---|
| .. | .. |
|---|
| 3360 | 3341 | #endif /* OEM_ANDROID */ |
|---|
| 3361 | 3342 | |
|---|
| 3362 | 3343 | if (ret) { |
|---|
| 3363 | | - DBUSERR(("fail to request nvram %s\n", path)); |
|---|
| 3344 | + DBUSERR(("fail to request nvram %s\n", file_name)); |
|---|
| 3364 | 3345 | return NULL; |
|---|
| 3365 | 3346 | } |
|---|
| 3366 | | - } else |
|---|
| 3367 | | - DBUSERR(("%s: %s (%zu bytes) open success\n", __FUNCTION__, path, firmware->size)); |
|---|
| 3347 | + } |
|---|
| 3368 | 3348 | |
|---|
| 3369 | 3349 | *fwlen = firmware->size; |
|---|
| 3370 | 3350 | *fw = (uint8 *)firmware->data; |
|---|
| .. | .. |
|---|
| 3373 | 3353 | |
|---|
| 3374 | 3354 | void * |
|---|
| 3375 | 3355 | dbus_get_fw_nvfile(int devid, int chiprev, uint8 **fw, int *fwlen, int type, uint16 boardtype, |
|---|
| 3376 | | - uint16 boardrev, char *path) |
|---|
| 3356 | + uint16 boardrev) |
|---|
| 3377 | 3357 | { |
|---|
| 3378 | 3358 | switch (type) { |
|---|
| 3379 | 3359 | case DBUS_FIRMWARE: |
|---|
| 3380 | | - return dbus_get_fwfile(devid, chiprev, fw, fwlen, boardtype, boardrev, path); |
|---|
| 3360 | + return dbus_get_fwfile(devid, chiprev, fw, fwlen, boardtype, boardrev); |
|---|
| 3381 | 3361 | case DBUS_NVFILE: |
|---|
| 3382 | | - return dbus_get_nvfile(devid, chiprev, fw, fwlen, boardtype, boardrev, path); |
|---|
| 3362 | + return dbus_get_nvfile(devid, chiprev, fw, fwlen, boardtype, boardrev); |
|---|
| 3383 | 3363 | default: |
|---|
| 3384 | 3364 | return NULL; |
|---|
| 3385 | 3365 | } |
|---|
| 3386 | 3366 | } |
|---|
| 3387 | | -#else |
|---|
| 3388 | | -void * |
|---|
| 3389 | | -dbus_get_fw_nvfile(int devid, int chiprev, uint8 **fw, int *fwlen, int type, uint16 boardtype, |
|---|
| 3390 | | - uint16 boardrev, char *path) |
|---|
| 3391 | | -{ |
|---|
| 3392 | | - const struct firmware *firmware = NULL; |
|---|
| 3393 | | - int err = DBUS_OK; |
|---|
| 3394 | | - |
|---|
| 3395 | | - err = dbus_request_firmware(path, &firmware); |
|---|
| 3396 | | - if (err) { |
|---|
| 3397 | | - DBUSERR(("fail to request firmware %s\n", path)); |
|---|
| 3398 | | - return NULL; |
|---|
| 3399 | | - } else { |
|---|
| 3400 | | - DBUSERR(("%s: %s (%zu bytes) open success\n", |
|---|
| 3401 | | - __FUNCTION__, path, firmware->size)); |
|---|
| 3402 | | - } |
|---|
| 3403 | | - |
|---|
| 3404 | | - *fwlen = firmware->size; |
|---|
| 3405 | | - *fw = (uint8 *)firmware->data; |
|---|
| 3406 | | - return (void *)firmware; |
|---|
| 3407 | | -} |
|---|
| 3408 | | -#endif |
|---|
| 3409 | 3367 | |
|---|
| 3410 | 3368 | void |
|---|
| 3411 | 3369 | dbus_release_fw_nvfile(void *firmware) |
|---|
| .. | .. |
|---|
| 3446 | 3404 | return intf_wlan; |
|---|
| 3447 | 3405 | } |
|---|
| 3448 | 3406 | #endif /* BCMUSBDEV_COMPOSITE */ |
|---|
| 3449 | | - |
|---|
| 3450 | | -#ifdef LINUX |
|---|
| 3451 | | -struct device * dbus_get_dev(void) |
|---|
| 3452 | | -{ |
|---|
| 3453 | | - return &g_probe_info.usb->dev; |
|---|
| 3454 | | -} |
|---|
| 3455 | | -#endif /* LINUX */ |
|---|