Changes in uspace/drv/bus/usb/ohci/hc.c [171e668:cffa14e6] 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
r171e668 rcffa14e6 41 41 #include <usb/debug.h> 42 42 #include <usb/usb.h> 43 #include <usb/ddfiface.h> 43 44 44 45 #include "hc.h" … … 87 88 static int hc_init_memory(hc_t *instance); 88 89 static int interrupt_emulator(hc_t *instance); 90 static int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch); 89 91 90 92 /** Get number of PIO ranges used in IRQ code. … … 135 137 } 136 138 139 /** Announce OHCI root hub to the DDF 140 * 141 * @param[in] instance OHCI driver intance 142 * @param[in] hub_fun DDF fuction representing OHCI root hub 143 * @return Error code 144 */ 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)0 171 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_RELEASE 196 } 197 137 198 /** Initialize OHCI hc driver structure 138 199 * … … 160 221 list_initialize(&instance->pending_batches); 161 222 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 162 230 ret = hc_init_memory(instance); 163 231 CHECK_RET_RETURN(ret, "Failed to create OHCI memory structures: %s.\n", … … 175 243 } 176 244 177 ohci_rh_init(&instance->rh, instance->registers, "ohci rh");245 rh_init(&instance->rh, instance->registers); 178 246 hc_start(instance); 179 247 … … 262 330 263 331 /* Check for root hub communication */ 264 if (batch->ep->address == ohci_rh_get_address(&instance->rh)) {332 if (batch->ep->address == instance->rh.address) { 265 333 usb_log_debug("OHCI root hub request.\n"); 266 return ohci_rh_schedule(&instance->rh, batch); 334 rh_request(&instance->rh, batch); 335 return EOK; 267 336 } 268 337 ohci_transfer_batch_t *ohci_batch = ohci_transfer_batch_get(batch); … … 303 372 usb_log_debug2("OHCI(%p) interrupt: %x.\n", instance, status); 304 373 if (status & I_RHSC) 305 ohci_rh_interrupt(&instance->rh);374 rh_interrupt(&instance->rh); 306 375 307 376 if (status & I_WDH) { … … 533 602 assert(instance); 534 603 535 bzero(&instance->rh, sizeof(instance->rh));604 memset(&instance->rh, 0, sizeof(instance->rh)); 536 605 /* Init queues */ 537 606 const int ret = hc_init_transfer_lists(instance);
Note:
See TracChangeset
for help on using the changeset viewer.
