Changeset df3ad97 in mainline


Ignore:
Timestamp:
2011-03-26T20:19:44Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
87b52c9, b330b309
Parents:
0368669c
Message:

fix for #132 2.0

Location:
uspace/drv/usbhub
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/port_status.h

    r0368669c rdf3ad97  
    7979
    8080/**
     81 * set the device request to be a port feature enable request
     82 * @param request
     83 * @param port
     84 * @param feature_selector
     85 */
     86static inline void usb_hub_set_enable_port_feature_request(
     87usb_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/**
    8199 * set the device request to be a port enable request
    82100 * @param request
     
    191209        request->length = 0;
    192210}
     211
    193212
    194213/** get i`th bit of port status */
  • uspace/drv/usbhub/usbhub.c

    r0368669c rdf3ad97  
    5353#include "usb/classes/classes.h"
    5454
     55
    5556static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,
    5657                usb_speed_t speed);
    5758
    58 static int usb_hub_attach_non_removable_devices(usb_hub_info_t * hub,
    59 usb_hub_descriptor_t * descriptor);
    60 
     59static 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 */
    6171int usb_hub_control_loop(void * hub_info_param){
    6272        usb_hub_info_t * hub_info = (usb_hub_info_t*)hub_info_param;
     
    103113 * This function is hub-specific and should be run only after the hub is
    104114 * configured using usb_hub_set_configuration function.
    105  * @param hub_info pointer to structure with usb hub data
     115 * @param hub_info hub representation
    106116 * @return error code
    107117 */
     
    149159                hub_info->attached_devs[i].address=0;
    150160        }
    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);
    152163        usb_log_debug2("freeing data\n");
    153164        free(serialized_descriptor);
     
    161172 * Check whether there is at least one configuration and sets the first one.
    162173 * 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
    165176 */
    166177static int usb_hub_set_configuration(usb_hub_info_t * hub_info){
     
    270281
    271282/**
    272  * Perform \a usb_hub_init_add_device on all ports with non-removable device
     283 * triggers actions to connect non0removable devices
    273284 *
    274285 * This will trigger operations leading to activated non-removable device.
    275286 * Control pipe of the hub must be open fo communication.
    276  * @param hub hub instance
     287 * @param hub hub representation
    277288 * @param descriptor usb hub descriptor
    278289 * @return error code
    279290 */
    280 static int usb_hub_attach_non_removable_devices(usb_hub_info_t * hub,
     291static int usb_hub_trigger_connecting_non_removable_devices(usb_hub_info_t * hub,
    281292                usb_hub_descriptor_t * descriptor)
    282293{
     
    287298        usb_port_status_t status;
    288299        uint8_t * non_removable_dev_bitmap = descriptor->devices_removable;
    289         //initialize all connected, non-removable devices
    290300        int port;
    291301        for(port=1;port<=descriptor->ports_count;++port){
     
    305315                                return opResult;
    306316                        }
    307                         //this should be true..
     317                        //set the status change bit, so it will be noticed in driver loop
    308318                        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                                }
    310331                        }
    311332                }
     
    335356/**
    336357 * Reset the port with new device and reserve the default address.
    337  * @param hc
    338  * @param port
    339  * @param target
     358 * @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
    340361 */
    341362static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,
     
    370391        if (opResult != EOK) {
    371392                usb_log_error("something went wrong when reseting a port %d\n",opResult);
    372                 //usb_hub_release_default_address(hc);
    373393                usb_hub_release_default_address(hub);
    374394        }
     
    378398/**
    379399 * 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
    383405 */
    384406static void usb_hub_finalize_add_device( usb_hub_info_t * hub,
     
    430452        }
    431453
    432 
    433454        //opResult = usb_hub_release_default_address(hc);
    434455        opResult = usb_hub_release_default_address(hub);
     
    465486
    466487/**
    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
    471495 */
    472496static void usb_hub_removed_device(
     
    507531 * Turn off the power on the port.
    508532 *
    509  * @param hub
    510  * @param port
     533 * @param hub hub representation
     534 * @param port port number, starting from 1
    511535 */
    512536static void usb_hub_over_current( usb_hub_info_t * hub,
     
    523547/**
    524548 * 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
    528553 */
    529554static void usb_hub_process_interrupt(usb_hub_info_t * hub,
     
    596621
    597622/**
    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
    602628 */
    603629int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
Note: See TracChangeset for help on using the changeset viewer.