]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Drivers/TimerDxe/TimerDxe.c
ArmPkg/Drivers/TimerDxe: Improve Timer initialisation.
[mirror_edk2.git] / ArmPkg / Drivers / TimerDxe / TimerDxe.c
index cbc34e8e412123515087f7e3e0080fbb93d84b44..dabcc8313b6304b391b03326af4c9d8163bacf02 100644 (file)
@@ -1,15 +1,15 @@
 /** @file\r
   Timer Architecture Protocol driver of the ARM flavor\r
 \r
-  Copyright (c) 2011 ARM Ltd. All rights reserved.<BR>\r
-  \r
-  This program and the accompanying materials                          \r
-  are licensed and made available under the terms and conditions of the BSD License         \r
-  which accompanies this distribution.  The full text of the license may be found at        \r
-  http://opensource.org/licenses/bsd-license.php                                            \r
+  Copyright (c) 2011-2013 ARM Ltd. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
 \r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
 \r
@@ -336,6 +336,10 @@ TimerInitialize (
   ASSERT_EFI_ERROR (Status);\r
 \r
   // Disable the timer\r
+  TimerCtrlReg = ArmArchTimerGetTimerCtrlReg ();\r
+  TimerCtrlReg |= ARM_ARCH_TIMER_IMASK;\r
+  TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;\r
+  ArmArchTimerSetTimerCtrlReg (TimerCtrlReg);\r
   Status = TimerDriverSetTimerPeriod (&gTimer, 0);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
@@ -349,11 +353,6 @@ TimerInitialize (
   Status = gInterrupt->RegisterInterruptSource (gInterrupt, PcdGet32 (PcdArmArchTimerIntrNum), TimerInterruptHandler);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  // Unmask timer interrupts\r
-  TimerCtrlReg = ArmArchTimerGetTimerCtrlReg ();\r
-  TimerCtrlReg &= ~ARM_ARCH_TIMER_IMASK;\r
-  ArmArchTimerSetTimerCtrlReg (TimerCtrlReg);\r
-\r
   // Set up default timer\r
   Status = TimerDriverSetTimerPeriod (&gTimer, FixedPcdGet32(PcdTimerPeriod)); // TIMER_DEFAULT_PERIOD\r
   ASSERT_EFI_ERROR (Status);\r
@@ -366,11 +365,9 @@ TimerInitialize (
                   );\r
   ASSERT_EFI_ERROR(Status);\r
 \r
-  // enable Secure timer interrupts\r
-  Status = gInterrupt->EnableInterruptSource (gInterrupt, PcdGet32 (PcdArmArchTimerSecIntrNum));\r
-\r
-  // enable NonSecure timer interrupts\r
-  Status = gInterrupt->EnableInterruptSource (gInterrupt, PcdGet32 (PcdArmArchTimerIntrNum));\r
+  // Everything is ready, unmask and enable timer interrupts\r
+  TimerCtrlReg = ARM_ARCH_TIMER_ENABLE;\r
+  ArmArchTimerSetTimerCtrlReg (TimerCtrlReg);\r
 \r
   // Register for an ExitBootServicesEvent\r
   Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, ExitBootServicesEvent, NULL, &EfiExitBootServicesEvent);\r