Changeset df3ad97 in mainline
- Timestamp:
- 2011-03-26T20:19:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 87b52c9, b330b309
- Parents:
- 0368669c
- Location:
- uspace/drv/usbhub
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/port_status.h
r0368669c rdf3ad97 79 79 80 80 /** 81 * set the device request to be a port feature enable request 82 * @param request 83 * @param port 84 * @param feature_selector 85 */ 86 static inline void usb_hub_set_enable_port_feature_request( 87 usb_device_request_setup_packet_t * request, uint16_t port, 88 uint16_t feature_selector 89 ){ 90 request->index = port; 91 request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE; 92 request->request = USB_HUB_REQUEST_SET_FEATURE; 93 request->value = feature_selector; 94 request->length = 0; 95 } 96 97 98 /** 81 99 * set the device request to be a port enable request 82 100 * @param request … … 191 209 request->length = 0; 192 210 } 211 193 212 194 213 /** get i`th bit of port status */ -
uspace/drv/usbhub/usbhub.c
r0368669c rdf3ad97 53 53 #include "usb/classes/classes.h" 54 54 55 55 56 static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port, 56 57 usb_speed_t speed); 57 58 58 static int usb_hub_attach_non_removable_devices(usb_hub_info_t * hub, 59 usb_hub_descriptor_t * descriptor); 60 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 fibril 64 * 65 * Hub`s fibril periodically asks for changes on hub and if needded calls 66 * change handling routine. 67 * @warning currently hub driver asks for changes once a second 68 * @param hub_info_param hub representation pointer 69 * @return zero 70 */ 61 71 int usb_hub_control_loop(void * hub_info_param){ 62 72 usb_hub_info_t * hub_info = (usb_hub_info_t*)hub_info_param; … … 103 113 * This function is hub-specific and should be run only after the hub is 104 114 * configured using usb_hub_set_configuration function. 105 * @param hub_info pointer to structure with usb hub data115 * @param hub_info hub representation 106 116 * @return error code 107 117 */ … … 149 159 hub_info->attached_devs[i].address=0; 150 160 } 151 usb_hub_attach_non_removable_devices(hub_info, descriptor); 161 //handle non-removable devices 162 usb_hub_trigger_connecting_non_removable_devices(hub_info, descriptor); 152 163 usb_log_debug2("freeing data\n"); 153 164 free(serialized_descriptor); … … 161 172 * Check whether there is at least one configuration and sets the first one. 162 173 * This function should be run prior to running any hub-specific action. 163 * @param hub_info 164 * @return 174 * @param hub_info hub representation 175 * @return error code 165 176 */ 166 177 static int usb_hub_set_configuration(usb_hub_info_t * hub_info){ … … 270 281 271 282 /** 272 * Perform \a usb_hub_init_add_device on all ports with non-removable device283 * triggers actions to connect non0removable devices 273 284 * 274 285 * This will trigger operations leading to activated non-removable device. 275 286 * Control pipe of the hub must be open fo communication. 276 * @param hub hub instance287 * @param hub hub representation 277 288 * @param descriptor usb hub descriptor 278 289 * @return error code 279 290 */ 280 static int usb_hub_ attach_non_removable_devices(usb_hub_info_t * hub,291 static int usb_hub_trigger_connecting_non_removable_devices(usb_hub_info_t * hub, 281 292 usb_hub_descriptor_t * descriptor) 282 293 { … … 287 298 usb_port_status_t status; 288 299 uint8_t * non_removable_dev_bitmap = descriptor->devices_removable; 289 //initialize all connected, non-removable devices290 300 int port; 291 301 for(port=1;port<=descriptor->ports_count;++port){ … … 305 315 return opResult; 306 316 } 307 // this should be true..317 //set the status change bit, so it will be noticed in driver loop 308 318 if(usb_port_dev_connected(&status)){ 309 usb_hub_init_add_device(hub,port,usb_port_speed(&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_size 325 ); 326 if (opResult != EOK) { 327 usb_log_warning( 328 "could not set port change on port %d errno:%d\n", 329 port, opResult); 330 } 310 331 } 311 332 } … … 335 356 /** 336 357 * Reset the port with new device and reserve the default address. 337 * @param h c338 * @param port 339 * @param target358 * @param hub hub representation 359 * @param port port number, starting from 1 360 * @param speed transfer speed of attached device, one of low, full or high 340 361 */ 341 362 static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port, … … 370 391 if (opResult != EOK) { 371 392 usb_log_error("something went wrong when reseting a port %d\n",opResult); 372 //usb_hub_release_default_address(hc);373 393 usb_hub_release_default_address(hub); 374 394 } … … 378 398 /** 379 399 * Finalize adding new device after port reset 380 * @param hc 381 * @param port 382 * @param target 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 383 405 */ 384 406 static void usb_hub_finalize_add_device( usb_hub_info_t * hub, … … 430 452 } 431 453 432 433 454 //opResult = usb_hub_release_default_address(hc); 434 455 opResult = usb_hub_release_default_address(hub); … … 465 486 466 487 /** 467 * Unregister device address in hc 468 * @param hc 469 * @param port 470 * @param target 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 471 495 */ 472 496 static void usb_hub_removed_device( … … 507 531 * Turn off the power on the port. 508 532 * 509 * @param hub 510 * @param port 533 * @param hub hub representation 534 * @param port port number, starting from 1 511 535 */ 512 536 static void usb_hub_over_current( usb_hub_info_t * hub, … … 523 547 /** 524 548 * Process interrupts on given hub port 525 * @param hc 526 * @param port 527 * @param target 549 * 550 * Accepts connection, over current and port reset change. 551 * @param hub hub representation 552 * @param port port number, starting from 1 528 553 */ 529 554 static void usb_hub_process_interrupt(usb_hub_info_t * hub, … … 596 621 597 622 /** 598 * Check changes on particular hub 599 * @param hub_info_param pointer to usb_hub_info_t structure 600 * @return error code if there is problem when initializing communication with 601 * hub, EOK otherwise 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 602 628 */ 603 629 int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
Note:
See TracChangeset
for help on using the changeset viewer.