3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
5 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
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.
15 #ifndef __EMBEDDED_GPIO_H__
16 #define __EMBEDDED_GPIO_H__
19 // Protocol interface structure
21 typedef struct _EMBEDDED_GPIO EMBEDDED_GPIO
;
26 typedef UINTN EMBEDDED_GPIO_PIN
;
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))
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
51 // Function Prototypes
55 (EFIAPI
*EMBEDDED_GPIO_GET
) (
56 IN EMBEDDED_GPIO
*This
,
57 IN EMBEDDED_GPIO_PIN Gpio
,
64 Gets the state of a GPIO pin
68 This - pointer to protocol
69 Gpio - which pin to read
70 Value - state of the pin
74 EFI_SUCCESS - GPIO state returned in Value
81 (EFIAPI
*EMBEDDED_GPIO_SET
) (
82 IN EMBEDDED_GPIO
*This
,
83 IN EMBEDDED_GPIO_PIN Gpio
,
84 IN EMBEDDED_GPIO_MODE Mode
90 Sets the state of a GPIO pin
94 This - pointer to protocol
95 Gpio - which pin to modify
100 EFI_SUCCESS - GPIO set as requested
107 (EFIAPI
*EMBEDDED_GPIO_GET_MODE
) (
108 IN EMBEDDED_GPIO
*This
,
109 IN EMBEDDED_GPIO_PIN Gpio
,
110 OUT EMBEDDED_GPIO_MODE
*Mode
116 Gets the mode (function) of a GPIO pin
120 This - pointer to protocol
122 Mode - pointer to output mode value
126 EFI_SUCCESS - mode value retrieved
133 (EFIAPI
*EMBEDDED_GPIO_SET_PULL
) (
134 IN EMBEDDED_GPIO
*This
,
135 IN EMBEDDED_GPIO_PIN Gpio
,
136 IN EMBEDDED_GPIO_PULL Direction
142 Sets the pull-up / pull-down resistor of a GPIO pin
146 This - pointer to protocol
148 Direction - pull-up, pull-down, or none
152 EFI_SUCCESS - pin was set
158 struct _EMBEDDED_GPIO
{
159 EMBEDDED_GPIO_GET Get
;
160 EMBEDDED_GPIO_SET Set
;
161 EMBEDDED_GPIO_GET_MODE GetMode
;
162 EMBEDDED_GPIO_SET_PULL SetPull
;
165 extern EFI_GUID gEmbeddedGpioProtocolGuid
;