Changeset 64639256 in mainline for uspace/drv/bus/usb/uhci/uhci.c
- Timestamp:
- 2011-07-17T09:56:53Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- df0956ee
- Parents:
- 04b3c8c (diff), 4069f5c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/uhci.c
r04b3c8c r64639256 64 64 { 65 65 assert(dev); 66 assert(dev->driver_data);67 66 return dev->driver_data; 68 67 } … … 78 77 assert(dev); 79 78 uhci_t *uhci = dev_to_uhci(dev); 80 hc_t *hc = &uhci->hc; 79 if (!uhci) { 80 usb_log_error("Interrupt on not yet initialized device.\n"); 81 return; 82 } 81 83 const uint16_t status = IPC_GET_ARG1(*call); 82 assert(hc); 83 hc_interrupt(hc, status); 84 hc_interrupt(&uhci->hc, status); 84 85 } 85 86 /*----------------------------------------------------------------------------*/ … … 192 193 } \ 193 194 free(instance); \ 195 device->driver_data = NULL; \ 194 196 usb_log_error(message); \ 195 197 return ret; \ … … 222 224 ret = pci_disable_legacy(device); 223 225 CHECK_RET_DEST_FREE_RETURN(ret, 224 "Failed(%d) to disable legacy USB: %s.\n", ret, str_error(ret)); 226 "Failed to disable legacy USB: %s.\n", str_error(ret)); 227 228 const size_t cmd_count = hc_irq_cmd_count(); 229 irq_cmd_t irq_cmds[cmd_count]; 230 ret = 231 hc_get_irq_commands(irq_cmds, sizeof(irq_cmds), reg_base, reg_size); 232 CHECK_RET_DEST_FREE_RETURN(ret, 233 "Failed to generate IRQ commands: %s.\n", str_error(ret)); 234 235 irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds }; 236 237 /* Register handler to avoid interrupt lockup */ 238 ret = register_interrupt_handler(device, irq, irq_handler, &irq_code); 239 CHECK_RET_DEST_FREE_RETURN(ret, 240 "Failed to register interrupt handler: %s.\n", str_error(ret)); 225 241 226 242 bool interrupts = false; 227 #ifdef CONFIG_USBHC_NO_INTERRUPTS228 usb_log_warning("Interrupts disabled in OS config, " \229 "falling back to polling.\n");230 #else231 243 ret = pci_enable_interrupts(device); 232 244 if (ret != EOK) { 233 usb_log_warning("Failed to enable interrupts: %s.\n", 234 str_error(ret)); 235 usb_log_info("HW interrupts not available, " \ 236 "falling back to polling.\n"); 245 usb_log_warning("Failed to enable interrupts: %s." 246 " Falling back to polling.\n", str_error(ret)); 237 247 } else { 238 248 usb_log_debug("Hw interrupts enabled.\n"); 239 249 interrupts = true; 240 250 } 241 #endif242 243 251 244 252 ret = hc_init(&instance->hc, (void*)reg_base, reg_size, interrupts); 245 253 CHECK_RET_DEST_FREE_RETURN(ret, 246 "Failed(%d) to init uhci_hcd: %s.\n", ret, str_error(ret)); 254 "Failed to init uhci_hcd: %s.\n", str_error(ret)); 255 256 device->driver_data = instance; 247 257 248 258 #define CHECK_RET_FINI_RETURN(ret, message...) \ … … 253 263 } else (void)0 254 264 255 /* It does no harm if we register this on polling */256 ret = register_interrupt_handler(device, irq, irq_handler,257 &instance->hc.interrupt_code);258 CHECK_RET_FINI_RETURN(ret,259 "Failed(%d) to register interrupt handler: %s.\n",260 ret, str_error(ret));261 262 265 ret = ddf_fun_bind(instance->hc_fun); 263 CHECK_RET_FINI_RETURN(ret, 264 "Failed(%d) to bind UHCI device function: %s.\n", 265 ret, str_error(ret)); 266 CHECK_RET_FINI_RETURN(ret, "Failed to bind UHCI device function: %s.\n", 267 str_error(ret)); 266 268 267 269 ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME); … … 272 274 (uintptr_t)instance->hc.registers + 0x10, 4); 273 275 CHECK_RET_FINI_RETURN(ret, 274 "Failed (%d) to setup UHCI root hub: %s.\n", ret, str_error(ret));276 "Failed to setup UHCI root hub: %s.\n", str_error(ret)); 275 277 276 278 ret = ddf_fun_bind(instance->rh_fun); 277 279 CHECK_RET_FINI_RETURN(ret, 278 "Failed(%d) to register UHCI root hub: %s.\n", ret, str_error(ret)); 279 280 device->driver_data = instance; 280 "Failed to register UHCI root hub: %s.\n", str_error(ret)); 281 281 282 return EOK; 282 283 #undef CHECK_RET_FINI_RETURN
Note:
See TracChangeset
for help on using the changeset viewer.