]>
Commit | Line | Data |
---|---|---|
0591696e FT |
1 | /** @file\r |
2 | \r | |
3 | EDKII Universal Flash Storage Host Controller Protocol.\r | |
4 | \r | |
095f0779 | 5 | Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r |
0591696e FT |
6 | This program and the accompanying materials are licensed and made available under \r |
7 | the terms and conditions of the BSD License that accompanies this distribution. \r | |
8 | The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php. \r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
12 | WITHOUT 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 | |
31 | typedef 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 | |
44 | typedef\r | |
45 | EFI_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 | |
56 | typedef 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 | |
73 | /** \r | |
74 | Provides the UFS controller-specific addresses needed to access system memory.\r | |
75 | \r | |
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 | |
80 | that were mapped. \r | |
81 | @param DeviceAddress The resulting map address for the bus master UFS controller to use to\r | |
82 | access the hosts HostAddress. \r | |
83 | @param Mapping A resulting value to pass to Unmap().\r | |
84 | \r | |
85 | @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.\r | |
86 | @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer. \r | |
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 | |
90 | \r | |
91 | **/\r | |
92 | typedef\r | |
93 | EFI_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 | |
103 | /** \r | |
104 | Completes the Map() operation and releases any corresponding resources.\r | |
105 | \r | |
106 | @param This A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance. \r | |
107 | @param Mapping The mapping value returned from Map().\r | |
108 | \r | |
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 | |
111 | \r | |
112 | **/\r | |
113 | typedef\r | |
114 | EFI_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 | |
120 | /** \r | |
121 | Allocates pages that are suitable for an EfiUfsHcOperationBusMasterCommonBuffer\r | |
122 | mapping. \r | |
123 | \r | |
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 | |
127 | EfiRuntimeServicesData. \r | |
128 | @param Pages The number of pages to allocate. \r | |
129 | @param HostAddress A pointer to store the base system memory address of the\r | |
130 | allocated range. \r | |
131 | @param Attributes The requested bit mask of attributes for the allocated range.\r | |
132 | \r | |
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 | |
135 | MEMORY_WRITE_COMBINE and MEMORY_CACHED. \r | |
136 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
137 | @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated. \r | |
138 | \r | |
139 | **/\r | |
140 | typedef\r | |
141 | EFI_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 | |
151 | /** \r | |
152 | Frees memory that was allocated with AllocateBuffer().\r | |
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 | |
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 | |
161 | \r | |
162 | **/\r | |
163 | typedef\r | |
164 | EFI_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 | |
171 | /** \r | |
172 | Flushes all posted write transactions from the UFS bus to attached UFS device.\r | |
173 | \r | |
174 | @param This A pointer to the EFI_UFS_HOST_CONTROLLER_PROTOCOL instance. \r | |
175 | \r | |
176 | @retval EFI_SUCCESS The posted write transactions were flushed from the UFS bus\r | |
177 | to attached UFS device. \r | |
178 | @retval EFI_DEVICE_ERROR The posted write transactions were not flushed from the UFS\r | |
179 | bus to attached UFS device due to a hardware error. \r | |
180 | \r | |
181 | **/\r | |
182 | typedef\r | |
183 | EFI_STATUS\r | |
184 | (EFIAPI *EDKII_UFS_HC_FLUSH)(\r | |
185 | IN EDKII_UFS_HOST_CONTROLLER_PROTOCOL *This\r | |
186 | );\r | |
187 | \r | |
095f0779 FT |
188 | typedef 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 | |
214 | typedef\r | |
215 | EFI_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 | |
227 | struct _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 | |
241 | extern EFI_GUID gEdkiiUfsHostControllerProtocolGuid;\r | |
242 | \r | |
243 | #endif\r |