]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Omap35xxPkg/Omap35xxTimerLib: Create a TimerConstructor in the TimerLib
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 6 Jul 2011 12:52:01 +0000 (12:52 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 6 Jul 2011 12:52:01 +0000 (12:52 +0000)
This constructor should be explicitely called by the Sec or PrePi phase
to initialize the OMAP353x timers.

This function is a copy of the Timer initialization function in BeagleBoardPkg/Sec.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11988 6f19259b-4bc3-4df7-8a09-765794883524

Omap35xxPkg/Library/Omap35xxTimerLib/TimerLib.c

index efd3d1a22316beb2bd3deb9ac394ec3cc8b83bed..0b610208057a896523973670c39ba12c72925d98 100644 (file)
@@ -12,7 +12,7 @@
 \r
 **/\r
 \r
-#include <Base.h>\r
+#include <Uefi.h>\r
 \r
 #include <Library/BaseLib.h>\r
 #include <Library/TimerLib.h>\r
 \r
 #include <Omap3530/Omap3530.h>\r
 \r
+RETURN_STATUS\r
+EFIAPI\r
+TimerConstructor (\r
+  VOID\r
+  )\r
+{\r
+  UINTN  Timer            = PcdGet32(PcdOmap35xxFreeTimer);\r
+  UINT32 TimerBaseAddress = TimerBase(Timer);\r
+\r
+  if ((MmioRead32 (TimerBaseAddress + GPTIMER_TCLR) & TCLR_ST_ON) == 0) {\r
+    // Set source clock for GPT3 & GPT4 to SYS_CLK\r
+    MmioOr32 (CM_CLKSEL_PER, CM_CLKSEL_PER_CLKSEL_GPT3_SYS | CM_CLKSEL_PER_CLKSEL_GPT4_SYS);\r
+\r
+    // Set count & reload registers\r
+    MmioWrite32 (TimerBaseAddress + GPTIMER_TCRR, 0x00000000);\r
+    MmioWrite32 (TimerBaseAddress + GPTIMER_TLDR, 0x00000000);\r
+\r
+    // Disable interrupts\r
+    MmioWrite32 (TimerBaseAddress + GPTIMER_TIER, TIER_TCAR_IT_DISABLE | TIER_OVF_IT_DISABLE | TIER_MAT_IT_DISABLE);\r
+\r
+    // Start Timer\r
+    MmioWrite32 (TimerBaseAddress + GPTIMER_TCLR, TCLR_AR_AUTORELOAD | TCLR_ST_ON);\r
+\r
+    // Disable OMAP Watchdog timer (WDT2)\r
+    MmioWrite32 (WDTIMER2_BASE + WSPR, 0xAAAA);\r
+    DEBUG ((EFI_D_ERROR, "Magic delay to disable watchdog timers properly.\n"));\r
+    MmioWrite32 (WDTIMER2_BASE + WSPR, 0x5555);\r
+  }\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 UINTN\r
 EFIAPI\r
 MicroSecondDelay (\r