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