]> git.proxmox.com Git - mirror_edk2.git/blobdiff - QuarkSocPkg/QuarkSouthCluster/Usb/Ohci/Pei/OhcPeim.h
QuarkSocPkg: Add new package for Quark SoC X1000
[mirror_edk2.git] / QuarkSocPkg / QuarkSouthCluster / Usb / Ohci / Pei / OhcPeim.h
diff --git a/QuarkSocPkg/QuarkSouthCluster/Usb/Ohci/Pei/OhcPeim.h b/QuarkSocPkg/QuarkSouthCluster/Usb/Ohci/Pei/OhcPeim.h
new file mode 100644 (file)
index 0000000..0fd5302
--- /dev/null
@@ -0,0 +1,258 @@
+/** @file\r
+Provides the definition of Usb Hc Protocol and OHCI controller\r
+private data structure.\r
+\r
+Copyright (c) 2013-2015 Intel Corporation.\r
+\r
+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
+**/\r
+\r
+\r
+\r
+#ifndef _OHCI_PEIM_H\r
+#define _OHCI_PEIM_H\r
+\r
+#include <PiPei.h>\r
+\r
+#include <Ppi/UsbController.h>\r
+#include <Ppi/UsbHostController.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/IoLib.h>\r
+\r
+typedef struct _USB_OHCI_HC_DEV USB_OHCI_HC_DEV;\r
+\r
+#include "UsbHcMem.h"\r
+#include "OhciReg.h"\r
+#include "OhciSched.h"\r
+#include "OhciUrb.h"\r
+#include "Descriptor.h"\r
+\r
+#define EFI_USB_SPEED_FULL 0x0000\r
+#define EFI_USB_SPEED_LOW  0x0001\r
+#define EFI_USB_SPEED_HIGH 0x0002\r
+\r
+#define PAGESIZE                    4096\r
+\r
+#define HC_1_MICROSECOND            1\r
+#define HC_1_MILLISECOND            (1000 * HC_1_MICROSECOND)\r
+#define HC_1_SECOND                 (1000 * HC_1_MILLISECOND)\r
+\r
+\r
+#define USB_OHCI_HC_DEV_SIGNATURE   SIGNATURE_32('o','h','c','i')\r
+\r
+struct _USB_OHCI_HC_DEV {\r
+  UINTN                        Signature;\r
+  PEI_USB_HOST_CONTROLLER_PPI  UsbHostControllerPpi;\r
+  EFI_PEI_PPI_DESCRIPTOR       PpiDescriptor;\r
+  UINT32                       UsbHostControllerBaseAddress;\r
+  VOID                         *MemPool;\r
+};\r
+\r
+#define PEI_RECOVERY_USB_OHC_DEV_FROM_EHCI_THIS(a)  CR (a, USB_OHCI_HC_DEV, UsbHostControllerPpi, USB_OHCI_HC_DEV_SIGNATURE)\r
+\r
+//\r
+// Func List\r
+//\r
+\r
+/**\r
+  Provides software reset for the USB host controller.\r
+\r
+  @param  PeiServices           The pointer of EFI_PEI_SERVICES.\r
+  @param  This                  The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r
+  @param  Attributes            A bit mask of the reset operation to perform.\r
+\r
+  @retval EFI_SUCCESS           The reset operation succeeded.\r
+  @retval EFI_INVALID_PARAMETER Attributes is not valid.\r
+  @retval EFI_UNSUPPOURTED      The type of reset specified by Attributes is\r
+                                not currently supported by the host controller.\r
+  @retval EFI_DEVICE_ERROR      Host controller isn't halted to reset.\r
+\r
+**/\r
+EFI_STATUS\r
+InitializeUsbHC (\r
+  IN EFI_PEI_SERVICES   **PeiServices,\r
+  IN USB_OHCI_HC_DEV    *Ohc,\r
+  IN UINT16             Attributes\r
+  );\r
+\r
+/**\r
+  Submits control transfer to a target USB device.\r
+\r
+  @param  PeiServices            The pointer of EFI_PEI_SERVICES.\r
+  @param  This                   The pointer of PEI_USB_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
+                                 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
+  @param  Data                   Data buffer to be transmitted or received from USB device.\r
+  @param  DataLength             The size (in bytes) of the data buffer.\r
+  @param  TimeOut                Indicates the maximum timeout, in millisecond.\r
+  @param  TransferResult         Return the result of this control transfer.\r
+\r
+  @retval EFI_SUCCESS            Transfer was completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES   The transfer failed due to lack of resources.\r
+  @retval EFI_INVALID_PARAMETER  Some parameters are invalid.\r
+  @retval EFI_TIMEOUT            Transfer failed due to timeout.\r
+  @retval EFI_DEVICE_ERROR       Transfer failed due to host controller or device error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+OhciControlTransfer (\r
+  IN  EFI_PEI_SERVICES                    **PeiServices,\r
+  IN  PEI_USB_HOST_CONTROLLER_PPI         *This,\r
+  IN  UINT8                               DeviceAddress,\r
+  IN  UINT8                               DeviceSpeed,\r
+  IN  UINT8                               MaxPacketLength,\r
+  IN  EFI_USB_DEVICE_REQUEST              *Request,\r
+  IN  EFI_USB_DATA_DIRECTION              TransferDirection,\r
+  IN  OUT VOID                            *Data,\r
+  IN  OUT UINTN                           *DataLength,\r
+  IN  UINTN                               TimeOut,\r
+  OUT UINT32                              *TransferResult\r
+  );\r
+/**\r
+  Submits bulk transfer to a bulk endpoint of a USB device.\r
+\r
+  @param  PeiServices           The pointer of EFI_PEI_SERVICES.\r
+  @param  This                  The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r
+  @param  DeviceAddress         Target device address.\r
+  @param  EndPointAddress       Endpoint number and its direction in bit 7.\r
+  @param  MaxiPacketLength      Maximum packet size the endpoint is capable of\r
+                                sending or receiving.\r
+  @param  Data                  A 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
+                                the subsequent bulk transfer.\r
+  @param  TimeOut               Indicates the maximum time, in millisecond, which the\r
+                                transfer is allowed to complete.\r
+  @param  TransferResult        A pointer to the detailed result information of the\r
+                                bulk transfer.\r
+\r
+  @retval EFI_SUCCESS           The transfer was completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  The transfer failed due to lack of resource.\r
+  @retval EFI_INVALID_PARAMETER Parameters are invalid.\r
+  @retval EFI_TIMEOUT           The transfer failed due to timeout.\r
+  @retval EFI_DEVICE_ERROR      The transfer failed due to host controller error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+OhciBulkTransfer (\r
+  IN EFI_PEI_SERVICES                     **PeiServices,\r
+  IN PEI_USB_HOST_CONTROLLER_PPI          *This,\r
+  IN  UINT8                               DeviceAddress,\r
+  IN  UINT8                               EndPointAddress,\r
+  IN  UINT8                               MaxPacketLength,\r
+  IN  OUT VOID                            *Data,\r
+  IN  OUT UINTN                           *DataLength,\r
+  IN  OUT UINT8                           *DataToggle,\r
+  IN  UINTN                               TimeOut,\r
+  OUT UINT32                              *TransferResult\r
+  );\r
+/**\r
+  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
+                                PEI_USB_HOST_CONTROLLER_PPI.\r
+  @param[out] NumOfPorts        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
+**/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+OhciGetRootHubNumOfPorts (\r
+  IN EFI_PEI_SERVICES                       **PeiServices,\r
+  IN PEI_USB_HOST_CONTROLLER_PPI           *This,\r
+  OUT UINT8                *NumOfPorts\r
+  );\r
+/**\r
+  Retrieves the current status of a USB root hub port.\r
+\r
+  @param  PeiServices            The pointer of EFI_PEI_SERVICES.\r
+  @param  This                   The pointer of PEI_USB_HOST_CONTROLLER_PPI.\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
+                                 by PortNumber was returned in PortStatus.\r
+  @retval EFI_INVALID_PARAMETER  PortNumber is invalid.\r
+\r
+**/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+OhciGetRootHubPortStatus (\r
+  IN  EFI_PEI_SERVICES             **PeiServices,\r
+  IN  PEI_USB_HOST_CONTROLLER_PPI  *This,\r
+  IN  UINT8                        PortNumber,\r
+  OUT EFI_USB_PORT_STATUS          *PortStatus\r
+  );\r
+/**\r
+\r
+  Sets a feature for the specified root hub port.\r
+\r
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL.\r
+  @param  PortNumber            Specifies the root hub port whose feature\r
+                                is requested to be set.\r
+  @param  PortFeature           Indicates the feature selector associated\r
+                                with the feature set request.\r
+\r
+  @retval EFI_SUCCESS           The feature specified by PortFeature was set for the\r
+                                USB root hub port specified by PortNumber.\r
+  @retval EFI_DEVICE_ERROR      Set feature failed because of hardware issue\r
+  @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+OhciSetRootHubPortFeature (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN PEI_USB_HOST_CONTROLLER_PPI  *This,\r
+  IN UINT8                        PortNumber,\r
+  IN EFI_USB_PORT_FEATURE         PortFeature\r
+  );\r
+/**\r
+  Clears a feature for the specified root hub port.\r
+\r
+  @param  PeiServices           The pointer of EFI_PEI_SERVICES.\r
+  @param  This                  The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r
+  @param  PortNumber            Specifies the root hub port whose feature\r
+                                is requested to be cleared.\r
+  @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
+                                 for the USB root hub port specified by PortNumber.\r
+  @retval EFI_INVALID_PARAMETER  PortNumber is invalid or PortFeature is invalid.\r
+\r
+**/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+OhciClearRootHubPortFeature (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN PEI_USB_HOST_CONTROLLER_PPI  *This,\r
+  IN UINT8                        PortNumber,\r
+  IN EFI_USB_PORT_FEATURE         PortFeature\r
+  );\r
+#endif\r