/** @file\r
*\r
* Copyright (c) 2011, ARM Limited. All rights reserved.\r
+* Copyright (c) 2016, Linaro Limited. All rights reserved.\r
*\r
* This program and the accompanying materials\r
* are licensed and made available under the terms and conditions of the BSD\r
#include <Protocol/EmbeddedGpio.h>\r
#include <Drivers/PL061Gpio.h>\r
\r
-BOOLEAN mPL061Initialized = FALSE;\r
\r
/**\r
Function implementations\r
// // Ensure interrupts are disabled\r
//}\r
\r
- mPL061Initialized = TRUE;\r
-\r
EXIT:\r
return Status;\r
}\r
OUT UINTN *Value\r
)\r
{\r
- EFI_STATUS Status = EFI_SUCCESS;\r
-\r
if ( (Value == NULL)\r
|| (Gpio > LAST_GPIO_PIN))\r
{\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- // Initialize the hardware if not already done\r
- if (!mPL061Initialized) {\r
- Status = PL061Initialize();\r
- if (EFI_ERROR(Status)) {\r
- goto EXIT;\r
- }\r
- }\r
-\r
if (MmioRead8 (PL061_GPIO_DATA_REG) & GPIO_PIN_MASK_HIGH_8BIT(Gpio)) {\r
*Value = 1;\r
} else {\r
*Value = 0;\r
}\r
\r
- EXIT:\r
- return Status;\r
+ return EFI_SUCCESS;\r
}\r
\r
/**\r
goto EXIT;\r
}\r
\r
- // Initialize the hardware if not already done\r
- if (!mPL061Initialized) {\r
- Status = PL061Initialize();\r
- if (EFI_ERROR(Status)) {\r
- goto EXIT;\r
- }\r
- }\r
-\r
switch (Mode)\r
{\r
case GPIO_MODE_INPUT:\r
OUT EMBEDDED_GPIO_MODE *Mode\r
)\r
{\r
- EFI_STATUS Status;\r
-\r
// Check for errors\r
if ( (Mode == NULL)\r
|| (Gpio > LAST_GPIO_PIN)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- // Initialize the hardware if not already done\r
- if (!mPL061Initialized) {\r
- Status = PL061Initialize();\r
- if (EFI_ERROR(Status)) {\r
- return Status;\r
- }\r
- }\r
-\r
// Check if it is input or output\r
if (MmioRead8 (PL061_GPIO_DIR_REG) & GPIO_PIN_MASK_HIGH_8BIT(Gpio)) {\r
// Pin set to output\r
//\r
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEmbeddedGpioProtocolGuid);\r
\r
+ Status = PL061Initialize();\r
+ if (EFI_ERROR(Status)) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
// Install the Embedded GPIO Protocol onto a new handle\r
Handle = NULL;\r
Status = gBS->InstallMultipleProtocolInterfaces(\r