Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 00694c5 in mainline


Ignore:
Timestamp:
2011-07-11T16:48:43Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
b21dfba
Parents:
5af769c
Message:

OHCI: Root hub: Add some comments and minor changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/root_hub.c

    r5af769c r00694c5  
    5858        .device_version = 0,
    5959        .length = sizeof (usb_standard_device_descriptor_t),
    60         .max_packet_size = 8,
     60        .max_packet_size = 64,
    6161        .vendor_id = 0x16db,
    6262        .product_id = 0x0001,
     
    101101        .descriptor_type = USB_DESCTYPE_ENDPOINT,
    102102        .endpoint_address = 1 + (1 << 7),
    103         .length = sizeof (usb_standard_endpoint_descriptor_t),
    104         .max_packet_size = 8,
     103        .length = sizeof(usb_standard_endpoint_descriptor_t),
     104        .max_packet_size = 2,
    105105        .poll_interval = 255,
    106106};
    107 
    108 /**
    109  * bitmask of hub features that are valid to be set
    110  */
    111 static const uint32_t hub_set_feature_valid_mask =
    112     RHS_LPSC_FLAG |
    113     RHS_OCIC_FLAG;
    114 
    115 /**
    116  * bitmask of hub features that are set by writing 1 and cleared by writing 0
    117  */
    118 static const uint32_t hub_set_feature_direct_mask =
    119     RHS_SET_PORT_POWER;
    120107
    121108/**
     
    145132//USB_HUB_FEATURE_PORT_LOW_SPEED for port set feature request
    146133
    147 /**
    148  * bitmask with port status changes
    149  */
    150 static const uint32_t port_status_change_mask = RHPS_CHANGE_WC_MASK;
    151 
    152134static void create_serialized_hub_descriptor(rh_t *instance);
    153 
    154135static void rh_init_descriptors(rh_t *instance);
    155 
    156136static void create_interrupt_mask_in_instance(rh_t *instance);
    157 
    158 static int get_status_request(
    159     rh_t *instance, usb_transfer_batch_t *request);
    160 
     137static int get_status_request(rh_t *instance, usb_transfer_batch_t *request);
    161138static int get_descriptor_request(
    162139    rh_t *instance, usb_transfer_batch_t *request);
    163 
    164140static int port_feature_set_request(
    165141    rh_t *instance, uint16_t feature, uint16_t port);
    166 
    167142static int port_feature_clear_request(
    168143    rh_t *instance, uint16_t feature, uint16_t port);
    169 
    170 static int request_with_output(
     144static int request_with_output(rh_t *instance, usb_transfer_batch_t *request);
     145static int request_without_data(rh_t *instance, usb_transfer_batch_t *request);
     146static int ctrl_request(rh_t *instance, usb_transfer_batch_t *request);
     147static void interrupt_mask_in_instance(
    171148    rh_t *instance, usb_transfer_batch_t *request);
    172 
    173 static int request_without_data(
    174     rh_t *instance, usb_transfer_batch_t *request);
    175 
    176 static int ctrl_request(rh_t *instance, usb_transfer_batch_t *request);
    177 
    178 static int interrupt_mask_in_instance(
    179     rh_t *instance, usb_transfer_batch_t *request);
    180 
    181149static bool is_zeros(const void *buffer, size_t size);
    182150
     
    381349        }
    382350
     351        /* Hub status: just filter relevant info from rh_status reg */
    383352        if (request_packet->request_type == USB_HUB_REQ_TYPE_GET_HUB_STATUS) {
    384353                const uint32_t data = instance->registers->rh_status &
     
    388357        }
    389358
     359        /* Copy appropriate rh_port_status register, OHCI designers were
     360         * kind enough to make those bit values match USB specification */
    390361        if (request_packet->request_type == USB_HUB_REQ_TYPE_GET_PORT_STATUS) {
    391                 unsigned port = request_packet->index;
     362                const unsigned port = request_packet->index;
    392363                if (port < 1 || port > instance->port_count)
    393364                        return EINVAL;
     
    417388
    418389        uint8_t * bitmap = instance->interrupt_buffer;
    419         uint32_t mask = (1 << (USB_HUB_FEATURE_C_HUB_LOCAL_POWER + 16))
    420             | (1 << (USB_HUB_FEATURE_C_HUB_OVER_CURRENT + 16));
    421390        bzero(bitmap, instance->interrupt_mask_size);
    422         if ((instance->registers->rh_status & mask) != 0) {
     391        /* Only local power source change and over-current change can happen */
     392        if (instance->registers->rh_status & (RHS_LPSC_FLAG | RHS_OCIC_FLAG)) {
    423393                bitmap[0] = 1;
    424394        }
    425         mask = port_status_change_mask;
    426395        size_t port = 1;
    427396        for (; port <= instance->port_count; ++port) {
    428                 if ((mask & instance->registers->rh_port_status[port - 1]) != 0) {
    429 
    430                         bitmap[(port) / 8] += 1 << (port % 8);
     397                /* Write-clean bits are those that indicate change */
     398                if (RHPS_CHANGE_WC_MASK
     399                    & instance->registers->rh_port_status[port - 1]) {
     400
     401                        bitmap[(port) / 8] |= 1 << (port % 8);
    431402                }
    432403        }
     
    731702/*----------------------------------------------------------------------------*/
    732703/**
    733  * process hanging interrupt request
     704 * Process waiting interrupt request
    734705 *
    735706 * If an interrupt transfer has been received and there was no change,
     
    743714 * @return
    744715 */
    745 int interrupt_mask_in_instance(
    746     rh_t *instance, usb_transfer_batch_t *request)
     716void interrupt_mask_in_instance(rh_t *instance, usb_transfer_batch_t *request)
    747717{
    748718        assert(instance);
     
    754724        instance->unfinished_interrupt_transfer = NULL;
    755725        usb_transfer_batch_finish_error(request, EOK);
    756 
    757         return EOK;
    758726}
    759727/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.