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.
17 #include <Library/IoLib.h>
18 #include <Library/OmapLib.h>
19 #include <Library/UefiBootServicesTableLib.h>
21 #include <Protocol/EmbeddedGpio.h>
23 #include <Omap3530/Omap3530.h>
27 IN EMBEDDED_GPIO
*This
,
28 IN EMBEDDED_GPIO_PIN Gpio
,
34 UINT32 DataInRegister
;
38 return EFI_UNSUPPORTED
;
41 Port
= GPIO_PORT(Gpio
);
44 DataInRegister
= GpioBase(Port
) + GPIO_DATAIN
;
46 if (MmioRead32 (DataInRegister
) & GPIO_DATAIN_MASK(Pin
)) {
57 IN EMBEDDED_GPIO
*This
,
58 IN EMBEDDED_GPIO_PIN Gpio
,
59 IN EMBEDDED_GPIO_MODE Mode
64 UINT32 OutputEnableRegister
;
65 UINT32 SetDataOutRegister
;
66 UINT32 ClearDataOutRegister
;
68 Port
= GPIO_PORT(Gpio
);
71 OutputEnableRegister
= GpioBase(Port
) + GPIO_OE
;
72 SetDataOutRegister
= GpioBase(Port
) + GPIO_SETDATAOUT
;
73 ClearDataOutRegister
= GpioBase(Port
) + GPIO_CLEARDATAOUT
;
78 MmioAndThenOr32(OutputEnableRegister
, ~GPIO_OE_MASK(Pin
), GPIO_OE_INPUT(Pin
));
81 case GPIO_MODE_OUTPUT_0
:
82 MmioWrite32 (ClearDataOutRegister
, GPIO_CLEARDATAOUT_BIT(Pin
));
83 MmioAndThenOr32(OutputEnableRegister
, ~GPIO_OE_MASK(Pin
), GPIO_OE_OUTPUT(Pin
));
86 case GPIO_MODE_OUTPUT_1
:
87 MmioWrite32 (SetDataOutRegister
, GPIO_SETDATAOUT_BIT(Pin
));
88 MmioAndThenOr32(OutputEnableRegister
, ~GPIO_OE_MASK(Pin
), GPIO_OE_OUTPUT(Pin
));
92 return EFI_UNSUPPORTED
;
100 IN EMBEDDED_GPIO
*This
,
101 IN EMBEDDED_GPIO_PIN Gpio
,
102 OUT EMBEDDED_GPIO_MODE
*Mode
105 return EFI_UNSUPPORTED
;
110 IN EMBEDDED_GPIO
*This
,
111 IN EMBEDDED_GPIO_PIN Gpio
,
112 IN EMBEDDED_GPIO_PULL Direction
115 return EFI_UNSUPPORTED
;
118 EMBEDDED_GPIO Gpio
= {
127 IN EFI_HANDLE ImageHandle
,
128 IN EFI_SYSTEM_TABLE
*SystemTable
133 Status
= gBS
->InstallMultipleProtocolInterfaces(&ImageHandle
, &gEmbeddedGpioProtocolGuid
, &Gpio
, NULL
);