From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, Joel Stanley <joel@jms.id.au>
Subject: [PATCH 02/21] clocksource/drivers/fttmr010: Set interrupt and shutdown
Date: Wed, 18 Mar 2020 18:41:12 +0100 [thread overview]
Message-ID: <20200318174131.20582-2-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20200318174131.20582-1-daniel.lezcano@linaro.org>
From: Joel Stanley <joel@jms.id.au>
In preparation for supporting the ast2600, pass the shutdown and
interrupt functions to the common init callback.
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20191107094218.13210-3-joel@jms.id.au
---
drivers/clocksource/timer-fttmr010.c | 51 +++++++++++++++++++++++++---
1 file changed, 46 insertions(+), 5 deletions(-)
diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c
index c2d30eb9dc72..edb1d5f193f5 100644
--- a/drivers/clocksource/timer-fttmr010.c
+++ b/drivers/clocksource/timer-fttmr010.c
@@ -37,6 +37,11 @@
#define TIMER3_MATCH2 (0x2c)
#define TIMER_CR (0x30)
+/*
+ * Control register set to clear for ast2600 only.
+ */
+#define AST2600_TIMER_CR_CLR (0x3c)
+
/*
* Control register (TMC30) bit fields for fttmr010/gemini/moxart timers.
*/
@@ -163,6 +168,16 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
return 0;
}
+static int ast2600_timer_shutdown(struct clock_event_device *evt)
+{
+ struct fttmr010 *fttmr010 = to_fttmr010(evt);
+
+ /* Stop */
+ writel(fttmr010->t1_enable_val, fttmr010->base + AST2600_TIMER_CR_CLR);
+
+ return 0;
+}
+
static int fttmr010_timer_shutdown(struct clock_event_device *evt)
{
struct fttmr010 *fttmr010 = to_fttmr010(evt);
@@ -244,7 +259,21 @@ static irqreturn_t fttmr010_timer_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}
-static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
+static irqreturn_t ast2600_timer_interrupt(int irq, void *dev_id)
+{
+ struct clock_event_device *evt = dev_id;
+ struct fttmr010 *fttmr010 = to_fttmr010(evt);
+
+ writel(0x1, fttmr010->base + TIMER_INTR_STATE);
+
+ evt->event_handler(evt);
+ return IRQ_HANDLED;
+}
+
+static int __init fttmr010_common_init(struct device_node *np,
+ bool is_aspeed,
+ int (*timer_shutdown)(struct clock_event_device *),
+ irq_handler_t irq_handler)
{
struct fttmr010 *fttmr010;
int irq;
@@ -345,7 +374,7 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
fttmr010->tick_rate);
}
- fttmr010->timer_shutdown = fttmr010_timer_shutdown;
+ fttmr010->timer_shutdown = timer_shutdown;
/*
* Setup clockevent timer (interrupt-driven) on timer 1.
@@ -354,7 +383,7 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
writel(0, fttmr010->base + TIMER1_LOAD);
writel(0, fttmr010->base + TIMER1_MATCH1);
writel(0, fttmr010->base + TIMER1_MATCH2);
- ret = request_irq(irq, fttmr010_timer_interrupt, IRQF_TIMER,
+ ret = request_irq(irq, irq_handler, IRQF_TIMER,
"FTTMR010-TIMER1", &fttmr010->clkevt);
if (ret) {
pr_err("FTTMR010-TIMER1 no IRQ\n");
@@ -401,14 +430,25 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
return ret;
}
+static __init int ast2600_timer_init(struct device_node *np)
+{
+ return fttmr010_common_init(np, true,
+ ast2600_timer_shutdown,
+ ast2600_timer_interrupt);
+}
+
static __init int aspeed_timer_init(struct device_node *np)
{
- return fttmr010_common_init(np, true);
+ return fttmr010_common_init(np, true,
+ fttmr010_timer_shutdown,
+ fttmr010_timer_interrupt);
}
static __init int fttmr010_timer_init(struct device_node *np)
{
- return fttmr010_common_init(np, false);
+ return fttmr010_common_init(np, false,
+ fttmr010_timer_shutdown,
+ fttmr010_timer_interrupt);
}
TIMER_OF_DECLARE(fttmr010, "faraday,fttmr010", fttmr010_timer_init);
@@ -416,3 +456,4 @@ TIMER_OF_DECLARE(gemini, "cortina,gemini-timer", fttmr010_timer_init);
TIMER_OF_DECLARE(moxart, "moxa,moxart-timer", fttmr010_timer_init);
TIMER_OF_DECLARE(ast2400, "aspeed,ast2400-timer", aspeed_timer_init);
TIMER_OF_DECLARE(ast2500, "aspeed,ast2500-timer", aspeed_timer_init);
+TIMER_OF_DECLARE(ast2600, "aspeed,ast2600-timer", ast2600_timer_init);
--
2.17.1
next prev parent reply other threads:[~2020-03-18 17:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-18 17:38 [GIT PULL] timer drivers for v5.7 Daniel Lezcano
2020-03-18 17:41 ` [PATCH 01/21] clocksource/drivers/fttmr010: Parametrise shutdown Daniel Lezcano
2020-03-18 17:41 ` Daniel Lezcano [this message]
2020-03-18 17:41 ` [PATCH 03/21] dt-bindings: fttmr010: Add ast2600 compatible Daniel Lezcano
2020-03-18 17:41 ` [PATCH 04/21] clocksource: Add driver for the Ingenic JZ47xx OST Daniel Lezcano
2020-03-18 17:41 ` [PATCH 05/21] clocksource/drivers/owl: Improve owl_timer_init fail messages Daniel Lezcano
2020-03-18 17:41 ` [PATCH 06/21] clocksource/drivers/timer-ti-dm: Do not update counter on updating the period Daniel Lezcano
2020-03-18 17:41 ` [PATCH 07/21] clocksource/drivers/timer-ti-dm: Drop bogus omap_dm_timer_of_set_source() Daniel Lezcano
2020-03-18 17:41 ` [PATCH 08/21] dt-bindings: timer: Add X1000 bindings Daniel Lezcano
2020-03-18 17:41 ` [PATCH 09/21] clocksource/drivers/ingenic: Add support for TCU of X1000 Daniel Lezcano
2020-03-18 17:41 ` [PATCH 10/21] clocksource: Replace setup_irq() by request_irq() Daniel Lezcano
2020-03-27 10:24 ` Linus Walleij
2020-03-18 17:41 ` [PATCH 11/21] clocksource/drivers/timer-cs5535: Request irq with non-NULL dev_id Daniel Lezcano
2020-03-18 17:41 ` [PATCH 12/21] clocksource/drivers/timer-microchip-pit64b: Fix rate for gck Daniel Lezcano
2020-03-18 17:41 ` [PATCH 13/21] clocksource/drivers/timer-ti-dm: Convert to SPDX identifier Daniel Lezcano
2020-03-18 17:41 ` [PATCH 14/21] clocksource/drivers/timer-ti-dm: Prepare for using cpuidle Daniel Lezcano
2020-03-18 17:41 ` [PATCH 15/21] clocksource/drivers/timer-ti-dm: Implement cpu_pm notifier for context save and restore Daniel Lezcano
2020-03-18 17:41 ` [PATCH 16/21] clocksource/drivers/timer-ti-dm: Do not update counter on updating the period Daniel Lezcano
2020-03-18 17:41 ` [PATCH 17/21] clocksource/drivers/timer-ti-dm: Add support to get pwm current status Daniel Lezcano
2020-03-18 17:41 ` [PATCH 18/21] clocksource/drivers/timer-ti-dm: Enable autoreload in set_pwm Daniel Lezcano
2020-03-18 17:41 ` [PATCH 19/21] clocksource/drivers/imx-tpm: Remove unused includes Daniel Lezcano
2020-03-18 17:41 ` [PATCH 20/21] clocksource/drivers/imx-sysctr: " Daniel Lezcano
2020-03-18 17:41 ` [PATCH 21/21] clocksource/drivers/timer-probe: Avoid creating dead devices Daniel Lezcano
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=20200318174131.20582-2-daniel.lezcano@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=joel@jms.id.au \
--cc=linux-kernel@vger.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: 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).