Changes in uspace/drv/usbhub/usbhub.c [df3ad97:fbefd0e] in mainline
- File:
-
- 1 edited
-
uspace/drv/usbhub/usbhub.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
rdf3ad97 rfbefd0e 53 53 #include "usb/classes/classes.h" 54 54 55 56 static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,57 usb_speed_t speed);58 59 static int usb_hub_trigger_connecting_non_removable_devices(60 usb_hub_info_t * hub, usb_hub_descriptor_t * descriptor);61 62 /**63 * control loop running in hub`s fibril64 *65 * Hub`s fibril periodically asks for changes on hub and if needded calls66 * change handling routine.67 * @warning currently hub driver asks for changes once a second68 * @param hub_info_param hub representation pointer69 * @return zero70 */71 55 int usb_hub_control_loop(void * hub_info_param){ 72 56 usb_hub_info_t * hub_info = (usb_hub_info_t*)hub_info_param; … … 107 91 108 92 /** 109 * Load hub-specific information into hub_info structure and process if needed93 * Load hub-specific information into hub_info structure. 110 94 * 111 95 * Particularly read port count and initialize structure holding port 112 * information. If there are non-removable devices, start initializing them.96 * information. 113 97 * This function is hub-specific and should be run only after the hub is 114 98 * configured using usb_hub_set_configuration function. 115 * @param hub_info hub representation99 * @param hub_info pointer to structure with usb hub data 116 100 * @return error code 117 101 */ 118 static int usb_hub_ process_hub_specific_info(usb_hub_info_t * hub_info){102 static int usb_hub_get_hub_specific_info(usb_hub_info_t * hub_info){ 119 103 // get hub descriptor 120 104 usb_log_debug("creating serialized descriptor\n"); … … 123 107 124 108 /* this was one fix of some bug, should not be needed anymore 125 * these lines allow to reset hub once more, it can be used as126 * brute-force initialization for non-removable devices127 109 int opResult = usb_request_set_configuration(&result->endpoints.control, 1); 128 110 if(opResult!=EOK){ … … 159 141 hub_info->attached_devs[i].address=0; 160 142 } 161 //handle non-removable devices162 usb_hub_trigger_connecting_non_removable_devices(hub_info, descriptor);163 143 usb_log_debug2("freeing data\n"); 164 144 free(serialized_descriptor); … … 172 152 * Check whether there is at least one configuration and sets the first one. 173 153 * This function should be run prior to running any hub-specific action. 174 * @param hub_info hub representation175 * @return error code154 * @param hub_info 155 * @return 176 156 */ 177 157 static int usb_hub_set_configuration(usb_hub_info_t * hub_info){ … … 182 162 std_descriptor->configuration_count); 183 163 if(std_descriptor->configuration_count<1){ 184 usb_log_error("there are no configurations available\n"); 164 usb_log_error("THERE ARE NO CONFIGURATIONS AVAILABLE\n"); 165 //shouldn`t I return? 166 //definitely 185 167 return EINVAL; 186 168 } … … 238 220 } 239 221 //get port count and create attached_devs 240 opResult = usb_hub_ process_hub_specific_info(hub_info);222 opResult = usb_hub_get_hub_specific_info(hub_info); 241 223 if(opResult!=EOK){ 242 224 usb_log_error("could not set hub configuration, errno %d\n",opResult); … … 276 258 //********************************************* 277 259 // 278 // hub driver code, main loop and port handling260 // hub driver code, main loop 279 261 // 280 262 //********************************************* 281 282 /**283 * triggers actions to connect non0removable devices284 *285 * This will trigger operations leading to activated non-removable device.286 * Control pipe of the hub must be open fo communication.287 * @param hub hub representation288 * @param descriptor usb hub descriptor289 * @return error code290 */291 static int usb_hub_trigger_connecting_non_removable_devices(usb_hub_info_t * hub,292 usb_hub_descriptor_t * descriptor)293 {294 usb_log_info("attaching non-removable devices(if any)\n");295 usb_device_request_setup_packet_t request;296 int opResult;297 size_t rcvd_size;298 usb_port_status_t status;299 uint8_t * non_removable_dev_bitmap = descriptor->devices_removable;300 int port;301 for(port=1;port<=descriptor->ports_count;++port){302 bool is_non_removable =303 ((non_removable_dev_bitmap[port/8]) >> (port%8)) %2;304 if(is_non_removable){305 usb_log_debug("non-removable device on port %d\n",port);306 usb_hub_set_port_status_request(&request, port);307 opResult = usb_pipe_control_read(308 hub->control_pipe,309 &request, sizeof(usb_device_request_setup_packet_t),310 &status, 4, &rcvd_size311 );312 if (opResult != EOK) {313 usb_log_error("could not get port status of port %d errno:%d\n",314 port, opResult);315 return opResult;316 }317 //set the status change bit, so it will be noticed in driver loop318 if(usb_port_dev_connected(&status)){319 usb_hub_set_enable_port_feature_request(&request, port,320 USB_HUB_FEATURE_C_PORT_CONNECTION);321 opResult = usb_pipe_control_read(322 hub->control_pipe,323 &request, sizeof(usb_device_request_setup_packet_t),324 &status, 4, &rcvd_size325 );326 if (opResult != EOK) {327 usb_log_warning(328 "could not set port change on port %d errno:%d\n",329 port, opResult);330 }331 }332 }333 }334 return EOK;335 }336 337 263 338 264 /** … … 356 282 /** 357 283 * Reset the port with new device and reserve the default address. 358 * @param h ub hub representation359 * @param port port number, starting from 1360 * @param speed transfer speed of attached device, one of low, full or high284 * @param hc 285 * @param port 286 * @param target 361 287 */ 362 288 static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port, … … 391 317 if (opResult != EOK) { 392 318 usb_log_error("something went wrong when reseting a port %d\n",opResult); 319 //usb_hub_release_default_address(hc); 393 320 usb_hub_release_default_address(hub); 394 321 } … … 398 325 /** 399 326 * Finalize adding new device after port reset 400 * 401 * Set device`s address and start it`s driver. 402 * @param hub hub representation 403 * @param port port number, starting from 1 404 * @param speed transfer speed of attached device, one of low, full or high 327 * @param hc 328 * @param port 329 * @param target 405 330 */ 406 331 static void usb_hub_finalize_add_device( usb_hub_info_t * hub, … … 452 377 } 453 378 379 454 380 //opResult = usb_hub_release_default_address(hc); 455 381 opResult = usb_hub_release_default_address(hub); … … 486 412 487 413 /** 488 * routine called when a device on port has been removed 489 * 490 * If the device on port had default address, it releases default address. 491 * Otherwise does not do anything, because DDF does not allow to remove device 492 * from it`s device tree. 493 * @param hub hub representation 494 * @param port port number, starting from 1 414 * Unregister device address in hc 415 * @param hc 416 * @param port 417 * @param target 495 418 */ 496 419 static void usb_hub_removed_device( … … 531 454 * Turn off the power on the port. 532 455 * 533 * @param hub hub representation534 * @param port port number, starting from 1456 * @param hub 457 * @param port 535 458 */ 536 459 static void usb_hub_over_current( usb_hub_info_t * hub, … … 547 470 /** 548 471 * Process interrupts on given hub port 549 * 550 * Accepts connection, over current and port reset change. 551 * @param hub hub representation 552 * @param port port number, starting from 1 472 * @param hc 473 * @param port 474 * @param target 553 475 */ 554 476 static void usb_hub_process_interrupt(usb_hub_info_t * hub, … … 621 543 622 544 /** 623 * check changes on hub 624 * 625 * Handles changes on each port with a status change. 626 * @param hub_info hub representation 627 * @return error code 545 * Check changes on particular hub 546 * @param hub_info_param pointer to usb_hub_info_t structure 547 * @return error code if there is problem when initializing communication with 548 * hub, EOK otherwise 628 549 */ 629 550 int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
Note:
See TracChangeset
for help on using the changeset viewer.
