Changeset 40c6cdf in mainline
- Timestamp:
- 2011-07-11T15:16:29Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bb58dc0b
- Parents:
- 03e3029
- Location:
- uspace/drv/bus/usb/ohci
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/ohci_regs.h
r03e3029 r40c6cdf 182 182 * specified in PPCM(RHDB), or all ports, 183 183 * 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 */ 185 185 #define RHS_OCI_FLAG (1 << 1)/* Over-current indicator, if per-port: 0 */ 186 186 #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 40 40 #include "root_hub.h" 41 41 #include <usb/classes/classes.h> 42 #include <usb/classes/hub.h> 42 43 #include <usb/dev/driver.h> 43 44 #include "ohci_regs.h" … … 106 107 107 108 /** 108 * bitmask of hub features that are valid to be cleared109 */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 /**121 109 * bitmask of hub features that are valid to be set 122 110 */ … … 183 171 static int get_configuration_request( 184 172 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);190 173 191 174 static int port_feature_set_request( … … 609 592 * @param instance root hub instance 610 593 * @param feature feature selector 611 * @return error code612 */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 hub628 *629 * @param instance root hub instance630 * @param feature feature selector631 * @return error code632 */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_status649 & (~hub_clear_feature_by_writing_one_mask))650 | (1 << feature);651 }652 return EOK;653 }654 /*----------------------------------------------------------------------------*/655 /**656 * process feature-enabling request on hub657 *658 * @param instance root hub instance659 * @param feature feature selector660 594 * @param port port number, counted from 1 661 595 * @param enable enable or disable the specified feature … … 789 723 { 790 724 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"); 798 727 return port_feature_clear_request(instance, 799 728 setup_request->value, setup_request->index); 800 729 } 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; 804 746 805 747 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: 812 751 usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n"); 813 752 return port_feature_set_request(instance, 814 753 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; 815 765 } 816 usb_log_error("Invalid HUB set feature request type: %d\n",817 request_type);818 return EINVAL;819 766 820 767 case USB_DEVREQ_SET_ADDRESS: 821 768 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); 824 770 825 771 default:
Note:
See TracChangeset
for help on using the changeset viewer.