* [PATCH 0/4] clocksource: Add ast2600 support to fttmr010
@ 2019-11-06 6:02 Joel Stanley
2019-11-06 6:02 ` [PATCH 1/4] clocksource: fttmr010: Parametrise shutdown Joel Stanley
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Joel Stanley @ 2019-11-06 6:02 UTC (permalink / raw)
To: Daniel Lezcano, Rob Herring
Cc: Thomas Gleixner, linux-kernel, devicetree, Linus Walleij, Andrew Jeffery
This series adds support for the AST2600 timer.
Joel Stanley (4):
clocksource: fttmr010: Parametrise shutdown
clocksource: fttmr010: Set interrupt and shutdown
clocksource: fttmr010: Add support for ast2600
dt-bindings: fttmr010: Add ast2600 compatible
.../bindings/timer/faraday,fttmr010.txt | 1 +
drivers/clocksource/timer-fttmr010.c | 68 +++++++++++++++----
2 files changed, 54 insertions(+), 15 deletions(-)
--
2.24.0.rc1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/4] clocksource: fttmr010: Parametrise shutdown
2019-11-06 6:02 [PATCH 0/4] clocksource: Add ast2600 support to fttmr010 Joel Stanley
@ 2019-11-06 6:02 ` Joel Stanley
2019-11-07 7:47 ` Linus Walleij
2019-11-06 6:02 ` [PATCH 2/4] clocksource: fttmr010: Set interrupt and shutdown Joel Stanley
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Joel Stanley @ 2019-11-06 6:02 UTC (permalink / raw)
To: Daniel Lezcano, Rob Herring
Cc: Thomas Gleixner, linux-kernel, devicetree, Linus Walleij, Andrew Jeffery
In preparation for supporting the ast2600 which uses a different method
to clear bits in the control register, use a callback for performing the
shutdown sequence.
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
drivers/clocksource/timer-fttmr010.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c
index fadff7915dd9..c2d30eb9dc72 100644
--- a/drivers/clocksource/timer-fttmr010.c
+++ b/drivers/clocksource/timer-fttmr010.c
@@ -97,6 +97,7 @@ struct fttmr010 {
bool is_aspeed;
u32 t1_enable_val;
struct clock_event_device clkevt;
+ int (*timer_shutdown)(struct clock_event_device *evt);
#ifdef CONFIG_ARM
struct delay_timer delay_timer;
#endif
@@ -140,9 +141,7 @@ static int fttmr010_timer_set_next_event(unsigned long cycles,
u32 cr;
/* Stop */
- cr = readl(fttmr010->base + TIMER_CR);
- cr &= ~fttmr010->t1_enable_val;
- writel(cr, fttmr010->base + TIMER_CR);
+ fttmr010->timer_shutdown(evt);
if (fttmr010->is_aspeed) {
/*
@@ -183,9 +182,7 @@ static int fttmr010_timer_set_oneshot(struct clock_event_device *evt)
u32 cr;
/* Stop */
- cr = readl(fttmr010->base + TIMER_CR);
- cr &= ~fttmr010->t1_enable_val;
- writel(cr, fttmr010->base + TIMER_CR);
+ fttmr010->timer_shutdown(evt);
/* Setup counter start from 0 or ~0 */
writel(0, fttmr010->base + TIMER1_COUNT);
@@ -211,9 +208,7 @@ static int fttmr010_timer_set_periodic(struct clock_event_device *evt)
u32 cr;
/* Stop */
- cr = readl(fttmr010->base + TIMER_CR);
- cr &= ~fttmr010->t1_enable_val;
- writel(cr, fttmr010->base + TIMER_CR);
+ fttmr010->timer_shutdown(evt);
/* Setup timer to fire at 1/HZ intervals. */
if (fttmr010->is_aspeed) {
@@ -350,6 +345,8 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
fttmr010->tick_rate);
}
+ fttmr010->timer_shutdown = fttmr010_timer_shutdown;
+
/*
* Setup clockevent timer (interrupt-driven) on timer 1.
*/
@@ -370,10 +367,10 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
fttmr010->clkevt.features = CLOCK_EVT_FEAT_PERIODIC |
CLOCK_EVT_FEAT_ONESHOT;
fttmr010->clkevt.set_next_event = fttmr010_timer_set_next_event;
- fttmr010->clkevt.set_state_shutdown = fttmr010_timer_shutdown;
+ fttmr010->clkevt.set_state_shutdown = fttmr010->timer_shutdown;
fttmr010->clkevt.set_state_periodic = fttmr010_timer_set_periodic;
fttmr010->clkevt.set_state_oneshot = fttmr010_timer_set_oneshot;
- fttmr010->clkevt.tick_resume = fttmr010_timer_shutdown;
+ fttmr010->clkevt.tick_resume = fttmr010->timer_shutdown;
fttmr010->clkevt.cpumask = cpumask_of(0);
fttmr010->clkevt.irq = irq;
clockevents_config_and_register(&fttmr010->clkevt,
--
2.24.0.rc1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/4] clocksource: fttmr010: Set interrupt and shutdown
2019-11-06 6:02 [PATCH 0/4] clocksource: Add ast2600 support to fttmr010 Joel Stanley
2019-11-06 6:02 ` [PATCH 1/4] clocksource: fttmr010: Parametrise shutdown Joel Stanley
@ 2019-11-06 6:02 ` Joel Stanley
2019-11-07 7:48 ` Linus Walleij
2019-11-06 6:03 ` [PATCH 3/4] clocksource: fttmr010: Add support for ast2600 Joel Stanley
2019-11-06 6:03 ` [PATCH 4/4] dt-bindings: fttmr010: Add ast2600 compatible Joel Stanley
3 siblings, 1 reply; 11+ messages in thread
From: Joel Stanley @ 2019-11-06 6:02 UTC (permalink / raw)
To: Daniel Lezcano, Rob Herring
Cc: Thomas Gleixner, linux-kernel, devicetree, Linus Walleij, Andrew Jeffery
In preparation for supporting the ast2600, pass the shutdown and
interrupt functions to the common init callback.
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
drivers/clocksource/timer-fttmr010.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c
index c2d30eb9dc72..8a79025339d0 100644
--- a/drivers/clocksource/timer-fttmr010.c
+++ b/drivers/clocksource/timer-fttmr010.c
@@ -244,7 +244,10 @@ 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 int __init fttmr010_common_init(struct device_node *np,
+ bool is_aspeed,
+ int (*timer_shutdown)(struct clock_event_device *),
+ irq_handler_t handler)
{
struct fttmr010 *fttmr010;
int irq;
@@ -345,7 +348,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 +357,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, handler, IRQF_TIMER,
"FTTMR010-TIMER1", &fttmr010->clkevt);
if (ret) {
pr_err("FTTMR010-TIMER1 no IRQ\n");
@@ -403,12 +406,16 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed)
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);
--
2.24.0.rc1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/4] clocksource: fttmr010: Add support for ast2600
2019-11-06 6:02 [PATCH 0/4] clocksource: Add ast2600 support to fttmr010 Joel Stanley
2019-11-06 6:02 ` [PATCH 1/4] clocksource: fttmr010: Parametrise shutdown Joel Stanley
2019-11-06 6:02 ` [PATCH 2/4] clocksource: fttmr010: Set interrupt and shutdown Joel Stanley
@ 2019-11-06 6:03 ` Joel Stanley
2019-11-07 7:50 ` Linus Walleij
2019-11-06 6:03 ` [PATCH 4/4] dt-bindings: fttmr010: Add ast2600 compatible Joel Stanley
3 siblings, 1 reply; 11+ messages in thread
From: Joel Stanley @ 2019-11-06 6:03 UTC (permalink / raw)
To: Daniel Lezcano, Rob Herring
Cc: Thomas Gleixner, linux-kernel, devicetree, Linus Walleij, Andrew Jeffery
The ast2600 has some minor differences to previous versions. The
interrupt handler must acknowledge the timer interrupt in a status
register. Secondly the control register becomes write to set only,
requiring the use of a separate set to clear register.
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
drivers/clocksource/timer-fttmr010.c | 34 ++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c
index 8a79025339d0..688d540ebddd 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 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 + TIMER_CR_CLR);
+
+ return 0;
+}
+
static int fttmr010_timer_shutdown(struct clock_event_device *evt)
{
struct fttmr010 *fttmr010 = to_fttmr010(evt);
@@ -244,6 +259,17 @@ static irqreturn_t fttmr010_timer_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}
+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 *),
@@ -404,6 +430,13 @@ static int __init fttmr010_common_init(struct device_node *np,
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,
@@ -423,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.24.0.rc1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/4] dt-bindings: fttmr010: Add ast2600 compatible
2019-11-06 6:02 [PATCH 0/4] clocksource: Add ast2600 support to fttmr010 Joel Stanley
` (2 preceding siblings ...)
2019-11-06 6:03 ` [PATCH 3/4] clocksource: fttmr010: Add support for ast2600 Joel Stanley
@ 2019-11-06 6:03 ` Joel Stanley
2019-11-07 0:47 ` Rob Herring
2019-11-07 7:51 ` Linus Walleij
3 siblings, 2 replies; 11+ messages in thread
From: Joel Stanley @ 2019-11-06 6:03 UTC (permalink / raw)
To: Daniel Lezcano, Rob Herring
Cc: Thomas Gleixner, linux-kernel, devicetree, Linus Walleij, Andrew Jeffery
The ast2600 contains a fttmr010 derivative.
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
Documentation/devicetree/bindings/timer/faraday,fttmr010.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/timer/faraday,fttmr010.txt b/Documentation/devicetree/bindings/timer/faraday,fttmr010.txt
index 195792270414..3cb2f4c98d64 100644
--- a/Documentation/devicetree/bindings/timer/faraday,fttmr010.txt
+++ b/Documentation/devicetree/bindings/timer/faraday,fttmr010.txt
@@ -11,6 +11,7 @@ Required properties:
"moxa,moxart-timer", "faraday,fttmr010"
"aspeed,ast2400-timer"
"aspeed,ast2500-timer"
+ "aspeed,ast2600-timer"
- reg : Should contain registers location and length
- interrupts : Should contain the three timer interrupts usually with
--
2.24.0.rc1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] dt-bindings: fttmr010: Add ast2600 compatible
2019-11-06 6:03 ` [PATCH 4/4] dt-bindings: fttmr010: Add ast2600 compatible Joel Stanley
@ 2019-11-07 0:47 ` Rob Herring
2019-11-07 7:51 ` Linus Walleij
1 sibling, 0 replies; 11+ messages in thread
From: Rob Herring @ 2019-11-07 0:47 UTC (permalink / raw)
To: Joel Stanley
Cc: Daniel Lezcano, Thomas Gleixner, linux-kernel, devicetree,
Linus Walleij, Andrew Jeffery
On Wed, 6 Nov 2019 16:33:01 +1030, Joel Stanley wrote:
> The ast2600 contains a fttmr010 derivative.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
> Documentation/devicetree/bindings/timer/faraday,fttmr010.txt | 1 +
> 1 file changed, 1 insertion(+)
>
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] clocksource: fttmr010: Parametrise shutdown
2019-11-06 6:02 ` [PATCH 1/4] clocksource: fttmr010: Parametrise shutdown Joel Stanley
@ 2019-11-07 7:47 ` Linus Walleij
2019-11-07 9:43 ` Joel Stanley
0 siblings, 1 reply; 11+ messages in thread
From: Linus Walleij @ 2019-11-07 7:47 UTC (permalink / raw)
To: Joel Stanley
Cc: Daniel Lezcano, Rob Herring, Thomas Gleixner, linux-kernel,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Andrew Jeffery
On Wed, Nov 6, 2019 at 7:03 AM Joel Stanley <joel@jms.id.au> wrote:
> In preparation for supporting the ast2600 which uses a different method
> to clear bits in the control register, use a callback for performing the
> shutdown sequence.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
Nice refactoring!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/4] clocksource: fttmr010: Set interrupt and shutdown
2019-11-06 6:02 ` [PATCH 2/4] clocksource: fttmr010: Set interrupt and shutdown Joel Stanley
@ 2019-11-07 7:48 ` Linus Walleij
0 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2019-11-07 7:48 UTC (permalink / raw)
To: Joel Stanley
Cc: Daniel Lezcano, Rob Herring, Thomas Gleixner, linux-kernel,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Andrew Jeffery
On Wed, Nov 6, 2019 at 7:03 AM Joel Stanley <joel@jms.id.au> wrote:
> In preparation for supporting the ast2600, pass the shutdown and
> interrupt functions to the common init callback.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
Provided the latter patches making use of it are OKed;
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/4] clocksource: fttmr010: Add support for ast2600
2019-11-06 6:03 ` [PATCH 3/4] clocksource: fttmr010: Add support for ast2600 Joel Stanley
@ 2019-11-07 7:50 ` Linus Walleij
0 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2019-11-07 7:50 UTC (permalink / raw)
To: Joel Stanley
Cc: Daniel Lezcano, Rob Herring, Thomas Gleixner, linux-kernel,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Andrew Jeffery
On Wed, Nov 6, 2019 at 7:03 AM Joel Stanley <joel@jms.id.au> wrote:
> The ast2600 has some minor differences to previous versions. The
> interrupt handler must acknowledge the timer interrupt in a status
> register. Secondly the control register becomes write to set only,
> requiring the use of a separate set to clear register.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> +/*
> + Control register set to clear for ast2600 only.
> + */
> +#define TIMER_CR_CLR (0x3c)
If it is AST2600-specific then please add some AST2600 prefix such as
AST2600_TIMER_CR_CLR (0x3c)
With that:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] dt-bindings: fttmr010: Add ast2600 compatible
2019-11-06 6:03 ` [PATCH 4/4] dt-bindings: fttmr010: Add ast2600 compatible Joel Stanley
2019-11-07 0:47 ` Rob Herring
@ 2019-11-07 7:51 ` Linus Walleij
1 sibling, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2019-11-07 7:51 UTC (permalink / raw)
To: Joel Stanley
Cc: Daniel Lezcano, Rob Herring, Thomas Gleixner, linux-kernel,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Andrew Jeffery
On Wed, Nov 6, 2019 at 7:03 AM Joel Stanley <joel@jms.id.au> wrote:
> The ast2600 contains a fttmr010 derivative.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] clocksource: fttmr010: Parametrise shutdown
2019-11-07 7:47 ` Linus Walleij
@ 2019-11-07 9:43 ` Joel Stanley
0 siblings, 0 replies; 11+ messages in thread
From: Joel Stanley @ 2019-11-07 9:43 UTC (permalink / raw)
To: Linus Walleij
Cc: Daniel Lezcano, Rob Herring, Thomas Gleixner, linux-kernel,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Andrew Jeffery
On Thu, 7 Nov 2019 at 07:47, Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Wed, Nov 6, 2019 at 7:03 AM Joel Stanley <joel@jms.id.au> wrote:
>
> > In preparation for supporting the ast2600 which uses a different method
> > to clear bits in the control register, use a callback for performing the
> > shutdown sequence.
> >
> > Signed-off-by: Joel Stanley <joel@jms.id.au>
>
> Nice refactoring!
Cheers. Thank you for the prompt review!
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
> Yours,
> Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-11-07 9:43 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06 6:02 [PATCH 0/4] clocksource: Add ast2600 support to fttmr010 Joel Stanley
2019-11-06 6:02 ` [PATCH 1/4] clocksource: fttmr010: Parametrise shutdown Joel Stanley
2019-11-07 7:47 ` Linus Walleij
2019-11-07 9:43 ` Joel Stanley
2019-11-06 6:02 ` [PATCH 2/4] clocksource: fttmr010: Set interrupt and shutdown Joel Stanley
2019-11-07 7:48 ` Linus Walleij
2019-11-06 6:03 ` [PATCH 3/4] clocksource: fttmr010: Add support for ast2600 Joel Stanley
2019-11-07 7:50 ` Linus Walleij
2019-11-06 6:03 ` [PATCH 4/4] dt-bindings: fttmr010: Add ast2600 compatible Joel Stanley
2019-11-07 0:47 ` Rob Herring
2019-11-07 7:51 ` Linus Walleij
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).