1/** @file
2
3  Copyright (c) 2015-2016, Linaro Limited. All rights reserved.
4
5  This program and the accompanying materials
6  are licensed and made available under the terms and conditions of the BSD License
7  which accompanies this distribution.  The full text of the license may be found at
8  http://opensource.org/licenses/bsd-license.php
9
10  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13**/
14
15#ifndef _DWUSBHOSTDXE_H_
16#define _DWUSBHOSTDXE_H_
17
18#include <Uefi.h>
19
20#include <Protocol/DwUsb.h>
21#include <Protocol/Usb2HostController.h>
22
23#include <Guid/EventGroup.h>
24
25#include <Library/DebugLib.h>
26#include <Library/BaseMemoryLib.h>
27#include <Library/UefiDriverEntryPoint.h>
28#include <Library/UefiBootServicesTableLib.h>
29#include <Library/UefiLib.h>
30#include <Library/BaseLib.h>
31#include <Library/MemoryAllocationLib.h>
32#include <Library/UncachedMemoryAllocationLib.h>
33#include <Library/PcdLib.h>
34#include <Library/ReportStatusCodeLib.h>
35#include <Library/DevicePathLib.h>
36#include <Library/PcdLib.h>
37#include <Library/IoLib.h>
38#include <Library/TimerLib.h>
39
40#define MAX_DEVICE                      16
41#define MAX_ENDPOINT                    16
42
43typedef struct _DWUSB_OTGHC_DEV DWUSB_OTGHC_DEV;
44
45#define DWUSB_OTGHC_DEV_SIGNATURE	SIGNATURE_32 ('d', 'w', 'h', 'c')
46#define DWHC_FROM_THIS(a)		CR(a, DWUSB_OTGHC_DEV, DwUsbOtgHc, DWUSB_OTGHC_DEV_SIGNATURE)
47
48//
49// The RequestType in EFI_USB_DEVICE_REQUEST is composed of
50// three fields: One bit direction, 2 bit type, and 5 bit
51// target.
52//
53#define USB_REQUEST_TYPE(Dir, Type, Target) \
54          ((UINT8)((((Dir) == EfiUsbDataIn ? 0x01 : 0) << 7) | (Type) | (Target)))
55
56typedef struct {
57	ACPI_HID_DEVICE_PATH		AcpiDevicePath;
58	PCI_DEVICE_PATH			PciDevicePath;
59	EFI_DEVICE_PATH_PROTOCOL	EndDevicePath;
60} EFI_USB_PCIIO_DEVICE_PATH;
61
62struct _DWUSB_OTGHC_DEV {
63	UINTN				Signature;
64	EFI_HANDLE			DeviceHandle;
65
66	EFI_USB2_HC_PROTOCOL		DwUsbOtgHc;
67
68	EFI_USB_HC_STATE		DwHcState;
69
70	EFI_USB_PCIIO_DEVICE_PATH	DevicePath;
71
72	EFI_EVENT			ExitBootServiceEvent;
73
74	UINT64				DwUsbBase;
75	UINT8				*StatusBuffer;
76	UINT8				*AlignedBuffer;
77
78	UINT16				PortStatus;
79	UINT16				PortChangeStatus;
80
81	UINT32				RhDevNum;
82};
83
84#endif //_DWUSBHOSTDXE_H_
85