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