ArmPkg: only attempt buildin MmCommunicationDxe for AArch64
[mirror_edk2.git] / EmbeddedPkg / Include / Protocol / EmbeddedGpio.h
CommitLineData
1e57a462 1/** @file\r
2\r
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
4\r
878b807a 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
1e57a462 6\r
7**/\r
8\r
9#ifndef __EMBEDDED_GPIO_H__\r
10#define __EMBEDDED_GPIO_H__\r
11\r
12//\r
13// Protocol interface structure\r
14//\r
15typedef struct _EMBEDDED_GPIO EMBEDDED_GPIO;\r
16\r
17//\r
18// Data Types\r
19//\r
20typedef UINTN EMBEDDED_GPIO_PIN;\r
21\r
22#define GPIO(Port, Pin) ((EMBEDDED_GPIO_PIN)(((Port) << (16)) | (Pin)))\r
23#define GPIO_PIN(x) ((EMBEDDED_GPIO_PIN)(x) & (0xFFFF))\r
24#define GPIO_PORT(x) ((EMBEDDED_GPIO_PIN)(x) >> (16))\r
25\r
26typedef enum {\r
27 GPIO_MODE_INPUT = 0x00,\r
28 GPIO_MODE_OUTPUT_0 = 0x0E,\r
29 GPIO_MODE_OUTPUT_1 = 0x0F,\r
30 GPIO_MODE_SPECIAL_FUNCTION_2 = 0x02,\r
31 GPIO_MODE_SPECIAL_FUNCTION_3 = 0x03,\r
32 GPIO_MODE_SPECIAL_FUNCTION_4 = 0x04,\r
33 GPIO_MODE_SPECIAL_FUNCTION_5 = 0x05,\r
34 GPIO_MODE_SPECIAL_FUNCTION_6 = 0x06,\r
35 GPIO_MODE_SPECIAL_FUNCTION_7 = 0x07\r
36} EMBEDDED_GPIO_MODE;\r
37\r
38typedef enum {\r
39 GPIO_PULL_NONE,\r
40 GPIO_PULL_UP,\r
41 GPIO_PULL_DOWN\r
42} EMBEDDED_GPIO_PULL;\r
43\r
44//\r
45// Function Prototypes\r
46//\r
47typedef\r
48EFI_STATUS\r
49(EFIAPI *EMBEDDED_GPIO_GET) (\r
50 IN EMBEDDED_GPIO *This,\r
51 IN EMBEDDED_GPIO_PIN Gpio,\r
52 OUT UINTN *Value\r
53 );\r
54/*++\r
55\r
56Routine Description:\r
57\r
58 Gets the state of a GPIO pin\r
59\r
60Arguments:\r
61\r
62 This - pointer to protocol\r
63 Gpio - which pin to read\r
64 Value - state of the pin\r
3402aac7 65\r
1e57a462 66Returns:\r
67\r
68 EFI_SUCCESS - GPIO state returned in Value\r
69\r
70--*/\r
71\r
72\r
73typedef\r
74EFI_STATUS\r
75(EFIAPI *EMBEDDED_GPIO_SET) (\r
76 IN EMBEDDED_GPIO *This,\r
77 IN EMBEDDED_GPIO_PIN Gpio,\r
78 IN EMBEDDED_GPIO_MODE Mode\r
79 );\r
80/*++\r
81\r
82Routine Description:\r
83\r
84 Sets the state of a GPIO pin\r
85\r
86Arguments:\r
87\r
88 This - pointer to protocol\r
89 Gpio - which pin to modify\r
90 Mode - mode to set\r
3402aac7 91\r
1e57a462 92Returns:\r
93\r
94 EFI_SUCCESS - GPIO set as requested\r
95\r
96--*/\r
97\r
98\r
99typedef\r
100EFI_STATUS\r
101(EFIAPI *EMBEDDED_GPIO_GET_MODE) (\r
102 IN EMBEDDED_GPIO *This,\r
103 IN EMBEDDED_GPIO_PIN Gpio,\r
104 OUT EMBEDDED_GPIO_MODE *Mode\r
105 );\r
106/*++\r
107\r
108Routine Description:\r
109\r
110 Gets the mode (function) of a GPIO pin\r
111\r
112Arguments:\r
113\r
114 This - pointer to protocol\r
115 Gpio - which pin\r
116 Mode - pointer to output mode value\r
3402aac7 117\r
1e57a462 118Returns:\r
119\r
120 EFI_SUCCESS - mode value retrieved\r
121\r
122--*/\r
123\r
124\r
125typedef\r
126EFI_STATUS\r
127(EFIAPI *EMBEDDED_GPIO_SET_PULL) (\r
128 IN EMBEDDED_GPIO *This,\r
129 IN EMBEDDED_GPIO_PIN Gpio,\r
130 IN EMBEDDED_GPIO_PULL Direction\r
131 );\r
132/*++\r
133\r
134Routine Description:\r
135\r
136 Sets the pull-up / pull-down resistor of a GPIO pin\r
137\r
138Arguments:\r
139\r
140 This - pointer to protocol\r
141 Gpio - which pin\r
142 Direction - pull-up, pull-down, or none\r
3402aac7 143\r
1e57a462 144Returns:\r
145\r
146 EFI_SUCCESS - pin was set\r
147\r
148--*/\r
149\r
150\r
151\r
152struct _EMBEDDED_GPIO {\r
153 EMBEDDED_GPIO_GET Get;\r
154 EMBEDDED_GPIO_SET Set;\r
155 EMBEDDED_GPIO_GET_MODE GetMode;\r
156 EMBEDDED_GPIO_SET_PULL SetPull;\r
157};\r
158\r
159extern EFI_GUID gEmbeddedGpioProtocolGuid;\r
160\r
78741ce9
HZ
161typedef struct _GPIO_CONTROLLER GPIO_CONTROLLER;\r
162typedef struct _PLATFORM_GPIO_CONTROLLER PLATFORM_GPIO_CONTROLLER;\r
163\r
164struct _GPIO_CONTROLLER {\r
165 UINTN RegisterBase;\r
166 UINTN GpioIndex;\r
167 UINTN InternalGpioCount;\r
168};\r
169\r
170struct _PLATFORM_GPIO_CONTROLLER {\r
171 UINTN GpioCount;\r
172 UINTN GpioControllerCount;\r
173 GPIO_CONTROLLER *GpioController;\r
174};\r
175\r
176extern EFI_GUID gPlatformGpioProtocolGuid;\r
177\r
3402aac7 178#endif\r