Changeset 40c6cdf in mainline


Ignore:
Timestamp:
2011-07-11T15:16:29Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bb58dc0b
Parents:
03e3029
Message:

OHCI: Root hub: Clean up HUB features (there are almost none supported).

Location:
uspace/drv/bus/usb/ohci
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/ohci_regs.h

    r03e3029 r40c6cdf  
    182182                                *        specified in PPCM(RHDB), or all ports,
    183183                                *        if power is set globally */
    184 #define RHS_CLEAR_PORT_POWER RHS_LPS_FLAG /* synonym for the above */
     184#define RHS_CLEAR_GLOBAL_POWER RHS_LPS_FLAG /* synonym for the above */
    185185#define RHS_OCI_FLAG  (1 <<  1)/* Over-current indicator, if per-port: 0 */
    186186#define RHS_DRWE_FLAG (1 << 15)/* read: 0-connect status change does not wake HC
  • uspace/drv/bus/usb/ohci/root_hub.c

    r03e3029 r40c6cdf  
    4040#include "root_hub.h"
    4141#include <usb/classes/classes.h>
     42#include <usb/classes/hub.h>
    4243#include <usb/dev/driver.h>
    4344#include "ohci_regs.h"
     
    106107
    107108/**
    108  * bitmask of hub features that are valid to be cleared
    109  */
    110 static const uint32_t hub_clear_feature_valid_mask =
    111     RHS_OCIC_FLAG |
    112     RHS_CLEAR_PORT_POWER;
    113 
    114 /**
    115  * bitmask of hub features that are cleared by writing 1 (and not 0)
    116  */
    117 static const uint32_t hub_clear_feature_by_writing_one_mask =
    118     RHS_CLEAR_PORT_POWER;
    119 
    120 /**
    121109 * bitmask of hub features that are valid to be set
    122110 */
     
    183171static int get_configuration_request(
    184172    rh_t *instance, usb_transfer_batch_t *request);
    185 
    186 static int hub_feature_set_request(rh_t *instance, uint16_t feature);
    187 
    188 static int hub_feature_clear_request(
    189     rh_t *instance, uint16_t feature);
    190173
    191174static int port_feature_set_request(
     
    609592 * @param instance root hub instance
    610593 * @param feature feature selector
    611  * @return error code
    612  */
    613 static int hub_feature_set_request(rh_t *instance,
    614     uint16_t feature) {
    615         if (!((1 << feature) & hub_set_feature_valid_mask))
    616                 return EINVAL;
    617         if (feature == USB_HUB_FEATURE_C_HUB_LOCAL_POWER)
    618                 feature = USB_HUB_FEATURE_C_HUB_LOCAL_POWER << 16;
    619         instance->registers->rh_status =
    620             (instance->registers->rh_status | (1 << feature))
    621             & (~hub_clear_feature_by_writing_one_mask);
    622 
    623         return EOK;
    624 }
    625 /*----------------------------------------------------------------------------*/
    626 /**
    627  * process feature-disabling request on hub
    628  *
    629  * @param instance root hub instance
    630  * @param feature feature selector
    631  * @return error code
    632  */
    633 int hub_feature_clear_request(rh_t *instance, uint16_t feature)
    634 {
    635         assert(instance);
    636 
    637         if (!((1 << feature) & hub_clear_feature_valid_mask))
    638                 return EINVAL;
    639 
    640         //is the feature cleared directly?
    641         if ((1 << feature) & hub_set_feature_direct_mask) {
    642                 instance->registers->rh_status =
    643                     (instance->registers->rh_status & (~(1 << feature)))
    644                     & (~hub_clear_feature_by_writing_one_mask);
    645         } else {//the feature is cleared by writing '1'
    646 
    647                 instance->registers->rh_status =
    648                     (instance->registers->rh_status
    649                     & (~hub_clear_feature_by_writing_one_mask))
    650                     | (1 << feature);
    651         }
    652         return EOK;
    653 }
    654 /*----------------------------------------------------------------------------*/
    655 /**
    656  * process feature-enabling request on hub
    657  *
    658  * @param instance root hub instance
    659  * @param feature feature selector
    660594 * @param port port number, counted from 1
    661595 * @param enable enable or disable the specified feature
     
    789723        {
    790724        case USB_DEVREQ_CLEAR_FEATURE:
    791                 if (request_type == USB_HUB_REQ_TYPE_SET_HUB_FEATURE) {
    792                         usb_log_debug("USB_HUB_REQ_TYPE_SET_HUB_FEATURE\n");
    793                         return hub_feature_clear_request(instance,
    794                             setup_request->value);
    795                 }
    796                 if (request_type == USB_HUB_REQ_TYPE_SET_PORT_FEATURE) {
    797                         usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
     725                if (request_type == USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE) {
     726                        usb_log_debug("USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE\n");
    798727                        return port_feature_clear_request(instance,
    799728                            setup_request->value, setup_request->index);
    800729                }
    801                 usb_log_error("Invalid HUB clear feature request type: %d\n",
    802                     request_type);
    803                 return EINVAL;
     730                if (request_type == USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE) {
     731                        usb_log_debug("USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE\n");
     732/*
     733 * Chapter 11.16.2 specifies that only C_HUB_LOCAL_POWER and
     734 * C_HUB_OVER_CURRENT are supported. C_HUB_OVER_CURRENT is represented
     735 * by OHCI RHS_OCIC_FLAG. C_HUB_LOCAL_POWER is not supported
     736 * as root hubs do not support local power status feature. (OHCI pg. 127)
     737 */
     738        if (setup_request->value == USB_HUB_FEATURE_C_HUB_OVER_CURRENT) {
     739                instance->registers->rh_status = RHS_OCIC_FLAG;
     740                return EOK;
     741        }
     742                }
     743                        usb_log_error("Invalid clear feature request type: %d\n",
     744                            request_type);
     745                        return EINVAL;
    804746
    805747        case USB_DEVREQ_SET_FEATURE:
    806                 if (request_type == USB_HUB_REQ_TYPE_SET_HUB_FEATURE) {
    807                         usb_log_debug("USB_HUB_REQ_TYPE_SET_HUB_FEATURE\n");
    808                         return hub_feature_set_request(instance,
    809                             setup_request->value);
    810                 }
    811                 if (request_type == USB_HUB_REQ_TYPE_SET_PORT_FEATURE) {
     748                switch (request_type)
     749                {
     750                case USB_HUB_REQ_TYPE_SET_PORT_FEATURE:
    812751                        usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
    813752                        return port_feature_set_request(instance,
    814753                            setup_request->value, setup_request->index);
     754
     755                case USB_HUB_REQ_TYPE_SET_HUB_FEATURE:
     756                /* Chapter 11.16.2 specifies that hub can be recipient
     757                 * only for C_HUB_LOCAL_POWER and C_HUB_OVER_CURRENT
     758                 * features. It makes no sense to SET either. */
     759                        usb_log_error("Invalid HUB set feature request.\n");
     760                        return ENOTSUP;
     761                default:
     762                        usb_log_error("Invalid set feature request type: %d\n",
     763                            request_type);
     764                        return EINVAL;
    815765                }
    816                 usb_log_error("Invalid HUB set feature request type: %d\n",
    817                     request_type);
    818                 return EINVAL;
    819766
    820767        case USB_DEVREQ_SET_ADDRESS:
    821768                usb_log_debug("USB_DEVREQ_SET_ADDRESS\n");
    822                 return address_set_request(instance,
    823                     setup_request->value);
     769                return address_set_request(instance, setup_request->value);
    824770
    825771        default:
Note: See TracChangeset for help on using the changeset viewer.