MdeModulePkg/AtaAtapiPassThru: Ensure GHC.AE bit is always set in Ahci
[mirror_edk2.git] / EmbeddedPkg / Include / Protocol / MmcHost.h
CommitLineData
1bfda055 1/** @file\r
2 Definition of the MMC Host Protocol\r
3\r
b4fdedc2 4 Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
3402aac7
RC
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. 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
1bfda055 13\r
14**/\r
15\r
16#ifndef __MMC_HOST_H__\r
17#define __MMC_HOST_H__\r
18\r
19///\r
20/// Global ID for the MMC Host Protocol\r
21///\r
22#define EFI_MMC_HOST_PROTOCOL_GUID \\r
23 { 0x3e591c00, 0x9e4a, 0x11df, {0x92, 0x44, 0x00, 0x02, 0xA5, 0xD5, 0xC5, 0x1B } }\r
24\r
25#define MMC_RESPONSE_TYPE_R1 0\r
26#define MMC_RESPONSE_TYPE_R1b 0\r
27#define MMC_RESPONSE_TYPE_R2 1\r
28#define MMC_RESPONSE_TYPE_R3 0\r
29#define MMC_RESPONSE_TYPE_R6 0\r
30#define MMC_RESPONSE_TYPE_R7 0\r
31#define MMC_RESPONSE_TYPE_OCR 0\r
32#define MMC_RESPONSE_TYPE_CID 1\r
33#define MMC_RESPONSE_TYPE_CSD 1\r
34#define MMC_RESPONSE_TYPE_RCA 0\r
35\r
36typedef UINT32 MMC_RESPONSE_TYPE;\r
37\r
38typedef UINT32 MMC_CMD;\r
39\r
40#define MMC_CMD_WAIT_RESPONSE (1 << 16)\r
41#define MMC_CMD_LONG_RESPONSE (1 << 17)\r
2b826e73 42#define MMC_CMD_NO_CRC_RESPONSE (1 << 18)\r
1bfda055 43\r
2b826e73 44#define MMC_INDX(Index) ((Index) & 0xFFFF)\r
45#define MMC_GET_INDX(MmcCmd) ((MmcCmd) & 0xFFFF)\r
1bfda055 46\r
2b826e73 47#define MMC_CMD0 (MMC_INDX(0) | MMC_CMD_NO_CRC_RESPONSE)\r
48#define MMC_CMD1 (MMC_INDX(1) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)\r
1bfda055 49#define MMC_CMD2 (MMC_INDX(2) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_LONG_RESPONSE)\r
50#define MMC_CMD3 (MMC_INDX(3) | MMC_CMD_WAIT_RESPONSE)\r
2b826e73 51#define MMC_CMD5 (MMC_INDX(5) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)\r
1bfda055 52#define MMC_CMD7 (MMC_INDX(7) | MMC_CMD_WAIT_RESPONSE)\r
53#define MMC_CMD8 (MMC_INDX(8) | MMC_CMD_WAIT_RESPONSE)\r
54#define MMC_CMD9 (MMC_INDX(9) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_LONG_RESPONSE)\r
55#define MMC_CMD11 (MMC_INDX(11) | MMC_CMD_WAIT_RESPONSE)\r
56#define MMC_CMD12 (MMC_INDX(12) | MMC_CMD_WAIT_RESPONSE)\r
57#define MMC_CMD13 (MMC_INDX(13) | MMC_CMD_WAIT_RESPONSE)\r
58#define MMC_CMD16 (MMC_INDX(16) | MMC_CMD_WAIT_RESPONSE)\r
59#define MMC_CMD17 (MMC_INDX(17) | MMC_CMD_WAIT_RESPONSE)\r
60#define MMC_CMD18 (MMC_INDX(18) | MMC_CMD_WAIT_RESPONSE)\r
61#define MMC_CMD20 (MMC_INDX(20) | MMC_CMD_WAIT_RESPONSE)\r
62#define MMC_CMD23 (MMC_INDX(23) | MMC_CMD_WAIT_RESPONSE)\r
63#define MMC_CMD24 (MMC_INDX(24) | MMC_CMD_WAIT_RESPONSE)\r
64#define MMC_CMD55 (MMC_INDX(55) | MMC_CMD_WAIT_RESPONSE)\r
2b826e73 65#define MMC_ACMD41 (MMC_INDX(41) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)\r
1bfda055 66\r
b4fdedc2
OM
67// Valid responses for CMD1 in eMMC\r
68#define EMMC_CMD1_CAPACITY_LESS_THAN_2GB 0x00FF8080 // Capacity <= 2GB, byte addressing used\r
69#define EMMC_CMD1_CAPACITY_GREATER_THAN_2GB 0x40FF8080 // Capacity > 2GB, 512-byte sector addressing used\r
70\r
1bfda055 71typedef enum _MMC_STATE {\r
72 MmcInvalidState = 0,\r
73 MmcHwInitializationState,\r
74 MmcIdleState,\r
75 MmcReadyState,\r
76 MmcIdentificationState,\r
77 MmcStandByState,\r
78 MmcTransferState,\r
79 MmcSendingDataState,\r
80 MmcReceiveDataState,\r
81 MmcProgrammingState,\r
82 MmcDisconnectState,\r
83} MMC_STATE;\r
84\r
16d88c2d 85///\r
86/// Forward declaration for EFI_MMC_HOST_PROTOCOL\r
87///\r
88typedef struct _EFI_MMC_HOST_PROTOCOL EFI_MMC_HOST_PROTOCOL;\r
89\r
90typedef BOOLEAN (EFIAPI *MMC_ISCARDPRESENT) (\r
91 IN EFI_MMC_HOST_PROTOCOL *This\r
92 );\r
93\r
94typedef BOOLEAN (EFIAPI *MMC_ISREADONLY) (\r
95 IN EFI_MMC_HOST_PROTOCOL *This\r
96 );\r
97\r
98typedef EFI_STATUS (EFIAPI *MMC_BUILDDEVICEPATH) (\r
99 IN EFI_MMC_HOST_PROTOCOL *This,\r
100 OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
101 );\r
102\r
103typedef EFI_STATUS (EFIAPI *MMC_NOTIFYSTATE) (\r
104 IN EFI_MMC_HOST_PROTOCOL *This,\r
105 IN MMC_STATE State\r
106 );\r
107\r
108typedef EFI_STATUS (EFIAPI *MMC_SENDCOMMAND) (\r
109 IN EFI_MMC_HOST_PROTOCOL *This,\r
110 IN MMC_CMD Cmd,\r
111 IN UINT32 Argument\r
112 );\r
113\r
114typedef EFI_STATUS (EFIAPI *MMC_RECEIVERESPONSE) (\r
115 IN EFI_MMC_HOST_PROTOCOL *This,\r
116 IN MMC_RESPONSE_TYPE Type,\r
117 IN UINT32 *Buffer\r
118 );\r
119\r
120typedef EFI_STATUS (EFIAPI *MMC_READBLOCKDATA) (\r
121 IN EFI_MMC_HOST_PROTOCOL *This,\r
122 IN EFI_LBA Lba,\r
123 IN UINTN Length,\r
124 OUT UINT32 *Buffer\r
125 );\r
126\r
127typedef EFI_STATUS (EFIAPI *MMC_WRITEBLOCKDATA) (\r
128 IN EFI_MMC_HOST_PROTOCOL *This,\r
129 IN EFI_LBA Lba,\r
130 IN UINTN Length,\r
131 IN UINT32 *Buffer\r
132 );\r
1bfda055 133\r
1bfda055 134\r
6b062a86 135struct _EFI_MMC_HOST_PROTOCOL {\r
1bfda055 136\r
16d88c2d 137 UINT32 Revision;\r
138 MMC_ISCARDPRESENT IsCardPresent;\r
139 MMC_ISREADONLY IsReadOnly;\r
140 MMC_BUILDDEVICEPATH BuildDevicePath;\r
1bfda055 141\r
16d88c2d 142 MMC_NOTIFYSTATE NotifyState;\r
1bfda055 143\r
16d88c2d 144 MMC_SENDCOMMAND SendCommand;\r
145 MMC_RECEIVERESPONSE ReceiveResponse;\r
1bfda055 146\r
16d88c2d 147 MMC_READBLOCKDATA ReadBlockData;\r
148 MMC_WRITEBLOCKDATA WriteBlockData;\r
1bfda055 149\r
6b062a86 150};\r
1bfda055 151\r
16d88c2d 152#define MMC_HOST_PROTOCOL_REVISION 0x00010001 // 1.1\r
153\r
1bfda055 154extern EFI_GUID gEfiMmcHostProtocolGuid;\r
155\r
156#endif\r
157\r