]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
UBUNTU: SAUCE: arm64: arch_timer: Move arch_timer_reg_read/write around
authorMarc Zyngier <marc.zyngier@arm.com>
Fri, 20 Jan 2017 18:28:32 +0000 (18:28 +0000)
committerTim Gardner <tim.gardner@canonical.com>
Tue, 28 Mar 2017 20:17:54 +0000 (14:17 -0600)
BugLink: https://bugs.launchpad.net/bugs/1675509
As we're about to move things around, let's start with the low
level read/write functions. This allows us to use these functions
in the errata handling code without having to use forward declaration
of static functions.

Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
(cherry picked from commit 685cbf2298afcf404bd519361c0915154ba48c89
 in the timers/errata-rework branch of
 git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/clocksource/arm_arch_timer.c

index 7e7e8721478b8483104159de9ead86e61e12ed77..3e6a5a5d9bd3ffa334b657259b0d4cc972fb20b6 100644 (file)
@@ -95,6 +95,68 @@ early_param("clocksource.arm_arch_timer.evtstrm", early_evtstrm_cfg);
  * Architected system timer support.
  */
 
+static __always_inline
+void arch_timer_reg_write(int access, enum arch_timer_reg reg, u32 val,
+                         struct clock_event_device *clk)
+{
+       if (access == ARCH_TIMER_MEM_PHYS_ACCESS) {
+               struct arch_timer *timer = to_arch_timer(clk);
+               switch (reg) {
+               case ARCH_TIMER_REG_CTRL:
+                       writel_relaxed(val, timer->base + CNTP_CTL);
+                       break;
+               case ARCH_TIMER_REG_TVAL:
+                       writel_relaxed(val, timer->base + CNTP_TVAL);
+                       break;
+               }
+       } else if (access == ARCH_TIMER_MEM_VIRT_ACCESS) {
+               struct arch_timer *timer = to_arch_timer(clk);
+               switch (reg) {
+               case ARCH_TIMER_REG_CTRL:
+                       writel_relaxed(val, timer->base + CNTV_CTL);
+                       break;
+               case ARCH_TIMER_REG_TVAL:
+                       writel_relaxed(val, timer->base + CNTV_TVAL);
+                       break;
+               }
+       } else {
+               arch_timer_reg_write_cp15(access, reg, val);
+       }
+}
+
+static __always_inline
+u32 arch_timer_reg_read(int access, enum arch_timer_reg reg,
+                       struct clock_event_device *clk)
+{
+       u32 val;
+
+       if (access == ARCH_TIMER_MEM_PHYS_ACCESS) {
+               struct arch_timer *timer = to_arch_timer(clk);
+               switch (reg) {
+               case ARCH_TIMER_REG_CTRL:
+                       val = readl_relaxed(timer->base + CNTP_CTL);
+                       break;
+               case ARCH_TIMER_REG_TVAL:
+                       val = readl_relaxed(timer->base + CNTP_TVAL);
+                       break;
+               }
+       } else if (access == ARCH_TIMER_MEM_VIRT_ACCESS) {
+               struct arch_timer *timer = to_arch_timer(clk);
+               switch (reg) {
+               case ARCH_TIMER_REG_CTRL:
+                       val = readl_relaxed(timer->base + CNTV_CTL);
+                       break;
+               case ARCH_TIMER_REG_TVAL:
+                       val = readl_relaxed(timer->base + CNTV_TVAL);
+                       break;
+               }
+       } else {
+               val = arch_timer_reg_read_cp15(access, reg);
+       }
+
+       return val;
+}
+
 #ifdef CONFIG_FSL_ERRATUM_A008585
 /*
  * The number of retries is an arbitrary value well beyond the highest number
@@ -293,68 +355,6 @@ static void arch_timer_check_ool_workaround(enum arch_timer_erratum_match_type t
 #define arch_timer_check_ool_workaround(t,a)           do { } while(0)
 #endif /* CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND */
 
-static __always_inline
-void arch_timer_reg_write(int access, enum arch_timer_reg reg, u32 val,
-                         struct clock_event_device *clk)
-{
-       if (access == ARCH_TIMER_MEM_PHYS_ACCESS) {
-               struct arch_timer *timer = to_arch_timer(clk);
-               switch (reg) {
-               case ARCH_TIMER_REG_CTRL:
-                       writel_relaxed(val, timer->base + CNTP_CTL);
-                       break;
-               case ARCH_TIMER_REG_TVAL:
-                       writel_relaxed(val, timer->base + CNTP_TVAL);
-                       break;
-               }
-       } else if (access == ARCH_TIMER_MEM_VIRT_ACCESS) {
-               struct arch_timer *timer = to_arch_timer(clk);
-               switch (reg) {
-               case ARCH_TIMER_REG_CTRL:
-                       writel_relaxed(val, timer->base + CNTV_CTL);
-                       break;
-               case ARCH_TIMER_REG_TVAL:
-                       writel_relaxed(val, timer->base + CNTV_TVAL);
-                       break;
-               }
-       } else {
-               arch_timer_reg_write_cp15(access, reg, val);
-       }
-}
-
-static __always_inline
-u32 arch_timer_reg_read(int access, enum arch_timer_reg reg,
-                       struct clock_event_device *clk)
-{
-       u32 val;
-
-       if (access == ARCH_TIMER_MEM_PHYS_ACCESS) {
-               struct arch_timer *timer = to_arch_timer(clk);
-               switch (reg) {
-               case ARCH_TIMER_REG_CTRL:
-                       val = readl_relaxed(timer->base + CNTP_CTL);
-                       break;
-               case ARCH_TIMER_REG_TVAL:
-                       val = readl_relaxed(timer->base + CNTP_TVAL);
-                       break;
-               }
-       } else if (access == ARCH_TIMER_MEM_VIRT_ACCESS) {
-               struct arch_timer *timer = to_arch_timer(clk);
-               switch (reg) {
-               case ARCH_TIMER_REG_CTRL:
-                       val = readl_relaxed(timer->base + CNTV_CTL);
-                       break;
-               case ARCH_TIMER_REG_TVAL:
-                       val = readl_relaxed(timer->base + CNTV_TVAL);
-                       break;
-               }
-       } else {
-               val = arch_timer_reg_read_cp15(access, reg);
-       }
-
-       return val;
-}
-
 static __always_inline irqreturn_t timer_handler(const int access,
                                        struct clock_event_device *evt)
 {