]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/EhciPei/EhcPeim.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / EhciPei / EhcPeim.c
index 5cad25e926c578df51411af22b2f25c9c78c4bda..6abd3d4d713098bf54e33e37c127a6bfccecabb1 100644 (file)
@@ -2,8 +2,8 @@
 PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPeiUsbControllerPpiGuid\r
 which is used to enable recovery function from USB Drivers.\r
 \r
-Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>\r
-  \r
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
+\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
 of the BSD License which accompanies this distribution.  The\r
@@ -39,7 +39,7 @@ USB_PORT_STATE_MAP  mUsbPortChangeMap[] = {
 \r
 /**\r
   Read Ehc Operation register.\r
-  \r
+\r
   @param  Ehc       The EHCI device.\r
   @param  Offset    The operation register offset.\r
 \r
@@ -53,17 +53,17 @@ EhcReadOpReg (
   )\r
 {\r
   UINT32                  Data;\r
\r
+\r
   ASSERT (Ehc->CapLen != 0);\r
 \r
   Data = MmioRead32 (Ehc->UsbHostControllerBaseAddress + Ehc->CapLen + Offset);\r
-  \r
+\r
   return Data;\r
 }\r
 \r
 /**\r
   Write the data to the EHCI operation register.\r
-  \r
+\r
   @param  Ehc       The EHCI device.\r
   @param  Offset    EHCI operation register offset.\r
   @param  Data      The data to write.\r
@@ -85,7 +85,7 @@ EhcWriteOpReg (
 \r
 /**\r
   Set one bit of the operational register while keeping other bits.\r
-  \r
+\r
   @param  Ehc       The EHCI device.\r
   @param  Offset    The offset of the operational register.\r
   @param  Bit       The bit mask of the register to set.\r
@@ -107,7 +107,7 @@ EhcSetOpRegBit (
 \r
 /**\r
   Clear one bit of the operational register while keeping other bits.\r
-  \r
+\r
   @param  Ehc       The EHCI device.\r
   @param  Offset    The offset of the operational register.\r
   @param  Bit       The bit mask of the register to clear.\r
@@ -128,9 +128,9 @@ EhcClearOpRegBit (
 }\r
 \r
 /**\r
-  Wait the operation register's bit as specified by Bit \r
+  Wait the operation register's bit as specified by Bit\r
   to become set (or clear).\r
-  \r
+\r
   @param  Ehc           The EHCI device.\r
   @param  Offset        The offset of the operational register.\r
   @param  Bit           The bit mask of the register to wait for.\r
@@ -165,7 +165,7 @@ EhcWaitOpRegBit (
 \r
 /**\r
   Read EHCI capability register.\r
-  \r
+\r
   @param  Ehc       The EHCI device.\r
   @param  Offset    Capability register address.\r
 \r
@@ -179,16 +179,16 @@ EhcReadCapRegister (
   )\r
 {\r
   UINT32                  Data;\r
-  \r
+\r
   Data = MmioRead32(Ehc->UsbHostControllerBaseAddress + Offset);\r
-  \r
+\r
   return Data;\r
 }\r
 \r
 /**\r
   Set door bell and wait it to be ACKed by host controller.\r
   This function is used to synchronize with the hardware.\r
-  \r
+\r
   @param  Ehc       The EHCI device.\r
   @param  Timeout   The time to wait before abort (in millisecond, ms).\r
 \r
@@ -223,9 +223,9 @@ EhcSetAndWaitDoorBell (
 }\r
 \r
 /**\r
-  Clear all the interrutp status bits, these bits \r
+  Clear all the interrutp status bits, these bits\r
   are Write-Clean.\r
-  \r
+\r
   @param  Ehc       The EHCI device.\r
 \r
 **/\r
@@ -238,9 +238,9 @@ EhcAckAllInterrupt (
 }\r
 \r
 /**\r
-  Enable the periodic schedule then wait EHC to \r
+  Enable the periodic schedule then wait EHC to\r
   actually enable it.\r
-  \r
+\r
   @param  Ehc       The EHCI device.\r
   @param  Timeout   The time to wait before abort (in millisecond, ms).\r
 \r
@@ -264,7 +264,7 @@ EhcEnablePeriodSchd (
 \r
 /**\r
   Enable asynchrounous schedule.\r
-  \r
+\r
   @param  Ehc       The EHCI device.\r
   @param  Timeout   Time to wait before abort.\r
 \r
@@ -288,7 +288,7 @@ EhcEnableAsyncSchd (
 \r
 /**\r
   Check whether Ehc is halted.\r
-  \r
+\r
   @param  Ehc       The EHCI device.\r
 \r
   @retval TRUE      The controller is halted.\r
@@ -305,7 +305,7 @@ EhcIsHalt (
 \r
 /**\r
   Check whether system error occurred.\r
-  \r
+\r
   @param  Ehc       The EHCI device.\r
 \r
   @retval TRUE      System error happened.\r
@@ -322,7 +322,7 @@ EhcIsSysError (
 \r
 /**\r
   Reset the host controller.\r
-  \r
+\r
   @param  Ehc             The EHCI device.\r
   @param  Timeout         Time to wait before abort (in millisecond, ms).\r
 \r
@@ -356,7 +356,7 @@ EhcResetHC (
 \r
 /**\r
   Halt the host controller.\r
-  \r
+\r
   @param  Ehc             The EHCI device.\r
   @param  Timeout         Time to wait before abort.\r
 \r
@@ -379,7 +379,7 @@ EhcHaltHC (
 \r
 /**\r
   Set the EHCI to run.\r
-  \r
+\r
   @param  Ehc             The EHCI device.\r
   @param  Timeout         Time to wait before abort.\r
 \r
@@ -402,7 +402,7 @@ EhcRunHC (
 \r
 /**\r
   Power On All EHCI Ports.\r
-  \r
+\r
   @param  Ehc             The EHCI device.\r
 \r
 **/\r
@@ -414,7 +414,7 @@ EhcPowerOnAllPorts (
   UINT8     PortNumber;\r
   UINT8     Index;\r
   UINT32    RegVal;\r
-  \r
+\r
   PortNumber = (UINT8)(Ehc->HcStructParams & HCSP_NPORTS);\r
   for (Index = 0; Index < PortNumber; Index++) {\r
     //\r
@@ -429,14 +429,14 @@ EhcPowerOnAllPorts (
 }\r
 \r
 /**\r
-  Initialize the HC hardware. \r
+  Initialize the HC hardware.\r
   EHCI spec lists the five things to do to initialize the hardware.\r
   1. Program CTRLDSSEGMENT.\r
   2. Set USBINTR to enable interrupts.\r
   3. Set periodic list base.\r
   4. Set USBCMD, interrupt threshold, frame list size etc.\r
   5. Write 1 to CONFIGFLAG to route all ports to EHCI.\r
-  \r
+\r
   @param  Ehc             The EHCI device.\r
 \r
   @retval EFI_SUCCESS     The EHCI has come out of halt state.\r
@@ -451,7 +451,7 @@ EhcInitHC (
   EFI_STATUS              Status;\r
   EFI_PHYSICAL_ADDRESS        TempPtr;\r
   UINTN               PageNumber;\r
-  \r
+\r
   ASSERT (EhcIsHalt (Ehc));\r
 \r
   //\r
@@ -472,9 +472,9 @@ EhcInitHC (
     return Status;\r
   }\r
 \r
-  EhcPowerOnAllPorts (Ehc);  \r
+  EhcPowerOnAllPorts (Ehc);\r
   MicroSecondDelay (EHC_ROOT_PORT_RECOVERY_STALL);\r
-  \r
+\r
   Status = EhcInitSched (Ehc);\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -523,26 +523,26 @@ EhcInitHC (
 \r
 /**\r
   Submits bulk transfer to a bulk endpoint of a USB device.\r
-  \r
+\r
   @param  PeiServices           The pointer of EFI_PEI_SERVICES.\r
   @param  This                  The pointer of PEI_USB2_HOST_CONTROLLER_PPI.\r
   @param  DeviceAddress         Target device address.\r
   @param  EndPointAddress       Endpoint number and its direction in bit 7.\r
-  @param  DeviceSpeed           Device speed, Low speed device doesn't support \r
+  @param  DeviceSpeed           Device speed, Low speed device doesn't support\r
                                 bulk transfer.\r
-  @param  MaximumPacketLength   Maximum packet size the endpoint is capable of \r
+  @param  MaximumPacketLength   Maximum packet size the endpoint is capable of\r
                                 sending or receiving.\r
-  @param  Data                  Array of pointers to the buffers of data to transmit \r
+  @param  Data                  Array of pointers to the buffers of data to transmit\r
                                 from or receive into.\r
   @param  DataLength            The lenght of the data buffer.\r
   @param  DataToggle            On input, the initial data toggle for the transfer;\r
-                                On output, it is updated to to next data toggle to use of \r
+                                On output, it is updated to to next data toggle to use of\r
                                 the subsequent bulk transfer.\r
   @param  TimeOut               Indicates the maximum time, in millisecond, which the\r
                                 transfer is allowed to complete.\r
                                 If Timeout is 0, then the caller must wait for the function\r
                                 to be completed until EFI_SUCCESS or EFI_DEVICE_ERROR is returned.\r
-  @param  Translator            A pointr to the transaction translator data.                                \r
+  @param  Translator            A pointr to the transaction translator data.\r
   @param  TransferResult        A pointer to the detailed result information of the\r
                                 bulk transfer.\r
 \r
@@ -577,7 +577,7 @@ EhcBulkTransfer (
   //\r
   // Validate the parameters\r
   //\r
-  if ((DataLength == NULL) || (*DataLength == 0) || \r
+  if ((DataLength == NULL) || (*DataLength == 0) ||\r
       (Data == NULL) || (Data[0] == NULL) || (TransferResult == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -652,10 +652,10 @@ ON_EXIT:
   Retrieves the number of root hub ports.\r
 \r
   @param[in]  PeiServices   The pointer to the PEI Services Table.\r
-  @param[in]  This          The pointer to this instance of the \r
+  @param[in]  This          The pointer to this instance of the\r
                             PEI_USB2_HOST_CONTROLLER_PPI.\r
-  @param[out] PortNumber    The pointer to the number of the root hub ports.                                \r
-                                \r
+  @param[out] PortNumber    The pointer to the number of the root hub ports.\r
+\r
   @retval EFI_SUCCESS           The port number was retrieved successfully.\r
   @retval EFI_INVALID_PARAMETER PortNumber is NULL.\r
 \r
@@ -671,19 +671,19 @@ EhcGetRootHubPortNumber (
 \r
   PEI_USB2_HC_DEV             *EhcDev;\r
   EhcDev = PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS (This);\r
-  \r
+\r
   if (PortNumber == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
-  }  \r
-  \r
+  }\r
+\r
   *PortNumber = (UINT8)(EhcDev->HcStructParams & HCSP_NPORTS);\r
   return EFI_SUCCESS;\r
-  \r
+\r
 }\r
 \r
 /**\r
   Clears a feature for the specified root hub port.\r
-  \r
+\r
   @param  PeiServices           The pointer of EFI_PEI_SERVICES.\r
   @param  This                  The pointer of PEI_USB2_HOST_CONTROLLER_PPI.\r
   @param  PortNumber            Specifies the root hub port whose feature\r
@@ -691,7 +691,7 @@ EhcGetRootHubPortNumber (
   @param  PortFeature           Indicates the feature selector associated with the\r
                                 feature clear request.\r
 \r
-  @retval EFI_SUCCESS            The feature specified by PortFeature was cleared \r
+  @retval EFI_SUCCESS            The feature specified by PortFeature was cleared\r
                                  for the USB root hub port specified by PortNumber.\r
   @retval EFI_INVALID_PARAMETER  PortNumber is invalid or PortFeature is invalid.\r
 \r
@@ -805,7 +805,7 @@ ON_EXIT:
 \r
 /**\r
   Sets a feature for the specified root hub port.\r
-  \r
+\r
   @param  PeiServices           The pointer of EFI_PEI_SERVICES\r
   @param  This                  The pointer of PEI_USB2_HOST_CONTROLLER_PPI\r
   @param  PortNumber            Root hub port to set.\r
@@ -876,7 +876,7 @@ EhcSetRootHubPortFeature (
         break;\r
       }\r
     }\r
-    \r
+\r
     //\r
     // Set one to PortReset bit must also set zero to PortEnable bit\r
     //\r
@@ -907,10 +907,10 @@ ON_EXIT:
 \r
 /**\r
   Retrieves the current status of a USB root hub port.\r
-  \r
+\r
   @param  PeiServices            The pointer of EFI_PEI_SERVICES.\r
   @param  This                   The pointer of PEI_USB2_HOST_CONTROLLER_PPI.\r
-  @param  PortNumber             The root hub port to retrieve the state from.  \r
+  @param  PortNumber             The root hub port to retrieve the state from.\r
   @param  PortStatus             Variable to receive the port state.\r
 \r
   @retval EFI_SUCCESS            The status of the USB root hub port specified.\r
@@ -957,9 +957,9 @@ EhcGetRootHubPortStatus (
 \r
   //\r
   // Identify device speed. If in K state, it is low speed.\r
-  // If the port is enabled after reset, the device is of \r
+  // If the port is enabled after reset, the device is of\r
   // high speed. The USB bus driver should retrieve the actual\r
-  // port speed after reset. \r
+  // port speed after reset.\r
   //\r
   if (EHC_BIT_IS_SET (State, PORTSC_LINESTATE_K)) {\r
     PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED;\r
@@ -967,7 +967,7 @@ EhcGetRootHubPortStatus (
   } else if (EHC_BIT_IS_SET (State, PORTSC_ENABLED)) {\r
     PortStatus->PortStatus |= USB_PORT_STAT_HIGH_SPEED;\r
   }\r
-  \r
+\r
   //\r
   // Convert the EHCI port/port change state to UEFI status\r
   //\r
@@ -993,12 +993,12 @@ ON_EXIT:
 \r
 /**\r
   Submits control transfer to a target USB device.\r
-  \r
+\r
   @param  PeiServices            The pointer of EFI_PEI_SERVICES.\r
   @param  This                   The pointer of PEI_USB2_HOST_CONTROLLER_PPI.\r
   @param  DeviceAddress          The target device address.\r
   @param  DeviceSpeed            Target device speed.\r
-  @param  MaximumPacketLength    Maximum packet size the default control transfer \r
+  @param  MaximumPacketLength    Maximum packet size the default control transfer\r
                                  endpoint is capable of sending or receiving.\r
   @param  Request                USB device request to send.\r
   @param  TransferDirection      Specifies the data direction for the data stage.\r
@@ -1052,12 +1052,12 @@ EhcControlTransfer (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if ((TransferDirection == EfiUsbNoData) && \r
+  if ((TransferDirection == EfiUsbNoData) &&\r
       ((Data != NULL) || (*DataLength != 0))) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if ((TransferDirection != EfiUsbNoData) && \r
+  if ((TransferDirection != EfiUsbNoData) &&\r
      ((Data == NULL) || (*DataLength == 0))) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -1225,7 +1225,7 @@ EhcPeimEntry (
     if (EFI_ERROR (Status)) {\r
       break;\r
     }\r
-    \r
+\r
     //\r
     // This PEIM is for UHC type controller.\r
     //\r
@@ -1303,19 +1303,19 @@ EhcPeimEntry (
 **/\r
 EFI_STATUS\r
 InitializeUsbHC (\r
-  IN PEI_USB2_HC_DEV      *EhcDev  \r
+  IN PEI_USB2_HC_DEV      *EhcDev\r
   )\r
 {\r
   EFI_STATUS  Status;\r
 \r
-       \r
+\r
   EhcResetHC (EhcDev, EHC_RESET_TIMEOUT);\r
 \r
   Status = EhcInitHC (EhcDev);\r
 \r
   if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;      \r
+    return EFI_ABORTED;\r
   }\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r