Changes in uspace/drv/bus/usb/ohci/hc.c [cffa14e6:171e668] in mainline
- File:
-
- 1 edited
-
uspace/drv/bus/usb/ohci/hc.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/hc.c
rcffa14e6 r171e668 41 41 #include <usb/debug.h> 42 42 #include <usb/usb.h> 43 #include <usb/ddfiface.h>44 43 45 44 #include "hc.h" … … 88 87 static int hc_init_memory(hc_t *instance); 89 88 static int interrupt_emulator(hc_t *instance); 90 static int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);91 89 92 90 /** Get number of PIO ranges used in IRQ code. … … 137 135 } 138 136 139 /** Announce OHCI root hub to the DDF140 *141 * @param[in] instance OHCI driver intance142 * @param[in] hub_fun DDF fuction representing OHCI root hub143 * @return Error code144 */145 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun)146 {147 assert(instance);148 assert(hub_fun);149 150 /* Try to get address 1 for root hub. */151 instance->rh.address = 1;152 int ret = usb_device_manager_request_address(153 &instance->generic.dev_manager, &instance->rh.address, false,154 USB_SPEED_FULL);155 if (ret != EOK) {156 usb_log_error("Failed to get OHCI root hub address: %s\n",157 str_error(ret));158 return ret;159 }160 161 #define CHECK_RET_UNREG_RETURN(ret, message...) \162 if (ret != EOK) { \163 usb_log_error(message); \164 usb_endpoint_manager_remove_ep( \165 &instance->generic.ep_manager, instance->rh.address, 0, \166 USB_DIRECTION_BOTH, NULL, NULL); \167 usb_device_manager_release_address( \168 &instance->generic.dev_manager, instance->rh.address); \169 return ret; \170 } else (void)0171 172 ret = usb_endpoint_manager_add_ep(173 &instance->generic.ep_manager, instance->rh.address, 0,174 USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64,175 0, NULL, NULL);176 CHECK_RET_UNREG_RETURN(ret,177 "Failed to register root hub control endpoint: %s.\n",178 str_error(ret));179 180 ret = ddf_fun_add_match_id(hub_fun, "usb&class=hub", 100);181 CHECK_RET_UNREG_RETURN(ret,182 "Failed to add root hub match-id: %s.\n", str_error(ret));183 184 ret = ddf_fun_bind(hub_fun);185 CHECK_RET_UNREG_RETURN(ret,186 "Failed to bind root hub function: %s.\n", str_error(ret));187 188 ret = usb_device_manager_bind_address(&instance->generic.dev_manager,189 instance->rh.address, ddf_fun_get_handle(hub_fun));190 if (ret != EOK)191 usb_log_warning("Failed to bind root hub address: %s.\n",192 str_error(ret));193 194 return EOK;195 #undef CHECK_RET_RELEASE196 }197 198 137 /** Initialize OHCI hc driver structure 199 138 * … … 221 160 list_initialize(&instance->pending_batches); 222 161 223 hcd_init(&instance->generic, USB_SPEED_FULL,224 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);225 instance->generic.private_data = instance;226 instance->generic.schedule = hc_schedule;227 instance->generic.ep_add_hook = ohci_endpoint_init;228 instance->generic.ep_remove_hook = ohci_endpoint_fini;229 230 162 ret = hc_init_memory(instance); 231 163 CHECK_RET_RETURN(ret, "Failed to create OHCI memory structures: %s.\n", … … 243 175 } 244 176 245 rh_init(&instance->rh, instance->registers);177 ohci_rh_init(&instance->rh, instance->registers, "ohci rh"); 246 178 hc_start(instance); 247 179 … … 330 262 331 263 /* Check for root hub communication */ 332 if (batch->ep->address == instance->rh.address) {264 if (batch->ep->address == ohci_rh_get_address(&instance->rh)) { 333 265 usb_log_debug("OHCI root hub request.\n"); 334 rh_request(&instance->rh, batch); 335 return EOK; 266 return ohci_rh_schedule(&instance->rh, batch); 336 267 } 337 268 ohci_transfer_batch_t *ohci_batch = ohci_transfer_batch_get(batch); … … 372 303 usb_log_debug2("OHCI(%p) interrupt: %x.\n", instance, status); 373 304 if (status & I_RHSC) 374 rh_interrupt(&instance->rh);305 ohci_rh_interrupt(&instance->rh); 375 306 376 307 if (status & I_WDH) { … … 602 533 assert(instance); 603 534 604 memset(&instance->rh, 0, sizeof(instance->rh));535 bzero(&instance->rh, sizeof(instance->rh)); 605 536 /* Init queues */ 606 537 const int ret = hc_init_transfer_lists(instance);
Note:
See TracChangeset
for help on using the changeset viewer.
