Changes in uspace/drv/bus/usb/ehci/main.c [7de1988c:6297465] in mainline
- File:
-
- 1 edited
-
uspace/drv/bus/usb/ehci/main.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/main.c
r7de1988c r6297465 33 33 * Main routines of EHCI driver. 34 34 */ 35 36 35 #include <ddf/driver.h> 37 36 #include <ddf/interrupt.h> 38 37 #include <device/hw_res.h> 39 38 #include <errno.h> 40 #include <stdbool.h>41 39 #include <str_error.h> 42 40 43 41 #include <usb_iface.h> 44 #include <usb/ddfiface.h>45 42 #include <usb/debug.h> 46 #include <usb/host/ hcd.h>43 #include <usb/host/ddf_helpers.h> 47 44 48 45 #include "res.h" 46 #include "ehci.h" 49 47 50 48 #define NAME "ehci" … … 60 58 .driver_ops = &ehci_driver_ops 61 59 }; 62 static ddf_dev_ops_t hc_ops = {63 .interfaces[USBHC_DEV_IFACE] = &hcd_iface,64 };65 60 66 61 … … 72 67 static int ehci_dev_add(ddf_dev_t *device) 73 68 { 74 ddf_fun_t *hc_fun = NULL;75 bool fun_bound = false;76 77 69 assert(device); 78 79 addr_range_t reg_range; 80 int irq = 0; 81 82 int rc = get_my_registers(device, ®_range, &irq); 83 if (rc != EOK) { 84 usb_log_error("Failed to get memory addresses for %" PRIun 85 ": %s.\n", ddf_dev_get_handle(device), str_error(rc)); 86 goto error; 70 hw_res_list_parsed_t hw_res; 71 int ret = hcd_ddf_get_registers(device, &hw_res); 72 if (ret != EOK || 73 hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) { 74 usb_log_error("Failed to get register memory addresses " 75 "for %" PRIun ": %s.\n", ddf_dev_get_handle(device), 76 str_error(ret)); 77 return ret; 87 78 } 79 addr_range_t regs = hw_res.mem_ranges.ranges[0]; 80 const int irq = hw_res.irqs.irqs[0]; 81 hw_res_list_parsed_clean(&hw_res); 88 82 89 83 usb_log_info("Memory mapped regs at %p (size %zu), IRQ %d.\n", 90 RNGABSPTR(reg _range), RNGSZ(reg_range), irq);84 RNGABSPTR(regs), RNGSZ(regs), irq); 91 85 92 r c = disable_legacy(device, ®_range);93 if (r c!= EOK) {86 ret = disable_legacy(device, ®s); 87 if (ret != EOK) { 94 88 usb_log_error("Failed to disable legacy USB: %s.\n", 95 str_error(rc)); 96 goto error; 97 } 98 99 hc_fun = ddf_fun_create(device, fun_exposed, "ehci_hc"); 100 if (hc_fun == NULL) { 101 usb_log_error("Failed to create EHCI function.\n"); 102 rc = ENOMEM; 103 goto error; 104 } 105 106 hcd_t *ehci_hc = ddf_fun_data_alloc(hc_fun, sizeof(hcd_t)); 107 if (ehci_hc == NULL) { 108 usb_log_error("Failed to alloc generic HC driver.\n"); 109 rc = ENOMEM; 110 goto error; 89 str_error(ret)); 90 return ret; 111 91 } 112 92 113 93 /* High Speed, no bandwidth */ 114 hcd_init(ehci_hc, USB_SPEED_HIGH, 0, NULL); 115 ddf_fun_set_ops(hc_fun, &hc_ops); 116 117 rc = ddf_fun_bind(hc_fun); 118 if (rc != EOK) { 119 usb_log_error("Failed to bind EHCI function: %s.\n", 120 str_error(rc)); 121 goto error; 122 } 123 124 fun_bound = true; 125 126 rc = ddf_fun_add_to_category(hc_fun, USB_HC_CATEGORY); 127 if (rc != EOK) { 128 usb_log_error("Failed to add EHCI to HC class: %s.\n", 129 str_error(rc)); 130 goto error; 94 ret = device_setup_ehci(device); 95 if (ret != EOK) { 96 usb_log_error("Failed to init ehci driver: %s\n", 97 str_error(ret)); 98 return ret; 131 99 } 132 100 … … 135 103 136 104 return EOK; 137 error:138 if (fun_bound)139 ddf_fun_unbind(hc_fun);140 if (hc_fun != NULL)141 ddf_fun_destroy(hc_fun);142 return rc;143 105 } 144 106
Note:
See TracChangeset
for help on using the changeset viewer.
