All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux dev-5.3 0/4] ast2600 timer support
@ 2019-11-06  9:17 Joel Stanley
  2019-11-06  9:17 ` [PATCH linux dev-5.3 1/4] ARM: dts: aspeed-g6: Add timer description Joel Stanley
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Joel Stanley @ 2019-11-06  9:17 UTC (permalink / raw)
  To: openbmc, Cédric Le Goater; +Cc: Andrew Jeffery

In order to use high resolution timers, an ARMv7 system needs an
additional clocksource that is not the arch timer.

The other option is to set the always-on property in the arch timer.
This has been discouraged in the past[1].

I propose we enable the aspeed timer in the openbmc tree, and work out
how to proceed longer term upstream. I've submitted the timer changes
upstream as we can have driver support regardless as to weather we use
it.

[1] https://lore.kernel.org/linux-arm-kernel/341949c8-7864-5d65-2797-988022724a4c@st.com/

Joel Stanley (4):
  ARM: dts: aspeed-g6: Add timer description
  clocksource: fttmr010: Parametrise shutdown
  clocksource: fttmr010: Set interrupt and shutdown
  clocksource: fttmr010: Add support for ast2600

 arch/arm/boot/dts/aspeed-g6.dtsi     | 15 ++++++
 drivers/clocksource/timer-fttmr010.c | 68 ++++++++++++++++++++++------
 2 files changed, 68 insertions(+), 15 deletions(-)

-- 
2.24.0.rc1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH linux dev-5.3 1/4] ARM: dts: aspeed-g6: Add timer description
  2019-11-06  9:17 [PATCH linux dev-5.3 0/4] ast2600 timer support Joel Stanley
@ 2019-11-06  9:17 ` Joel Stanley
  2019-11-06 14:28   ` Cédric Le Goater
  2019-11-06  9:17 ` [PATCH linux dev-5.3 2/4] clocksource: fttmr010: Parametrise shutdown Joel Stanley
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Joel Stanley @ 2019-11-06  9:17 UTC (permalink / raw)
  To: openbmc, Cédric Le Goater; +Cc: Andrew Jeffery

The AST2600 has 8 32-bit timers on the APB bus.

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 arch/arm/boot/dts/aspeed-g6.dtsi | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm/boot/dts/aspeed-g6.dtsi b/arch/arm/boot/dts/aspeed-g6.dtsi
index 6db29ee769d5..e574254f298d 100644
--- a/arch/arm/boot/dts/aspeed-g6.dtsi
+++ b/arch/arm/boot/dts/aspeed-g6.dtsi
@@ -310,6 +310,21 @@
 				status = "disabled";
 			};
 
+			timer: timer@1e782000 {
+				compatible = "aspeed,ast2600-timer";
+				reg = <0x1e782000 0x90>;
+				interrupts-extended = <&gic  GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>,
+						<&gic  GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>,
+						<&gic  GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
+						<&gic  GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>,
+						<&gic  GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>,
+						<&gic  GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>,
+						<&gic  GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>,
+						<&gic  GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&syscon ASPEED_CLK_APB1>;
+				clock-names = "PCLK";
+                        };
+
 			uart1: serial@1e783000 {
 				compatible = "ns16550a";
 				reg = <0x1e783000 0x20>;
-- 
2.24.0.rc1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH linux dev-5.3 2/4] clocksource: fttmr010: Parametrise shutdown
  2019-11-06  9:17 [PATCH linux dev-5.3 0/4] ast2600 timer support Joel Stanley
  2019-11-06  9:17 ` [PATCH linux dev-5.3 1/4] ARM: dts: aspeed-g6: Add timer description Joel Stanley
@ 2019-11-06  9:17 ` Joel Stanley
  2019-11-06 14:32   ` Cédric Le Goater
  2019-11-06  9:17 ` [PATCH linux dev-5.3 3/4] clocksource: fttmr010: Set interrupt and shutdown Joel Stanley
  2019-11-06  9:17 ` [PATCH linux dev-5.3 4/4] clocksource: fttmr010: Add support for ast2600 Joel Stanley
  3 siblings, 1 reply; 9+ messages in thread
From: Joel Stanley @ 2019-11-06  9:17 UTC (permalink / raw)
  To: openbmc, Cédric Le Goater; +Cc: 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] 9+ messages in thread

* [PATCH linux dev-5.3 3/4] clocksource: fttmr010: Set interrupt and shutdown
  2019-11-06  9:17 [PATCH linux dev-5.3 0/4] ast2600 timer support Joel Stanley
  2019-11-06  9:17 ` [PATCH linux dev-5.3 1/4] ARM: dts: aspeed-g6: Add timer description Joel Stanley
  2019-11-06  9:17 ` [PATCH linux dev-5.3 2/4] clocksource: fttmr010: Parametrise shutdown Joel Stanley
@ 2019-11-06  9:17 ` Joel Stanley
  2019-11-06 14:34   ` Cédric Le Goater
  2019-11-06  9:17 ` [PATCH linux dev-5.3 4/4] clocksource: fttmr010: Add support for ast2600 Joel Stanley
  3 siblings, 1 reply; 9+ messages in thread
From: Joel Stanley @ 2019-11-06  9:17 UTC (permalink / raw)
  To: openbmc, Cédric Le Goater; +Cc: 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] 9+ messages in thread

* [PATCH linux dev-5.3 4/4] clocksource: fttmr010: Add support for ast2600
  2019-11-06  9:17 [PATCH linux dev-5.3 0/4] ast2600 timer support Joel Stanley
                   ` (2 preceding siblings ...)
  2019-11-06  9:17 ` [PATCH linux dev-5.3 3/4] clocksource: fttmr010: Set interrupt and shutdown Joel Stanley
