]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Protocol/UfsHostController.h
MdeModulePkg/S3SmmInitDone.h: Fix copyright coding style error.
[mirror_edk2.git] / MdeModulePkg / Include / Protocol / UfsHostController.h
CommitLineData
0591696e
FT
1/** @file\r
2\r
3 EDKII Universal Flash Storage Host Controller Protocol.\r
4\r
d1102dba
LG
5Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
6This program and the accompanying materials are licensed and made available under\r
7the terms and conditions of the BSD License that accompanies this distribution.\r
0591696e 8The full text of the license may be found at\r
d1102dba 9http://opensource.org/licenses/bsd-license.php.\r
0591696e 10\r
d1102dba 11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
0591696e
FT
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16\r
17#ifndef __EDKII_UFS_HC_PROTOCOL_H__\r
18#define __EDKII_UFS_HC_PROTOCOL_H__\r
19\r
20//\r
21// UFS Host Controller Protocol GUID value\r
22//\r
23#define EDKII_UFS_HOST_CONTROLLER_PROTOCOL_GUID \\r
24 { \\r
25 0xebc01af5, 0x7a9, 0x489e, { 0xb7, 0xce, 0xdc, 0x8, 0x9e, 0x45, 0x9b, 0x2f } \\r
26 }\r
27\r
28//\r
29// Forward reference for pure ANSI compatability\r
30//\r
31typedef struct _EDKII_UFS_HOST_CONTROLLER_PROTOCOL EDKII_UFS_HOST_CONTROLLER_PROTOCOL;\r
32\r
33\r
34/**\r
35 Get the MMIO base address of UFS host controller.\r
36\r
37 @param This The protocol instance pointer.\r
38 @param MmioBar Pointer to the UFS host controller MMIO base address.\r
39\r
40 @retval EFI_SUCCESS The operation succeeds.\r
41 @retval EFI_INVALID_PARAMETER The parameters are invalid.\r
42\r
43**/\r
44typedef\r
45EFI_STATUS\r
46(EFIAPI *EDKII_UFS_HC_GET_MMIO_BAR)(\r
47 IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This,\r
48 OUT UINTN *MmioBar\r
49 );\r
50\r
51///\r
52/// *******************************************************\r
53/// EFI_UFS_HOST_CONTROLLER_OPERATION\r
54/// *******************************************************\r
55///\r
56typedef enum {\r
57 ///\r
58 /// A read operation from system memory by a bus master.\r
59 ///\r
60 EdkiiUfsHcOperationBusMasterRead,\r
61 ///\r
62 /// A write operation from system memory by a bus master.\r
63 ///\r
64 EdkiiUfsHcOperationBusMasterWrite,\r
65 ///\r
66 /// Provides both read and write access to system memory by both the processor and a\r
67 /// bus master. The buffer is coherent from both the processor's and the bus master's point of view.\r
68 ///\r
69 EdkiiUfsHcOperationBusMasterCommonBuffer,\r
70 EdkiiUfsHcOperationMaximum\r
71} EDKII_UFS_HOST_CONTROLLER_OPERATION;\r
72\r
d1102dba 73/**\r
0591696e 74 Provides the UFS controller-specific addresses needed to access system memory.\r
d1102dba 75\r
0591696e
FT
76 @param This A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance.\r
77 @param Operation Indicates if the bus master is going to read or write to system memory.\r
78 @param HostAddress The system memory address to map to the UFS controller.\r
79 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes\r
d1102dba 80 that were mapped.\r
0591696e 81 @param DeviceAddress The resulting map address for the bus master UFS controller to use to\r
d1102dba 82 access the hosts HostAddress.\r
0591696e 83 @param Mapping A resulting value to pass to Unmap().\r
d1102dba 84\r
0591696e 85 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.\r
d1102dba 86 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.\r
0591696e
FT
87 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
88 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
89 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.\r
d1102dba 90\r
0591696e
FT
91**/\r
92typedef\r
93EFI_STATUS\r
94(EFIAPI *EDKII_UFS_HC_MAP)(\r
95 IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This,\r
96 IN EDKII_UFS_HOST_CONTROLLER_OPERATION Operation,\r
97 IN VOID *HostAddress,\r
98 IN OUT UINTN *NumberOfBytes,\r
99 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r
100 OUT VOID **Mapping\r
101 );\r
102\r
d1102dba 103/**\r
0591696e 104 Completes the Map() operation and releases any corresponding resources.\r
d1102dba
LG
105\r
106 @param This A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance.\r
0591696e 107 @param Mapping The mapping value returned from Map().\r
d1102dba 108\r
0591696e
FT
109 @retval EFI_SUCCESS The range was unmapped.\r
110 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.\r
d1102dba 111\r
0591696e
FT
112**/\r
113typedef\r
114EFI_STATUS\r
115(EFIAPI *EDKII_UFS_HC_UNMAP)(\r
116 IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This,\r
117 IN VOID *Mapping\r
118 );\r
119\r
d1102dba 120/**\r
0591696e 121 Allocates pages that are suitable for an EfiUfsHcOperationBusMasterCommonBuffer\r
d1102dba
LG
122 mapping.\r
123\r
0591696e
FT
124 @param This A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance.\r
125 @param Type This parameter is not used and must be ignored.\r
126 @param MemoryType The type of memory to allocate, EfiBootServicesData or\r
d1102dba
LG
127 EfiRuntimeServicesData.\r
128 @param Pages The number of pages to allocate.\r
0591696e 129 @param HostAddress A pointer to store the base system memory address of the\r
d1102dba 130 allocated range.\r
0591696e 131 @param Attributes The requested bit mask of attributes for the allocated range.\r
d1102dba 132\r
0591696e
FT
133 @retval EFI_SUCCESS The requested memory pages were allocated.\r
134 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are\r
d1102dba 135 MEMORY_WRITE_COMBINE and MEMORY_CACHED.\r
0591696e 136 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
d1102dba
LG
137 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.\r
138\r
0591696e
FT
139**/\r
140typedef\r
141EFI_STATUS\r
142(EFIAPI *EDKII_UFS_HC_ALLOCATE_BUFFER)(\r
143 IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This,\r
144 IN EFI_ALLOCATE_TYPE Type,\r
145 IN EFI_MEMORY_TYPE MemoryType,\r
146 IN UINTN Pages,\r
147 OUT VOID **HostAddress,\r
148 IN UINT64 Attributes\r
149 );\r
150\r
d1102dba 151/**\r
0591696e 152 Frees memory that was allocated with AllocateBuffer().\r
d1102dba
LG
153\r
154 @param This A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance.\r
155 @param Pages The number of pages to free.\r
156 @param HostAddress The base system memory address of the allocated range.\r
157\r
0591696e
FT
158 @retval EFI_SUCCESS The requested memory pages were freed.\r
159 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages\r
160 was not allocated with AllocateBuffer().\r
d1102dba 161\r
0591696e
FT
162**/\r
163typedef\r
164EFI_STATUS\r
165(EFIAPI *EDKII_UFS_HC_FREE_BUFFER)(\r
166 IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This,\r
167 IN UINTN Pages,\r
168 IN VOID *HostAddress\r
169 );\r
170\r
d1102dba 171/**\r
0591696e 172 Flushes all posted write transactions from the UFS bus to attached UFS device.\r
d1102dba
LG
173\r
174 @param This A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance.\r
175\r
0591696e 176 @retval EFI_SUCCESS The posted write transactions were flushed from the UFS bus\r
d1102dba 177 to attached UFS device.\r
0591696e 178 @retval EFI_DEVICE_ERROR The posted write transactions were not flushed from the UFS\r
d1102dba
LG
179 bus to attached UFS device due to a hardware error.\r
180\r
0591696e
FT
181**/\r
182typedef\r
183EFI_STATUS\r
184(EFIAPI *EDKII_UFS_HC_FLUSH)(\r
185 IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This\r
186 );\r
187\r
095f0779
FT
188typedef enum {\r
189 EfiUfsHcWidthUint8 = 0,\r
190 EfiUfsHcWidthUint16,\r
191 EfiUfsHcWidthUint32,\r
192 EfiUfsHcWidthUint64,\r
193 EfiUfsHcWidthMaximum\r
194} EDKII_UFS_HOST_CONTROLLER_PROTOCOL_WIDTH;\r
195\r
196/**\r
197 Enable a UFS bus driver to access UFS MMIO registers in the UFS Host Controller memory space.\r
198\r
199 @param This A pointer to the EDKII_UFS_HOST_CONTROLLER_PROTOCOL instance.\r
200 @param Width Signifies the width of the memory operations.\r
201 @param Offset The offset within the UFS Host Controller MMIO space to start the\r
202 memory operation.\r
203 @param Count The number of memory operations to perform.\r
204 @param Buffer For read operations, the destination buffer to store the results.\r
205 For write operations, the source buffer to write data from.\r
206\r
207 @retval EFI_SUCCESS The data was read from or written to the UFS host controller.\r
208 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not\r
209 valid for the UFS Host Controller memory space.\r
210 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
211 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
212\r
213**/\r
214typedef\r
215EFI_STATUS\r
216(EFIAPI *EDKII_UFS_HC_MMIO_READ_WRITE)(\r
217 IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This,\r
218 IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL_WIDTH Width,\r
219 IN UINT64 Offset,\r
220 IN UINTN Count,\r
221 IN OUT VOID *Buffer\r
222 );\r
223\r
0591696e
FT
224///\r
225/// UFS Host Controller Protocol structure.\r
226///\r
227struct _EDKII_UFS_HOST_CONTROLLER_PROTOCOL {\r
228 EDKII_UFS_HC_GET_MMIO_BAR GetUfsHcMmioBar;\r
229 EDKII_UFS_HC_ALLOCATE_BUFFER AllocateBuffer;\r
230 EDKII_UFS_HC_FREE_BUFFER FreeBuffer;\r
231 EDKII_UFS_HC_MAP Map;\r
232 EDKII_UFS_HC_UNMAP Unmap;\r
233 EDKII_UFS_HC_FLUSH Flush;\r
095f0779
FT
234 EDKII_UFS_HC_MMIO_READ_WRITE Read;\r
235 EDKII_UFS_HC_MMIO_READ_WRITE Write;\r
0591696e
FT
236};\r
237\r
238///\r
239/// UFS Host Controller Protocol GUID variable.\r
240///\r
241extern EFI_GUID gEdkiiUfsHostControllerProtocolGuid;\r
242\r
243#endif\r