ArmPkg: only attempt buildin MmCommunicationDxe for AArch64
[mirror_edk2.git] / EmbeddedPkg / Include / Ppi / EmbeddedGpio.h
CommitLineData
b1832e16
AB
1/** @file\r
2\r
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
4 Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>\r
5\r
878b807a 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
b1832e16
AB
7\r
8**/\r
9\r
10#ifndef __EMBEDDED_GPIO_PPI_H__\r
11#define __EMBEDDED_GPIO_PPI_H__\r
12\r
13//\r
14// Protocol interface structure\r
15//\r
16typedef struct _EMBEDDED_GPIO_PPI EMBEDDED_GPIO_PPI;\r
17\r
18//\r
19// Data Types\r
20//\r
21typedef UINTN EMBEDDED_GPIO_PIN;\r
22\r
23#define GPIO(Port, Pin) ((EMBEDDED_GPIO_PIN)(((Port) << (16)) | (Pin)))\r
24#define GPIO_PIN(x) ((EMBEDDED_GPIO_PIN)(x) & (0xFFFF))\r
25#define GPIO_PORT(x) ((EMBEDDED_GPIO_PIN)(x) >> (16))\r
26\r
27typedef enum {\r
28 GPIO_MODE_INPUT = 0x00,\r
29 GPIO_MODE_OUTPUT_0 = 0x0E,\r
30 GPIO_MODE_OUTPUT_1 = 0x0F,\r
31 GPIO_MODE_SPECIAL_FUNCTION_2 = 0x02,\r
32 GPIO_MODE_SPECIAL_FUNCTION_3 = 0x03,\r
33 GPIO_MODE_SPECIAL_FUNCTION_4 = 0x04,\r
34 GPIO_MODE_SPECIAL_FUNCTION_5 = 0x05,\r
35 GPIO_MODE_SPECIAL_FUNCTION_6 = 0x06,\r
36 GPIO_MODE_SPECIAL_FUNCTION_7 = 0x07\r
37} EMBEDDED_GPIO_MODE;\r
38\r
39typedef enum {\r
40 GPIO_PULL_NONE,\r
41 GPIO_PULL_UP,\r
42 GPIO_PULL_DOWN\r
43} EMBEDDED_GPIO_PULL;\r
44\r
45//\r
46// Function Prototypes\r
47//\r
48\r
49/**\r
50\r
51 Gets the state of a GPIO pin\r
52\r
53 @param This Pointer to protocol\r
54 @param Gpio Which pin to read\r
55 @param Value State of the pin\r
56\r
57 @retval EFI_SUCCESS GPIO state returned in Value\r
58 @retval EFI_INVALID_PARAMETER Value is NULL\r
59 @retval EFI_NOT_FOUND Pin does not exit\r
60\r
61**/\r
62typedef\r
63EFI_STATUS\r
64(EFIAPI *EMBEDDED_GPIO_GET) (\r
65 IN EMBEDDED_GPIO_PPI *This,\r
66 IN EMBEDDED_GPIO_PIN Gpio,\r
67 OUT UINTN *Value\r
68 );\r
69\r
70/**\r
71\r
72 Sets the state of a GPIO pin\r
73\r
74 @param This Pointer to protocol\r
75 @param Gpio Which pin to modify\r
76 @param Mode Mode to set\r
77\r
78 @retval EFI_SUCCESS GPIO set as requested\r
79 @retval EFI_INVALID_PARAMETER Invalid mode\r
80 @retval EFI_NOT_FOUND Pin does not exit\r
81\r
82**/\r
83typedef\r
84EFI_STATUS\r
85(EFIAPI *EMBEDDED_GPIO_SET) (\r
86 IN EMBEDDED_GPIO_PPI *This,\r
87 IN EMBEDDED_GPIO_PIN Gpio,\r
88 IN EMBEDDED_GPIO_MODE Mode\r
89 );\r
90\r
91\r
92/**\r
93\r
94 Gets the mode (function) of a GPIO pin\r
95\r
96 @param This Pointer to protocol\r
97 @param Gpio Which pin\r
98 @param Mode Pointer to output mode value\r
99\r
100 @retval EFI_SUCCESS Mode value retrieved\r
101 @retval EFI_INVALID_PARAMETER Mode is NULL\r
102 @retval EFI_NOT_FOUND Pin does not exit\r
103\r
104**/\r
105typedef\r
106EFI_STATUS\r
107(EFIAPI *EMBEDDED_GPIO_GET_MODE) (\r
108 IN EMBEDDED_GPIO_PPI *This,\r
109 IN EMBEDDED_GPIO_PIN Gpio,\r
110 OUT EMBEDDED_GPIO_MODE *Mode\r
111 );\r
112\r
113\r
114/**\r
115\r
116 Sets the pull-up / pull-down resistor of a GPIO pin\r
117\r
118 @param This Pointer to PPI\r
119 @param Gpio Port/pin index\r
120 @param Pull The pullup/pulldown mode to set\r
121\r
122 @retval EFI_SUCCESS Mode was set\r
123 @retval EFI_NOT_FOUND Pin does not exist\r
124 @retval EFI_UNSUPPORTED Action not supported\r
125\r
126**/\r
127typedef\r
128EFI_STATUS\r
129(EFIAPI *EMBEDDED_GPIO_SET_PULL) (\r
130 IN EMBEDDED_GPIO_PPI *This,\r
131 IN EMBEDDED_GPIO_PIN Gpio,\r
132 IN EMBEDDED_GPIO_PULL Direction\r
133 );\r
134\r
135\r
136struct _EMBEDDED_GPIO_PPI {\r
137 EMBEDDED_GPIO_GET Get;\r
138 EMBEDDED_GPIO_SET Set;\r
139 EMBEDDED_GPIO_GET_MODE GetMode;\r
140 EMBEDDED_GPIO_SET_PULL SetPull;\r
141};\r
142\r
143extern EFI_GUID gEmbeddedGpioPpiGuid;\r
144\r
145#endif\r