public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org
Cc: leif.lindholm@linaro.org, Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH edk2-platforms 3/4] Silicon/SynQuacer: set CNTFRQ field of MMIO timer frame
Date: Mon, 29 Jan 2018 15:44:15 +0000	[thread overview]
Message-ID: <20180129154416.3622-4-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20180129154416.3622-1-ard.biesheuvel@linaro.org>

Even though the ARM ARM quite clearly states that the CNTFRQ field of
each MMIO timer frame should be a read-only alias of the CNTFRQ field
of the base frame, the SynQuacer SoC implements it as a register that
is programmable separately.

So let's program it from the hardware rather than overriding the
frequency using a DT property.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi           |  1 -
 Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c   | 18 ++++++++++++++++++
 Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h   |  1 +
 Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf |  2 ++
 Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h        |  3 +++
 5 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi
index 12b90a64da8b..3db3c5ed1c50 100644
--- a/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi
+++ b/Silicon/Socionext/SynQuacer/DeviceTree/SynQuacer.dtsi
@@ -368,7 +368,6 @@
     mmio-timer@2a810000 {
         compatible = "arm,armv7-timer-mem";
         reg = <0x0 0x2a810000 0x0 0x10000>;
-        clock-frequency = <100000000>;
         #address-cells = <2>;
         #size-cells = <2>;
         ranges;
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
index 7d7d2ec80e8e..aab830dc3a5a 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
@@ -174,6 +174,23 @@ SmmuEnableCoherentDma (
     SMMU_SCR0_SHCFG_INNER | SMMU_SCR0_MTCFG | SMMU_SCR0_MEMATTR_INNER_OUTER_WB);
 }
 
+#define MMIO_TIMER_CNTFRQ_OFFSET          0x10
+
+STATIC
+VOID
+SetMmioTimerFrequency (
+  VOID
+  )
+{
+  //
+  // Initialize the CNTFRQ field of the first non-secure MMIO timer frame.
+  // This field should be a read-only alias of the global frequency register
+  // but in reality, it is a separate field that needs to be set explicitly.
+  //
+  MmioWrite32 (SYNQUACER_MMIO_TIMER_CNT_BASE0 + MMIO_TIMER_CNTFRQ_OFFSET,
+    ArmGenericTimerGetTimerFreq ());
+}
+
 STATIC
 EFI_STATUS
 InstallHiiPages (
@@ -297,6 +314,7 @@ PlatformDxeEntryPoint (
   ASSERT_EFI_ERROR (Status);
 
   SmmuEnableCoherentDma ();
+  SetMmioTimerFrequency ();
 
   Status = RegisterPcieNotifier ();
   ASSERT_EFI_ERROR (Status);
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h
index b109bd359e13..a391d2f67c29 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.h
@@ -18,6 +18,7 @@
 #include <PiDxe.h>
 #include <Guid/SynQuacerPlatformFormSet.h>
 #include <IndustryStandard/Pci.h>
+#include <Library/ArmGenericTimerCounterLib.h>
 #include <Library/BaseLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
index e13e16f3da6b..49d9deee57ea 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
@@ -30,6 +30,7 @@ [Sources]
   PlatformDxeHii.vfr
 
 [Packages]
+  ArmPkg/ArmPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
@@ -38,6 +39,7 @@ [Packages]
   Silicon/Socionext/SynQuacer/SynQuacer.dec
 
 [LibraryClasses]
+  ArmGenericTimerCounterLib
   BaseLib
   BaseMemoryLib
   DebugLib
diff --git a/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h b/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h
index f43adcc8607f..fff760477488 100644
--- a/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h
+++ b/Silicon/Socionext/SynQuacer/Include/Platform/MemoryMap.h
@@ -69,4 +69,7 @@
 #define SYNQUACER_SCB_SMMU_BASE         0x52E00000
 #define SYNQUACER_SCB_SMMU_SIZE         SIZE_64KB
 
+#define SYNQUACER_MMIO_TIMER_CTL_BASE   0x2A810000
+#define SYNQUACER_MMIO_TIMER_CNT_BASE0  0x2A830000
+
 #endif
-- 
2.11.0



  parent reply	other threads:[~2018-01-29 15:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29 15:44 [PATCH edk2-platforms 0/4] SynQuacer: assorted updates Ard Biesheuvel
2018-01-29 15:44 ` [PATCH edk2-platforms 1/4] Platform/SynQuacerEvalBoard: add RamDiskDxe driver to build Ard Biesheuvel
2018-01-29 15:44 ` [PATCH edk2-platforms 2/4] Platform/SynQuacerEvalBoard: add BGRT and ConsolePrefDxe drivers Ard Biesheuvel
2018-01-29 15:44 ` Ard Biesheuvel [this message]
2018-01-29 15:44 ` [PATCH edk2-platforms 4/4] Silicon/SynQuacerPlatformFlashAccessLib: add capsule update progress bar Ard Biesheuvel
2018-01-29 15:50 ` [PATCH edk2-platforms 0/4] SynQuacer: assorted updates Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180129154416.3622-4-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox