Changeset a1732929 in mainline for uspace/drv/bus/usb/ohci/hc.c
- Timestamp:
- 2018-01-15T17:04:34Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.