Changeset a1732929 in mainline for uspace/drv/bus/usb/ohci
- Timestamp:
- 2018-01-15T17:04:34Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9ff99e8
- Parents:
- c1a966e
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-01-15 17:04:32)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-01-15 17:04:34)
- Location:
- uspace/drv/bus/usb/ohci
- Files:
-
- 4 edited
-
endpoint_list.c (modified) (5 diffs)
-
hc.c (modified) (26 diffs)
-
ohci_batch.c (modified) (11 diffs)
-
ohci_rh.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/endpoint_list.c
rc1a966e ra1732929 57 57 instance->list_head = malloc32(sizeof(ed_t)); 58 58 if (!instance->list_head) { 59 usb_log_error("Failed to allocate list head. \n");59 usb_log_error("Failed to allocate list head."); 60 60 return ENOMEM; 61 61 } 62 62 instance->list_head_pa = addr_to_phys(instance->list_head); 63 usb_log_debug2("Transfer list %s setup with ED: %p(0x%0" PRIx32 ")). \n",63 usb_log_debug2("Transfer list %s setup with ED: %p(0x%0" PRIx32 ")).", 64 64 name, instance->list_head, instance->list_head_pa); 65 65 … … 96 96 assert(instance); 97 97 assert(ep); 98 usb_log_debug2("Queue %s: Adding endpoint(%p). \n", instance->name, ep);98 usb_log_debug2("Queue %s: Adding endpoint(%p).", instance->name, ep); 99 99 100 100 fibril_mutex_lock(&instance->guard); … … 126 126 ohci_endpoint_t *first = list_get_instance( 127 127 list_first(&instance->endpoint_list), ohci_endpoint_t, link); 128 usb_log_debug("HCD EP(%p) added to list %s, first is %p(%p). \n",128 usb_log_debug("HCD EP(%p) added to list %s, first is %p(%p).", 129 129 ep, instance->name, first, first->ed); 130 130 if (last_ed == instance->list_head) { 131 usb_log_debug2("%s head ED(%p-0x%0" PRIx32 "): %x:%x:%x:%x. \n",131 usb_log_debug2("%s head ED(%p-0x%0" PRIx32 "): %x:%x:%x:%x.", 132 132 instance->name, last_ed, instance->list_head_pa, 133 133 last_ed->status, last_ed->td_tail, last_ed->td_head, … … 151 151 fibril_mutex_lock(&instance->guard); 152 152 153 usb_log_debug2("Queue %s: removing endpoint(%p). \n", instance->name, ep);153 usb_log_debug2("Queue %s: removing endpoint(%p).", instance->name, ep); 154 154 155 155 const char *qpos = NULL; … … 171 171 write_barrier(); 172 172 173 usb_log_debug("HCD EP(%p) removed (%s) from %s, next %x. \n",173 usb_log_debug("HCD EP(%p) removed (%s) from %s, next %x.", 174 174 ep, qpos, instance->name, ep->ed->next); 175 175 -
uspace/drv/bus/usb/ohci/hc.c
rc1a966e ra1732929 136 136 OHCI_WR(code->cmds[1].value, OHCI_USED_INTERRUPTS); 137 137 138 usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d. \n",138 usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.", 139 139 RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]); 140 140 … … 160 160 (void **) &instance->registers); 161 161 if (ret != EOK) { 162 usb_log_error("Failed to gain access to registers: %s. \n",162 usb_log_error("Failed to gain access to registers: %s.", 163 163 str_error(ret)); 164 164 return ret; 165 165 } 166 usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible. \n",166 usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.", 167 167 hw_res->mem_ranges.ranges[0].address.absolute, 168 168 hw_res->mem_ranges.ranges[0].size); … … 173 173 ret = hc_init_memory(instance); 174 174 if (ret != EOK) { 175 usb_log_error("Failed to create OHCI memory structures: %s. \n",175 usb_log_error("Failed to create OHCI memory structures: %s.", 176 176 str_error(ret)); 177 177 // TODO: We should disable pio access here … … 293 293 /* Check for root hub communication */ 294 294 if (batch->target.address == ohci_rh_get_address(&hc->rh)) { 295 usb_log_debug("OHCI root hub request. \n");295 usb_log_debug("OHCI root hub request."); 296 296 return ohci_rh_schedule(&hc->rh, batch); 297 297 } … … 341 341 if ((status & ~I_SF) == 0) /* ignore sof status */ 342 342 return; 343 usb_log_debug2("OHCI(%p) interrupt: %x. \n", hc, status);343 usb_log_debug2("OHCI(%p) interrupt: %x.", hc, status); 344 344 if (status & I_RHSC) 345 345 ohci_rh_interrupt(&hc->rh); … … 347 347 if (status & I_WDH) { 348 348 fibril_mutex_lock(&hc->guard); 349 usb_log_debug2("HCCA: %p-%#" PRIx32 " (%p). \n", hc->hcca,349 usb_log_debug2("HCCA: %p-%#" PRIx32 " (%p).", hc->hcca, 350 350 OHCI_RD(hc->registers->hcca), 351 351 (void *) addr_to_phys(hc->hcca)); 352 usb_log_debug2("Periodic current: %#" PRIx32 ". \n",352 usb_log_debug2("Periodic current: %#" PRIx32 ".", 353 353 OHCI_RD(hc->registers->periodic_current)); 354 354 … … 370 370 371 371 if (status & I_UE) { 372 usb_log_fatal("Error like no other! \n");372 usb_log_fatal("Error like no other!"); 373 373 hc_start(&hc->base); 374 374 } … … 387 387 hc_t *instance = hcd_to_hc(hcd); 388 388 389 usb_log_debug("Requesting OHCI control. \n");389 usb_log_debug("Requesting OHCI control."); 390 390 if (OHCI_RD(instance->registers->revision) & R_LEGACY_FLAG) { 391 391 /* Turn off legacy emulation, it should be enough to zero … … 396 396 volatile uint32_t *ohci_emulation_reg = 397 397 (uint32_t*)((char*)instance->registers + LEGACY_REGS_OFFSET); 398 usb_log_debug("OHCI legacy register %p: %x. \n",398 usb_log_debug("OHCI legacy register %p: %x.", 399 399 ohci_emulation_reg, OHCI_RD(*ohci_emulation_reg)); 400 400 /* Zero everything but A20State */ … … 402 402 OHCI_CLR(*ohci_emulation_reg, ~0x100); 403 403 usb_log_debug( 404 "OHCI legacy register (should be 0 or 0x100) %p: %x. \n",404 "OHCI legacy register (should be 0 or 0x100) %p: %x.", 405 405 ohci_emulation_reg, OHCI_RD(*ohci_emulation_reg)); 406 406 } … … 408 408 /* Interrupt routing enabled => smm driver is active */ 409 409 if (OHCI_RD(instance->registers->control) & C_IR) { 410 usb_log_debug("SMM driver: request ownership change. \n");410 usb_log_debug("SMM driver: request ownership change."); 411 411 // TODO: should we ack interrupts before doing this? 412 412 OHCI_SET(instance->registers->command_status, CS_OCR); … … 415 415 async_usleep(1000); 416 416 } 417 usb_log_info("SMM driver: Ownership taken. \n");417 usb_log_info("SMM driver: Ownership taken."); 418 418 C_HCFS_SET(instance->registers->control, C_HCFS_RESET); 419 419 async_usleep(50000); … … 424 424 /* Interrupt routing disabled && status != USB_RESET => BIOS active */ 425 425 if (hc_status != C_HCFS_RESET) { 426 usb_log_debug("BIOS driver found. \n");426 usb_log_debug("BIOS driver found."); 427 427 if (hc_status == C_HCFS_OPERATIONAL) { 428 usb_log_info("BIOS driver: HC operational. \n");428 usb_log_info("BIOS driver: HC operational."); 429 429 return EOK; 430 430 } … … 432 432 C_HCFS_SET(instance->registers->control, C_HCFS_RESUME); 433 433 async_usleep(20000); 434 usb_log_info("BIOS driver: HC resumed. \n");434 usb_log_info("BIOS driver: HC resumed."); 435 435 return EOK; 436 436 } … … 438 438 /* HC is in reset (hw startup) => no other driver 439 439 * maintain reset for at least the time specified in USB spec (50 ms)*/ 440 usb_log_debug("Host controller found in reset state. \n");440 usb_log_debug("Host controller found in reset state."); 441 441 async_usleep(50000); 442 442 return EOK; … … 454 454 /* OHCI guide page 42 */ 455 455 assert(instance); 456 usb_log_debug2("Started hc initialization routine. \n");456 usb_log_debug2("Started hc initialization routine."); 457 457 458 458 /* Save contents of fm_interval register */ 459 459 const uint32_t fm_interval = OHCI_RD(instance->registers->fm_interval); 460 usb_log_debug2("Old value of HcFmInterval: %x. \n", fm_interval);460 usb_log_debug2("Old value of HcFmInterval: %x.", fm_interval); 461 461 462 462 /* Reset hc */ 463 usb_log_debug2("HC reset. \n");463 usb_log_debug2("HC reset."); 464 464 size_t time = 0; 465 465 OHCI_WR(instance->registers->command_status, CS_HCR); … … 468 468 time += 10; 469 469 } 470 usb_log_debug2("HC reset complete in %zu us. \n", time);470 usb_log_debug2("HC reset complete in %zu us.", time); 471 471 472 472 /* Restore fm_interval */ … … 475 475 476 476 /* hc is now in suspend state */ 477 usb_log_debug2("HC should be in suspend state(%x). \n",477 usb_log_debug2("HC should be in suspend state(%x).", 478 478 OHCI_RD(instance->registers->control)); 479 479 … … 484 484 OHCI_WR(instance->registers->bulk_head, 485 485 instance->lists[USB_TRANSFER_BULK].list_head_pa); 486 usb_log_debug2("Bulk HEAD set to: %p (%#" PRIx32 "). \n",486 usb_log_debug2("Bulk HEAD set to: %p (%#" PRIx32 ").", 487 487 instance->lists[USB_TRANSFER_BULK].list_head, 488 488 instance->lists[USB_TRANSFER_BULK].list_head_pa); … … 490 490 OHCI_WR(instance->registers->control_head, 491 491 instance->lists[USB_TRANSFER_CONTROL].list_head_pa); 492 usb_log_debug2("Control HEAD set to: %p (%#" PRIx32 "). \n",492 usb_log_debug2("Control HEAD set to: %p (%#" PRIx32 ").", 493 493 instance->lists[USB_TRANSFER_CONTROL].list_head, 494 494 instance->lists[USB_TRANSFER_CONTROL].list_head_pa); … … 496 496 /* Enable queues */ 497 497 OHCI_SET(instance->registers->control, (C_PLE | C_IE | C_CLE | C_BLE)); 498 usb_log_debug("Queues enabled(%x). \n",498 usb_log_debug("Queues enabled(%x).", 499 499 OHCI_RD(instance->registers->control)); 500 500 … … 503 503 OHCI_WR(instance->registers->interrupt_enable, 504 504 OHCI_USED_INTERRUPTS); 505 usb_log_debug("Enabled interrupts: %x. \n",505 usb_log_debug("Enabled interrupts: %x.", 506 506 OHCI_RD(instance->registers->interrupt_enable)); 507 507 OHCI_WR(instance->registers->interrupt_enable, I_MI); … … 513 513 OHCI_WR(instance->registers->periodic_start, 514 514 ((frame_length / 10) * 9) & PS_MASK << PS_SHIFT); 515 usb_log_debug2("All periodic start set to: %x(%u - 90%% of %d). \n",515 usb_log_debug2("All periodic start set to: %x(%u - 90%% of %d).", 516 516 OHCI_RD(instance->registers->periodic_start), 517 517 OHCI_RD(instance->registers->periodic_start), frame_length); 518 518 C_HCFS_SET(instance->registers->control, C_HCFS_OPERATIONAL); 519 usb_log_debug("OHCI HC up and running (ctl_reg=0x%x). \n",519 usb_log_debug("OHCI HC up and running (ctl_reg=0x%x).", 520 520 OHCI_RD(instance->registers->control)); 521 521 … … 536 536 const int ret = endpoint_list_init(&instance->lists[type], name); \ 537 537 if (ret != EOK) { \ 538 usb_log_error("Failed to setup %s endpoint list: %s. \n", \538 usb_log_error("Failed to setup %s endpoint list: %s.", \ 539 539 name, str_error(ret)); \ 540 540 endpoint_list_fini(&instance->lists[USB_TRANSFER_ISOCHRONOUS]);\ … … 577 577 if (instance->hcca == NULL) 578 578 return ENOMEM; 579 usb_log_debug2("OHCI HCCA initialized at %p. \n", instance->hcca);579 usb_log_debug2("OHCI HCCA initialized at %p.", instance->hcca); 580 580 581 581 for (unsigned i = 0; i < HCCA_INT_EP_COUNT; ++i) { … … 583 583 instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa); 584 584 } 585 usb_log_debug2("Interrupt HEADs set to: %p (%#" PRIx32 "). \n",585 usb_log_debug2("Interrupt HEADs set to: %p (%#" PRIx32 ").", 586 586 instance->lists[USB_TRANSFER_INTERRUPT].list_head, 587 587 instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa); -
uspace/drv/bus/usb/ohci/ohci_batch.c
rc1a966e ra1732929 175 175 assert(ohci_batch); 176 176 177 usb_log_debug("Batch %p checking %zu td(s) for completion. \n",177 usb_log_debug("Batch %p checking %zu td(s) for completion.", 178 178 &ohci_batch->base, ohci_batch->td_count); 179 usb_log_debug2("ED: %08x:%08x:%08x:%08x. \n",179 usb_log_debug2("ED: %08x:%08x:%08x:%08x.", 180 180 ohci_batch->ed->status, ohci_batch->ed->td_head, 181 181 ohci_batch->ed->td_tail, ohci_batch->ed->next); … … 196 196 for (size_t i = 0; i < ohci_batch->td_count; ++i) { 197 197 assert(ohci_batch->tds[i] != NULL); 198 usb_log_debug("TD %zu: %08x:%08x:%08x:%08x. \n", i,198 usb_log_debug("TD %zu: %08x:%08x:%08x:%08x.", i, 199 199 ohci_batch->tds[i]->status, ohci_batch->tds[i]->cbp, 200 200 ohci_batch->tds[i]->next, ohci_batch->tds[i]->be); … … 217 217 -= td_remain_size(ohci_batch->tds[i]); 218 218 } else { 219 usb_log_debug("Batch %p found error TD(%zu):%08x. \n",219 usb_log_debug("Batch %p found error TD(%zu):%08x.", 220 220 &ohci_batch->base, i, 221 221 ohci_batch->tds[i]->status); … … 295 295 assert(dir == USB_DIRECTION_IN || dir == USB_DIRECTION_OUT); 296 296 297 usb_log_debug("Using ED(%p): %08x:%08x:%08x:%08x. \n", ohci_batch->ed,297 usb_log_debug("Using ED(%p): %08x:%08x:%08x:%08x.", ohci_batch->ed, 298 298 ohci_batch->ed->status, ohci_batch->ed->td_tail, 299 299 ohci_batch->ed->td_head, ohci_batch->ed->next); … … 312 312 ohci_batch->tds[0], ohci_batch->tds[1], USB_DIRECTION_BOTH, 313 313 buffer, USB_SETUP_PACKET_SIZE, toggle); 314 usb_log_debug("Created CONTROL SETUP TD: %08x:%08x:%08x:%08x. \n",314 usb_log_debug("Created CONTROL SETUP TD: %08x:%08x:%08x:%08x.", 315 315 ohci_batch->tds[0]->status, ohci_batch->tds[0]->cbp, 316 316 ohci_batch->tds[0]->next, ohci_batch->tds[0]->be); … … 328 328 ohci_batch->tds[td_current + 1], 329 329 data_dir, buffer, transfer_size, toggle); 330 usb_log_debug("Created CONTROL DATA TD: %08x:%08x:%08x:%08x. \n",330 usb_log_debug("Created CONTROL DATA TD: %08x:%08x:%08x:%08x.", 331 331 ohci_batch->tds[td_current]->status, 332 332 ohci_batch->tds[td_current]->cbp, … … 344 344 td_init(ohci_batch->tds[td_current], ohci_batch->tds[td_current + 1], 345 345 status_dir, NULL, 0, 1); 346 usb_log_debug("Created CONTROL STATUS TD: %08x:%08x:%08x:%08x. \n",346 usb_log_debug("Created CONTROL STATUS TD: %08x:%08x:%08x:%08x.", 347 347 ohci_batch->tds[td_current]->status, 348 348 ohci_batch->tds[td_current]->cbp, … … 350 350 ohci_batch->tds[td_current]->be); 351 351 usb_log_debug2( 352 "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized. \n", \352 "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized.", \ 353 353 &ohci_batch->base, 354 354 usb_str_transfer_type(ohci_batch->base.ep->transfer_type), … … 371 371 usb_direction_t dir = ohci_batch->base.dir; 372 372 assert(dir == USB_DIRECTION_IN || dir == USB_DIRECTION_OUT); 373 usb_log_debug("Using ED(%p): %08x:%08x:%08x:%08x. \n", ohci_batch->ed,373 usb_log_debug("Using ED(%p): %08x:%08x:%08x:%08x.", ohci_batch->ed, 374 374 ohci_batch->ed->status, ohci_batch->ed->td_tail, 375 375 ohci_batch->ed->td_head, ohci_batch->ed->next); … … 386 386 dir, buffer, transfer_size, -1); 387 387 388 usb_log_debug("Created DATA TD: %08x:%08x:%08x:%08x. \n",388 usb_log_debug("Created DATA TD: %08x:%08x:%08x:%08x.", 389 389 ohci_batch->tds[td_current]->status, 390 390 ohci_batch->tds[td_current]->cbp, … … 398 398 } 399 399 usb_log_debug2( 400 "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized. \n", \400 "Batch %p %s %s " USB_TRANSFER_BATCH_FMT " initialized.", \ 401 401 &ohci_batch->base, 402 402 usb_str_transfer_type(ohci_batch->base.ep->transfer_type), -
uspace/drv/bus/usb/ohci/ohci_rh.c
rc1a966e ra1732929 114 114 instance->registers = regs; 115 115 instance->port_count = OHCI_RD(regs->rh_desc_a) & RHDA_NDS_MASK; 116 usb_log_debug2("rh_desc_a: %x. \n", OHCI_RD(regs->rh_desc_a));116 usb_log_debug2("rh_desc_a: %x.", OHCI_RD(regs->rh_desc_a)); 117 117 if (instance->port_count > OHCI_MAX_PORTS) { 118 118 usb_log_warning("OHCI specification does not allow %d ports. " 119 "Max %d ports will be used. \n", instance->port_count,119 "Max %d ports will be used.", instance->port_count, 120 120 OHCI_MAX_PORTS); 121 121 instance->port_count = OHCI_MAX_PORTS; 122 122 } 123 usb_log_info("%s: Found %u ports. \n", name, instance->port_count);123 usb_log_info("%s: Found %u ports.", name, instance->port_count); 124 124 125 125 #if defined OHCI_POWER_SWITCH_no 126 usb_log_info("%s: Set power mode to no power switching. \n", name);126 usb_log_info("%s: Set power mode to no power switching.", name); 127 127 /* Set port power mode to no power-switching. (always on) */ 128 128 OHCI_SET(regs->rh_desc_a, RHDA_NPS_FLAG); … … 132 132 133 133 #elif defined OHCI_POWER_SWITCH_ganged 134 usb_log_info("%s: Set power mode to ganged power switching. \n", name);134 usb_log_info("%s: Set power mode to ganged power switching.", name); 135 135 /* Set port power mode to ganged power-switching. */ 136 136 OHCI_CLR(regs->rh_desc_a, RHDA_NPS_FLAG); … … 144 144 OHCI_CLR(regs->rh_desc_a, RHDA_OCPM_FLAG); 145 145 #else 146 usb_log_info("%s: Set power mode to per-port power switching. \n", name);146 usb_log_info("%s: Set power mode to per-port power switching.", name); 147 147 /* Set port power mode to per port power-switching. */ 148 148 OHCI_CLR(regs->rh_desc_a, RHDA_NPS_FLAG); … … 356 356 case USB_HUB_FEATURE_C_PORT_RESET: /*20*/ 357 357 usb_log_debug2("Clearing port C_CONNECTION, C_ENABLE, " 358 "C_SUSPEND, C_OC or C_RESET on port %u. \n", port);358 "C_SUSPEND, C_OC or C_RESET on port %u.", port); 359 359 /* Bit offsets correspond to the feature number */ 360 360 OHCI_WR(hub->registers->rh_port_status[port], … … 405 405 case USB_HUB_FEATURE_PORT_RESET: /*4*/ 406 406 usb_log_debug2("Setting port POWER, ENABLE, SUSPEND or RESET " 407 "on port %u. \n", port);407 "on port %u.", port); 408 408 /* Bit offsets correspond to the feature number */ 409 409 OHCI_WR(hub->registers->rh_port_status[port], 1 << feature); … … 451 451 } 452 452 453 usb_log_debug2("OHCI root hub interrupt mask: %hx. \n", mask);453 usb_log_debug2("OHCI root hub interrupt mask: %hx.", mask); 454 454 455 455 if (mask == 0)
Note:
See TracChangeset
for help on using the changeset viewer.
