summaryrefslogtreecommitdiff
path: root/Platform/BroxtonPlatformPkg/Common/Features/UsbDeviceDxe/UsbFuncIo.h
blob: 711be0772f609dc3e5b1a209a5aacde38f3d6cc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/** @file
  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>

  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php.

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#ifndef __EFI_USB_FUNCTION_IO_INTERFACE_H__
#define __EFI_USB_FUNCTION_IO_INTERFACE_H__

#include <Uefi.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h>
#include <Library/DriverLib.h>
#include <Library/PcdLib.h>
#include <Protocol/EfiUsbFnIo.h>
#include <Library/PmicLib.h>
#include <Library/UsbDeviceLib.h>
#include <Library/PrintLib.h>
#include "UsbIoNode.h"
#include "XdciDWC.h"
#include "UsbDeviceMode.h"

//
// Debug message setting
//
#define USB_FUIO_DEBUG_INFO              EFI_D_INFO
#define USB_FUIO_DEBUG_LOAD              EFI_D_LOAD
#define USB_FUIO_DEBUG_ERROR             EFI_D_ERROR
#define USB_FUIO_DEBUG_EVENT_I           0 //DEBUG_INIT
#define USB_FUIO_DEBUG_EVENT_D           EFI_D_ERROR
#define USB_FUIO_DEBUG_EVENT_NOTREADY_D  EFI_D_ERROR
#define USB_FUIO_DEBUG_EVENT_NOTREADY_I  0 //DEBUG_INIT

#define MAX_TRANSFER_PACKET     (8 * 1024 * 1024)

#define USBFU_VID     0x8086
#define USBFU_PID     0x0A65

#pragma pack(1)
typedef struct {
  UINT8                     ProgInterface;
  UINT8                     SubClassCode;
  UINT8                     BaseCode;
} USB_CLASSC;

//
// Event Buffer Struct
//
typedef struct  {
  UINT32 Event;
  UINT32 DevTstLmp1;
  UINT32 DevTstLmp2;
  UINT32 Reserved;
} USBD_EVENT_BUF;

typedef struct  {
  UINT32                        EpNum;
  EFI_USBFN_ENDPOINT_DIRECTION  Direction;
  UINTN                         XferAddress;
  UINT32                        XferLength;
  UINT8                         LogEpNum;
  BOOLEAN                       Complete;
  BOOLEAN                       ZlpFlag;
} USBD_EP_XFER_REC;

#pragma pack()

EFI_STATUS
UsbFnInitDevice (
  IN EFI_USBFN_IO_PROTOCOL        *This
  );

EFI_STATUS
UsbFnDeInitDevice (
  IN EFI_USBFN_IO_PROTOCOL        *This
  );

EFI_STATUS
EFIAPI
DetectPort (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  OUT EFI_USBFN_PORT_TYPE          *PortType
  );

EFI_STATUS
EFIAPI
AllocateTransferBuffer (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  IN UINTN                         Size,
  OUT VOID                         **Buffer
  );

EFI_STATUS
EFIAPI
FreeTransferBuffer (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  IN VOID                          *Buffer
  );

EFI_STATUS
EFIAPI
ConfigureEnableEndpoints (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  IN EFI_USB_DEVICE_INFO           *DeviceInfo
 );

EFI_STATUS
EFIAPI
GetEndpointMaxPacketSize (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  IN EFI_USB_ENDPOINT_TYPE         EndpointType,
  IN EFI_USB_BUS_SPEED             BusSpeed,
  OUT UINT16                       *MaxPacketSize
 );

EFI_STATUS
EFIAPI
GetMaxTransferSize (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  OUT UINTN                        *MaxTransferSize
  );

EFI_STATUS
EFIAPI
GetDeviceInfo (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  IN EFI_USBFN_DEVICE_INFO_ID      Id,
  IN OUT UINTN                     *BufferSize,
  OUT VOID                         *Buffer OPTIONAL
  );

EFI_STATUS
EFIAPI
GetVendorIdProductId (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  OUT UINT16                       *Vid,
  OUT UINT16                       *Pid
  );

EFI_STATUS
EFIAPI
AbortTransfer (
  IN EFI_USBFN_IO_PROTOCOL        *This,
  IN UINT8                        EndpointIndex,
  IN EFI_USBFN_ENDPOINT_DIRECTION Direction
  );

EFI_STATUS
EFIAPI
GetEndpointStallState (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  IN UINT8                         EndpointIndex,
  IN EFI_USBFN_ENDPOINT_DIRECTION  Direction,
  IN OUT BOOLEAN                   *State
  );

EFI_STATUS
EFIAPI
SetEndpointStallState (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  IN UINT8                         EndpointIndex,
  IN EFI_USBFN_ENDPOINT_DIRECTION  Direction,
  IN BOOLEAN                       State
  );

EFI_STATUS
EFIAPI
EventHandler (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  OUT EFI_USBFN_MESSAGE            *Message,
  IN OUT UINTN                     *PayloadSize,
  OUT EFI_USBFN_MESSAGE_PAYLOAD    *Payload
  );

EFI_STATUS
EFIAPI
Transfer (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  IN UINT8                         EndpointIndex,
  IN EFI_USBFN_ENDPOINT_DIRECTION  Direction,
  IN OUT UINTN                     *BufferSize,
  IN OUT VOID                      *Buffer
  );

EFI_STATUS
EFIAPI
StartController (
  IN EFI_USBFN_IO_PROTOCOL         *This
  );

EFI_STATUS
EFIAPI
StopController (
  IN EFI_USBFN_IO_PROTOCOL         *This
  );

EFI_STATUS
EFIAPI
SetEndpointPolicy (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  IN UINT8                         EndpointIndex,
  IN EFI_USBFN_ENDPOINT_DIRECTION  Direction,
  IN EFI_USBFN_POLICY_TYPE         PolicyType,
  IN UINTN                         BufferSize,
  IN VOID                          *Buffer
  );

EFI_STATUS
EFIAPI
GetEndpointPolicy (
  IN EFI_USBFN_IO_PROTOCOL         *This,
  IN UINT8                         EndpointIndex,
  IN EFI_USBFN_ENDPOINT_DIRECTION  Direction,
  IN EFI_USBFN_POLICY_TYPE         PolicyType,
  IN OUT UINTN                     *BufferSize,
  IN OUT VOID                      *Buffer
  );

VOID
UsbFnSetEpInfo (
  IN USB_EP_INFO                 *EpDest,
  IN USB_DEVICE_ENDPOINT_INFO    *EpSrc
  );

extern EFI_USBFN_IO_PROTOCOL         mUsbFunIoProtocol;
#endif