TianoCore EDK2 master
Loading...
Searching...
No Matches
EmbeddedGpio.h
Go to the documentation of this file.
1
9#ifndef __EMBEDDED_GPIO_H__
10#define __EMBEDDED_GPIO_H__
11
12//
13// Protocol interface structure
14//
15typedef struct _EMBEDDED_GPIO EMBEDDED_GPIO;
16
17//
18// Data Types
19//
20typedef UINTN EMBEDDED_GPIO_PIN;
21
22#define GPIO(Port, Pin) ((EMBEDDED_GPIO_PIN)(((Port) << (16)) | (Pin)))
23#define GPIO_PIN(x) ((EMBEDDED_GPIO_PIN)(x) & (0xFFFF))
24#define GPIO_PORT(x) ((EMBEDDED_GPIO_PIN)(x) >> (16))
25
26typedef enum {
27 GPIO_MODE_INPUT = 0x00,
28 GPIO_MODE_OUTPUT_0 = 0x0E,
29 GPIO_MODE_OUTPUT_1 = 0x0F,
30 GPIO_MODE_SPECIAL_FUNCTION_2 = 0x02,
31 GPIO_MODE_SPECIAL_FUNCTION_3 = 0x03,
32 GPIO_MODE_SPECIAL_FUNCTION_4 = 0x04,
33 GPIO_MODE_SPECIAL_FUNCTION_5 = 0x05,
34 GPIO_MODE_SPECIAL_FUNCTION_6 = 0x06,
35 GPIO_MODE_SPECIAL_FUNCTION_7 = 0x07
36} EMBEDDED_GPIO_MODE;
37
38typedef enum {
39 GPIO_PULL_NONE,
40 GPIO_PULL_UP,
41 GPIO_PULL_DOWN
42} EMBEDDED_GPIO_PULL;
43
44//
45// Function Prototypes
46//
47typedef
49(EFIAPI *EMBEDDED_GPIO_GET)(
50 IN EMBEDDED_GPIO *This,
51 IN EMBEDDED_GPIO_PIN Gpio,
52 OUT UINTN *Value
53 );
54
55/*++
56
57Routine Description:
58
59 Gets the state of a GPIO pin
60
61Arguments:
62
63 This - pointer to protocol
64 Gpio - which pin to read
65 Value - state of the pin
66
67Returns:
68
69 EFI_SUCCESS - GPIO state returned in Value
70
71--*/
72
73typedef
75(EFIAPI *EMBEDDED_GPIO_SET)(
76 IN EMBEDDED_GPIO *This,
77 IN EMBEDDED_GPIO_PIN Gpio,
78 IN EMBEDDED_GPIO_MODE Mode
79 );
80
81/*++
82
83Routine Description:
84
85 Sets the state of a GPIO pin
86
87Arguments:
88
89 This - pointer to protocol
90 Gpio - which pin to modify
91 Mode - mode to set
92
93Returns:
94
95 EFI_SUCCESS - GPIO set as requested
96
97--*/
98
99typedef
101(EFIAPI *EMBEDDED_GPIO_GET_MODE)(
102 IN EMBEDDED_GPIO *This,
103 IN EMBEDDED_GPIO_PIN Gpio,
104 OUT EMBEDDED_GPIO_MODE *Mode
105 );
106
107/*++
108
109Routine Description:
110
111 Gets the mode (function) of a GPIO pin
112
113Arguments:
114
115 This - pointer to protocol
116 Gpio - which pin
117 Mode - pointer to output mode value
118
119Returns:
120
121 EFI_SUCCESS - mode value retrieved
122
123--*/
124
125typedef
127(EFIAPI *EMBEDDED_GPIO_SET_PULL)(
128 IN EMBEDDED_GPIO *This,
129 IN EMBEDDED_GPIO_PIN Gpio,
130 IN EMBEDDED_GPIO_PULL Direction
131 );
132
133/*++
134
135Routine Description:
136
137 Sets the pull-up / pull-down resistor of a GPIO pin
138
139Arguments:
140
141 This - pointer to protocol
142 Gpio - which pin
143 Direction - pull-up, pull-down, or none
144
145Returns:
146
147 EFI_SUCCESS - pin was set
148
149--*/
150
156};
157
158extern EFI_GUID gEmbeddedGpioProtocolGuid;
159
160typedef struct _GPIO_CONTROLLER GPIO_CONTROLLER;
162
164 UINTN RegisterBase;
165 UINTN GpioIndex;
166 UINTN InternalGpioCount;
167};
168
170 UINTN GpioCount;
171 UINTN GpioControllerCount;
172 GPIO_CONTROLLER *GpioController;
173};
174
175extern EFI_GUID gPlatformGpioProtocolGuid;
176
177#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS(EFIAPI * EMBEDDED_GPIO_GET)(IN EMBEDDED_GPIO_PPI *This, IN EMBEDDED_GPIO_PIN Gpio, OUT UINTN *Value)
Definition: EmbeddedGpio.h:64
EFI_STATUS(EFIAPI * EMBEDDED_GPIO_GET_MODE)(IN EMBEDDED_GPIO_PPI *This, IN EMBEDDED_GPIO_PIN Gpio, OUT EMBEDDED_GPIO_MODE *Mode)
Definition: EmbeddedGpio.h:106
EFI_STATUS(EFIAPI * EMBEDDED_GPIO_SET_PULL)(IN EMBEDDED_GPIO_PPI *This, IN EMBEDDED_GPIO_PIN Gpio, IN EMBEDDED_GPIO_PULL Direction)
Definition: EmbeddedGpio.h:127
EFI_STATUS(EFIAPI * EMBEDDED_GPIO_SET)(IN EMBEDDED_GPIO_PPI *This, IN EMBEDDED_GPIO_PIN Gpio, IN EMBEDDED_GPIO_MODE Mode)
Definition: EmbeddedGpio.h:85
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
Definition: Base.h:213