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

Changeset 735236a in mainline


Ignore:
Timestamp:
2011-07-11T17:55:42Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
7372a9a0
Parents:
14426a0
Message:

OHCI: Root hub: Add support for multiple power modes.

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

Legend:

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

    r14426a0 r735236a  
    193193                                *        specified in PPCM(RHDB), or all ports,
    194194                                *        if power is set globally */
    195 #define RHS_SET_PORT_POWER RHS_LPSC_FLAG /* synonym for the above */
     195#define RHS_SET_GLOBAL_POWER RHS_LPSC_FLAG /* synonym for the above */
    196196#define RHS_OCIC_FLAG (1 << 17)/* Over-current indicator change   */
    197197#define RHS_CLEAR_DRWE (1 << 31)
  • uspace/drv/bus/usb/ohci/root_hub.c

    r14426a0 r735236a  
    490490        assert(instance);
    491491
    492         if (!((1 << feature) & port_set_feature_valid_mask))
    493                 return EINVAL;
    494492        if (port < 1 || port > instance->port_count)
    495493                return EINVAL;
    496494
    497         instance->registers->rh_port_status[port - 1] =
    498             (instance->registers->rh_port_status[port - 1] | (1 << feature))
    499             & (~port_clear_feature_valid_mask);
    500         return EOK;
     495        switch (feature)
     496        {
     497        case USB_HUB_FEATURE_PORT_POWER:   //8
     498                /* No power switching */
     499                if (instance->registers->rh_desc_a & RHDA_NPS_FLAG)
     500                        return EOK;
     501                /* Ganged power switching */
     502                if (!(instance->registers->rh_desc_a & RHDA_PSM_FLAG)) {
     503                        instance->registers->rh_status = RHS_SET_GLOBAL_POWER;
     504                        return EOK;
     505                }
     506        case USB_HUB_FEATURE_PORT_ENABLE:  //1
     507        case USB_HUB_FEATURE_PORT_SUSPEND: //2
     508        case USB_HUB_FEATURE_PORT_RESET:   //4
     509                /* Nice thing is that these shifts correspond to the position
     510                 * of control bits in register */
     511                instance->registers->rh_port_status[port - 1] = (1 << feature);
     512                return EOK;
     513        default:
     514                return ENOTSUP;
     515        }
    501516}
    502517/*----------------------------------------------------------------------------*/
     
    510525 * @return error code
    511526 */
    512 int port_feature_clear_request(
    513     rh_t *instance, uint16_t feature, uint16_t port)
    514 {
    515         assert(instance);
    516 
    517         if (!((1 << feature) & port_clear_feature_valid_mask))
    518                 return EINVAL;
     527int port_feature_clear_request(rh_t *instance, uint16_t feature, uint16_t port)
     528{
     529        assert(instance);
     530
    519531        if (port < 1 || port > instance->port_count)
    520532                return EINVAL;
    521533
    522         /* Some weird stuff... */
    523         if (feature == USB_HUB_FEATURE_PORT_POWER)
    524                 feature = USB_HUB_FEATURE_PORT_LOW_SPEED;
    525         if (feature == USB_HUB_FEATURE_PORT_SUSPEND)
    526                 feature = USB_HUB_FEATURE_PORT_OVER_CURRENT;
    527 
    528         instance->registers->rh_port_status[port - 1] =
    529             (instance->registers->rh_port_status[port - 1]
    530             & (~port_clear_feature_valid_mask))
    531             | (1 << feature);
    532         return EOK;
     534        /* Enabled features to clear: see page 269 of USB specs */
     535        switch (feature)
     536        {
     537        case USB_HUB_FEATURE_PORT_POWER:          //8
     538                /* No power switching */
     539                if (instance->registers->rh_desc_a & RHDA_NPS_FLAG)
     540                        return ENOTSUP;
     541                /* Ganged power switching */
     542                if (!(instance->registers->rh_desc_a & RHDA_PSM_FLAG)) {
     543                        instance->registers->rh_status = RHS_CLEAR_GLOBAL_POWER;
     544                        return EOK;
     545                }
     546                instance->registers->rh_port_status[port - 1] =
     547                        RHPS_CLEAR_PORT_POWER;
     548                return EOK;
     549
     550        case USB_HUB_FEATURE_PORT_ENABLE:         //1
     551                instance->registers->rh_port_status[port - 1] =
     552                        RHPS_CLEAR_PORT_ENABLE;
     553                return EOK;
     554
     555        case USB_HUB_FEATURE_PORT_SUSPEND:        //2
     556                instance->registers->rh_port_status[port - 1] =
     557                        RHPS_CLEAR_PORT_SUSPEND;
     558                return EOK;
     559
     560        case USB_HUB_FEATURE_C_PORT_CONNECTION:   //16
     561        case USB_HUB_FEATURE_C_PORT_ENABLE:       //17
     562        case USB_HUB_FEATURE_C_PORT_SUSPEND:      //18
     563        case USB_HUB_FEATURE_C_PORT_OVER_CURRENT: //19
     564        case USB_HUB_FEATURE_C_PORT_RESET:        //20
     565                /* Nice thing is that these shifts correspond to the position
     566                 * of control bits in register */
     567                instance->registers->rh_port_status[port - 1] = (1 << feature);
     568                return EOK;
     569        default:
     570                return ENOTSUP;
     571        }
    533572}
    534573/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.