linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: cinifr@gmail.com (Fan Rong)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] Add physical count arch timer support for clocksource in ARMv7.
Date: Thu, 12 Sep 2013 14:51:26 +0800	[thread overview]
Message-ID: <1378968687-8200-4-git-send-email-cinifr@gmail.com> (raw)
In-Reply-To: <1378968687-8200-1-git-send-email-cinifr@gmail.com>

Signed-off-by: Fan Rong <cinifr@gmail.com>
---
 arch/arm/include/asm/arch_timer.h    |   11 +++++++++++
 drivers/clocksource/Kconfig          |    8 ++++++++
 drivers/clocksource/arm_arch_timer.c |   10 +++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
index 5665134..24c904a 100644
--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -87,6 +87,17 @@ static inline u64 arch_counter_get_cntvct(void)
 	return cval;
 }
 
+static inline u64 arch_counter_get_cntpct(void)
+{
+	u64 cval;
+
+	isb();
+	asm volatile("mrrc p15, 0, %Q0, %R0, c14" : "=r" (cval));
+	return cval;
+}
+
+
+
 static inline void arch_counter_set_user_access(void)
 {
 	u32 cntkctl;
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 41c6946..a4981d2 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -109,3 +109,11 @@ config VF_PIT_TIMER
 	bool
 	help
 	  Support for Period Interrupt Timer on Freescale Vybrid Family SoCs.
+menu "Clock Source"
+
+config ARM_ARCH_TIMER_USE_PHYCNT
+	bool "Use Physical Count Timer"
+	depends on ARM_ARCH_TIMER
+	help
+          If bootloader dont set Virtual Offset register,Physical Count Timer is needed to replace Virtual Count Timer.
+endmenu
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index fbd9ccd..884e4d1 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -372,7 +372,11 @@ static u64 arch_counter_get_cntvct_mem(void)
  * to exist on arm64. arm doesn't use this before DT is probed so even
  * if we don't have the cp15 accessors we won't have a problem.
  */
-u64 (*arch_timer_read_counter)(void) = arch_counter_get_cntvct;
+#ifdef CONFIG_ARM_ARCH_TIMER_USE_PHYCNT
+	u64 (*arch_timer_read_counter)(void) = arch_counter_get_cntpct;
+#else
+	u64 (*arch_timer_read_counter)(void) = arch_counter_get_cntvct;
+#endif
 
 static cycle_t arch_counter_read(struct clocksource *cs)
 {
@@ -410,7 +414,11 @@ static void __init arch_counter_register(unsigned type)
 
 	/* Register the CP15 based counter if we have one */
 	if (type & ARCH_CP15_TIMER)
+#ifdef CONFIG_ARM_ARCH_TIMER_USE_PHYCNT
+		arch_timer_read_counter = arch_counter_get_cntpct;
+#else
 		arch_timer_read_counter = arch_counter_get_cntvct;
+#endif
 	else
 		arch_timer_read_counter = arch_counter_get_cntvct_mem;
 
-- 
1.7.9.5

  parent reply	other threads:[~2013-09-12  6:51 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-12  6:51 [PATCH 0/4] Add smp support for Allwinner A20 and phy arch count timer Fan Rong
2013-09-12  6:51 ` [PATCH 1/4] Add smp support for Allwinner A20(sunxi 7i) Fan Rong
2013-09-12 14:26   ` Mark Rutland
2013-09-12 15:53     ` cinifr
2013-09-12 14:40   ` Russell King - ARM Linux
2013-09-12  6:51 ` [PATCH 2/4] Add cpuconfig nodes in dts for smp configure Fan Rong
2013-09-14 11:50   ` Maxime Ripard
2013-09-12  6:51 ` Fan Rong [this message]
2013-09-12 11:24   ` [PATCH 3/4] Add physical count arch timer support for clocksource in ARMv7 Mark Rutland
2013-09-12 14:33     ` Russell King - ARM Linux
2013-09-12 16:09       ` cinifr
2013-09-12 15:39     ` [linux-sunxi] " Ian Campbell
2013-09-12 16:07     ` cinifr
2013-09-12 16:39       ` Marc Zyngier
2013-09-13  8:49         ` cinifr
2013-09-13  9:30           ` Marc Zyngier
2013-09-13 13:09             ` cinifr
2013-09-13 13:40               ` Marc Zyngier
2013-09-13 14:55                 ` cinifr
2013-09-18  9:03                 ` cinifr
2013-09-14 12:05             ` maxime.ripard at free-electrons.com
2013-09-16  8:16               ` Marc Zyngier
2013-09-12  6:51 ` [PATCH 4/4] Add arch count timer node in dts for Allwinner A20(sunxi 7i) Fan Rong
2013-09-12 14:57   ` Mark Rutland
2013-09-12 15:44     ` [linux-sunxi] " Ian Campbell
2013-09-12 16:23       ` cinifr
2013-09-12 19:53         ` Henrik Nordström
2013-09-12 14:39 ` [PATCH 0/4] Add smp support for Allwinner A20 and phy arch count timer Mark Rutland
2013-09-12 15:46   ` cinifr
2013-09-13 11:20     ` Mark Rutland
2013-09-13 13:23       ` cinifr

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-all 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=1378968687-8200-4-git-send-email-cinifr@gmail.com \
    --to=cinifr@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).