Changes in uspace/drv/ohci/hc.c [3e4f2e0:4125b7d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/hc.c
r3e4f2e0 r4125b7d 40 40 #include <usb/usb.h> 41 41 #include <usb/ddfiface.h> 42 #include <usb/usbdevice.h> 42 43 43 44 #include "hc.h" 44 45 #include "hcd_endpoint.h" 45 46 46 #define OHCI_USED_INTERRUPTS \47 (I_SO | I_WDH | I_UE | I_RHSC)48 47 static int interrupt_emulator(hc_t *instance); 49 48 static void hc_gain_control(hc_t *instance); 49 static void hc_init_hw(hc_t *instance); 50 50 static int hc_init_transfer_lists(hc_t *instance); 51 51 static int hc_init_memory(hc_t *instance); … … 90 90 usb_log_error("Failed add root hub match-id.\n"); 91 91 } 92 ret = ddf_fun_bind(hub_fun);93 92 return ret; 94 93 } 95 94 /*----------------------------------------------------------------------------*/ 96 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts) 95 int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev, 96 uintptr_t regs, size_t reg_size, bool interrupts) 97 97 { 98 98 assert(instance); … … 109 109 ret, str_error(ret)); 110 110 111 list_initialize(&instance->pending_batches);112 111 usb_device_keeper_init(&instance->manager); 113 112 ret = usb_endpoint_manager_init(&instance->ep_manager, … … 116 115 str_error(ret)); 117 116 117 hc_gain_control(instance); 118 118 ret = hc_init_memory(instance); 119 119 CHECK_RET_RETURN(ret, "Failed to create OHCI memory structures: %s.\n", 120 120 str_error(ret)); 121 #undef CHECK_RET_RETURN 122 123 124 // hc_init_hw(instance); 125 hc_gain_control(instance); 121 hc_init_hw(instance); 126 122 fibril_mutex_initialize(&instance->guard); 127 123 … … 134 130 } 135 131 132 list_initialize(&instance->pending_batches); 133 #undef CHECK_RET_RETURN 136 134 return EOK; 137 135 } … … 287 285 { 288 286 assert(instance); 289 usb_log_debug("OHCI(%p) interrupt: %x.\n", instance, status); 290 if ((status & ~I_SF) == 0) /* ignore sof status */ 287 if ((status & ~IS_SF) == 0) /* ignore sof status */ 291 288 return; 292 if (status & I _RHSC)289 if (status & IS_RHSC) 293 290 rh_interrupt(&instance->rh); 294 291 295 296 if (status & I_WDH) { 292 usb_log_debug("OHCI interrupt: %x.\n", status); 293 294 if (status & IS_WDH) { 297 295 fibril_mutex_lock(&instance->guard); 298 296 usb_log_debug2("HCCA: %p-%#" PRIx32 " (%p).\n", instance->hcca, … … 334 332 { 335 333 assert(instance); 336 usb_log_debug("Requesting OHCI control.\n");337 334 /* Turn off legacy emulation */ 338 335 volatile uint32_t *ohci_emulation_reg = 339 336 (uint32_t*)((char*)instance->registers + 0x100); 340 337 usb_log_debug("OHCI legacy register %p: %x.\n", 341 ohci_emulation_reg, *ohci_emulation_reg); 342 /* Do not change A20 state */ 343 *ohci_emulation_reg &= 0x100; 344 usb_log_debug("OHCI legacy register %p: %x.\n", 345 ohci_emulation_reg, *ohci_emulation_reg); 338 ohci_emulation_reg, *ohci_emulation_reg); 339 *ohci_emulation_reg = 0; 346 340 347 341 /* Interrupt routing enabled => smm driver is active */ … … 353 347 } 354 348 usb_log_info("SMM driver: Ownership taken.\n"); 355 instance->registers->control &= (C_HCFS_RESET << C_HCFS_SHIFT);356 async_usleep(50000);357 349 return; 358 350 } … … 380 372 } 381 373 /*----------------------------------------------------------------------------*/ 382 void hc_ start_hw(hc_t *instance)374 void hc_init_hw(hc_t *instance) 383 375 { 384 376 /* OHCI guide page 42 */ … … 429 421 instance->registers->control); 430 422 431 /* Enable interrupts */ 432 instance->registers->interrupt_enable = OHCI_USED_INTERRUPTS; 423 /* Disable interrupts */ 424 instance->registers->interrupt_disable = I_SF | I_OC; 425 usb_log_debug2("Disabling interrupts: %x.\n", 426 instance->registers->interrupt_disable); 427 instance->registers->interrupt_disable = I_MI; 433 428 usb_log_debug2("Enabled interrupts: %x.\n", 434 429 instance->registers->interrupt_enable); 435 instance->registers->interrupt_enable = I_MI;436 430 437 431 /* Set periodic start to 90% */ … … 479 473 { 480 474 assert(instance); 481 482 bzero(&instance->rh, sizeof(instance->rh));483 475 /* Init queues */ 484 476 hc_init_transfer_lists(instance); … … 500 492 instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa); 501 493 502 /* Init interrupt code */503 instance->interrupt_code.cmds = instance->interrupt_commands;504 {505 /* Read status register */506 instance->interrupt_commands[0].cmd = CMD_MEM_READ_32;507 instance->interrupt_commands[0].dstarg = 1;508 instance->interrupt_commands[0].addr =509 (void*)&instance->registers->interrupt_status;510 511 /* Test whether we are the interrupt cause */512 instance->interrupt_commands[1].cmd = CMD_BTEST;513 instance->interrupt_commands[1].value =514 OHCI_USED_INTERRUPTS;515 instance->interrupt_commands[1].srcarg = 1;516 instance->interrupt_commands[1].dstarg = 2;517 518 /* Predicate cleaning and accepting */519 instance->interrupt_commands[2].cmd = CMD_PREDICATE;520 instance->interrupt_commands[2].value = 2;521 instance->interrupt_commands[2].srcarg = 2;522 523 /* Write clean status register */524 instance->interrupt_commands[3].cmd = CMD_MEM_WRITE_A_32;525 instance->interrupt_commands[3].srcarg = 1;526 instance->interrupt_commands[3].addr =527 (void*)&instance->registers->interrupt_status;528 529 /* Accept interrupt */530 instance->interrupt_commands[4].cmd = CMD_ACCEPT;531 532 instance->interrupt_code.cmdcount = OHCI_NEEDED_IRQ_COMMANDS;533 }534 535 494 return EOK; 536 495 }
Note:
See TracChangeset
for help on using the changeset viewer.