ArmPlatformPkg: PL061 - only initialize on protocol load
For whatever reason, every single operation on the PL061 looked for an "Initialized" flag, and manually called the initialization function if not set. Move this to a single call on protocol installation. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Ryan Harkin <ryan.harkin@linaro.org>
This commit is contained in:
parent
fe28290e97
commit
2a77a37ea4
@ -1,6 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011, ARM Limited. All rights reserved.
|
* Copyright (c) 2011, ARM Limited. All rights reserved.
|
||||||
|
* Copyright (c) 2016, Linaro Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials
|
* This program and the accompanying materials
|
||||||
* are licensed and made available under the terms and conditions of the BSD
|
* are licensed and made available under the terms and conditions of the BSD
|
||||||
@ -27,7 +28,6 @@
|
|||||||
#include <Protocol/EmbeddedGpio.h>
|
#include <Protocol/EmbeddedGpio.h>
|
||||||
#include <Drivers/PL061Gpio.h>
|
#include <Drivers/PL061Gpio.h>
|
||||||
|
|
||||||
BOOLEAN mPL061Initialized = FALSE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Function implementations
|
Function implementations
|
||||||
@ -78,8 +78,6 @@ PL061Initialize (
|
|||||||
// // Ensure interrupts are disabled
|
// // Ensure interrupts are disabled
|
||||||
//}
|
//}
|
||||||
|
|
||||||
mPL061Initialized = TRUE;
|
|
||||||
|
|
||||||
EXIT:
|
EXIT:
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@ -109,30 +107,19 @@ Get (
|
|||||||
OUT UINTN *Value
|
OUT UINTN *Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status = EFI_SUCCESS;
|
|
||||||
|
|
||||||
if ( (Value == NULL)
|
if ( (Value == NULL)
|
||||||
|| (Gpio > LAST_GPIO_PIN))
|
|| (Gpio > LAST_GPIO_PIN))
|
||||||
{
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the hardware if not already done
|
|
||||||
if (!mPL061Initialized) {
|
|
||||||
Status = PL061Initialize();
|
|
||||||
if (EFI_ERROR(Status)) {
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MmioRead8 (PL061_GPIO_DATA_REG) & GPIO_PIN_MASK_HIGH_8BIT(Gpio)) {
|
if (MmioRead8 (PL061_GPIO_DATA_REG) & GPIO_PIN_MASK_HIGH_8BIT(Gpio)) {
|
||||||
*Value = 1;
|
*Value = 1;
|
||||||
} else {
|
} else {
|
||||||
*Value = 0;
|
*Value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXIT:
|
return EFI_SUCCESS;
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,14 +156,6 @@ Set (
|
|||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the hardware if not already done
|
|
||||||
if (!mPL061Initialized) {
|
|
||||||
Status = PL061Initialize();
|
|
||||||
if (EFI_ERROR(Status)) {
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Mode)
|
switch (Mode)
|
||||||
{
|
{
|
||||||
case GPIO_MODE_INPUT:
|
case GPIO_MODE_INPUT:
|
||||||
@ -233,22 +212,12 @@ GetMode (
|
|||||||
OUT EMBEDDED_GPIO_MODE *Mode
|
OUT EMBEDDED_GPIO_MODE *Mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors
|
||||||
if ( (Mode == NULL)
|
if ( (Mode == NULL)
|
||||||
|| (Gpio > LAST_GPIO_PIN)) {
|
|| (Gpio > LAST_GPIO_PIN)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the hardware if not already done
|
|
||||||
if (!mPL061Initialized) {
|
|
||||||
Status = PL061Initialize();
|
|
||||||
if (EFI_ERROR(Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if it is input or output
|
// Check if it is input or output
|
||||||
if (MmioRead8 (PL061_GPIO_DIR_REG) & GPIO_PIN_MASK_HIGH_8BIT(Gpio)) {
|
if (MmioRead8 (PL061_GPIO_DIR_REG) & GPIO_PIN_MASK_HIGH_8BIT(Gpio)) {
|
||||||
// Pin set to output
|
// Pin set to output
|
||||||
@ -329,6 +298,11 @@ PL061InstallProtocol (
|
|||||||
//
|
//
|
||||||
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEmbeddedGpioProtocolGuid);
|
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEmbeddedGpioProtocolGuid);
|
||||||
|
|
||||||
|
Status = PL061Initialize();
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
// Install the Embedded GPIO Protocol onto a new handle
|
// Install the Embedded GPIO Protocol onto a new handle
|
||||||
Handle = NULL;
|
Handle = NULL;
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces(
|
Status = gBS->InstallMultipleProtocolInterfaces(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user