@ 2019-11-06  9:17 ` Joel Stanley
  2019-11-06 14:40   ` Cédric Le Goater
  3 siblings, 1 reply; 9+ messages in thread
From: Joel Stanley @ 2019-11-06  9:17 UTC (permalink / raw)
  To: openbmc, Cédric Le Goater; +Cc: 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] 9+ messages in thread

* Re: [PATCH linux dev-5.3 1/4] ARM: dts: aspeed-g6: Add timer description
  2019-11-06  9:17 ` [PATCH linux dev-5.3 1/4] ARM: dts: aspeed-g6: Add timer description Joel Stanley
@ 2019-11-06 14:28   ` Cédric Le Goater
  0 siblings, 0 replies; 9+ messages in thread
From: Cédric Le Goater @ 2019-11-06 14:28 UTC (permalink / raw)
  To: Joel Stanley, openbmc; +Cc: Andrew Jeffery

On 06/11/2019 10:17, Joel Stanley wrote:
> The AST2600 has 8 32-bit timers on the APB bus.
> 
> Signed-off-by: Joel Stanley <joel@jms.id.au>


Reviewed-by: Cédric Le Goater <clg@kaod.org>

> ---
>  arch/arm/boot/dts/aspeed-g6.dtsi | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/aspeed-g6.dtsi b/arch/arm/boot/dts/aspeed-g6.dtsi
> index 6db29ee769d5..e574254f298d 100644
> --- a/arch/arm/boot/dts/aspeed-g6.dtsi
> +++ b/arch/arm/boot/dts/aspeed-g6.dtsi
> @@ -310,6 +310,21 @@
>  				status = "disabled";
>  			};
>  
> +			timer: timer@1e782000 {
> +				compatible = "aspeed,ast2600-timer";
> +				reg = <0x1e782000 0x90>;
> +				interrupts-extended = <&gic  GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>,
> +						<&gic  GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>,
> +						<&gic  GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
> +						<&gic  GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>,
> +						<&gic  GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>,
> +						<&gic  GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>,
> +						<&gic  GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>,
> +						<&gic  GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
> +				clocks = <&syscon ASPEED_CLK_APB1>;
> +				clock-names = "PCLK";
> +                        };
> +
>  			uart1: serial@1e783000 {
>  				compatible = "ns16550a";
>  				reg = <0x1e783000 0x20>;
> 
x

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH linux dev-5.3 2/4] clocksource: fttmr010: Parametrise shutdown
  2019-11-06  9:17 ` [PATCH linux dev-5.3 2/4] clocksource: fttmr010: Parametrise shutdown Joel Stanley
@ 2019-11-06 14:32   ` Cédric Le Goater
  0 siblings, 0 replies; 9+ messages in thread
From: Cédric Le Goater @ 2019-11-06 14:32 UTC (permalink / raw)
  To: Joel Stanley, openbmc; +Cc: Andrew Jeffery

On 06/11/2019 10:17, Joel Stanley 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>


Reviewed-by: Cédric Le Goater <clg@kaod.org>

> ---
>  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,
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH linux dev-5.3 3/4] clocksource: fttmr010: Set interrupt and shutdown
  2019-11-06  9:17 ` [PATCH linux dev-5.3 3/4] clocksource: fttmr010: Set interrupt and shutdown Joel Stanley
@ 2019-11-06 14:34   ` Cédric Le Goater
  0 siblings, 0 replies; 9+ messages in thread
From: Cédric Le Goater @ 2019-11-06 14:34 UTC (permalink / raw)
  To: Joel Stanley, openbmc; +Cc: Andrew Jeffery

On 06/11/2019 10:17, Joel Stanley 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>

Reviewed-by: Cédric Le Goater <clg@kaod.org>

> ---
>  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)

may be rename handler -> irq_handler. This is minor, just better for 
readability.

C. 

>  {
>  	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);
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH linux dev-5.3 4/4] clocksource: fttmr010: Add support for ast2600
  2019-11-06  9:17 ` [PATCH linux dev-5.3 4/4] clocksource: fttmr010: Add support for ast2600 Joel Stanley
@ 2019-11-06 14:40   ` Cédric Le Goater
  0 siblings, 0 replies; 9+ messages in thread
From: Cédric Le Goater @ 2019-11-06 14:40 UTC (permalink / raw)
  To: Joel Stanley, openbmc; +Cc: Andrew Jeffery

On 06/11/2019 10:17, Joel Stanley 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>

Reviewed-by: Cédric Le Goater <clg@kaod.org>

> ---
>  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);
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-11-06 21:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06  9:17 [PATCH linux dev-5.3 0/4] ast2600 timer support Joel Stanley
2019-11-06  9:17 ` [PATCH linux dev-5.3 1/4] ARM: dts: aspeed-g6: Add timer description Joel Stanley
2019-11-06 14:28   ` Cédric Le Goater
2019-11-06  9:17 ` [PATCH linux dev-5.3 2/4] clocksource: fttmr010: Parametrise shutdown Joel Stanley
2019-11-06 14:32   ` Cédric Le Goater
2019-11-06  9:17 ` [PATCH linux dev-5.3 3/4] clocksource: fttmr010: Set interrupt and shutdown Joel Stanley
2019-11-06 14:34   ` Cédric Le Goater
2019-11-06  9:17 ` [PATCH linux dev-5.3 4/4] clocksource: fttmr010: Add support for ast2600 Joel Stanley
2019-11-06 14:40   ` Cédric Le Goater

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.