VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/EmbeddedPkg/Include/Protocol/EmbeddedGpio.h@ 85718

Last change on this file since 85718 was 85718, checked in by vboxsync, 4 years ago

Devices/EFI: Merge edk-stable202005 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
1/** @file
2
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
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
48EFI_STATUS
49(EFIAPI *EMBEDDED_GPIO_GET) (
50 IN EMBEDDED_GPIO *This,
51 IN EMBEDDED_GPIO_PIN Gpio,
52 OUT UINTN *Value
53 );
54/*++
55
56Routine Description:
57
58 Gets the state of a GPIO pin
59
60Arguments:
61
62 This - pointer to protocol
63 Gpio - which pin to read
64 Value - state of the pin
65
66Returns:
67
68 EFI_SUCCESS - GPIO state returned in Value
69
70--*/
71
72
73typedef
74EFI_STATUS
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
82Routine Description:
83
84 Sets the state of a GPIO pin
85
86Arguments:
87
88 This - pointer to protocol
89 Gpio - which pin to modify
90 Mode - mode to set
91
92Returns:
93
94 EFI_SUCCESS - GPIO set as requested
95
96--*/
97
98
99typedef
100EFI_STATUS
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
108Routine Description:
109
110 Gets the mode (function) of a GPIO pin
111
112Arguments:
113
114 This - pointer to protocol
115 Gpio - which pin
116 Mode - pointer to output mode value
117
118Returns:
119
120 EFI_SUCCESS - mode value retrieved
121
122--*/
123
124
125typedef
126EFI_STATUS
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
134Routine Description:
135
136 Sets the pull-up / pull-down resistor of a GPIO pin
137
138Arguments:
139
140 This - pointer to protocol
141 Gpio - which pin
142 Direction - pull-up, pull-down, or none
143
144Returns:
145
146 EFI_SUCCESS - pin was set
147
148--*/
149
150
151
152struct _EMBEDDED_GPIO {
153 EMBEDDED_GPIO_GET Get;
154 EMBEDDED_GPIO_SET Set;
155 EMBEDDED_GPIO_GET_MODE GetMode;
156 EMBEDDED_GPIO_SET_PULL SetPull;
157};
158
159extern EFI_GUID gEmbeddedGpioProtocolGuid;
160
161typedef struct _GPIO_CONTROLLER GPIO_CONTROLLER;
162typedef struct _PLATFORM_GPIO_CONTROLLER PLATFORM_GPIO_CONTROLLER;
163
164struct _GPIO_CONTROLLER {
165 UINTN RegisterBase;
166 UINTN GpioIndex;
167 UINTN InternalGpioCount;
168};
169
170struct _PLATFORM_GPIO_CONTROLLER {
171 UINTN GpioCount;
172 UINTN GpioControllerCount;
173 GPIO_CONTROLLER *GpioController;
174};
175
176extern EFI_GUID gPlatformGpioProtocolGuid;
177
178#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette