Changeset 26e7d6d in mainline for uspace/drv/bus/usb/uhci/uhci.c
- Timestamp:
- 2011-09-19T16:31:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a347a11
- Parents:
- 3842a955 (diff), 086290d (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 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/uhci.c
r3842a955 r26e7d6d 41 41 42 42 #include "uhci.h" 43 #include "iface.h"44 43 #include "pci.h" 45 44 … … 64 63 { 65 64 assert(dev); 66 assert(dev->driver_data);67 65 return dev->driver_data; 68 66 } … … 78 76 assert(dev); 79 77 uhci_t *uhci = dev_to_uhci(dev); 80 hc_t *hc = &uhci->hc; 78 if (!uhci) { 79 usb_log_error("Interrupt on not yet initialized device.\n"); 80 return; 81 } 81 82 const uint16_t status = IPC_GET_ARG1(*call); 82 assert(hc); 83 hc_interrupt(hc, status); 83 hc_interrupt(&uhci->hc, status); 84 84 } 85 85 /*----------------------------------------------------------------------------*/ 86 86 /** Operations supported by the HC driver */ 87 87 static ddf_dev_ops_t hc_ops = { 88 .interfaces[USBHC_DEV_IFACE] = &hc _iface, /* see iface.h/c */88 .interfaces[USBHC_DEV_IFACE] = &hcd_iface, /* see iface.h/c */ 89 89 }; 90 90 /*----------------------------------------------------------------------------*/ … … 99 99 { 100 100 assert(fun); 101 usb_device_keeper_t *manager = &dev_to_uhci(fun->dev)->hc.manager; 102 usb_address_t addr = usb_device_keeper_find(manager, handle); 101 usb_device_manager_t *manager = 102 &dev_to_uhci(fun->dev)->hc.generic.dev_manager; 103 const usb_address_t addr = usb_device_manager_find(manager, handle); 103 104 104 105 if (addr < 0) { … … 191 192 ddf_fun_destroy(instance->rh_fun); \ 192 193 } \ 193 free(instance); \194 device->driver_data = NULL; \ 194 195 usb_log_error(message); \ 195 196 return ret; \ … … 201 202 CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI HC function.\n"); 202 203 instance->hc_fun->ops = &hc_ops; 203 instance->hc_fun->driver_data = &instance->hc ;204 instance->hc_fun->driver_data = &instance->hc.generic; 204 205 205 206 instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci_rh"); … … 222 223 ret = pci_disable_legacy(device); 223 224 CHECK_RET_DEST_FREE_RETURN(ret, 224 "Failed(%d) to disable legacy USB: %s.\n", ret, str_error(ret)); 225 "Failed to disable legacy USB: %s.\n", str_error(ret)); 226 227 const size_t cmd_count = hc_irq_cmd_count(); 228 irq_cmd_t irq_cmds[cmd_count]; 229 ret = 230 hc_get_irq_commands(irq_cmds, sizeof(irq_cmds), reg_base, reg_size); 231 CHECK_RET_DEST_FREE_RETURN(ret, 232 "Failed to generate IRQ commands: %s.\n", str_error(ret)); 233 234 irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds }; 235 236 /* Register handler to avoid interrupt lockup */ 237 ret = register_interrupt_handler(device, irq, irq_handler, &irq_code); 238 CHECK_RET_DEST_FREE_RETURN(ret, 239 "Failed to register interrupt handler: %s.\n", str_error(ret)); 225 240 226 241 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 242 ret = pci_enable_interrupts(device); 232 243 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"); 244 usb_log_warning("Failed to enable interrupts: %s." 245 " Falling back to polling.\n", str_error(ret)); 237 246 } else { 238 247 usb_log_debug("Hw interrupts enabled.\n"); 239 248 interrupts = true; 240 249 } 241 #endif242 243 250 244 251 ret = hc_init(&instance->hc, (void*)reg_base, reg_size, interrupts); 245 252 CHECK_RET_DEST_FREE_RETURN(ret, 246 "Failed(%d) to init uhci_hcd: %s.\n", ret, str_error(ret)); 253 "Failed to init uhci_hcd: %s.\n", str_error(ret)); 254 255 device->driver_data = instance; 247 256 248 257 #define CHECK_RET_FINI_RETURN(ret, message...) \ … … 253 262 } else (void)0 254 263 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 264 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 267 ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME); 265 CHECK_RET_FINI_RETURN(ret, "Failed to bind UHCI device function: %s.\n", 266 str_error(ret)); 267 268 ret = ddf_fun_add_to_category(instance->hc_fun, USB_HC_CATEGORY); 268 269 CHECK_RET_FINI_RETURN(ret, 269 270 "Failed to add UHCI to HC class: %s.\n", str_error(ret)); … … 272 273 (uintptr_t)instance->hc.registers + 0x10, 4); 273 274 CHECK_RET_FINI_RETURN(ret, 274 "Failed (%d) to setup UHCI root hub: %s.\n", ret, str_error(ret));275 "Failed to setup UHCI root hub: %s.\n", str_error(ret)); 275 276 276 277 ret = ddf_fun_bind(instance->rh_fun); 277 278 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; 279 "Failed to register UHCI root hub: %s.\n", str_error(ret)); 280 281 281 return EOK; 282 282 #undef CHECK_RET_FINI_RETURN
Note:
See TracChangeset
for help on using the changeset viewer.