=== modified file 'uspace/drv/ohci/hc.c'
|
|
|
34 | 34 | #include <errno.h> |
35 | 35 | #include <str_error.h> |
36 | 36 | #include <adt/list.h> |
| 37 | #include <time.h> |
37 | 38 | #include <libarch/ddi.h> |
38 | 39 | |
39 | 40 | #include <usb/debug.h> |
… |
… |
|
472 | 473 | } |
473 | 474 | usb_log_debug2("HC reset complete in %zu us.\n", time); |
474 | 475 | |
| 476 | struct timeval start, end; |
| 477 | int ret = gettimeofday(&start, NULL); |
| 478 | assert(ret == EOK); |
| 479 | |
| 480 | /* hc is now in suspend state */ |
| 481 | usb_log_debug2("HC should be in suspend state(%x):%x.\n", |
| 482 | C_HCFS_SUSPEND << C_HCFS_SHIFT, instance->registers->control); |
| 483 | |
475 | 484 | /* Restore fm_interval */ |
476 | 485 | instance->registers->fm_interval = fm_interval; |
477 | | assert((instance->registers->command_status & CS_HCR) == 0); |
478 | | |
479 | | /* hc is now in suspend state */ |
480 | | usb_log_debug2("HC should be in suspend state(%x).\n", |
481 | | instance->registers->control); |
482 | 486 | |
483 | 487 | /* Use HCCA */ |
484 | 488 | instance->registers->hcca = addr_to_phys(instance->hcca); |
… |
… |
|
514 | 518 | instance->registers->periodic_start, |
515 | 519 | instance->registers->periodic_start, frame_length); |
516 | 520 | |
517 | | instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT); |
| 521 | ret = gettimeofday(&end, NULL); |
| 522 | assert(ret == EOK); |
| 523 | |
| 524 | /* The Host Controller is now in the USBSUSPEND state; |
| 525 | * it must not stay in this state more than 2 ms |
| 526 | * or the USBRESUME state will need to be entered for |
| 527 | * the minimum time specified in the USB Specification |
| 528 | * for the assertion of resume on the USB. |
| 529 | * OpenHCI - 5.1.1.4 |
| 530 | */ |
| 531 | if (tv_sub(&end, &start) > 2000) { |
| 532 | usb_log_info("OHCI setup took too long, force resume.\n"); |
| 533 | /* We may use simple &= to change status as RESUME is bit |
| 534 | * subset of SUSPEND (suspend = 0x3, resume 0x1)*/ |
| 535 | instance->registers->control &= |
| 536 | (C_HCFS_RESUME << C_HCFS_SHIFT); |
| 537 | async_usleep(20000); |
| 538 | |
| 539 | } |
| 540 | instance->registers->control = |
| 541 | (instance->registers->control & ~(C_HCFS_MASK << C_HCFS_SHIFT)) | |
| 542 | (C_HCFS_OPERATIONAL << C_HCFS_SHIFT); |
518 | 543 | usb_log_info("OHCI HC up and running(%x).\n", |
519 | 544 | instance->registers->control); |
520 | 545 | } |