/** @file
Template for Timer Architecture Protocol driver of the ARM flavor
- Copyright (c) 2008-2009, Apple Inc. All rights reserved.
+ Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
- 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 License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
#include <Protocol/Timer.h>
#include <Protocol/HardwareInterrupt.h>
-#include <Protocol/TimerDebugSupport.h>
#include <Omap3530/Omap3530.h>
// The notification function to call on every timer interrupt.
volatile EFI_TIMER_NOTIFY mTimerNotifyFunction = (EFI_TIMER_NOTIFY)NULL;
-volatile EFI_PERIODIC_CALLBACK mTimerPeriodicCallback = (EFI_PERIODIC_CALLBACK)NULL;
// The current period of the timer interrupt
//
OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
-
- if (mTimerPeriodicCallback) {
- mTimerPeriodicCallback(SystemContext);
- }
-
if (mTimerNotifyFunction) {
mTimerNotifyFunction(mTimerPeriod);
}
MmioWrite32 (TISR, TISR_CLEAR_ALL);
// Poll interrupt status bits to ensure clearing
- while ((MmioRead32(TISR) & TISR_ALL_INTERRUPT_MASK) != TISR_NO_INTERRUPTS_PENDING);
+ while ((MmioRead32 (TISR) & TISR_ALL_INTERRUPT_MASK) != TISR_NO_INTERRUPTS_PENDING);
gBS->RestoreTPL (OriginalTPL);
}
Status = gInterrupt->DisableInterruptSource(gInterrupt, gVector);
} else {
// Calculate required timer count
- TimerCount = DivU64x32(TimerPeriod * 100, PcdGet32(PcdEmbeddedFdPerformanceCounterPeriodInNanoseconds));
+ TimerCount = DivU64x32(TimerPeriod * 100, PcdGet32(PcdEmbeddedPerformanceCounterPeriodInNanoseconds));
// Set GPTIMER3 Load register
LoadValue = (INT32) -TimerCount;
}
-EFI_STATUS
-EFIAPI
-TimerDriverRegisterPeriodicCallback (
- IN TIMER_DEBUG_SUPPORT_PROTOCOL *This,
- IN EFI_PERIODIC_CALLBACK PeriodicCallback
- )
-{
- if ((PeriodicCallback == NULL) && (mTimerPeriodicCallback == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((PeriodicCallback != NULL) && (mTimerPeriodicCallback != NULL)) {
- return EFI_ALREADY_STARTED;
- }
-
- mTimerPeriodicCallback = PeriodicCallback;
-
- return EFI_SUCCESS;
-}
-
-
/**
Interface stucture for the Timer Architectural Protocol.
TimerDriverGenerateSoftInterrupt
};
-TIMER_DEBUG_SUPPORT_PROTOCOL gTimerDebugSupport = {
- TimerDriverRegisterPeriodicCallback
-};
-
/**
Initialize the state information for the Timer Architectural Protocol and
UINT32 TimerBaseAddress;
// Find the interrupt controller protocol. ASSERT if not found.
- Status = gBS->LocateProtocol(&gHardwareInterruptProtocolGuid, NULL, (VOID **)&gInterrupt);
+ Status = gBS->LocateProtocol (&gHardwareInterruptProtocolGuid, NULL, (VOID **)&gInterrupt);
ASSERT_EFI_ERROR (Status);
// Set up the timer registers
- TimerBaseAddress = TimerBase(FixedPcdGet32(PcdBeagleArchTimer));
+ TimerBaseAddress = TimerBase (FixedPcdGet32(PcdOmap35xxArchTimer));
TISR = TimerBaseAddress + GPTIMER_TISR;
TCLR = TimerBaseAddress + GPTIMER_TCLR;
TLDR = TimerBaseAddress + GPTIMER_TLDR;
TIER = TimerBaseAddress + GPTIMER_TIER;
// Disable the timer
- Status = TimerDriverSetTimerPeriod(&gTimer, 0);
+ Status = TimerDriverSetTimerPeriod (&gTimer, 0);
ASSERT_EFI_ERROR (Status);
// Install interrupt handler
- gVector = InterruptVectorForTimer(FixedPcdGet32(PcdBeagleArchTimer));
- Status = gInterrupt->RegisterInterruptSource(gInterrupt, gVector, TimerInterruptHandler);
+ gVector = InterruptVectorForTimer (FixedPcdGet32(PcdOmap35xxArchTimer));
+ Status = gInterrupt->RegisterInterruptSource (gInterrupt, gVector, TimerInterruptHandler);
ASSERT_EFI_ERROR (Status);
+ // Turn on the functional clock for Timer
+ MmioOr32 (CM_FCLKEN_PER, CM_FCLKEN_PER_EN_GPT3_ENABLE);
+
// Set up default timer
- Status = TimerDriverSetTimerPeriod(&gTimer, FixedPcdGet32(PcdTimerPeriod));
+ Status = TimerDriverSetTimerPeriod (&gTimer, FixedPcdGet32(PcdTimerPeriod));
ASSERT_EFI_ERROR (Status);
// Install the Timer Architectural Protocol onto a new handle
- Status = gBS->InstallMultipleProtocolInterfaces(&Handle,
- &gEfiTimerArchProtocolGuid, &gTimer,
- &gTimerDebugSupportProtocolGuid, &gTimerDebugSupport,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Handle,
+ &gEfiTimerArchProtocolGuid, &gTimer,
+ NULL
+ );
ASSERT_EFI_ERROR(Status);
return Status;