/** @file\r
\r
-Copyright (c) 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- Module Name:\r
-\r
- UsbHub.c\r
-\r
- Abstract:\r
-\r
- Unified interface for RootHub and Hub\r
-\r
- Revision History\r
+ Unified interface for RootHub and Hub.\r
\r
+Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#include "UsbBus.h"\r
\r
+//\r
+// Array that maps the change bit to feature value which is\r
+// used to clear these change bit. USB HUB API will clear\r
+// these change bit automatically. For non-root hub, these\r
+// bits determine whether hub will report the port in changed\r
+// bit maps.\r
+//\r
+USB_CHANGE_FEATURE_MAP mHubFeatureMap[] = {\r
+ { USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange },\r
+ { USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange },\r
+ { USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange },\r
+ { USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange },\r
+ { USB_PORT_STAT_C_RESET, EfiUsbPortResetChange }\r
+};\r
+\r
+USB_CHANGE_FEATURE_MAP mRootHubFeatureMap[] = {\r
+ { USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange },\r
+ { USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange },\r
+ { USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange },\r
+ { USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange },\r
+ { USB_PORT_STAT_C_RESET, EfiUsbPortResetChange },\r
+};\r
+\r
//\r
// USB hub class specific requests. Although USB hub\r
// is related to an interface, these requests are sent\r
// to the control endpoint of the device.\r
//\r
\r
+/**\r
+ USB hub control transfer to set the hub depth.\r
+\r
+ @param HubDev The device of the hub.\r
+ @param Depth The depth to set.\r
+\r
+ @retval EFI_SUCCESS Depth of the hub is set.\r
+ @retval Others Failed to set the depth.\r
+\r
+**/\r
+EFI_STATUS\r
+UsbHubCtrlSetHubDepth (\r
+ IN USB_DEVICE *HubDev,\r
+ IN UINT16 Depth\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = UsbCtrlRequest (\r
+ HubDev,\r
+ EfiUsbNoData,\r
+ USB_REQ_TYPE_CLASS,\r
+ USB_HUB_TARGET_HUB,\r
+ USB_HUB_REQ_SET_DEPTH,\r
+ Depth,\r
+ 0,\r
+ NULL,\r
+ 0\r
+ );\r
+\r
+ return Status;\r
+}\r
\r
/**\r
- USB hub control transfer to clear the hub feature\r
+ USB hub control transfer to clear the hub feature.\r
\r
- @param HubDev The device of the hub\r
- @param Feature The feature to clear\r
+ @param HubDev The device of the hub.\r
+ @param Feature The feature to clear.\r
\r
- @retval EFI_SUCCESS Feature of the hub is cleared\r
- @retval Others Failed to clear the feature\r
+ @retval EFI_SUCCESS Feature of the hub is cleared.\r
+ @retval Others Failed to clear the feature.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubCtrlClearHubFeature (\r
- IN USB_DEVICE *HubDev,\r
- IN UINT16 Feature\r
+ IN USB_DEVICE *HubDev,\r
+ IN UINT16 Feature\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
Status = UsbCtrlRequest (\r
HubDev,\r
return Status;\r
}\r
\r
-\r
/**\r
- Clear the feature of the device's port\r
+ Clear the feature of the device's port.\r
\r
- @param HubDev The hub device\r
- @param Port The port to clear feature\r
- @param Feature The feature to clear\r
+ @param HubDev The hub device.\r
+ @param Port The port to clear feature.\r
+ @param Feature The feature to clear.\r
\r
@retval EFI_SUCCESS The feature of the port is cleared.\r
@retval Others Failed to clear the feature.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubCtrlClearPortFeature (\r
- IN USB_DEVICE *HubDev,\r
- IN UINT8 Port,\r
- IN UINT16 Feature\r
+ IN USB_DEVICE *HubDev,\r
+ IN UINT8 Port,\r
+ IN UINT16 Feature\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
//\r
// In USB bus, all the port index starts from 0. But HUB\r
USB_HUB_TARGET_PORT,\r
USB_HUB_REQ_CLEAR_FEATURE,\r
Feature,\r
- (UINT16) (Port + 1),\r
+ (UINT16)(Port + 1),\r
NULL,\r
0\r
);\r
return Status;\r
}\r
\r
-\r
-\r
/**\r
Clear the transaction translate buffer if full/low\r
speed control/bulk transfer failed and the transfer\r
buffer of transaction translator, not that of the\r
parent.\r
\r
- @param HubDev The hub device\r
- @param Port The port of the hub\r
- @param DevAddr Address of the failed transaction\r
- @param EpNum The endpoint number of the failed transaction\r
- @param EpType The type of failed transaction\r
+ @param HubDev The hub device.\r
+ @param Port The port of the hub.\r
+ @param DevAddr Address of the failed transaction.\r
+ @param EpNum The endpoint number of the failed transaction.\r
+ @param EpType The type of failed transaction.\r
\r
- @retval EFI_SUCCESS The TT buffer is cleared\r
- @retval Others Failed to clear the TT buffer\r
+ @retval EFI_SUCCESS The TT buffer is cleared.\r
+ @retval Others Failed to clear the TT buffer.\r
\r
**/\r
EFI_STATUS\r
UsbHubCtrlClearTTBuffer (\r
- IN USB_DEVICE *HubDev,\r
- IN UINT8 Port,\r
- IN UINT16 DevAddr,\r
- IN UINT16 EpNum,\r
- IN UINT16 EpType\r
+ IN USB_DEVICE *HubDev,\r
+ IN UINT8 Port,\r
+ IN UINT16 DevAddr,\r
+ IN UINT16 EpNum,\r
+ IN UINT16 EpType\r
)\r
{\r
- EFI_STATUS Status;\r
- UINT16 Value;\r
+ EFI_STATUS Status;\r
+ UINT16 Value;\r
\r
//\r
// Check USB2.0 spec page 424 for wValue's encoding\r
//\r
- Value = (UINT16) ((EpNum & 0x0F) | (DevAddr << 4) |\r
- ((EpType & 0x03) << 11) | ((EpNum & 0x80) << 15));\r
+ Value = (UINT16)((EpNum & 0x0F) | (DevAddr << 4) |\r
+ ((EpType & 0x03) << 11) | ((EpNum & 0x80) << 15));\r
\r
Status = UsbCtrlRequest (\r
HubDev,\r
USB_HUB_TARGET_PORT,\r
USB_HUB_REQ_CLEAR_TT,\r
Value,\r
- (UINT16) (Port + 1),\r
+ (UINT16)(Port + 1),\r
NULL,\r
0\r
);\r
return Status;\r
}\r
\r
-\r
/**\r
- Usb hub control transfer to get the hub descriptor\r
+ Usb hub control transfer to get the (super speed) hub descriptor.\r
\r
- @param HubDev The hub device\r
- @param Buf The buffer to hold the descriptor\r
- @param Len The length to retrieve\r
+ @param HubDev The hub device.\r
+ @param Buf The buffer to hold the descriptor.\r
+ @param Len The length to retrieve.\r
\r
- @retval EFI_SUCCESS The hub descriptor is retrieved\r
- @retval Others Failed to retrieve the hub descriptor\r
+ @retval EFI_SUCCESS The hub descriptor is retrieved.\r
+ @retval Others Failed to retrieve the hub descriptor.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubCtrlGetHubDesc (\r
- IN USB_DEVICE *HubDev,\r
- OUT VOID *Buf,\r
- IN UINTN Len\r
+ IN USB_DEVICE *HubDev,\r
+ OUT VOID *Buf,\r
+ IN UINTN Len\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
+ UINT8 DescType;\r
+\r
+ DescType = (HubDev->Speed == EFI_USB_SPEED_SUPER) ?\r
+ USB_DESC_TYPE_HUB_SUPER_SPEED :\r
+ USB_DESC_TYPE_HUB;\r
\r
Status = UsbCtrlRequest (\r
HubDev,\r
USB_REQ_TYPE_CLASS,\r
USB_HUB_TARGET_HUB,\r
USB_HUB_REQ_GET_DESC,\r
- (UINT16) (USB_DESC_TYPE_HUB << 8),\r
+ (UINT16)(DescType << 8),\r
0,\r
Buf,\r
Len\r
return Status;\r
}\r
\r
-\r
/**\r
- Usb hub control transfer to get the hub status\r
+ Usb hub control transfer to get the hub status.\r
\r
- @param HubDev The hub device\r
- @param State The variable to return the status\r
+ @param HubDev The hub device.\r
+ @param State The variable to return the status.\r
\r
- @retval EFI_SUCCESS The hub status is returned in State\r
- @retval Others Failed to get the hub status\r
+ @retval EFI_SUCCESS The hub status is returned in State.\r
+ @retval Others Failed to get the hub status.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubCtrlGetHubStatus (\r
- IN USB_DEVICE *HubDev,\r
- OUT UINT32 *State\r
+ IN USB_DEVICE *HubDev,\r
+ OUT UINT32 *State\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
Status = UsbCtrlRequest (\r
HubDev,\r
return Status;\r
}\r
\r
-\r
/**\r
- Usb hub control transfer to get the port status\r
+ Usb hub control transfer to get the port status.\r
\r
- @param HubDev The hub device\r
- @param Port The port of the hub\r
- @param State Variable to return the hub port state\r
+ @param HubDev The hub device.\r
+ @param Port The port of the hub.\r
+ @param State Variable to return the hub port state.\r
\r
- @retval EFI_SUCCESS The port state is returned in State\r
- @retval Others Failed to retrive the port state\r
+ @retval EFI_SUCCESS The port state is returned in State.\r
+ @retval Others Failed to retrieve the port state.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubCtrlGetPortStatus (\r
- IN USB_DEVICE *HubDev,\r
- IN UINT8 Port,\r
- OUT VOID *State\r
+ IN USB_DEVICE *HubDev,\r
+ IN UINT8 Port,\r
+ OUT VOID *State\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
//\r
// In USB bus, all the port index starts from 0. But HUB\r
USB_HUB_TARGET_PORT,\r
USB_HUB_REQ_GET_STATUS,\r
0,\r
- (UINT16) (Port + 1),\r
+ (UINT16)(Port + 1),\r
State,\r
4\r
);\r
return Status;\r
}\r
\r
-\r
-/**\r
- Usb hub control transfer to reset the TT (Transaction Transaltor)\r
-\r
- @param HubDev The hub device\r
- @param Port The port of the hub\r
-\r
- @retval EFI_SUCCESS The TT of the hub is reset\r
- @retval Others Failed to reset the port\r
-\r
-**/\r
-EFI_STATUS\r
-UsbHubCtrlResetTT (\r
- IN USB_DEVICE *HubDev,\r
- IN UINT8 Port\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- Status = UsbCtrlRequest (\r
- HubDev,\r
- EfiUsbNoData,\r
- USB_REQ_TYPE_CLASS,\r
- USB_HUB_TARGET_HUB,\r
- USB_HUB_REQ_RESET_TT,\r
- 0,\r
- (UINT16) (Port + 1),\r
- NULL,\r
- 0\r
- );\r
-\r
- return Status;\r
-}\r
-\r
-\r
/**\r
- Usb hub control transfer to set the hub feature\r
+ Usb hub control transfer to set the port feature.\r
\r
- @param HubDev The hub device\r
- @param Feature The feature to set\r
+ @param HubDev The Usb hub device.\r
+ @param Port The Usb port to set feature for.\r
+ @param Feature The feature to set.\r
\r
- @retval EFI_SUCESS The feature is set for the hub\r
- @retval Others Failed to set the feature\r
+ @retval EFI_SUCCESS The feature is set for the port.\r
+ @retval Others Failed to set the feature.\r
\r
**/\r
EFI_STATUS\r
-UsbHubCtrlSetHubFeature (\r
- IN USB_DEVICE *HubDev,\r
- IN UINT8 Feature\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- Status = UsbCtrlRequest (\r
- HubDev,\r
- EfiUsbNoData,\r
- USB_REQ_TYPE_CLASS,\r
- USB_HUB_TARGET_HUB,\r
- USB_HUB_REQ_SET_FEATURE,\r
- Feature,\r
- 0,\r
- NULL,\r
- 0\r
- );\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Usb hub control transfer to set the port feature\r
-\r
- @param HubDev The Usb hub device\r
- @param Port The Usb port to set feature for\r
- @param Feature The feature to set\r
-\r
- @retval EFI_SUCCESS The feature is set for the port\r
- @retval Others Failed to set the feature\r
-\r
-**/\r
-STATIC\r
-EFI_STATUS\r
UsbHubCtrlSetPortFeature (\r
- IN USB_DEVICE *HubDev,\r
- IN UINT8 Port,\r
- IN UINT8 Feature\r
+ IN USB_DEVICE *HubDev,\r
+ IN UINT8 Port,\r
+ IN UINT8 Feature\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
//\r
// In USB bus, all the port index starts from 0. But HUB\r
USB_HUB_TARGET_PORT,\r
USB_HUB_REQ_SET_FEATURE,\r
Feature,\r
- (UINT16) (Port + 1),\r
+ (UINT16)(Port + 1),\r
NULL,\r
0\r
);\r
return Status;\r
}\r
\r
-\r
/**\r
Read the whole usb hub descriptor. It is necessary\r
to do it in two steps because hub descriptor is of\r
- variable length\r
+ variable length.\r
\r
- @param HubDev The hub device\r
- @param HubDesc The variable to return the descriptor\r
+ @param HubDev The hub device.\r
+ @param HubDesc The variable to return the descriptor.\r
\r
- @retval EFI_SUCCESS The hub descriptor is read\r
- @retval Others Failed to read the hub descriptor\r
+ @retval EFI_SUCCESS The hub descriptor is read.\r
+ @retval Others Failed to read the hub descriptor.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubReadDesc (\r
IN USB_DEVICE *HubDev,\r
OUT EFI_USB_HUB_DESCRIPTOR *HubDesc\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
//\r
// First get the hub descriptor length\r
//\r
// Get the whole hub descriptor\r
//\r
- Status = UsbHubCtrlGetHubDesc (HubDev, HubDesc, HubDesc->Length);\r
-\r
- return Status;\r
+ return UsbHubCtrlGetHubDesc (HubDev, HubDesc, HubDesc->Length);\r
}\r
\r
-\r
-\r
/**\r
Ack the hub change bits. If these bits are not ACKed, Hub will\r
always return changed bit map from its interrupt endpoint.\r
\r
- @param HubDev The hub device\r
+ @param HubDev The hub device.\r
\r
- @retval EFI_SUCCESS The hub change status is ACKed\r
- @retval Others Failed to ACK the hub status\r
+ @retval EFI_SUCCESS The hub change status is ACKed.\r
+ @retval Others Failed to ACK the hub status.\r
\r
**/\r
EFI_STATUS\r
UsbHubAckHubStatus (\r
- IN USB_DEVICE *HubDev\r
+ IN USB_DEVICE *HubDev\r
)\r
{\r
- EFI_USB_PORT_STATUS HubState;\r
- EFI_STATUS Status;\r
+ EFI_USB_PORT_STATUS HubState;\r
+ EFI_STATUS Status;\r
\r
- Status = UsbHubCtrlGetHubStatus (HubDev, (UINT32 *) &HubState);\r
+ Status = UsbHubCtrlGetHubStatus (HubDev, (UINT32 *)&HubState);\r
\r
if (EFI_ERROR (Status)) {\r
return Status;\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
Test whether the interface is a hub interface.\r
\r
- @param UsbIf The interface to test\r
+ @param UsbIf The interface to test.\r
\r
- @retval TRUE The interface is a hub interface\r
- @retval FALSE The interface isn't a hub interface\r
+ @retval TRUE The interface is a hub interface.\r
+ @retval FALSE The interface isn't a hub interface.\r
\r
**/\r
BOOLEAN\r
UsbIsHubInterface (\r
- IN USB_INTERFACE *UsbIf\r
+ IN USB_INTERFACE *UsbIf\r
)\r
{\r
EFI_USB_INTERFACE_DESCRIPTOR *Setting;\r
Setting = &UsbIf->IfSetting->Desc;\r
\r
if ((Setting->InterfaceClass == USB_HUB_CLASS_CODE) &&\r
- (Setting->InterfaceSubClass == USB_HUB_SUBCLASS_CODE)) {\r
-\r
+ (Setting->InterfaceSubClass == USB_HUB_SUBCLASS_CODE))\r
+ {\r
return TRUE;\r
}\r
\r
return FALSE;\r
}\r
\r
-\r
/**\r
The callback function to the USB hub status change\r
interrupt endpoint. It is called periodically by\r
the underlying host controller.\r
\r
- @param Data The data read\r
- @param DataLength The length of the data read\r
- @param Context The context\r
- @param Result The result of the last interrupt transfer\r
+ @param Data The data read.\r
+ @param DataLength The length of the data read.\r
+ @param Context The context.\r
+ @param Result The result of the last interrupt transfer.\r
\r
- @retval EFI_SUCCESS The process is OK\r
- @retval EFI_OUT_OF_RESOURCES Failed to allocate resource\r
+ @retval EFI_SUCCESS The process is OK.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
+EFIAPI\r
UsbOnHubInterrupt (\r
- IN VOID *Data,\r
- IN UINTN DataLength,\r
- IN VOID *Context,\r
- IN UINT32 Result\r
+ IN VOID *Data,\r
+ IN UINTN DataLength,\r
+ IN VOID *Context,\r
+ IN UINT32 Result\r
)\r
{\r
- USB_INTERFACE *HubIf;\r
- EFI_USB_IO_PROTOCOL *UsbIo;\r
- EFI_USB_ENDPOINT_DESCRIPTOR *EpDesc;\r
- EFI_STATUS Status;\r
+ USB_INTERFACE *HubIf;\r
+ EFI_USB_IO_PROTOCOL *UsbIo;\r
+ EFI_USB_ENDPOINT_DESCRIPTOR *EpDesc;\r
+ EFI_STATUS Status;\r
\r
- HubIf = (USB_INTERFACE *) Context;\r
- UsbIo = &(HubIf->UsbIo);\r
- EpDesc = &(HubIf->HubEp->Desc);\r
+ HubIf = (USB_INTERFACE *)Context;\r
+ UsbIo = &(HubIf->UsbIo);\r
+ EpDesc = &(HubIf->HubEp->Desc);\r
\r
if (Result != EFI_USB_NOERROR) {\r
//\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- DEBUG (( EFI_D_ERROR, "UsbOnHubInterrupt: failed to remove async transfer - %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "UsbOnHubInterrupt: failed to remove async transfer - %r\n", Status));\r
return Status;\r
}\r
\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- DEBUG (( EFI_D_ERROR, "UsbOnHubInterrupt: failed to submit new async transfer - %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "UsbOnHubInterrupt: failed to submit new async transfer - %r\n", Status));\r
}\r
\r
return Status;\r
// OK, actually something is changed, save the change map\r
// then signal the HUB to do enumeration. This is a good\r
// practise since UsbOnHubInterrupt is called in the context\r
- // of host contrller's AsyncInterrupt monitor.\r
+ // of host controller's AsyncInterrupt monitor.\r
//\r
HubIf->ChangeMap = AllocateZeroPool (DataLength);\r
\r
return EFI_SUCCESS;\r
}\r
\r
-//\r
-// Array that maps the change bit to feature value which is\r
-// used to clear these change bit. USB HUB API will clear\r
-// these change bit automatically. For non-root hub, these\r
-// bits determine whether hub will report the port in changed\r
-// bit maps.\r
-//\r
-#define USB_HUB_MAP_SIZE 5\r
-\r
-USB_CHANGE_FEATURE_MAP mHubFeatureMap[USB_HUB_MAP_SIZE] = {\r
- {USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange},\r
- {USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange},\r
- {USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange},\r
- {USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange},\r
- {USB_PORT_STAT_C_RESET, EfiUsbPortResetChange},\r
-};\r
-\r
-#define USB_ROOT_HUB_MAP_SIZE 5\r
-\r
-USB_CHANGE_FEATURE_MAP mRootHubFeatureMap[USB_ROOT_HUB_MAP_SIZE] = {\r
- {USB_PORT_STAT_C_CONNECTION, EfiUsbPortConnectChange},\r
- {USB_PORT_STAT_C_ENABLE, EfiUsbPortEnableChange},\r
- {USB_PORT_STAT_C_SUSPEND, EfiUsbPortSuspendChange},\r
- {USB_PORT_STAT_C_OVERCURRENT, EfiUsbPortOverCurrentChange},\r
- {USB_PORT_STAT_C_RESET, EfiUsbPortResetChange},\r
-};\r
-\r
-\r
-\r
/**\r
- Initialize the device for a non-root hub\r
+ Initialize the device for a non-root hub.\r
\r
- @param HubIf The USB hub interface\r
+ @param HubIf The USB hub interface.\r
\r
- @retval EFI_SUCCESS The hub is initialized\r
- @retval EFI_DEVICE_ERROR Failed to initialize the hub\r
+ @retval EFI_SUCCESS The hub is initialized.\r
+ @retval EFI_DEVICE_ERROR Failed to initialize the hub.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubInit (\r
- IN USB_INTERFACE *HubIf\r
+ IN USB_INTERFACE *HubIf\r
)\r
{\r
- EFI_USB_HUB_DESCRIPTOR HubDesc;\r
+ UINT8 HubDescBuffer[256];\r
+ EFI_USB_HUB_DESCRIPTOR *HubDesc;\r
USB_ENDPOINT_DESC *EpDesc;\r
USB_INTERFACE_SETTING *Setting;\r
EFI_USB_IO_PROTOCOL *UsbIo;\r
USB_DEVICE *HubDev;\r
EFI_STATUS Status;\r
UINT8 Index;\r
+ UINT8 NumEndpoints;\r
+ UINT16 Depth;\r
\r
//\r
// Locate the interrupt endpoint for port change map\r
//\r
- HubIf->IsHub = FALSE;\r
- Setting = HubIf->IfSetting;\r
- HubDev = HubIf->Device;\r
- EpDesc = NULL;\r
+ HubIf->IsHub = FALSE;\r
+ Setting = HubIf->IfSetting;\r
+ HubDev = HubIf->Device;\r
+ EpDesc = NULL;\r
+ NumEndpoints = Setting->Desc.NumEndpoints;\r
\r
- for (Index = 0; Index < Setting->Desc.NumEndpoints; Index++) {\r
+ for (Index = 0; Index < NumEndpoints; Index++) {\r
ASSERT ((Setting->Endpoints != NULL) && (Setting->Endpoints[Index] != NULL));\r
\r
EpDesc = Setting->Endpoints[Index];\r
\r
if (USB_BIT_IS_SET (EpDesc->Desc.EndpointAddress, USB_ENDPOINT_DIR_IN) &&\r
- (USB_ENDPOINT_TYPE (&EpDesc->Desc) == USB_ENDPOINT_INTERRUPT)) {\r
+ (USB_ENDPOINT_TYPE (&EpDesc->Desc) == USB_ENDPOINT_INTERRUPT))\r
+ {\r
break;\r
}\r
}\r
\r
- if (Index == Setting->Desc.NumEndpoints) {\r
- DEBUG (( EFI_D_ERROR, "UsbHubInit: no interrupt endpoint found for hub %d\n", HubDev->Address));\r
+ if (Index == NumEndpoints) {\r
+ DEBUG ((DEBUG_ERROR, "UsbHubInit: no interrupt endpoint found for hub %d\n", HubDev->Address));\r
return EFI_DEVICE_ERROR;\r
}\r
\r
- Status = UsbHubReadDesc (HubDev, &HubDesc);\r
+ //\r
+ // The length field of descriptor is UINT8 type, so the buffer\r
+ // with 256 bytes is enough to hold the descriptor data.\r
+ //\r
+ HubDesc = (EFI_USB_HUB_DESCRIPTOR *)HubDescBuffer;\r
+ Status = UsbHubReadDesc (HubDev, HubDesc);\r
\r
if (EFI_ERROR (Status)) {\r
- DEBUG (( EFI_D_ERROR, "UsbHubInit: failed to read HUB descriptor %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "UsbHubInit: failed to read HUB descriptor %r\n", Status));\r
return Status;\r
}\r
\r
- HubIf->NumOfPort = HubDesc.NumPorts;\r
+ HubIf->NumOfPort = HubDesc->NumPorts;\r
\r
- DEBUG (( EFI_D_INFO, "UsbHubInit: hub %d has %d ports\n", HubDev->Address,HubIf->NumOfPort));\r
+ DEBUG ((DEBUG_INFO, "UsbHubInit: hub %d has %d ports\n", HubDev->Address, HubIf->NumOfPort));\r
+\r
+ //\r
+ // OK, set IsHub to TRUE. Now usb bus can handle this device\r
+ // as a working HUB. If failed earlier, bus driver will not\r
+ // recognize it as a hub. Other parts of the bus should be able\r
+ // to work.\r
+ //\r
+ HubIf->IsHub = TRUE;\r
+ HubIf->HubApi = &mUsbHubApi;\r
+ HubIf->HubEp = EpDesc;\r
+\r
+ if (HubIf->Device->Speed == EFI_USB_SPEED_SUPER) {\r
+ Depth = (UINT16)(HubIf->Device->Tier - 1);\r
+ DEBUG ((DEBUG_INFO, "UsbHubInit: Set Hub Depth as 0x%x\n", Depth));\r
+ UsbHubCtrlSetHubDepth (HubIf->Device, Depth);\r
+\r
+ for (Index = 0; Index < HubDesc->NumPorts; Index++) {\r
+ UsbHubCtrlSetPortFeature (HubIf->Device, Index, USB_HUB_PORT_REMOTE_WAKE_MASK);\r
+ }\r
+ } else {\r
+ //\r
+ // Feed power to all the hub ports. It should be ok\r
+ // for both gang/individual powered hubs.\r
+ //\r
+ for (Index = 0; Index < HubDesc->NumPorts; Index++) {\r
+ UsbHubCtrlSetPortFeature (HubIf->Device, Index, (EFI_USB_PORT_FEATURE)USB_HUB_PORT_POWER);\r
+ }\r
+\r
+ //\r
+ // Update for the usb hub has no power on delay requirement\r
+ //\r
+ if (HubDesc->PwrOn2PwrGood > 0) {\r
+ gBS->Stall (HubDesc->PwrOn2PwrGood * USB_SET_PORT_POWER_STALL);\r
+ }\r
+\r
+ UsbHubAckHubStatus (HubIf->Device);\r
+ }\r
\r
//\r
// Create an event to enumerate the hub's port. On\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- DEBUG (( EFI_D_ERROR, "UsbHubInit: failed to create signal for hub %d - %r\n",\r
- HubDev->Address, Status));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "UsbHubInit: failed to create signal for hub %d - %r\n",\r
+ HubDev->Address,\r
+ Status\r
+ ));\r
\r
return Status;\r
}\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- DEBUG (( EFI_D_ERROR, "UsbHubInit: failed to queue interrupt transfer for hub %d - %r\n",\r
- HubDev->Address, Status));\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "UsbHubInit: failed to queue interrupt transfer for hub %d - %r\n",\r
+ HubDev->Address,\r
+ Status\r
+ ));\r
\r
gBS->CloseEvent (HubIf->HubNotify);\r
HubIf->HubNotify = NULL;\r
return Status;\r
}\r
\r
- //\r
- // OK, set IsHub to TRUE. Now usb bus can handle this device\r
- // as a working HUB. If failed eariler, bus driver will not\r
- // recognize it as a hub. Other parts of the bus should be able\r
- // to work.\r
- //\r
- HubIf->IsHub = TRUE;\r
- HubIf->HubApi = &mUsbHubApi;\r
- HubIf->HubEp = EpDesc;\r
-\r
- //\r
- // Feed power to all the hub ports. It should be ok\r
- // for both gang/individual powered hubs.\r
- //\r
- for (Index = 0; Index < HubDesc.NumPorts; Index++) {\r
- UsbHubCtrlSetPortFeature (HubIf->Device, Index, (EFI_USB_PORT_FEATURE) USB_HUB_PORT_POWER);\r
- }\r
-\r
- gBS->Stall (HubDesc.PwrOn2PwrGood * USB_SET_PORT_POWER_STALL);\r
- UsbHubAckHubStatus (HubIf->Device);\r
-\r
- DEBUG (( EFI_D_INFO, "UsbHubInit: hub %d initialized\n", HubDev->Address));\r
+ DEBUG ((DEBUG_INFO, "UsbHubInit: hub %d initialized\n", HubDev->Address));\r
return Status;\r
}\r
\r
-\r
-\r
/**\r
Get the port status. This function is required to\r
ACK the port change bits although it will return\r
the port changes in PortState. Bus enumeration code\r
doesn't need to ACK the port change bits.\r
\r
- @param HubIf The hub interface\r
- @param Port The port of the hub to get state\r
- @param PortState Variable to return the port state\r
+ @param HubIf The hub interface.\r
+ @param Port The port of the hub to get state.\r
+ @param PortState Variable to return the port state.\r
\r
- @retval EFI_SUCCESS The port status is successfully returned\r
- @retval Others Failed to return the status\r
+ @retval EFI_SUCCESS The port status is successfully returned.\r
+ @retval Others Failed to return the status.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubGetPortStatus (\r
- IN USB_INTERFACE *HubIf,\r
- IN UINT8 Port,\r
- OUT EFI_USB_PORT_STATUS *PortState\r
+ IN USB_INTERFACE *HubIf,\r
+ IN UINT8 Port,\r
+ OUT EFI_USB_PORT_STATUS *PortState\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
- Status = UsbHubCtrlGetPortStatus (HubIf->Device, Port, PortState);\r
+ Status = UsbHubCtrlGetPortStatus (HubIf->Device, Port, PortState);\r
\r
return Status;\r
}\r
\r
-\r
-\r
/**\r
Clear the port change status.\r
\r
- @param HubIf The hub interface\r
- @param Port The hub port\r
-\r
- @return None\r
+ @param HubIf The hub interface.\r
+ @param Port The hub port.\r
\r
**/\r
-STATIC\r
VOID\r
UsbHubClearPortChange (\r
- IN USB_INTERFACE *HubIf,\r
- IN UINT8 Port\r
+ IN USB_INTERFACE *HubIf,\r
+ IN UINT8 Port\r
)\r
{\r
EFI_USB_PORT_STATUS PortState;\r
// It may lead to extra port state report. USB bus should\r
// be able to handle this.\r
//\r
- for (Index = 0; Index < USB_HUB_MAP_SIZE; Index++) {\r
+ for (Index = 0; Index < ARRAY_SIZE (mHubFeatureMap); Index++) {\r
Map = &mHubFeatureMap[Index];\r
\r
if (USB_BIT_IS_SET (PortState.PortChangeStatus, Map->ChangedBit)) {\r
- UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT16) Map->Feature);\r
+ UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT16)Map->Feature);\r
}\r
}\r
}\r
\r
-\r
-\r
/**\r
- Function to set the port feature for non-root hub\r
+ Function to set the port feature for non-root hub.\r
\r
- @param HubIf The hub interface\r
- @param Port The port of the hub\r
- @param Feature The feature of the port to set\r
+ @param HubIf The hub interface.\r
+ @param Port The port of the hub.\r
+ @param Feature The feature of the port to set.\r
\r
- @retval EFI_SUCCESS The hub port feature is set\r
- @retval Others Failed to set the port feature\r
+ @retval EFI_SUCCESS The hub port feature is set.\r
+ @retval Others Failed to set the port feature.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubSetPortFeature (\r
- IN USB_INTERFACE *HubIf,\r
- IN UINT8 Port,\r
- IN EFI_USB_PORT_FEATURE Feature\r
+ IN USB_INTERFACE *HubIf,\r
+ IN UINT8 Port,\r
+ IN EFI_USB_PORT_FEATURE Feature\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
- Status = UsbHubCtrlSetPortFeature (HubIf->Device, Port, (UINT8) Feature);\r
+ Status = UsbHubCtrlSetPortFeature (HubIf->Device, Port, (UINT8)Feature);\r
\r
return Status;\r
}\r
\r
-\r
/**\r
- Interface function to clear the port feature for non-root hub\r
+ Interface function to clear the port feature for non-root hub.\r
\r
- @param HubIf The hub interface\r
- @param Port The port of the hub to clear feature for\r
- @param Feature The feature to clear\r
+ @param HubIf The hub interface.\r
+ @param Port The port of the hub to clear feature for.\r
+ @param Feature The feature to clear.\r
\r
- @retval EFI_SUCCESS The port feature is cleared\r
- @retval Others Failed to clear the port feature\r
+ @retval EFI_SUCCESS The port feature is cleared.\r
+ @retval Others Failed to clear the port feature.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubClearPortFeature (\r
- IN USB_INTERFACE *HubIf,\r
- IN UINT8 Port,\r
- IN EFI_USB_PORT_FEATURE Feature\r
+ IN USB_INTERFACE *HubIf,\r
+ IN UINT8 Port,\r
+ IN EFI_USB_PORT_FEATURE Feature\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
- Status = UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT8) Feature);\r
+ Status = UsbHubCtrlClearPortFeature (HubIf->Device, Port, (UINT8)Feature);\r
\r
return Status;\r
}\r
\r
-\r
/**\r
- Interface funtion to reset the port\r
+ Interface function to reset the port.\r
\r
- @param HubIf The hub interface\r
- @param Port The port to reset\r
+ @param HubIf The hub interface.\r
+ @param Port The port to reset.\r
\r
- @retval EFI_SUCCESS The hub port is reset\r
- @retval EFI_TIMEOUT Failed to reset the port in time\r
- @retval Others Failed to reset the port\r
+ @retval EFI_SUCCESS The hub port is reset.\r
+ @retval EFI_TIMEOUT Failed to reset the port in time.\r
+ @retval Others Failed to reset the port.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubResetPort (\r
- IN USB_INTERFACE *HubIf,\r
- IN UINT8 Port\r
+ IN USB_INTERFACE *HubIf,\r
+ IN UINT8 Port\r
)\r
{\r
- EFI_USB_PORT_STATUS PortState;\r
- UINTN Index;\r
- EFI_STATUS Status;\r
+ EFI_USB_PORT_STATUS PortState;\r
+ UINTN Index;\r
+ EFI_STATUS Status;\r
\r
- Status = UsbHubSetPortFeature (HubIf, Port, (EFI_USB_PORT_FEATURE) USB_HUB_PORT_RESET);\r
+ Status = UsbHubSetPortFeature (HubIf, Port, (EFI_USB_PORT_FEATURE)USB_HUB_PORT_RESET);\r
\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
//\r
- // Drive the reset signal for at least 10ms. Check USB 2.0 Spec\r
+ // Drive the reset signal for worst 20ms. Check USB 2.0 Spec\r
// section 7.1.7.5 for timing requirements.\r
//\r
gBS->Stall (USB_SET_PORT_RESET_STALL);\r
\r
//\r
- // USB hub will clear RESET bit if reset is actually finished.\r
+ // Check USB_PORT_STAT_C_RESET bit to see if the resetting state is done.\r
//\r
ZeroMem (&PortState, sizeof (EFI_USB_PORT_STATUS));\r
\r
for (Index = 0; Index < USB_WAIT_PORT_STS_CHANGE_LOOP; Index++) {\r
Status = UsbHubGetPortStatus (HubIf, Port, &PortState);\r
\r
- if (!EFI_ERROR (Status) &&\r
- !USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_RESET)) {\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
\r
+ if (!EFI_ERROR (Status) &&\r
+ USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET))\r
+ {\r
+ gBS->Stall (USB_SET_PORT_RECOVERY_STALL);\r
return EFI_SUCCESS;\r
}\r
\r
return EFI_TIMEOUT;\r
}\r
\r
-\r
/**\r
- Release the hub's control of the interface\r
+ Release the hub's control of the interface.\r
\r
- @param HubIf The hub interface\r
+ @param HubIf The hub interface.\r
\r
- @retval EFI_SUCCESS The interface is release of hub control\r
+ @retval EFI_SUCCESS The interface is release of hub control.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbHubRelease (\r
- IN USB_INTERFACE *HubIf\r
+ IN USB_INTERFACE *HubIf\r
)\r
{\r
- EFI_USB_IO_PROTOCOL *UsbIo;\r
- EFI_STATUS Status;\r
+ EFI_USB_IO_PROTOCOL *UsbIo;\r
+ EFI_STATUS Status;\r
\r
UsbIo = &HubIf->UsbIo;\r
Status = UsbIo->UsbAsyncInterruptTransfer (\r
\r
gBS->CloseEvent (HubIf->HubNotify);\r
\r
- HubIf->IsHub = FALSE;\r
- HubIf->HubApi = NULL;\r
- HubIf->HubEp = NULL;\r
- HubIf->HubNotify = NULL;\r
+ HubIf->IsHub = FALSE;\r
+ HubIf->HubApi = NULL;\r
+ HubIf->HubEp = NULL;\r
+ HubIf->HubNotify = NULL;\r
\r
- DEBUG (( EFI_D_INFO, "UsbHubRelease: hub device %d released\n", HubIf->Device->Address));\r
+ DEBUG ((DEBUG_INFO, "UsbHubRelease: hub device %d released\n", HubIf->Device->Address));\r
return EFI_SUCCESS;\r
}\r
\r
-\r
-\r
/**\r
- Initialize the interface for root hub\r
+ Initialize the interface for root hub.\r
\r
- @param HubIf The root hub interface\r
+ @param HubIf The root hub interface.\r
\r
- @retval EFI_SUCCESS The interface is initialied for root hub\r
- @retval Others Failed to initialize the hub\r
+ @retval EFI_SUCCESS The interface is initialized for root hub.\r
+ @retval Others Failed to initialize the hub.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbRootHubInit (\r
- IN USB_INTERFACE *HubIf\r
+ IN USB_INTERFACE *HubIf\r
)\r
{\r
- EFI_STATUS Status;\r
- UINT8 MaxSpeed;\r
- UINT8 NumOfPort;\r
- UINT8 Support64;\r
+ EFI_STATUS Status;\r
+ UINT8 MaxSpeed;\r
+ UINT8 NumOfPort;\r
+ UINT8 Support64;\r
\r
Status = UsbHcGetCapability (HubIf->Device->Bus, &MaxSpeed, &NumOfPort, &Support64);\r
\r
return Status;\r
}\r
\r
- DEBUG (( EFI_D_INFO, "UsbRootHubInit: root hub %x - max speed %d, %d ports\n",\r
- HubIf, MaxSpeed, NumOfPort));\r
-\r
- HubIf->IsHub = TRUE;\r
- HubIf->HubApi = &mUsbRootHubApi;\r
- HubIf->HubEp = NULL;\r
- HubIf->MaxSpeed = MaxSpeed;\r
- HubIf->NumOfPort = NumOfPort;\r
- HubIf->HubNotify = NULL;\r
+ DEBUG ((\r
+ DEBUG_INFO,\r
+ "UsbRootHubInit: root hub %p - max speed %d, %d ports\n",\r
+ HubIf,\r
+ MaxSpeed,\r
+ NumOfPort\r
+ ));\r
+\r
+ HubIf->IsHub = TRUE;\r
+ HubIf->HubApi = &mUsbRootHubApi;\r
+ HubIf->HubEp = NULL;\r
+ HubIf->MaxSpeed = MaxSpeed;\r
+ HubIf->NumOfPort = NumOfPort;\r
+ HubIf->HubNotify = NULL;\r
\r
//\r
// Create a timer to poll root hub ports periodically\r
return Status;\r
}\r
\r
-\r
-\r
/**\r
Get the port status. This function is required to\r
ACK the port change bits although it will return\r
the port changes in PortState. Bus enumeration code\r
doesn't need to ACK the port change bits.\r
\r
- @param HubIf The root hub interface\r
- @param Port The root hub port to get the state\r
- @param PortState Variable to return the port state\r
+ @param HubIf The root hub interface.\r
+ @param Port The root hub port to get the state.\r
+ @param PortState Variable to return the port state.\r
\r
- @retval EFI_SUCCESS The port state is returned\r
- @retval Others Failed to retrieve the port state\r
+ @retval EFI_SUCCESS The port state is returned.\r
+ @retval Others Failed to retrieve the port state.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbRootHubGetPortStatus (\r
- IN USB_INTERFACE *HubIf,\r
- IN UINT8 Port,\r
- OUT EFI_USB_PORT_STATUS *PortState\r
+ IN USB_INTERFACE *HubIf,\r
+ IN UINT8 Port,\r
+ OUT EFI_USB_PORT_STATUS *PortState\r
)\r
{\r
- USB_BUS *Bus;\r
- EFI_STATUS Status;\r
+ USB_BUS *Bus;\r
+ EFI_STATUS Status;\r
\r
- Bus = HubIf->Device->Bus;\r
- Status = UsbHcGetRootHubPortStatus (Bus, Port, PortState);\r
+ Bus = HubIf->Device->Bus;\r
+ Status = UsbHcGetRootHubPortStatus (Bus, Port, PortState);\r
\r
return Status;\r
}\r
\r
-\r
/**\r
Clear the port change status.\r
\r
- @param HubIf The root hub interface\r
- @param Port The root hub port\r
-\r
- @retval EFI_SUCCESS The port state is returned\r
- @retval Others Failed to retrieve the port state\r
+ @param HubIf The root hub interface.\r
+ @param Port The root hub port.\r
\r
**/\r
-STATIC\r
VOID\r
UsbRootHubClearPortChange (\r
- IN USB_INTERFACE *HubIf,\r
- IN UINT8 Port\r
+ IN USB_INTERFACE *HubIf,\r
+ IN UINT8 Port\r
)\r
{\r
EFI_USB_PORT_STATUS PortState;\r
// It may lead to extra port state report. USB bus should\r
// be able to handle this.\r
//\r
- for (Index = 0; Index < USB_ROOT_HUB_MAP_SIZE; Index++) {\r
+ for (Index = 0; Index < ARRAY_SIZE (mRootHubFeatureMap); Index++) {\r
Map = &mRootHubFeatureMap[Index];\r
\r
if (USB_BIT_IS_SET (PortState.PortChangeStatus, Map->ChangedBit)) {\r
- UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, (EFI_USB_PORT_FEATURE) Map->Feature);\r
+ UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, (EFI_USB_PORT_FEATURE)Map->Feature);\r
}\r
}\r
}\r
\r
-\r
-\r
/**\r
- Set the root hub port feature\r
+ Set the root hub port feature.\r
\r
- @param HubIf The Usb hub interface\r
- @param Port The hub port\r
- @param Feature The feature to set\r
+ @param HubIf The Usb hub interface.\r
+ @param Port The hub port.\r
+ @param Feature The feature to set.\r
\r
- @retval EFI_SUCCESS The root hub port is set with the feature\r
- @retval Others Failed to set the feature\r
+ @retval EFI_SUCCESS The root hub port is set with the feature.\r
+ @retval Others Failed to set the feature.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbRootHubSetPortFeature (\r
- IN USB_INTERFACE *HubIf,\r
- IN UINT8 Port,\r
- IN EFI_USB_PORT_FEATURE Feature\r
+ IN USB_INTERFACE *HubIf,\r
+ IN UINT8 Port,\r
+ IN EFI_USB_PORT_FEATURE Feature\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
- Status = UsbHcSetRootHubPortFeature (HubIf->Device->Bus, Port, Feature);\r
+ Status = UsbHcSetRootHubPortFeature (HubIf->Device->Bus, Port, Feature);\r
\r
return Status;\r
}\r
\r
-\r
/**\r
- Clear the root hub port feature\r
+ Clear the root hub port feature.\r
\r
- @param HubIf The root hub interface\r
- @param Port The root hub port\r
- @param Feature The feature to clear\r
+ @param HubIf The root hub interface.\r
+ @param Port The root hub port.\r
+ @param Feature The feature to clear.\r
\r
- @retval EFI_SUCCESS The root hub port is cleared of the feature\r
- @retval Others Failed to clear the feature\r
+ @retval EFI_SUCCESS The root hub port is cleared of the feature.\r
+ @retval Others Failed to clear the feature.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbRootHubClearPortFeature (\r
- IN USB_INTERFACE *HubIf,\r
- IN UINT8 Port,\r
- IN EFI_USB_PORT_FEATURE Feature\r
+ IN USB_INTERFACE *HubIf,\r
+ IN UINT8 Port,\r
+ IN EFI_USB_PORT_FEATURE Feature\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
- Status = UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, Feature);\r
+ Status = UsbHcClearRootHubPortFeature (HubIf->Device->Bus, Port, Feature);\r
\r
return Status;\r
}\r
\r
-\r
/**\r
- Interface funtion to reset the root hub port\r
+ Interface function to reset the root hub port.\r
\r
- @param RootIf The root hub interface\r
- @param Port The port to reset\r
+ @param RootIf The root hub interface.\r
+ @param Port The port to reset.\r
\r
- @retval EFI_SUCCESS The hub port is reset\r
- @retval EFI_TIMEOUT Failed to reset the port in time\r
- @retval EFI_NOT_FOUND The low/full speed device connected to high speed\r
- root hub is released to the companion UHCI\r
- @retval Others Failed to reset the port\r
+ @retval EFI_SUCCESS The hub port is reset.\r
+ @retval EFI_TIMEOUT Failed to reset the port in time.\r
+ @retval EFI_NOT_FOUND The low/full speed device connected to high speed.\r
+ root hub is released to the companion UHCI.\r
+ @retval Others Failed to reset the port.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbRootHubResetPort (\r
- IN USB_INTERFACE *RootIf,\r
- IN UINT8 Port\r
+ IN USB_INTERFACE *RootIf,\r
+ IN UINT8 Port\r
)\r
{\r
- USB_BUS *Bus;\r
- EFI_STATUS Status;\r
- EFI_USB_PORT_STATUS PortState;\r
- UINTN Index;\r
+ USB_BUS *Bus;\r
+ EFI_STATUS Status;\r
+ EFI_USB_PORT_STATUS PortState;\r
+ UINTN Index;\r
\r
//\r
// Notice: although EHCI requires that ENABLED bit be cleared\r
// when reset the port, we don't need to care that here. It\r
// should be handled in the EHCI driver.\r
//\r
- Bus = RootIf->Device->Bus;\r
- Status = UsbHcSetRootHubPortFeature (Bus, Port, EfiUsbPortReset);\r
+ Bus = RootIf->Device->Bus;\r
+\r
+ Status = UsbHcSetRootHubPortFeature (Bus, Port, EfiUsbPortReset);\r
\r
if (EFI_ERROR (Status)) {\r
- DEBUG (( EFI_D_ERROR, "UsbRootHubResetPort: failed to start reset on port %d\n", Port));\r
+ DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: failed to start reset on port %d\n", Port));\r
return Status;\r
}\r
\r
Status = UsbHcClearRootHubPortFeature (Bus, Port, EfiUsbPortReset);\r
\r
if (EFI_ERROR (Status)) {\r
- DEBUG (( EFI_D_ERROR, "UsbRootHubResetPort: failed to clear reset on port %d\n", Port));\r
+ DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: failed to clear reset on port %d\n", Port));\r
return Status;\r
}\r
\r
}\r
\r
if (Index == USB_WAIT_PORT_STS_CHANGE_LOOP) {\r
- DEBUG ((EFI_D_ERROR, "UsbRootHubResetPort: reset not finished in time on port %d\n", Port));\r
+ DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: reset not finished in time on port %d\n", Port));\r
return EFI_TIMEOUT;\r
}\r
\r
// automatically enable the port, we need to enable it manually.\r
//\r
if (RootIf->MaxSpeed == EFI_USB_SPEED_HIGH) {\r
- DEBUG (( EFI_D_ERROR, "UsbRootHubResetPort: release low/full speed device (%d) to UHCI\n", Port));\r
+ DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: release low/full speed device (%d) to UHCI\n", Port));\r
\r
UsbRootHubSetPortFeature (RootIf, Port, EfiUsbPortOwner);\r
return EFI_NOT_FOUND;\r
-\r
} else {\r
-\r
Status = UsbRootHubSetPortFeature (RootIf, Port, EfiUsbPortEnable);\r
\r
if (EFI_ERROR (Status)) {\r
- DEBUG (( EFI_D_ERROR, "UsbRootHubResetPort: failed to enable port %d for UHCI\n", Port));\r
+ DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: failed to enable port %d for UHCI\n", Port));\r
return Status;\r
}\r
\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
- Release the root hub's control of the interface\r
+ Release the root hub's control of the interface.\r
\r
- @param HubIf The root hub interface\r
+ @param HubIf The root hub interface.\r
\r
@retval EFI_SUCCESS The root hub's control of the interface is\r
released.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
UsbRootHubRelease (\r
- IN USB_INTERFACE *HubIf\r
+ IN USB_INTERFACE *HubIf\r
)\r
{\r
- DEBUG (( EFI_D_INFO, "UsbRootHubRelease: root hub released for hub %x\n", HubIf));\r
+ DEBUG ((DEBUG_INFO, "UsbRootHubRelease: root hub released for hub %p\n", HubIf));\r
\r
gBS->SetTimer (HubIf->HubNotify, TimerCancel, USB_ROOTHUB_POLL_INTERVAL);\r
gBS->CloseEvent (HubIf->HubNotify);\r
return EFI_SUCCESS;\r
}\r
\r
-USB_HUB_API mUsbHubApi = {\r
+USB_HUB_API mUsbHubApi = {\r
UsbHubInit,\r
UsbHubGetPortStatus,\r
UsbHubClearPortChange,\r
UsbHubRelease\r
};\r
\r
-USB_HUB_API mUsbRootHubApi = {\r
+USB_HUB_API mUsbRootHubApi = {\r
UsbRootHubInit,\r
UsbRootHubGetPortStatus,\r
UsbRootHubClearPortChange,\r