2014-09-09 18:07:43 +02:00
|
|
|
/** @file
|
|
|
|
|
|
|
|
Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
|
|
|
|
Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
|
|
|
|
|
2019-04-04 01:03:18 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2014-09-09 18:07:43 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include <Library/ArmGenericTimerCounterLib.h>
|
2017-01-20 12:58:37 +01:00
|
|
|
#include <Library/ArmLib.h>
|
2014-09-09 18:07:43 +02:00
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerEnableTimer (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN TimerCtrlReg;
|
|
|
|
|
2017-01-20 12:58:37 +01:00
|
|
|
TimerCtrlReg = ArmReadCntvCtl ();
|
2014-09-09 18:07:43 +02:00
|
|
|
TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntvCtl (TimerCtrlReg);
|
2014-09-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
2018-04-23 16:47:18 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerReenableTimer (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-09-09 18:07:43 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerDisableTimer (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN TimerCtrlReg;
|
|
|
|
|
2017-01-20 12:58:37 +01:00
|
|
|
TimerCtrlReg = ArmReadCntvCtl ();
|
2014-09-09 18:07:43 +02:00
|
|
|
TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntvCtl (TimerCtrlReg);
|
2014-09-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerSetTimerFreq (
|
|
|
|
IN UINTN FreqInHz
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntFrq (FreqInHz);
|
2014-09-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINTN
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerGetTimerFreq (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
return ArmReadCntFrq ();
|
2014-09-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINTN
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerGetTimerVal (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
return ArmReadCntvTval ();
|
2014-09-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerSetTimerVal (
|
|
|
|
IN UINTN Value
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntvTval (Value);
|
2014-09-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerGetSystemCount (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
return ArmReadCntvCt ();
|
2014-09-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINTN
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerGetTimerCtrlReg (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
return ArmReadCntvCtl ();
|
2014-09-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerSetTimerCtrlReg (
|
|
|
|
UINTN Value
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntvCtl (Value);
|
2014-09-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerGetCompareVal (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
return ArmReadCntvCval ();
|
2014-09-09 18:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerSetCompareVal (
|
|
|
|
IN UINT64 Value
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntvCval (Value);
|
2014-09-09 18:07:43 +02:00
|
|
|
}
|