[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220308142410.3193729-4-vincent.whitchurch@axis.com>
Date: Tue, 8 Mar 2022 15:24:09 +0100
From: Vincent Whitchurch <vincent.whitchurch@...s.com>
To: <krzysztof.kozlowski@...onical.com>, <tglx@...utronix.de>,
<daniel.lezcano@...aro.org>
CC: <kernel@...s.com>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-samsung-soc@...r.kernel.org>, <devicetree@...r.kernel.org>,
<alim.akhtar@...sung.com>, <robh+dt@...nel.org>,
Vincent Whitchurch <vincent.whitchurch@...s.com>
Subject: [PATCH v2 3/4] clocksource/drivers/exynos_mct: Support local-timer-index property
Support the documented semantics of the local-timer-index property: Use
it as the first index of the local timer, ensure that global timer clock
events device is not registered, and don't write to the global FRC if it
is already started.
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@...s.com>
---
Notes:
v2: Use devicetree property instead of module parameter.
drivers/clocksource/exynos_mct.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
index f29c812b70c9..5f8b516614eb 100644
--- a/drivers/clocksource/exynos_mct.c
+++ b/drivers/clocksource/exynos_mct.c
@@ -33,7 +33,7 @@
#define EXYNOS4_MCT_G_INT_ENB EXYNOS4_MCTREG(0x248)
#define EXYNOS4_MCT_G_WSTAT EXYNOS4_MCTREG(0x24C)
#define _EXYNOS4_MCT_L_BASE EXYNOS4_MCTREG(0x300)
-#define EXYNOS4_MCT_L_BASE(x) (_EXYNOS4_MCT_L_BASE + (0x100 * x))
+#define EXYNOS4_MCT_L_BASE(x) (_EXYNOS4_MCT_L_BASE + (0x100 * (x)))
#define EXYNOS4_MCT_L_MASK (0xffffff00)
#define MCT_L_TCNTB_OFFSET (0x00)
@@ -75,6 +75,7 @@ enum {
static void __iomem *reg_base;
static unsigned long clk_rate;
static unsigned int mct_int_type;
+static unsigned int mct_local_idx;
static int mct_irqs[MCT_NR_IRQS];
struct mct_clock_event_device {
@@ -157,6 +158,17 @@ static void exynos4_mct_frc_start(void)
u32 reg;
reg = readl_relaxed(reg_base + EXYNOS4_MCT_G_TCON);
+
+ /*
+ * If the FRC is already running, we don't need to start it again. We
+ * could probably just do this on all systems, but, to avoid any risk
+ * for regressions, we only do it on systems where it's absolutely
+ * necessary (i.e., on systems where writes to the global registers
+ * need to be avoided).
+ */
+ if (mct_local_idx && (reg & MCT_G_TCON_START))
+ return;
+
reg |= MCT_G_TCON_START;
exynos4_mct_write(reg, EXYNOS4_MCT_G_TCON);
}
@@ -449,7 +461,7 @@ static int exynos4_mct_starting_cpu(unsigned int cpu)
per_cpu_ptr(&percpu_mct_tick, cpu);
struct clock_event_device *evt = &mevt->evt;
- mevt->base = EXYNOS4_MCT_L_BASE(cpu);
+ mevt->base = EXYNOS4_MCT_L_BASE(mct_local_idx + cpu);
snprintf(mevt->name, sizeof(mevt->name), "mct_tick%d", cpu);
evt->name = mevt->name;
@@ -554,13 +566,14 @@ static int __init exynos4_timer_interrupts(struct device_node *np,
} else {
for_each_possible_cpu(cpu) {
int mct_irq;
+ unsigned int irqidx = MCT_L0_IRQ + mct_local_idx + cpu;
struct mct_clock_event_device *pcpu_mevt =
per_cpu_ptr(&percpu_mct_tick, cpu);
pcpu_mevt->evt.irq = -1;
- if (MCT_L0_IRQ + cpu >= ARRAY_SIZE(mct_irqs))
+ if (irqidx >= ARRAY_SIZE(mct_irqs))
break;
- mct_irq = mct_irqs[MCT_L0_IRQ + cpu];
+ mct_irq = mct_irqs[irqidx];
irq_set_status_flags(mct_irq, IRQ_NOAUTOEN);
if (request_irq(mct_irq,
@@ -607,6 +620,8 @@ static int __init mct_init_dt(struct device_node *np, unsigned int int_type)
{
int ret;
+ of_property_read_u32(np, "local-timer-index", &mct_local_idx);
+
ret = exynos4_timer_resources(np);
if (ret)
return ret;
@@ -619,7 +634,7 @@ static int __init mct_init_dt(struct device_node *np, unsigned int int_type)
if (ret)
return ret;
- return exynos4_clockevent_init();
+ return (mct_local_idx == 0) ? exynos4_clockevent_init() : ret;
}
--
2.34.1
Powered by blists - more mailing lists