Changes in uspace/drv/ohci/hc.c [8953514:3e4f2e0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified uspace/drv/ohci/hc.c ¶
r8953514 r3e4f2e0 51 51 static int hc_init_memory(hc_t *instance); 52 52 /*----------------------------------------------------------------------------*/ 53 /** Announce OHCI root hub to the DDF54 *55 * @param[in] instance OHCI driver intance56 * @param[in] hub_fun DDF fuction representing OHCI root hub57 * @return Error code58 */59 53 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun) 60 54 { … … 62 56 assert(hub_fun); 63 57 64 const usb_address_t hub_address = 58 int ret; 59 60 usb_address_t hub_address = 65 61 device_keeper_get_free_address(&instance->manager, USB_SPEED_FULL); 66 62 if (hub_address <= 0) { 67 usb_log_error("Failed(%d) to get OHCI root hub address.\n", 68 hub_address); 63 usb_log_error("Failed to get OHCI root hub address.\n"); 69 64 return hub_address; 70 65 } … … 73 68 &instance->manager, hub_address, hub_fun->handle); 74 69 75 #define CHECK_RET_RELEASE(ret, message...) \ 76 if (ret != EOK) { \ 77 usb_log_error(message); \ 78 hc_remove_endpoint(instance, hub_address, 0, USB_DIRECTION_BOTH); \ 79 usb_device_keeper_release(&instance->manager, hub_address); \ 80 return ret; \ 81 } else (void)0 82 83 int ret = hc_add_endpoint(instance, hub_address, 0, USB_SPEED_FULL, 70 ret = hc_add_endpoint(instance, hub_address, 0, USB_SPEED_FULL, 84 71 USB_TRANSFER_CONTROL, USB_DIRECTION_BOTH, 64, 0, 0); 85 CHECK_RET_RELEASE(ret, "Failed(%d) to add OHCI rh endpoint 0.\n", ret); 72 if (ret != EOK) { 73 usb_log_error("Failed to add OHCI rh endpoint 0.\n"); 74 usb_device_keeper_release(&instance->manager, hub_address); 75 return ret; 76 } 86 77 87 78 char *match_str = NULL; 88 79 /* DDF needs heap allocated string */ 89 80 ret = asprintf(&match_str, "usb&class=hub"); 90 ret = ret > 0 ? 0 : ret; 91 CHECK_RET_RELEASE(ret, "Failed(%d) to create match-id string.\n", ret); 81 if (ret < 0) { 82 usb_log_error( 83 "Failed(%d) to create root hub match-id string.\n", ret); 84 usb_device_keeper_release(&instance->manager, hub_address); 85 return ret; 86 } 92 87 93 88 ret = ddf_fun_add_match_id(hub_fun, match_str, 100); 94 CHECK_RET_RELEASE(ret, "Failed(%d) add root hub match-id.\n", ret); 95 89 if (ret != EOK) { 90 usb_log_error("Failed add root hub match-id.\n"); 91 } 96 92 ret = ddf_fun_bind(hub_fun); 97 CHECK_RET_RELEASE(ret, "Failed(%d) to bind root hub function.\n", ret); 98 99 return EOK; 100 #undef CHECK_RET_RELEASE 101 } 102 /*----------------------------------------------------------------------------*/ 103 /** Initialize OHCI hc driver structure 104 * 105 * @param[in] instance Memory place for the structure. 106 * @param[in] regs Address of the memory mapped I/O registers. 107 * @param[in] reg_size Size of the memory mapped area. 108 * @param[in] interrupts True if w interrupts should be used 109 * @return Error code 110 */ 93 return ret; 94 } 95 /*----------------------------------------------------------------------------*/ 111 96 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts) 112 97 { … … 136 121 #undef CHECK_RET_RETURN 137 122 123 124 // hc_init_hw(instance); 125 hc_gain_control(instance); 138 126 fibril_mutex_initialize(&instance->guard); 139 hc_gain_control(instance);140 127 141 128 rh_init(&instance->rh, instance->registers); … … 150 137 } 151 138 /*----------------------------------------------------------------------------*/ 152 /** Create end register endpoint structures153 *154 * @param[in] instance OHCI driver structure.155 * @param[in] address USB address of the device.156 * @param[in] endpoint USB endpoint number.157 * @param[in] speed Communication speeed of the device.158 * @param[in] type Endpoint's transfer type.159 * @param[in] direction Endpoint's direction.160 * @param[in] mps Maximum packet size the endpoint accepts.161 * @param[in] size Maximum allowed buffer size.162 * @param[in] interval Time between transfers(interrupt transfers only).163 * @return Error code164 */165 139 int hc_add_endpoint( 166 140 hc_t *instance, usb_address_t address, usb_endpoint_t endpoint, … … 220 194 } 221 195 /*----------------------------------------------------------------------------*/ 222 /** Dequeue and delete endpoint structures223 *224 * @param[in] instance OHCI hc driver structure.225 * @param[in] address USB address of the device.226 * @param[in] endpoint USB endpoint number.227 * @param[in] direction Direction of the endpoint.228 * @return Error code229 */230 196 int hc_remove_endpoint(hc_t *instance, usb_address_t address, 231 197 usb_endpoint_t endpoint, usb_direction_t direction) … … 278 244 } 279 245 /*----------------------------------------------------------------------------*/ 280 /** Get access to endpoint structures281 *282 * @param[in] instance OHCI hc driver structure.283 * @param[in] address USB address of the device.284 * @param[in] endpoint USB endpoint number.285 * @param[in] direction Direction of the endpoint.286 * @param[out] bw Reserved bandwidth.287 * @return Error code288 */289 246 endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address, 290 247 usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw) … … 298 255 } 299 256 /*----------------------------------------------------------------------------*/ 300 /** Add USB transfer to the schedule.301 *302 * @param[in] instance OHCI hc driver structure.303 * @param[in] batch Batch representing the transfer.304 * @return Error code.305 */306 257 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch) 307 258 { … … 310 261 assert(batch->ep); 311 262 312 /* Check for root hub communication */263 /* check for root hub communication */ 313 264 if (batch->ep->address == instance->rh.address) { 314 265 return rh_request(&instance->rh, batch); … … 318 269 list_append(&batch->link, &instance->pending_batches); 319 270 batch_commit(batch); 320 321 /* Control and bulk schedules need a kick to start working */ 322 switch (batch->ep->transfer_type) 323 { 271 switch (batch->ep->transfer_type) { 324 272 case USB_TRANSFER_CONTROL: 325 273 instance->registers->command_status |= CS_CLF; … … 331 279 break; 332 280 } 281 333 282 fibril_mutex_unlock(&instance->guard); 334 283 return EOK; 335 284 } 336 285 /*----------------------------------------------------------------------------*/ 337 /** Interrupt handling routine338 *339 * @param[in] instance OHCI hc driver structure.340 * @param[in] status Value of the status register at the time of interrupt.341 */342 286 void hc_interrupt(hc_t *instance, uint32_t status) 343 287 { … … 348 292 if (status & I_RHSC) 349 293 rh_interrupt(&instance->rh); 294 350 295 351 296 if (status & I_WDH) { … … 371 316 fibril_mutex_unlock(&instance->guard); 372 317 } 373 374 if (status & I_UE) { 375 hc_start_hw(instance); 376 } 377 378 } 379 /*----------------------------------------------------------------------------*/ 380 /** Check status register regularly 381 * 382 * @param[in] instance OHCI hc driver structure. 383 * @return Error code 384 */ 318 } 319 /*----------------------------------------------------------------------------*/ 385 320 int interrupt_emulator(hc_t *instance) 386 321 { … … 391 326 instance->registers->interrupt_status = status; 392 327 hc_interrupt(instance, status); 393 async_usleep( 10000);328 async_usleep(50000); 394 329 } 395 330 return EOK; 396 331 } 397 332 /*----------------------------------------------------------------------------*/ 398 /** Turn off any (BIOS)driver that might be in control of the device.399 *400 * @param[in] instance OHCI hc driver structure.401 */402 333 void hc_gain_control(hc_t *instance) 403 334 { … … 449 380 } 450 381 /*----------------------------------------------------------------------------*/ 451 /** OHCI hw initialization routine.452 *453 * @param[in] instance OHCI hc driver structure.454 */455 382 void hc_start_hw(hc_t *instance) 456 383 { … … 520 447 } 521 448 /*----------------------------------------------------------------------------*/ 522 /** Initialize schedule queues523 *524 * @param[in] instance OHCI hc driver structure525 * @return Error code526 */527 449 int hc_init_transfer_lists(hc_t *instance) 528 450 { 529 451 assert(instance); 452 530 453 #define SETUP_ENDPOINT_LIST(type) \ 531 454 do { \ … … 535 458 usb_log_error("Failed(%d) to setup %s endpoint list.\n", \ 536 459 ret, name); \ 537 endpoint_list_fini(&instance->lists[USB_TRANSFER_ISOCHRONOUS]); \460 endpoint_list_fini(&instance->lists[USB_TRANSFER_ISOCHRONOUS]); \ 538 461 endpoint_list_fini(&instance->lists[USB_TRANSFER_INTERRUPT]); \ 539 462 endpoint_list_fini(&instance->lists[USB_TRANSFER_CONTROL]); \ 540 463 endpoint_list_fini(&instance->lists[USB_TRANSFER_BULK]); \ 541 return ret; \542 464 } \ 543 465 } while (0) … … 554 476 } 555 477 /*----------------------------------------------------------------------------*/ 556 /** Initialize memory structures used by the OHCI hcd.557 *558 * @param[in] instance OHCI hc driver structure.559 * @return Error code.560 */561 478 int hc_init_memory(hc_t *instance) 562 479 { … … 565 482 bzero(&instance->rh, sizeof(instance->rh)); 566 483 /* Init queues */ 567 const int ret = hc_init_transfer_lists(instance); 568 if (ret != EOK) { 569 return ret; 570 } 484 hc_init_transfer_lists(instance); 571 485 572 486 /*Init HCCA */ … … 588 502 /* Init interrupt code */ 589 503 instance->interrupt_code.cmds = instance->interrupt_commands; 590 instance->interrupt_code.cmdcount = OHCI_NEEDED_IRQ_COMMANDS;591 504 { 592 505 /* Read status register */ … … 608 521 instance->interrupt_commands[2].srcarg = 2; 609 522 610 /* Write -clean status register */523 /* Write clean status register */ 611 524 instance->interrupt_commands[3].cmd = CMD_MEM_WRITE_A_32; 612 525 instance->interrupt_commands[3].srcarg = 1; … … 616 529 /* Accept interrupt */ 617 530 instance->interrupt_commands[4].cmd = CMD_ACCEPT; 531 532 instance->interrupt_code.cmdcount = OHCI_NEEDED_IRQ_COMMANDS; 618 533 } 619 534
Note:
See TracChangeset
for help on using the changeset viewer.