diff options
Diffstat (limited to 'SamsungPlatformPkgOrigen/ExynosPkg/Library')
10 files changed, 0 insertions, 908 deletions
diff --git a/SamsungPlatformPkgOrigen/ExynosPkg/Library/ExynosLib/ExynosLib.c b/SamsungPlatformPkgOrigen/ExynosPkg/Library/ExynosLib/ExynosLib.c deleted file mode 100644 index a1e1799f0..000000000 --- a/SamsungPlatformPkgOrigen/ExynosPkg/Library/ExynosLib/ExynosLib.c +++ /dev/null @@ -1,36 +0,0 @@ -/** @file - - Copyright (c) 2011, Samsung Electronics Co. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include <Base.h> -#include <Library/DebugLib.h> -#include <Library/PcdLib.h> -#include <Platform/ArmPlatform.h> - -UINT32 -GpioBase ( - IN UINTN Port - ) -{ - - ASSERT( (Port >= GPA0) && (Port <= GPZ)); - - /*decide which part of gpio is being requested. give the corresponding base address*/ - if(Port & 0x10) { - return (PcdGet32(PcdGpioPart2Base) + (Port*DISTANCE_BTWN_PORTS)); - }else { - return (PcdGet32(PcdGpioPart1Base) + (Port*DISTANCE_BTWN_PORTS)); - } - - ASSERT(FALSE); return 0; -} diff --git a/SamsungPlatformPkgOrigen/ExynosPkg/Library/ExynosLib/ExynosLib.inf b/SamsungPlatformPkgOrigen/ExynosPkg/Library/ExynosLib/ExynosLib.inf deleted file mode 100644 index be92d99ce..000000000 --- a/SamsungPlatformPkgOrigen/ExynosPkg/Library/ExynosLib/ExynosLib.inf +++ /dev/null @@ -1,40 +0,0 @@ -#/** @file -# -# Copyright (c) 2011, Samsung Electronics Co. All rights reserved.<BR> -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = ExynosLib - FILE_GUID = d035f5c2-1b92-4746-9f6c-5ff6202970df - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - LIBRARY_CLASS = ExynosLib - -[Sources.common] - ExynosLib.c - -[Packages] - MdePkg/MdePkg.dec - EmbeddedPkg/EmbeddedPkg.dec - SamsungPlatformPkgOrigen/ExynosPkg/ExynosPkg.dec - -[LibraryClasses] - DebugLib - IoLib - -[Protocols] - -[Guids] - -[Pcd] - gExynosPkgTokenSpaceGuid.PcdGpioPart1Base - gExynosPkgTokenSpaceGuid.PcdGpioPart2Base diff --git a/SamsungPlatformPkgOrigen/ExynosPkg/Library/GdbSerialLib/GdbSerialLib.c b/SamsungPlatformPkgOrigen/ExynosPkg/Library/GdbSerialLib/GdbSerialLib.c deleted file mode 100644 index 353cad11e..000000000 --- a/SamsungPlatformPkgOrigen/ExynosPkg/Library/GdbSerialLib/GdbSerialLib.c +++ /dev/null @@ -1,118 +0,0 @@ -/** @file - Basic serial IO abstaction for GDB - - Copyright (c) 2011, Samsung Electronics Co. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include <Uefi.h> -#include <Library/GdbSerialLib.h> -#include <Library/PcdLib.h> -#include <Library/IoLib.h> -#include <Platform/ArmPlatform.h> - -RETURN_STATUS -EFIAPI -GdbSerialLibConstructor ( - VOID - ) -{ - return GdbSerialInit (115200, 0, 8, 1); -} - -RETURN_STATUS -EFIAPI -GdbSerialInit ( - IN UINT64 BaudRate, - IN UINT8 Parity, - IN UINT8 DataBits, - IN UINT8 StopBits - ) -{ - if ((Parity != 0) || (DataBits != 8) || (StopBits != 1)) { - return RETURN_UNSUPPORTED; - } - - if (BaudRate != 115200) { - // Could add support for different Baud rates.... - return RETURN_UNSUPPORTED; - } - - UINT32 Base = PcdGet32 (PcdGdbUartBase); - - // initialize baud rate generator to 115200 based on EB clock REFCLK24MHZ - MmioWrite32 (Base + UARTIBRD, UART_115200_IDIV); - MmioWrite32 (Base + UARTFBRD, UART_115200_FDIV); - - // no parity, 1 stop, no fifo, 8 data bits - MmioWrite32 (Base + UARTLCR_H, 0x60); - - // clear any pending errors - MmioWrite32 (Base + UARTECR, 0); - - // enable tx, rx, and uart overall - MmioWrite32 (Base + UARTCR, 0x301); - - return RETURN_SUCCESS; -} - -BOOLEAN -EFIAPI -GdbIsCharAvailable ( - VOID - ) -{ - UINT32 FR = PcdGet32 (PcdGdbUartBase) + UTRSTAT_OFFSET; - - if ((MmioRead32 (FR) & UART_RX_EMPTY_FLAG_MASK) == 0) { - return TRUE; - } else { - return FALSE; - } -} - -CHAR8 -EFIAPI -GdbGetChar ( - VOID - ) -{ - UINT32 FR = PcdGet32 (PcdGdbUartBase) + UTRSTAT_OFFSET; - UINT32 DR = PcdGet32 (PcdGdbUartBase) + URXH_OFFSET; - - while ((MmioRead32 (FR) & UART_RX_EMPTY_FLAG_MASK) == 0); - return MmioRead8 (DR); -} - -VOID -EFIAPI -GdbPutChar ( - IN CHAR8 Char - ) -{ - UINT32 FR = PcdGet32 (PcdGdbUartBase) + UTRSTAT_OFFSET; - UINT32 DR = PcdGet32 (PcdGdbUartBase) + UTXH_OFFSET; - - while ((MmioRead32 (FR) & UART_TX_EMPTY_FLAG_MASK) != 0); - MmioWrite8 (DR, Char); - return; -} - -VOID -GdbPutString ( - IN CHAR8 *String - ) -{ - while (*String != '\0') { - GdbPutChar (*String); - String++; - } -} diff --git a/SamsungPlatformPkgOrigen/ExynosPkg/Library/GdbSerialLib/GdbSerialLib.inf b/SamsungPlatformPkgOrigen/ExynosPkg/Library/GdbSerialLib/GdbSerialLib.inf deleted file mode 100644 index 2e41b7049..000000000 --- a/SamsungPlatformPkgOrigen/ExynosPkg/Library/GdbSerialLib/GdbSerialLib.inf +++ /dev/null @@ -1,40 +0,0 @@ -#/** @file -# -# Copyright (c) 2011, Samsung Electronics Co. All rights reserved.<BR> -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = GdbSerialLib - FILE_GUID = E8EA1309-2F14-428f-ABE3-7016CE4B4305 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = GdbSerialLib - - CONSTRUCTOR = GdbSerialLibConstructor - - -[Sources.common] - GdbSerialLib.c - - -[Packages] - MdePkg/MdePkg.dec - SamsungPlatformPkgOrigen/ExynosPkg/ExynosPkg.dec - EmbeddedPkg/EmbeddedPkg.dec - - -[LibraryClasses] - DebugLib - IoLib - -[FixedPcd] - gExynosPkgTokenSpaceGuid.PcdGdbUartBase diff --git a/SamsungPlatformPkgOrigen/ExynosPkg/Library/ResetSystemLib/ResetSystemLib.c b/SamsungPlatformPkgOrigen/ExynosPkg/Library/ResetSystemLib/ResetSystemLib.c deleted file mode 100644 index daaa1299c..000000000 --- a/SamsungPlatformPkgOrigen/ExynosPkg/Library/ResetSystemLib/ResetSystemLib.c +++ /dev/null @@ -1,167 +0,0 @@ -/** @file - Template library implementation to support ResetSystem Runtime call. - - Fill in the templates with what ever makes you system reset. - - - Copyright (c) 2011, Samsung Electronics Co. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - - -#include <PiDxe.h> - -#include <Library/ArmLib.h> -#include <Library/BaseLib.h> -#include <Library/MemoryAllocationLib.h> -#include <Library/PcdLib.h> -#include <Library/IoLib.h> -#include <Library/DebugLib.h> -#include <Library/EfiResetSystemLib.h> -#include <Library/UefiBootServicesTableLib.h> -#include <Library/CacheMaintenanceLib.h> -#include <Platform/ArmPlatform.h> - -VOID DestroyExynosMemMap(VOID); -typedef VOID (EFIAPI *CALL_STUB)(VOID); - -VOID -DestroyExynosMemMap ( - VOID - ) -{ - EFI_STATUS Status; - UINTN MemoryMapSize; - EFI_MEMORY_DESCRIPTOR *MemoryMap; - UINTN MapKey; - UINTN DescriptorSize; - UINTN DescriptorVersion; - UINTN Pages; - - MemoryMap = NULL; - MemoryMapSize = 0; - do { - Status = gBS->GetMemoryMap ( - &MemoryMapSize, - MemoryMap, - &MapKey, - &DescriptorSize, - &DescriptorVersion - ); - if (Status == EFI_BUFFER_TOO_SMALL) { - - Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1; - MemoryMap = AllocatePages (Pages); - - // - // Get System MemoryMap - // - Status = gBS->GetMemoryMap ( - &MemoryMapSize, - MemoryMap, - &MapKey, - &DescriptorSize, - &DescriptorVersion - ); - // Don't do anything between the GetMemoryMap() and ExitBootServices() - if (!EFI_ERROR (Status)) { - Status = gBS->ExitBootServices (gImageHandle, MapKey); - if (EFI_ERROR (Status)) { - FreePages (MemoryMap, Pages); - MemoryMap = NULL; - MemoryMapSize = 0; - } - } - } - } while (EFI_ERROR (Status)); - - //Clean and invalidate caches. - WriteBackInvalidateDataCache(); - InvalidateInstructionCache(); - - //Turning off Caches and MMU - ArmDisableDataCache (); - ArmDisableInstructionCache (); - ArmDisableMmu (); -} - - - -/** - Resets the entire platform. - - @param ResetType The type of reset to perform. - @param ResetStatus The status code for the reset. - @param DataSize The size, in bytes, of WatchdogData. - @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or - EfiResetShutdown the data buffer starts with a Null-terminated - Unicode string, optionally followed by additional binary data. - -**/ -EFI_STATUS -EFIAPI -LibResetSystem ( - IN EFI_RESET_TYPE ResetType, - IN EFI_STATUS ResetStatus, - IN UINTN DataSize, - IN CHAR16 *ResetData OPTIONAL - ) -{ - CALL_STUB StartOfFv; - UINTN PmuBase; - if (ResetData != NULL) { - DEBUG ((EFI_D_ERROR, "%s", ResetData)); - } - - DestroyExynosMemMap(); - - switch (ResetType) { - case EfiResetWarm: - //Perform warm reset of the system by jumping to the begining of the FV -// ((ptrImageStart)PcdGet32(PcdFvBaseAddress))(); - StartOfFv = (CALL_STUB)(UINTN)PcdGet32(PcdFvBaseAddress); - StartOfFv (); - break; - case EfiResetCold: - case EfiResetShutdown: - default: - //Perform cold reset of the system. - PmuBase = (UINTN)PcdGet32(PcdPmuBase); - MmioWrite32 ((PmuBase + SWRESET_OFFSET), 0x01); - while ((MmioRead32(PmuBase + SWRESET_OFFSET)) != 0x1); - break; - } - - // If the reset didn't work, return an error. - ASSERT (FALSE); - return EFI_DEVICE_ERROR; -} - - - -/** - Initialize any infrastructure required for LibResetSystem () to function. - - @param ImageHandle The firmware allocated handle for the EFI image. - @param SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. - -**/ -EFI_STATUS -EFIAPI -LibInitializeResetSystem ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - return EFI_SUCCESS; -} diff --git a/SamsungPlatformPkgOrigen/ExynosPkg/Library/ResetSystemLib/ResetSystemLib.inf b/SamsungPlatformPkgOrigen/ExynosPkg/Library/ResetSystemLib/ResetSystemLib.inf deleted file mode 100644 index 7b363d027..000000000 --- a/SamsungPlatformPkgOrigen/ExynosPkg/Library/ResetSystemLib/ResetSystemLib.inf +++ /dev/null @@ -1,44 +0,0 @@ -#/** @file -# Reset System lib to make it easy to port new platforms -# -# Copyright (c) 2011, Samsung Electronics Co. All rights reserved.<BR> -# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = ArmEbResetSystemLib - FILE_GUID = CEFFA65C-B568-453e-9E11-B81AE683D035 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = EfiResetSystemLib - - -[Sources.common] - ResetSystemLib.c - -[Packages] - MdePkg/MdePkg.dec - ArmPkg/ArmPkg.dec - EmbeddedPkg/EmbeddedPkg.dec - ArmPlatformPkg/ArmPlatformPkg.dec - SamsungPlatformPkgOrigen/ExynosPkg/ExynosPkg.dec -[LibraryClasses] - ArmLib - IoLib - BaseLib - DebugLib - MemoryAllocationLib - CacheMaintenanceLib -[FixedPcd] - gArmTokenSpaceGuid.PcdFvBaseAddress -[Pcd] - gExynosPkgTokenSpaceGuid.PcdPmuBase diff --git a/SamsungPlatformPkgOrigen/ExynosPkg/Library/SerialPortLib/SerialPortLib.c b/SamsungPlatformPkgOrigen/ExynosPkg/Library/SerialPortLib/SerialPortLib.c deleted file mode 100644 index 548330e61..000000000 --- a/SamsungPlatformPkgOrigen/ExynosPkg/Library/SerialPortLib/SerialPortLib.c +++ /dev/null @@ -1,150 +0,0 @@ -/** @file - Serial I/O Port library functions with no library constructor/destructor - - - Copyright (c) 2011, Samsung Electronics Co. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include <Include/Uefi.h> -#include <Library/SerialPortLib.h> -#include <Library/SerialPortExtLib.h> -#include <Library/PcdLib.h> -#include <Library/IoLib.h> -#include <Platform/ArmPlatform.h> - -/* - - Programmed hardware of Serial port. - Irrespective of the previous settings Initialize it to current requirement -**/ -RETURN_STATUS -EFIAPI -SerialPortInitialize ( - VOID - ) -{ -#if 0 - UINT32 UARTConsoleBase; - UINT32 SmdkCmuBase; - - UARTConsoleBase=PcdGet32(PcdConsoleUartBase); - SmdkCmuBase=PcdGet32(PcdCmuBase); - - MmioWrite32 (SmdkCmuBase + CLK_SRC_PERIL0_OFFSET, CLK_SRC_PERIL0_VAL); - MmioWrite32 (SmdkCmuBase + CLK_DIV_PERIL0_OFFSET, CLK_DIV_PERIL0_VAL); - - if (PL011_CONSOLE_UART_SPEED == 115200) { - // Initialize baud rate generator - MmioWrite32 (UARTConsoleBase + UARTIBRD, UART_115200_IDIV); - MmioWrite32 (UARTConsoleBase + UARTFBRD, UART_115200_FDIV); - } else if (PL011_CONSOLE_UART_SPEED == 38400) { - // Initialize baud rate generator - MmioWrite32 (UARTConsoleBase + UARTIBRD, UART_38400_IDIV); - MmioWrite32 (UARTConsoleBase + UARTFBRD, UART_38400_FDIV); - } else if (PL011_CONSOLE_UART_SPEED == 19200) { - // Initialize baud rate generator - MmioWrite32 (UARTConsoleBase + UARTIBRD, UART_19200_IDIV); - MmioWrite32 (UARTConsoleBase + UARTFBRD, UART_19200_FDIV); - } else { - return EFI_INVALID_PARAMETER; - } - - // No parity, 1 stop, no fifo, 8 data bits - MmioWrite32 (UARTConsoleBase + UARTLCR_H, UART_LCON_VAL); - - // configure FIFO contrl regs - MmioWrite32 (UARTConsoleBase + UARTECR, UART_ECR_VAL); - - // enable tx, rx, and uart overall - MmioWrite32 (UARTConsoleBase + UARTCR, UART_CR_VAL); -#endif - return EFI_SUCCESS; -} - -/** - Write data to serial device. - - @param Buffer Point of data buffer which need to be writed. - @param NumberOfBytes Number of output bytes which are cached in Buffer. - - @retval 0 Write data failed. - @retval !0 Actual number of bytes writed to serial device. - -**/ -UINTN -EFIAPI -SerialPortWrite ( - IN UINT8 *Buffer, - IN UINTN NumberOfBytes -) -{ - UINTN Count; - UINT32 UARTConsoleBase; - - UARTConsoleBase=PcdGet32(PcdConsoleUartBase); - for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) { - while ((MmioRead32 (UARTConsoleBase + UTRSTAT_OFFSET) & UART_TX_EMPTY_FLAG_MASK) == 0); - MmioWrite8 (UARTConsoleBase + UTXH_OFFSET, *Buffer); - } - - return NumberOfBytes; -} - -/** - Read data from serial device and save the datas in buffer. - - @param Buffer Point of data buffer which need to be writed. - @param NumberOfBytes Number of output bytes which are cached in Buffer. - - @retval 0 Read data failed. - @retval !0 Aactual number of bytes read from serial device. - -**/ -UINTN -EFIAPI -SerialPortRead ( - OUT UINT8 *Buffer, - IN UINTN NumberOfBytes -) -{ - UINTN Count; - UINT32 UARTConsoleBase; - - UARTConsoleBase=PcdGet32(PcdConsoleUartBase); - for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) { - while ((MmioRead32 (UARTConsoleBase + UTRSTAT_OFFSET) & UART_RX_EMPTY_FLAG_MASK) == 0); - *Buffer = MmioRead8 (UARTConsoleBase + URXH_OFFSET); - } - - return NumberOfBytes; -} - -/** - Check to see if any data is avaiable to be read from the debug device. - - @retval EFI_SUCCESS At least one byte of data is avaiable to be read - @retval EFI_NOT_READY No data is avaiable to be read - @retval EFI_DEVICE_ERROR The serial device is not functioning properly - -**/ -BOOLEAN -EFIAPI -SerialPortPoll ( - VOID - ) -{ - UINT32 UARTConsoleBase; - UARTConsoleBase=PcdGet32(PcdConsoleUartBase); - - return ((MmioRead32 (UARTConsoleBase + UTRSTAT_OFFSET) & UART_RX_EMPTY_FLAG_MASK) != 0); -} - diff --git a/SamsungPlatformPkgOrigen/ExynosPkg/Library/SerialPortLib/SerialPortLib.inf b/SamsungPlatformPkgOrigen/ExynosPkg/Library/SerialPortLib/SerialPortLib.inf deleted file mode 100644 index 73349aa70..000000000 --- a/SamsungPlatformPkgOrigen/ExynosPkg/Library/SerialPortLib/SerialPortLib.inf +++ /dev/null @@ -1,38 +0,0 @@ -#/** @file -# -# Component discription file for NorFlashDxe module -# -# Copyright (c) 2011, Samsung Electronics Co. All rights reserved.<BR> -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = SerialPortLib - FILE_GUID = 8ecefc8f-a2c4-4091-b80f-20f7aeb0567f - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = SerialPortLib - -[Sources.common] - SerialPortLib.c - -[LibraryClasses] - IoLib - -[Packages] - EmbeddedPkg/EmbeddedPkg.dec - MdePkg/MdePkg.dec - # ArmPlatformPkg/ArmPlatformPkg.dec - SamsungPlatformPkgOrigen/ExynosPkg/ExynosPkg.dec - -[FixedPcd] - gExynosPkgTokenSpaceGuid.PcdConsoleUartBase - gExynosPkgTokenSpaceGuid.PcdCmuBase diff --git a/SamsungPlatformPkgOrigen/ExynosPkg/Library/TimerLib/TimerLib.c b/SamsungPlatformPkgOrigen/ExynosPkg/Library/TimerLib/TimerLib.c deleted file mode 100755 index 6baf2cec6..000000000 --- a/SamsungPlatformPkgOrigen/ExynosPkg/Library/TimerLib/TimerLib.c +++ /dev/null @@ -1,234 +0,0 @@ -/** @file - - Copyright (c) 2011, Samsung Electronics Co. All rights reserved.<BR> - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include <Base.h> - -#include <Library/BaseLib.h> -#include <Library/TimerLib.h> -#include <Library/DebugLib.h> -#include <Library/PcdLib.h> -#include <Library/IoLib.h> -#include <Platform/ArmPlatform.h> -#include <Library/ExynosTimerLib.h> - - -// Setup SP810's Timer2 for managing delay functions. And Timer3 for Performance counter -// Note: ArmVE's Timer0 and Timer1 are used by TimerDxe. -RETURN_STATUS -EFIAPI -TimerConstructor ( - VOID - ) -{ - UINT32 PWMTimerBase; - UINT32 rwVal; - - PWMTimerBase = PcdGet32(PcdPWMTimerBase); - -/** - This function is for initializing for PWM Timer - Timer 2 = > Delay Counter - Timer 3 = > Performance Counter -**/ -// PWM Input Clock(ACLK_100) is 100 Mhz so We need to prescale about 1Mhz to make udelay function - rwVal = MmioRead32 (PWMTimerBase + PWM_TCFG0_OFFSET); - rwVal &= ~(0xFF << PRESCALE_GRP1_START_POS); - rwVal |= (PRESCALE_TIMER_GRP1 << PRESCALE_GRP1_START_POS); - MmioWrite32 ((PWMTimerBase + PWM_TCFG0_OFFSET), rwVal); - MmioWrite32 ((PWMTimerBase + PWM_TCFG1_OFFSET), 0x0); - -// PWM Timer INT disable - rwVal = MmioRead32 (PWMTimerBase + PWM_TINT_CSTAT_OFFSET); - MmioWrite32 ((PWMTimerBase + PWM_TINT_CSTAT_OFFSET), rwVal & ~(TIMER_INTR_MASK(TIMER_2) | TIMER_INTR_MASK(TIMER_3))); - -// PWM Timer 2,3 make to stop - rwVal = MmioRead32 (PWMTimerBase + PWM_TCON_OFFSET); - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal & (STOP_TIMER_VAL(TIMER_2) | STOP_TIMER_VAL(TIMER_3))); - -// PWM Timer 3 used by Free running counter with Auto re-load mode - MmioWrite32 ((PWMTimerBase + PWM_TCNTB3_OFFSET), MAX_COUNT_VAL); -// Set and Clear PWM Manually update for Timer 3 - rwVal = MmioRead32 (PWMTimerBase + PWM_TCON_OFFSET); - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal | UPDATE_COUNT_BUF_MASK(TIMER_3)); - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal & ~UPDATE_COUNT_BUF_MASK(TIMER_3)); -// Set Auto re-load and start Timer - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal | RELOAD_AND_START(TIMER_3)); - - DEBUG ((EFI_D_ERROR, "Timer 2,3 Enabled\n")); - - return RETURN_SUCCESS; -} - -/** - Stalls the CPU for at least the given number of microseconds. - - Stalls the CPU for the number of microseconds specified by MicroSeconds. - - @param MicroSeconds The minimum number of microseconds to delay. - - @return The value of MicroSeconds inputted. - -**/ -UINTN -EFIAPI -MicroSecondDelay ( - IN UINTN MicroSeconds - ) -{ - UINT32 rwVal; - UINT32 PWMTimerBase; - - PWMTimerBase=PcdGet32(PcdPWMTimerBase); - // load the timer count register - MmioWrite32 ((PWMTimerBase + PWM_TCNTB2_OFFSET), MicroSeconds); - - -// PWM Timer 2 stop - rwVal = MmioRead32 (PWMTimerBase + PWM_TCON_OFFSET); - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal & STOP_TIMER_VAL(TIMER_2)); - -// Set and Clear PWM Manually update for Timer 2 - rwVal = MmioRead32 (PWMTimerBase + PWM_TCON_OFFSET); - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal | UPDATE_COUNT_BUF_MASK(TIMER_2)); - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal & ~UPDATE_COUNT_BUF_MASK(TIMER_2)); - //Start Timer 2 - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal | START_TIMER(TIMER_2)); - //Wait for requested delay time - while (MmioRead32 (PWMTimerBase + PWM_TCNTO2_OFFSET) > 0) { - ; - } - - return MicroSeconds; -} - -/** - Stalls the CPU for at least the given number of nanoseconds. - - Stalls the CPU for the number of nanoseconds specified by NanoSeconds. - - @param NanoSeconds The minimum number of nanoseconds to delay. - - @return The value of NanoSeconds inputted. - -**/ -UINTN -EFIAPI -NanoSecondDelay ( - IN UINTN NanoSeconds - ) -{ - UINT32 MicroSeconds; - UINT32 rwVal; - UINT32 PWMTimerBase; - - PWMTimerBase=PcdGet32(PcdPWMTimerBase); - - // Round up to 1us Tick Number - MicroSeconds = (UINT32)NanoSeconds / 1000; - MicroSeconds += ((UINT32)NanoSeconds % 1000) == 0 ? 0 : 1; - // load the timer count register - MmioWrite32 ((PWMTimerBase + PWM_TCNTB2_OFFSET), MicroSeconds); - -// PWM Timer 2 stop - rwVal = MmioRead32 (PWMTimerBase + PWM_TCON_OFFSET); - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal & STOP_TIMER_VAL(TIMER_2)); -// Set and Clear PWM Manually update for Timer 2 - rwVal = MmioRead32 (PWMTimerBase + PWM_TCON_OFFSET); - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal | UPDATE_COUNT_BUF_MASK(TIMER_2)); - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal & ~UPDATE_COUNT_BUF_MASK(TIMER_2)); - //Start Timer 2 - rwVal = MmioRead32 (PWMTimerBase + PWM_TCON_OFFSET); - MmioWrite32 ((PWMTimerBase + PWM_TCON_OFFSET), rwVal | START_TIMER(TIMER_2)); - - //Wait for requested delay time - while (MmioRead32 (PWMTimerBase + PWM_TCNTO0_OFFSET) > 0) { - ; - } - - return NanoSeconds; -} - -/** - Retrieves the current value of a 64-bit free running performance counter. - - The counter can either count up by 1 or count down by 1. If the physical - performance counter counts by a larger increment, then the counter values - must be translated. The properties of the counter can be retrieved from - GetPerformanceCounterProperties(). - - @return The current value of the free running performance counter. - -**/ -UINT64 -EFIAPI -GetPerformanceCounter ( - VOID - ) -{ - UINT32 PWMTimerBase; - - PWMTimerBase=PcdGet32(PcdPWMTimerBase); - // Free running 64-bit/32-bit counter is needed here. - // Don't think we need this to boot, just to do performance profile - // ASSERT (FALSE); - UINT32 val = MmioRead32 (PWMTimerBase + PWM_TCNTO3_OFFSET); - - ASSERT(val > 0); - - return (UINT64)val; -} - - -/** - Retrieves the 64-bit frequency in Hz and the range of performance counter - values. - - If StartValue is not NULL, then the value that the performance counter starts - with immediately after is it rolls over is returned in StartValue. If - EndValue is not NULL, then the value that the performance counter end with - immediately before it rolls over is returned in EndValue. The 64-bit - frequency of the performance counter in Hz is always returned. If StartValue - is less than EndValue, then the performance counter counts up. If StartValue - is greater than EndValue, then the performance counter counts down. For - example, a 64-bit free running counter that counts up would have a StartValue - of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter - that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0. - - @param StartValue The value the performance counter starts with when it - rolls over. - @param EndValue The value that the performance counter ends with before - it rolls over. - - @return The frequency in Hz. - -**/ -UINT64 -EFIAPI -GetPerformanceCounterProperties ( - OUT UINT64 *StartValue, OPTIONAL - OUT UINT64 *EndValue OPTIONAL - ) -{ - if (StartValue != NULL) { - // Timer starts with the reload value - *StartValue = (UINT64)0ULL; - } - - if (EndValue != NULL) { - // Timer counts up to 0xFFFFFFFF - *EndValue = 0xFFFFFFFF; - } - - return 1000000; -} diff --git a/SamsungPlatformPkgOrigen/ExynosPkg/Library/TimerLib/TimerLib.inf b/SamsungPlatformPkgOrigen/ExynosPkg/Library/TimerLib/TimerLib.inf deleted file mode 100755 index b62a797e1..000000000 --- a/SamsungPlatformPkgOrigen/ExynosPkg/Library/TimerLib/TimerLib.inf +++ /dev/null @@ -1,41 +0,0 @@ -#/** @file -# Timer library implementation -# -# -# Copyright (c) 2011, Samsung Electronics Co. All rights reserved.<BR> -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = Exynos4210TimerLib - FILE_GUID = 34cfa85e-a798-4e46-8d38-1843d7a0caea - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = TimerLib - - CONSTRUCTOR = TimerConstructor - -[Sources.common] - TimerLib.c - -[Packages] - MdePkg/MdePkg.dec - ArmPkg/ArmPkg.dec - ArmPlatformPkg/ArmPlatformPkg.dec - SamsungPlatformPkgOrigen/ExynosPkg/ExynosPkg.dec - -[LibraryClasses] - DebugLib - IoLib - BaseLib - -[Pcd.common] - gExynosPkgTokenSpaceGuid.PcdPWMTimerBase |