diff options
author | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-07-01 15:30:01 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-07-01 15:30:01 +0000 |
commit | 5cc45b70c310f853f28b2351f3d93109ff858dcf (patch) | |
tree | 22917c5dfa20a9f553c1adda9ce6efc04b722dc7 /ArmPlatformPkg/Drivers/PL061GpioDxe | |
parent | 7fb54d9d04f52e22f6df16e0035c565c3dce7bd4 (diff) | |
download | edk2-platforms-5cc45b70c310f853f28b2351f3d93109ff858dcf.tar.xz |
ArmPkg: Move ARM Platform drivers from ArmPkg/Drivers/ to ArmPlatformPkg/Drivers/
The idea is to keep ArmPkg responsible for the ARM architectural modules and ArmPlatformPkg
the ARM development platform packages (with their respective drivers).
ArmPlatformPkg: Reduce driver dependency on ArmPlatform.h
- Move some driver definitions from C-Macro to PCD values
- Unify PCD driver namespace
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11956 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/Drivers/PL061GpioDxe')
-rw-r--r-- | ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c | 73 | ||||
-rw-r--r-- | ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf | 15 |
2 files changed, 43 insertions, 45 deletions
diff --git a/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c b/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c index 0e263c03a7..cb811d89d6 100644 --- a/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c +++ b/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061Gpio.c @@ -13,23 +13,20 @@ **/ -#include <Base.h> #include <PiDxe.h> #include <Library/BaseLib.h> -#include <Library/DebugLib.h> #include <Library/BaseMemoryLib.h> +#include <Library/DebugLib.h> +#include <Library/IoLib.h> +#include <Library/PcdLib.h> #include <Library/UefiBootServicesTableLib.h> -#include <Library/UefiRuntimeServicesTableLib.h> #include <Library/UefiLib.h> -#include <Library/IoLib.h> +#include <Library/UefiRuntimeServicesTableLib.h> #include <Protocol/EmbeddedGpio.h> -#include <ArmPlatform.h> #include <Drivers/PL061Gpio.h> -#define LOW_4_BITS 0x0000000F - BOOLEAN mPL061Initialized = FALSE; /** @@ -42,18 +39,18 @@ PL061Identify ( ) { // Check if this is a PrimeCell Peripheral - if( ( MmioRead8( PL061_GPIO_PCELL_ID0 ) != 0x0D ) - || ( MmioRead8( PL061_GPIO_PCELL_ID1 ) != 0xF0 ) - || ( MmioRead8( PL061_GPIO_PCELL_ID2 ) != 0x05 ) - || ( MmioRead8( PL061_GPIO_PCELL_ID3 ) != 0xB1 ) ) { + if ( (MmioRead8 (PL061_GPIO_PCELL_ID0) != 0x0D) + || (MmioRead8 (PL061_GPIO_PCELL_ID1) != 0xF0) + || (MmioRead8 (PL061_GPIO_PCELL_ID2) != 0x05) + || (MmioRead8 (PL061_GPIO_PCELL_ID3) != 0xB1)) { return EFI_NOT_FOUND; } // Check if this PrimeCell Peripheral is the PL061 GPIO - if( ( MmioRead8( PL061_GPIO_PERIPH_ID0 ) != 0x61 ) - || ( MmioRead8( PL061_GPIO_PERIPH_ID1 ) != 0x10 ) - || ( ( MmioRead8( PL061_GPIO_PERIPH_ID2 ) & LOW_4_BITS ) != 0x04 ) - || ( MmioRead8( PL061_GPIO_PERIPH_ID3 ) != 0x00 ) ) { + if ( (MmioRead8 (PL061_GPIO_PERIPH_ID0) != 0x61) + || (MmioRead8 (PL061_GPIO_PERIPH_ID1) != 0x10) + || ((MmioRead8 (PL061_GPIO_PERIPH_ID2) & 0xF) != 0x04) + || (MmioRead8 (PL061_GPIO_PERIPH_ID3) != 0x00)) { return EFI_NOT_FOUND; } @@ -62,14 +59,14 @@ PL061Identify ( EFI_STATUS PL061Initialize ( -VOID + VOID ) { EFI_STATUS Status; // Check if the PL061 GPIO module exists on board Status = PL061Identify(); - if (EFI_ERROR( Status )) { + if (EFI_ERROR (Status)) { Status = EFI_DEVICE_ERROR; goto EXIT; } @@ -77,7 +74,7 @@ VOID // Do other hardware initialisation things here as required // Disable Interrupts - //if( MmioRead8( PL061_GPIO_IE_REG ) != 0 ) { + //if (MmioRead8 (PL061_GPIO_IE_REG) != 0) { // // Ensure interrupts are disabled //} @@ -114,21 +111,21 @@ Get ( { EFI_STATUS Status = EFI_SUCCESS; - if( ( Value == NULL ) - || ( Gpio > LAST_GPIO_PIN ) ) + if ( (Value == NULL) + || (Gpio > LAST_GPIO_PIN)) { return EFI_INVALID_PARAMETER; } // Initialize the hardware if not already done - if( !mPL061Initialized ) { + if (!mPL061Initialized) { Status = PL061Initialize(); - if( EFI_ERROR(Status) ) { + 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; } else { *Value = 0; @@ -167,15 +164,15 @@ Set ( EFI_STATUS Status = EFI_SUCCESS; // Check for errors - if( Gpio > LAST_GPIO_PIN ) { + if (Gpio > LAST_GPIO_PIN) { Status = EFI_INVALID_PARAMETER; goto EXIT; } // Initialize the hardware if not already done - if( !mPL061Initialized ) { + if (!mPL061Initialized) { Status = PL061Initialize(); - if( EFI_ERROR(Status) ) { + if (EFI_ERROR(Status)) { goto EXIT; } } @@ -184,21 +181,21 @@ Set ( { case GPIO_MODE_INPUT: // Set the corresponding direction bit to LOW for input - MmioAnd8( PL061_GPIO_DIR_REG, GPIO_PIN_MASK_LOW_8BIT(Gpio) ); + MmioAnd8 (PL061_GPIO_DIR_REG, GPIO_PIN_MASK_LOW_8BIT(Gpio)); break; case GPIO_MODE_OUTPUT_0: // Set the corresponding data bit to LOW for 0 - MmioAnd8( PL061_GPIO_DATA_REG, GPIO_PIN_MASK_LOW_8BIT(Gpio) ); + MmioAnd8 (PL061_GPIO_DATA_REG, GPIO_PIN_MASK_LOW_8BIT(Gpio)); // Set the corresponding direction bit to HIGH for output - MmioOr8( PL061_GPIO_DIR_REG, GPIO_PIN_MASK_HIGH_8BIT(Gpio) ); + MmioOr8 (PL061_GPIO_DIR_REG, GPIO_PIN_MASK_HIGH_8BIT(Gpio)); break; case GPIO_MODE_OUTPUT_1: // Set the corresponding data bit to HIGH for 1 - MmioOr8( PL061_GPIO_DATA_REG, GPIO_PIN_MASK_HIGH_8BIT(Gpio) ); + MmioOr8 (PL061_GPIO_DATA_REG, GPIO_PIN_MASK_HIGH_8BIT(Gpio)); // Set the corresponding direction bit to HIGH for output - MmioOr8( PL061_GPIO_DIR_REG, GPIO_PIN_MASK_HIGH_8BIT(Gpio) ); + MmioOr8 (PL061_GPIO_DIR_REG, GPIO_PIN_MASK_HIGH_8BIT(Gpio)); break; default: @@ -239,23 +236,23 @@ GetMode ( EFI_STATUS Status; // Check for errors - if( ( Mode == NULL ) - || ( Gpio > LAST_GPIO_PIN ) ) { + if ( (Mode == NULL) + || (Gpio > LAST_GPIO_PIN)) { return EFI_INVALID_PARAMETER; } // Initialize the hardware if not already done - if( !mPL061Initialized ) { + if (!mPL061Initialized) { Status = PL061Initialize(); - if( EFI_ERROR(Status) ) { + if (EFI_ERROR(Status)) { return Status; } } // 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 - if( MmioRead8( PL061_GPIO_DATA_REG ) & GPIO_PIN_MASK_HIGH_8BIT(Gpio) ) { + if (MmioRead8 (PL061_GPIO_DATA_REG) & GPIO_PIN_MASK_HIGH_8BIT(Gpio)) { *Mode = GPIO_MODE_OUTPUT_1; } else { *Mode = GPIO_MODE_OUTPUT_0; @@ -338,7 +335,7 @@ PL061InstallProtocol ( &Handle, &gEmbeddedGpioProtocolGuid, &gGpio, NULL - ); + ); if (EFI_ERROR(Status)) { Status = EFI_OUT_OF_RESOURCES; } diff --git a/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf b/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf index 53eebdaec9..b5adda3a89 100644 --- a/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf +++ b/ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf @@ -31,19 +31,20 @@ [LibraryClasses] BaseLib - UefiRuntimeServicesTableLib - UefiLib - UefiBootServicesTableLib BaseMemoryLib DebugLib - UefiDriverEntryPoint IoLib + PcdLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + UefiRuntimeServicesTableLib -[Guids] +[Pcd] + gArmPlatformTokenSpaceGuid.PcdPL061GpioBase [Protocols] gEmbeddedGpioProtocolGuid - [Depex] -TRUE + TRUE |