]> git.proxmox.com Git - mirror_edk2.git/blame - EmbeddedPkg/Include/Protocol/EmbeddedGpio.h
Adding support for BeagleBoard.
[mirror_edk2.git] / EmbeddedPkg / Include / Protocol / EmbeddedGpio.h
CommitLineData
2ef2b01e
A
1/** @file
2
3 Copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR>
4
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13**/
14
15#ifndef __EMBEDDED_GPIO_H__
16#define __EMBEDDED_GPIO_H__
17
18//
19// Protocol interface structure
20//
21typedef struct _EMBEDDED_GPIO EMBEDDED_GPIO;
22
23//
24// Data Types
25//
26typedef UINTN EMBEDDED_GPIO_PIN;
27
28#define GPIO(Port, Pin) ((EMBEDDED_GPIO_PIN)(((Port) << (16)) | (Pin)))
29#define GPIO_PIN(x) ((EMBEDDED_GPIO_PIN)(x) & (0xFFFF))
30#define GPIO_PORT(x) ((EMBEDDED_GPIO_PIN)(x) >> (16))
31
32typedef enum {
33 GPIO_MODE_INPUT = 0x00,
34 GPIO_MODE_OUTPUT_0 = 0x0E,
35 GPIO_MODE_OUTPUT_1 = 0x0F,
36 GPIO_MODE_SPECIAL_FUNCTION_2 = 0x02,
37 GPIO_MODE_SPECIAL_FUNCTION_3 = 0x03,
38 GPIO_MODE_SPECIAL_FUNCTION_4 = 0x04,
39 GPIO_MODE_SPECIAL_FUNCTION_5 = 0x05,
40 GPIO_MODE_SPECIAL_FUNCTION_6 = 0x06,
41 GPIO_MODE_SPECIAL_FUNCTION_7 = 0x07
42} EMBEDDED_GPIO_MODE;
43
44typedef enum {
45 GPIO_PULL_NONE,
46 GPIO_PULL_UP,
47 GPIO_PULL_DOWN
48} EMBEDDED_GPIO_PULL;
49
50//
51// Function Prototypes
52//
53typedef
54EFI_STATUS
55(EFIAPI *EMBEDDED_GPIO_GET) (
56 IN EMBEDDED_GPIO *This,
57 IN EMBEDDED_GPIO_PIN Gpio,
58 OUT UINTN *Value
59 );
60/*++
61
62Routine Description:
63
64 Gets the state of a GPIO pin
65
66Arguments:
67
68 This - pointer to protocol
69 Gpio - which pin to read
70 Value - state of the pin
71
72Returns:
73
74 EFI_SUCCESS - GPIO state returned in Value
75
76--*/
77
78
79typedef
80EFI_STATUS
81(EFIAPI *EMBEDDED_GPIO_SET) (
82 IN EMBEDDED_GPIO *This,
83 IN EMBEDDED_GPIO_PIN Gpio,
84 IN EMBEDDED_GPIO_MODE Mode
85 );
86/*++
87
88Routine Description:
89
90 Sets the state of a GPIO pin
91
92Arguments:
93
94 This - pointer to protocol
95 Gpio - which pin to modify
96 Mode - mode to set
97
98Returns:
99
100 EFI_SUCCESS - GPIO set as requested
101
102--*/
103
104
105typedef
106EFI_STATUS
107(EFIAPI *EMBEDDED_GPIO_GET_MODE) (
108 IN EMBEDDED_GPIO *This,
109 IN EMBEDDED_GPIO_PIN Gpio,
110 OUT EMBEDDED_GPIO_MODE *Mode
111 );
112/*++
113
114Routine Description:
115
116 Gets the mode (function) of a GPIO pin
117
118Arguments:
119
120 This - pointer to protocol
121 Gpio - which pin
122 Mode - pointer to output mode value
123
124Returns:
125
126 EFI_SUCCESS - mode value retrieved
127
128--*/
129
130
131typedef
132EFI_STATUS
133(EFIAPI *EMBEDDED_GPIO_SET_PULL) (
134 IN EMBEDDED_GPIO *This,
135 IN EMBEDDED_GPIO_PIN Gpio,
136 IN EMBEDDED_GPIO_PULL Direction
137 );
138/*++
139
140Routine Description:
141
142 Sets the pull-up / pull-down resistor of a GPIO pin
143
144Arguments:
145
146 This - pointer to protocol
147 Gpio - which pin
148 Direction - pull-up, pull-down, or none
149
150Returns:
151
152 EFI_SUCCESS - pin was set
153
154--*/
155
156
157
158struct _EMBEDDED_GPIO {
159 EMBEDDED_GPIO_GET Get;
160 EMBEDDED_GPIO_SET Set;
161 EMBEDDED_GPIO_GET_MODE GetMode;
162 EMBEDDED_GPIO_SET_PULL SetPull;
163};
164
165extern EFI_GUID gEmbeddedGpioProtocolGuid;
166
167#endif