]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h
MdeModulePkg: Add definition of the EDKII_UFS_HC_PLATFORM_PROTOCOL
[mirror_edk2.git] / MdeModulePkg / Include / Protocol / UfsHostControllerPlatform.h
1 /** @file
2 EDKII_UFS_HC_PLATFORM_PROTOCOL definition.
3
4 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef __EDKII_UFS_HC_PLATFORM_PROTOCOL_H__
10 #define __EDKII_UFS_HC_PLATFORM_PROTOCOL_H__
11
12 #include <Protocol/UfsHostController.h>
13
14 #define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 1
15
16 extern EFI_GUID gEdkiiUfsHcPlatformProtocolGuid;
17
18 typedef struct _EDKII_UFS_HC_PLATFORM_PROTOCOL EDKII_UFS_HC_PLATFORM_PROTOCOL;
19
20 typedef struct _EDKII_UFS_HC_DRIVER_INTERFACE EDKII_UFS_HC_DRIVER_INTERFACE;
21
22 typedef struct {
23 UINT32 Opcode;
24 UINT32 Arg1;
25 UINT32 Arg2;
26 UINT32 Arg3;
27 } EDKII_UIC_COMMAND;
28
29 /**
30 Execute UIC command
31
32 @param[in] This Pointer to driver interface produced by the UFS controller.
33 @param[in, out] UicCommand Descriptor of the command that will be executed.
34
35 @retval EFI_SUCCESS Command executed successfully.
36 @retval EFI_INVALID_PARAMETER This or UicCommand is NULL.
37 @retval Others Command failed to execute.
38 **/
39 typedef
40 EFI_STATUS
41 (EFIAPI *EDKII_UFS_EXEC_UIC_COMMAND) (
42 IN EDKII_UFS_HC_DRIVER_INTERFACE *This,
43 IN OUT EDKII_UIC_COMMAND *UicCommand
44 );
45
46 struct _EDKII_UFS_HC_DRIVER_INTERFACE {
47 ///
48 /// Protocol to accesss host controller MMIO and PCI registers.
49 ///
50 EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHcProtocol;
51 ///
52 /// Function implementing UIC command execution.
53 ///
54 EDKII_UFS_EXEC_UIC_COMMAND UfsExecUicCommand;
55 };
56
57 typedef struct {
58 UINT32 Capabilities;
59 UINT32 Version;
60 } EDKII_UFS_HC_INFO;
61
62 /**
63 Allows platform protocol to override host controller information
64
65 @param[in] ControllerHandle Handle of the UFS controller.
66 @param[in, out] HcInfo Pointer EDKII_UFS_HC_INFO associated with host controller.
67
68 @retval EFI_SUCCESS Function completed successfully.
69 @retval EFI_INVALID_PARAMETER HcInfo is NULL.
70 @retval Others Function failed to complete.
71 **/
72 typedef
73 EFI_STATUS
74 (EFIAPI *EDKII_UFS_HC_PLATFORM_OVERRIDE_HC_INFO) (
75 IN EFI_HANDLE ControllerHandle,
76 IN OUT EDKII_UFS_HC_INFO *HcInfo
77 );
78
79 typedef enum {
80 EdkiiUfsHcPreHce,
81 EdkiiUfsHcPostHce,
82 EdkiiUfsHcPreLinkStartup,
83 EdkiiUfsHcPostLinkStartup
84 } EDKII_UFS_HC_PLATFORM_CALLBACK_PHASE;
85
86 /**
87 Callback function for platform driver.
88
89 @param[in] ControllerHandle Handle of the UFS controller.
90 @param[in] CallbackPhase Specifies when the platform protocol is called
91 @param[in, out] CallbackData Data specific to the callback phase.
92 For PreHce and PostHce - EDKII_UFS_HC_DRIVER_INTERFACE.
93 For PreLinkStartup and PostLinkStartup - EDKII_UFS_HC_DRIVER_INTERFACE.
94
95 @retval EFI_SUCCESS Override function completed successfully.
96 @retval EFI_INVALID_PARAMETER CallbackPhase is invalid or CallbackData is NULL when phase expects valid data.
97 @retval Others Function failed to complete.
98 **/
99 typedef
100 EFI_STATUS
101 (EFIAPI *EDKII_UFS_HC_PLATFORM_CALLBACK) (
102 IN EFI_HANDLE ControllerHandle,
103 IN EDKII_UFS_HC_PLATFORM_CALLBACK_PHASE CallbackPhase,
104 IN OUT VOID *CallbackData
105 );
106
107 struct _EDKII_UFS_HC_PLATFORM_PROTOCOL {
108 ///
109 /// Version of the protocol.
110 ///
111 UINT32 Version;
112 ///
113 /// Allows platform driver to override host controller information.
114 ///
115 EDKII_UFS_HC_PLATFORM_OVERRIDE_HC_INFO OverrideHcInfo;
116 ///
117 /// Allows platform driver to implement platform specific flows
118 /// for host controller.
119 ///
120 EDKII_UFS_HC_PLATFORM_CALLBACK Callback;
121 };
122
123 #endif
124