From: Vincent Whitchurch <vincent.whitchurch@axis.com> To: <krzysztof.kozlowski@canonical.com>, <tglx@linutronix.de>, <daniel.lezcano@linaro.org> Cc: <kernel@axis.com>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-samsung-soc@vger.kernel.org>, <devicetree@vger.kernel.org>, <alim.akhtar@samsung.com>, <robh+dt@kernel.org>, Vincent Whitchurch <vincent.whitchurch@axis.com> Subject: [PATCH v2 3/4] clocksource/drivers/exynos_mct: Support local-timer-index property Date: Tue, 8 Mar 2022 15:24:09 +0100 [thread overview] Message-ID: <20220308142410.3193729-4-vincent.whitchurch@axis.com> (raw) In-Reply-To: <20220308142410.3193729-1-vincent.whitchurch@axis.com> 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@axis.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
WARNING: multiple messages have this Message-ID (diff)
From: Vincent Whitchurch <vincent.whitchurch@axis.com> To: <krzysztof.kozlowski@canonical.com>, <tglx@linutronix.de>, <daniel.lezcano@linaro.org> Cc: <kernel@axis.com>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-samsung-soc@vger.kernel.org>, <devicetree@vger.kernel.org>, <alim.akhtar@samsung.com>, <robh+dt@kernel.org>, Vincent Whitchurch <vincent.whitchurch@axis.com> Subject: [PATCH v2 3/4] clocksource/drivers/exynos_mct: Support local-timer-index property Date: Tue, 8 Mar 2022 15:24:09 +0100 [thread overview] Message-ID: <20220308142410.3193729-4-vincent.whitchurch@axis.com> (raw) In-Reply-To: <20220308142410.3193729-1-vincent.whitchurch@axis.com> 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@axis.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-03-08 14:24 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-08 14:24 [PATCH v2 0/4] clocksource: Add MCT support for ARTPEC-8 Vincent Whitchurch 2022-03-08 14:24 ` Vincent Whitchurch 2022-03-08 14:24 ` [PATCH v2 1/4] dt-bindings: timer: exynos4210-mct: Add ARTPEC-8 MCT Vincent Whitchurch 2022-03-08 14:24 ` Vincent Whitchurch 2022-03-08 14:37 ` Krzysztof Kozlowski 2022-03-08 14:37 ` Krzysztof Kozlowski 2022-03-08 14:24 ` [PATCH v2 2/4] dt-bindings: timer: exynos4210-mct: Support using only local timer Vincent Whitchurch 2022-03-08 14:24 ` Vincent Whitchurch 2022-03-08 14:44 ` Krzysztof Kozlowski 2022-03-08 14:44 ` Krzysztof Kozlowski 2022-03-08 14:24 ` Vincent Whitchurch [this message] 2022-03-08 14:24 ` [PATCH v2 3/4] clocksource/drivers/exynos_mct: Support local-timer-index property Vincent Whitchurch 2022-03-08 14:57 ` Krzysztof Kozlowski 2022-03-08 14:57 ` Krzysztof Kozlowski 2022-03-11 11:35 ` Vincent Whitchurch 2022-03-11 11:35 ` Vincent Whitchurch 2022-03-11 12:51 ` Krzysztof Kozlowski 2022-03-11 12:51 ` Krzysztof Kozlowski 2022-03-21 8:00 ` Marek Szyprowski 2022-03-21 8:00 ` Marek Szyprowski 2022-03-30 8:21 ` Vincent Whitchurch 2022-03-30 8:21 ` Vincent Whitchurch 2022-04-07 7:48 ` Vincent Whitchurch 2022-04-07 7:48 ` Vincent Whitchurch 2022-03-08 14:24 ` [PATCH v2 4/4] clocksource/drivers/exynos_mct: Enable building on ARTPEC Vincent Whitchurch 2022-03-08 14:24 ` Vincent Whitchurch 2022-03-08 14:58 ` Krzysztof Kozlowski 2022-03-08 14:58 ` Krzysztof Kozlowski
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=20220308142410.3193729-4-vincent.whitchurch@axis.com \ --to=vincent.whitchurch@axis.com \ --cc=alim.akhtar@samsung.com \ --cc=daniel.lezcano@linaro.org \ --cc=devicetree@vger.kernel.org \ --cc=kernel@axis.com \ --cc=krzysztof.kozlowski@canonical.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-samsung-soc@vger.kernel.org \ --cc=robh+dt@kernel.org \ --cc=tglx@linutronix.de \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.