linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] kill get_clock_tick_rate()
@ 2016-09-19 19:12 Robert Jarzmik
  2016-09-19 19:12 ` [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator Robert Jarzmik
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Robert Jarzmik @ 2016-09-19 19:12 UTC (permalink / raw)
  To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
	Michael Turquette, Stephen Boyd, Daniel Lezcano, Thomas Gleixner,
	Wim Van Sebroeck
  Cc: linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

Hi,

This serie aims at killing get_clock_tick_rate() from pxa and sa1100 and replace
it by clock API calls.

I'd like to have this reviewed and acked afterwards at least by :
 - Russell for the mach-sa1100 and sa1100_wdt.c
 - Stephen or Michael for the clk-pxa25x.c
 - Thomas or Daniel for the clocksource part
 - Wim for sa1100_wdt.c

If the review converges, I'd also like to take it through the pxa/for-next tree,
or alternatively Russell's tree if there is a dependency I'm not seeing, for
v4.10 cycle.

Cheers.

Robert Jarzmik (3):
  ARM: sa11x0/pxa: acquire timer rate from the clock rate
  watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
  ARM: sa11x0/pxa: get rid of get_clock_tick_rate

Russell King - ARM Linux (1):
  clk: pxa25x: OSTIMER0 clocks from the main oscillator

 arch/arm/mach-pxa/generic.c                  | 18 +-----------------
 arch/arm/mach-pxa/include/mach/hardware.h    |  2 --
 arch/arm/mach-sa1100/generic.c               |  2 +-
 arch/arm/mach-sa1100/include/mach/hardware.h |  4 ----
 drivers/clk/pxa/clk-pxa25x.c                 |  2 +-
 drivers/clocksource/pxa_timer.c              | 11 +++++------
 drivers/watchdog/sa1100_wdt.c                | 24 +++++++++++++++++++++++-
 include/clocksource/pxa.h                    |  3 +--
 8 files changed, 32 insertions(+), 34 deletions(-)

-- 
2.1.4

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

* [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator
  2016-09-19 19:12 [PATCH 0/4] kill get_clock_tick_rate() Robert Jarzmik
@ 2016-09-19 19:12 ` Robert Jarzmik
  2016-09-19 19:23   ` Stephen Boyd
  2016-09-19 19:12 ` [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate Robert Jarzmik
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 19+ messages in thread
From: Robert Jarzmik @ 2016-09-19 19:12 UTC (permalink / raw)
  To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
	Michael Turquette, Stephen Boyd, Daniel Lezcano, Thomas Gleixner,
	Wim Van Sebroeck
  Cc: linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog, Russell King

From: Russell King - ARM Linux <linux@armlinux.org.uk>

The OSTIMER0 clock ticks at the main oscillator rate, not the 32kHz
oscillator rate.  Ensure that it is parented to the main oscillator.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 drivers/clk/pxa/clk-pxa25x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/pxa/clk-pxa25x.c b/drivers/clk/pxa/clk-pxa25x.c
index a98b98e2a9e4..56b0a6027e38 100644
--- a/drivers/clk/pxa/clk-pxa25x.c
+++ b/drivers/clk/pxa/clk-pxa25x.c
@@ -230,7 +230,7 @@ static struct dummy_clk dummy_clks[] __initdata = {
 	DUMMY_CLK("GPIO11_CLK", NULL, "osc_3_6864mhz"),
 	DUMMY_CLK("GPIO12_CLK", NULL, "osc_32_768khz"),
 	DUMMY_CLK(NULL, "sa1100-rtc", "osc_32_768khz"),
-	DUMMY_CLK("OSTIMER0", NULL, "osc_32_768khz"),
+	DUMMY_CLK("OSTIMER0", NULL, "osc_3_6864mhz"),
 	DUMMY_CLK("UARTCLK", "pxa2xx-ir", "STUART"),
 };
 
-- 
2.1.4

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

* [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate
  2016-09-19 19:12 [PATCH 0/4] kill get_clock_tick_rate() Robert Jarzmik
  2016-09-19 19:12 ` [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator Robert Jarzmik
@ 2016-09-19 19:12 ` Robert Jarzmik
  2016-09-19 19:48   ` Daniel Lezcano
  2016-09-26 21:57   ` Russell King - ARM Linux
  2016-09-19 19:12 ` [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Robert Jarzmik
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 19+ messages in thread
From: Robert Jarzmik @ 2016-09-19 19:12 UTC (permalink / raw)
  To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
	Michael Turquette, Stephen Boyd, Daniel Lezcano, Thomas Gleixner,
	Wim Van Sebroeck
  Cc: linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

As both pxa and sa1100 provide a clock to the timer, the rate can be
inferred from the clock rather than hard encoded in a functional call.

This patch changes the pxa timer to have a mandatory clock which is used
as the timer rate.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 arch/arm/mach-pxa/generic.c     |  3 +--
 arch/arm/mach-sa1100/generic.c  |  2 +-
 drivers/clocksource/pxa_timer.c | 11 +++++------
 include/clocksource/pxa.h       |  3 +--
 4 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index ec510ecf8370..2a9297991d74 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -69,8 +69,7 @@ void __init pxa_timer_init(void)
 		pxa27x_clocks_init();
 	if (cpu_is_pxa3xx())
 		pxa3xx_clocks_init();
-	pxa_timer_nodt_init(IRQ_OST0, io_p2v(0x40a00000),
-			    get_clock_tick_rate());
+	pxa_timer_nodt_init(IRQ_OST0, io_p2v(0x40a00000));
 }
 
 /*
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index 3e09beddb6e8..2eb00691b07d 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -378,7 +378,7 @@ void __init sa1100_map_io(void)
 
 void __init sa1100_timer_init(void)
 {
-	pxa_timer_nodt_init(IRQ_OST0, io_p2v(0x90000000), 3686400);
+	pxa_timer_nodt_init(IRQ_OST0, io_p2v(0x90000000));
 }
 
 static struct resource irq_resource =
diff --git a/drivers/clocksource/pxa_timer.c b/drivers/clocksource/pxa_timer.c
index 3e1cb512f3ce..9cae38eebec2 100644
--- a/drivers/clocksource/pxa_timer.c
+++ b/drivers/clocksource/pxa_timer.c
@@ -220,17 +220,16 @@ CLOCKSOURCE_OF_DECLARE(pxa_timer, "marvell,pxa-timer", pxa_timer_dt_init);
 /*
  * Legacy timer init for non device-tree boards.
  */
-void __init pxa_timer_nodt_init(int irq, void __iomem *base,
-	unsigned long clock_tick_rate)
+void __init pxa_timer_nodt_init(int irq, void __iomem *base)
 {
 	struct clk *clk;
 
 	timer_base = base;
 	clk = clk_get(NULL, "OSTIMER0");
-	if (clk && !IS_ERR(clk))
+	if (clk && !IS_ERR(clk)) {
 		clk_prepare_enable(clk);
-	else
+		pxa_timer_common_init(irq, clk_get_rate(clk));
+	} else {
 		pr_crit("%s: unable to get clk\n", __func__);
-
-	pxa_timer_common_init(irq, clock_tick_rate);
+	}
 }
diff --git a/include/clocksource/pxa.h b/include/clocksource/pxa.h
index 1efbe5a66958..a9a0f03024a4 100644
--- a/include/clocksource/pxa.h
+++ b/include/clocksource/pxa.h
@@ -12,7 +12,6 @@
 #ifndef _CLOCKSOURCE_PXA_H
 #define _CLOCKSOURCE_PXA_H
 
-extern void pxa_timer_nodt_init(int irq, void __iomem *base,
-			   unsigned long clock_tick_rate);
+extern void pxa_timer_nodt_init(int irq, void __iomem *base);
 
 #endif
-- 
2.1.4

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

* [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
  2016-09-19 19:12 [PATCH 0/4] kill get_clock_tick_rate() Robert Jarzmik
  2016-09-19 19:12 ` [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator Robert Jarzmik
  2016-09-19 19:12 ` [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate Robert Jarzmik
@ 2016-09-19 19:12 ` Robert Jarzmik
  2016-09-19 20:08   ` Guenter Roeck
                     ` (3 more replies)
  2016-09-19 19:12 ` [PATCH 4/4] ARM: " Robert Jarzmik
  2016-09-26 19:29 ` [PATCH 0/4] kill get_clock_tick_rate() Robert Jarzmik
  4 siblings, 4 replies; 19+ messages in thread
From: Robert Jarzmik @ 2016-09-19 19:12 UTC (permalink / raw)
  To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
	Michael Turquette, Stephen Boyd, Daniel Lezcano, Thomas Gleixner,
	Wim Van Sebroeck
  Cc: linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

The OS timer rate used for the watchdog can now be fetched from the
standard clock API. This will remove the last user of
get_clock_tick_rate() in both pxa and sa11x0 architectures.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 drivers/watchdog/sa1100_wdt.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/sa1100_wdt.c b/drivers/watchdog/sa1100_wdt.c
index e1d39a1e9628..8965e3f536c3 100644
--- a/drivers/watchdog/sa1100_wdt.c
+++ b/drivers/watchdog/sa1100_wdt.c
@@ -22,6 +22,7 @@
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/clk.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
@@ -155,12 +156,27 @@ static struct miscdevice sa1100dog_miscdev = {
 };
 
 static int margin __initdata = 60;		/* (secs) Default is 1 minute */
+static struct clk *clk;
 
 static int __init sa1100dog_init(void)
 {
 	int ret;
 
-	oscr_freq = get_clock_tick_rate();
+	clk = clk_get(NULL, "OSTIMER0");
+	if (IS_ERR(clk)) {
+		pr_err("SA1100/PXA2xx Watchdog Timer: clock not found: %d\n",
+		       (int) PTR_ERR(clk));
+		return PTR_ERR(clk);
+	}
+
+	ret = clk_prepare_enable(clk);
+	if (ret) {
+		pr_err("SA1100/PXA2xx Watchdog Timer: clock failed to prepare+enable: %d\n",
+		       ret);
+		goto err;
+	}
+
+	oscr_freq = clk_get_rate(clk);
 
 	/*
 	 * Read the reset status, and save it for later.  If
@@ -176,11 +192,17 @@ static int __init sa1100dog_init(void)
 		pr_info("SA1100/PXA2xx Watchdog Timer: timer margin %d sec\n",
 			margin);
 	return ret;
+err:
+	clk_disable_unprepare(clk);
+	clk_put(clk);
+	return ret;
 }
 
 static void __exit sa1100dog_exit(void)
 {
 	misc_deregister(&sa1100dog_miscdev);
+	clk_disable_unprepare(clk);
+	clk_put(clk);
 }
 
 module_init(sa1100dog_init);
-- 
2.1.4

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

* [PATCH 4/4] ARM: sa11x0/pxa: get rid of get_clock_tick_rate
  2016-09-19 19:12 [PATCH 0/4] kill get_clock_tick_rate() Robert Jarzmik
                   ` (2 preceding siblings ...)
  2016-09-19 19:12 ` [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Robert Jarzmik
@ 2016-09-19 19:12 ` Robert Jarzmik
  2016-09-19 19:58   ` Daniel Lezcano
  2016-09-26 21:58   ` Russell King - ARM Linux
  2016-09-26 19:29 ` [PATCH 0/4] kill get_clock_tick_rate() Robert Jarzmik
  4 siblings, 2 replies; 19+ messages in thread
From: Robert Jarzmik @ 2016-09-19 19:12 UTC (permalink / raw)
  To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Russell King,
	Michael Turquette, Stephen Boyd, Daniel Lezcano, Thomas Gleixner,
	Wim Van Sebroeck
  Cc: linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

The last user of this function is gone, so remove it. The clock API
should now be used to get clock rates.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 arch/arm/mach-pxa/generic.c                  | 15 ---------------
 arch/arm/mach-pxa/include/mach/hardware.h    |  2 --
 arch/arm/mach-sa1100/include/mach/hardware.h |  4 ----
 3 files changed, 21 deletions(-)

diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index 2a9297991d74..cb73a9723d0e 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -43,21 +43,6 @@ void clear_reset_status(unsigned int mask)
 	}
 }
 
-unsigned long get_clock_tick_rate(void)
-{
-	unsigned long clock_tick_rate;
-
-	if (cpu_is_pxa25x())
-		clock_tick_rate = 3686400;
-	else if (machine_is_mainstone())
-		clock_tick_rate = 3249600;
-	else
-		clock_tick_rate = 3250000;
-
-	return clock_tick_rate;
-}
-EXPORT_SYMBOL(get_clock_tick_rate);
-
 /*
  * For non device-tree builds, keep legacy timer init
  */
diff --git a/arch/arm/mach-pxa/include/mach/hardware.h b/arch/arm/mach-pxa/include/mach/hardware.h
index 8d63c211b22f..55064124ca4e 100644
--- a/arch/arm/mach-pxa/include/mach/hardware.h
+++ b/arch/arm/mach-pxa/include/mach/hardware.h
@@ -303,8 +303,6 @@
  */
 extern unsigned int get_memclk_frequency_10khz(void);
 
-/* return the clock tick rate of the OS timer */
-extern unsigned long get_clock_tick_rate(void);
 #endif
 
 #endif  /* _ASM_ARCH_HARDWARE_H */
diff --git a/arch/arm/mach-sa1100/include/mach/hardware.h b/arch/arm/mach-sa1100/include/mach/hardware.h
index cbedd75a9d65..474844a93e29 100644
--- a/arch/arm/mach-sa1100/include/mach/hardware.h
+++ b/arch/arm/mach-sa1100/include/mach/hardware.h
@@ -61,10 +61,6 @@
 # define __REG(x)	(*((volatile unsigned long __iomem *)io_p2v(x)))
 # define __PREG(x)	(io_v2p((unsigned long)&(x)))
 
-static inline unsigned long get_clock_tick_rate(void)
-{
-	return 3686400;
-}
 #else
 
 # define __REG(x)	io_p2v(x)
-- 
2.1.4

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

* Re: [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator
  2016-09-19 19:12 ` [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator Robert Jarzmik
@ 2016-09-19 19:23   ` Stephen Boyd
  0 siblings, 0 replies; 19+ messages in thread
From: Stephen Boyd @ 2016-09-19 19:23 UTC (permalink / raw)
  To: Robert Jarzmik
  Cc: Daniel Mack, Haojian Zhuang, Russell King, Michael Turquette,
	Daniel Lezcano, Thomas Gleixner, Wim Van Sebroeck,
	linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog,
	Russell King

On 09/19, Robert Jarzmik wrote:
> From: Russell King - ARM Linux <linux@armlinux.org.uk>
> 
> The OSTIMER0 clock ticks at the main oscillator rate, not the 32kHz
> oscillator rate.  Ensure that it is parented to the main oscillator.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
> Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
> ---

Acked-by: Stephen Boyd <sboyd@codeaurora.org>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate
  2016-09-19 19:12 ` [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate Robert Jarzmik
@ 2016-09-19 19:48   ` Daniel Lezcano
  2016-09-26 21:57   ` Russell King - ARM Linux
  1 sibling, 0 replies; 19+ messages in thread
From: Daniel Lezcano @ 2016-09-19 19:48 UTC (permalink / raw)
  To: Robert Jarzmik, Daniel Mack, Haojian Zhuang, Russell King,
	Michael Turquette, Stephen Boyd, Thomas Gleixner,
	Wim Van Sebroeck
  Cc: linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

On 19/09/2016 21:12, Robert Jarzmik wrote:
> As both pxa and sa1100 provide a clock to the timer, the rate can be
> inferred from the clock rather than hard encoded in a functional call.
> 
> This patch changes the pxa timer to have a mandatory clock which is used
> as the timer rate.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

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

* Re: [PATCH 4/4] ARM: sa11x0/pxa: get rid of get_clock_tick_rate
  2016-09-19 19:12 ` [PATCH 4/4] ARM: " Robert Jarzmik
@ 2016-09-19 19:58   ` Daniel Lezcano
  2016-09-26 21:58   ` Russell King - ARM Linux
  1 sibling, 0 replies; 19+ messages in thread
From: Daniel Lezcano @ 2016-09-19 19:58 UTC (permalink / raw)
  To: Robert Jarzmik, Daniel Mack, Haojian Zhuang, Russell King,
	Michael Turquette, Stephen Boyd, Thomas Gleixner,
	Wim Van Sebroeck
  Cc: linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

On 19/09/2016 21:12, Robert Jarzmik wrote:
> The last user of this function is gone, so remove it. The clock API
> should now be used to get clock rates.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

* Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
  2016-09-19 19:12 ` [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Robert Jarzmik
@ 2016-09-19 20:08   ` Guenter Roeck
  2016-09-19 22:36     ` Russell King - ARM Linux
  2016-09-20  4:35   ` Guenter Roeck
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 19+ messages in thread
From: Guenter Roeck @ 2016-09-19 20:08 UTC (permalink / raw)
  To: Robert Jarzmik
  Cc: Daniel Mack, Haojian Zhuang, Russell King, Michael Turquette,
	Stephen Boyd, Daniel Lezcano, Thomas Gleixner, Wim Van Sebroeck,
	linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

On Mon, Sep 19, 2016 at 09:12:14PM +0200, Robert Jarzmik wrote:
> The OS timer rate used for the watchdog can now be fetched from the
> standard clock API. This will remove the last user of
> get_clock_tick_rate() in both pxa and sa11x0 architectures.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

Did you test this ? Potential problem, if built into the kernel, could be that
the clocks might not be ready by the time the driver is instantiated. Unless
this is converted to a platform driver, it won't be able to handle a
-EPROBE_DEFER from the clock subsystem.

Guenter

> ---
>  drivers/watchdog/sa1100_wdt.c | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/sa1100_wdt.c b/drivers/watchdog/sa1100_wdt.c
> index e1d39a1e9628..8965e3f536c3 100644
> --- a/drivers/watchdog/sa1100_wdt.c
> +++ b/drivers/watchdog/sa1100_wdt.c
> @@ -22,6 +22,7 @@
>  
>  #include <linux/module.h>
>  #include <linux/moduleparam.h>
> +#include <linux/clk.h>
>  #include <linux/types.h>
>  #include <linux/kernel.h>
>  #include <linux/fs.h>
> @@ -155,12 +156,27 @@ static struct miscdevice sa1100dog_miscdev = {
>  };
>  
>  static int margin __initdata = 60;		/* (secs) Default is 1 minute */
> +static struct clk *clk;
>  
>  static int __init sa1100dog_init(void)
>  {
>  	int ret;
>  
> -	oscr_freq = get_clock_tick_rate();
> +	clk = clk_get(NULL, "OSTIMER0");
> +	if (IS_ERR(clk)) {
> +		pr_err("SA1100/PXA2xx Watchdog Timer: clock not found: %d\n",
> +		       (int) PTR_ERR(clk));
> +		return PTR_ERR(clk);
> +	}
> +
> +	ret = clk_prepare_enable(clk);
> +	if (ret) {
> +		pr_err("SA1100/PXA2xx Watchdog Timer: clock failed to prepare+enable: %d\n",
> +		       ret);
> +		goto err;
> +	}
> +
> +	oscr_freq = clk_get_rate(clk);
>  
>  	/*
>  	 * Read the reset status, and save it for later.  If
> @@ -176,11 +192,17 @@ static int __init sa1100dog_init(void)
>  		pr_info("SA1100/PXA2xx Watchdog Timer: timer margin %d sec\n",
>  			margin);
>  	return ret;
> +err:
> +	clk_disable_unprepare(clk);
> +	clk_put(clk);
> +	return ret;
>  }
>  
>  static void __exit sa1100dog_exit(void)
>  {
>  	misc_deregister(&sa1100dog_miscdev);
> +	clk_disable_unprepare(clk);
> +	clk_put(clk);
>  }
>  
>  module_init(sa1100dog_init);
> -- 
> 2.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
  2016-09-19 20:08   ` Guenter Roeck
@ 2016-09-19 22:36     ` Russell King - ARM Linux
  2016-09-20  4:37       ` Guenter Roeck
  0 siblings, 1 reply; 19+ messages in thread
From: Russell King - ARM Linux @ 2016-09-19 22:36 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Robert Jarzmik, Daniel Mack, Haojian Zhuang, Michael Turquette,
	Stephen Boyd, Daniel Lezcano, Thomas Gleixner, Wim Van Sebroeck,
	linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

On Mon, Sep 19, 2016 at 01:08:16PM -0700, Guenter Roeck wrote:
> On Mon, Sep 19, 2016 at 09:12:14PM +0200, Robert Jarzmik wrote:
> > The OS timer rate used for the watchdog can now be fetched from the
> > standard clock API. This will remove the last user of
> > get_clock_tick_rate() in both pxa and sa11x0 architectures.
> > 
> > Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> 
> Did you test this ? Potential problem, if built into the kernel, could be that
> the clocks might not be ready by the time the driver is instantiated. Unless
> this is converted to a platform driver, it won't be able to handle a
> -EPROBE_DEFER from the clock subsystem.

Really not a problem at all.  The OSTIMER0 is required for the system
tick, and if that's not present, the kernel will be without any kind
of time keeping, so a missing watchdog driver is the least of the
problems.

Therefore, both PXA and SA11x0 register their clocks really early to
ensure that OSTIMER0 is available by the time_init() stage, which is
way before driver probe time.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
  2016-09-19 19:12 ` [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Robert Jarzmik
  2016-09-19 20:08   ` Guenter Roeck
@ 2016-09-20  4:35   ` Guenter Roeck
  2016-09-26 21:58   ` Russell King - ARM Linux
  2016-09-27 19:13   ` Wim Van Sebroeck
  3 siblings, 0 replies; 19+ messages in thread
From: Guenter Roeck @ 2016-09-20  4:35 UTC (permalink / raw)
  To: Robert Jarzmik, Daniel Mack, Haojian Zhuang, Russell King,
	Michael Turquette, Stephen Boyd, Daniel Lezcano, Thomas Gleixner,
	Wim Van Sebroeck
  Cc: linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

On 09/19/2016 12:12 PM, Robert Jarzmik wrote:
> The OS timer rate used for the watchdog can now be fetched from the
> standard clock API. This will remove the last user of
> get_clock_tick_rate() in both pxa and sa11x0 architectures.
>
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/sa1100_wdt.c | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/sa1100_wdt.c b/drivers/watchdog/sa1100_wdt.c
> index e1d39a1e9628..8965e3f536c3 100644
> --- a/drivers/watchdog/sa1100_wdt.c
> +++ b/drivers/watchdog/sa1100_wdt.c
> @@ -22,6 +22,7 @@
>
>  #include <linux/module.h>
>  #include <linux/moduleparam.h>
> +#include <linux/clk.h>
>  #include <linux/types.h>
>  #include <linux/kernel.h>
>  #include <linux/fs.h>
> @@ -155,12 +156,27 @@ static struct miscdevice sa1100dog_miscdev = {
>  };
>
>  static int margin __initdata = 60;		/* (secs) Default is 1 minute */
> +static struct clk *clk;
>
>  static int __init sa1100dog_init(void)
>  {
>  	int ret;
>
> -	oscr_freq = get_clock_tick_rate();
> +	clk = clk_get(NULL, "OSTIMER0");
> +	if (IS_ERR(clk)) {
> +		pr_err("SA1100/PXA2xx Watchdog Timer: clock not found: %d\n",
> +		       (int) PTR_ERR(clk));
> +		return PTR_ERR(clk);
> +	}
> +
> +	ret = clk_prepare_enable(clk);
> +	if (ret) {
> +		pr_err("SA1100/PXA2xx Watchdog Timer: clock failed to prepare+enable: %d\n",
> +		       ret);
> +		goto err;
> +	}
> +
> +	oscr_freq = clk_get_rate(clk);
>
>  	/*
>  	 * Read the reset status, and save it for later.  If
> @@ -176,11 +192,17 @@ static int __init sa1100dog_init(void)
>  		pr_info("SA1100/PXA2xx Watchdog Timer: timer margin %d sec\n",
>  			margin);
>  	return ret;
> +err:
> +	clk_disable_unprepare(clk);
> +	clk_put(clk);
> +	return ret;
>  }
>
>  static void __exit sa1100dog_exit(void)
>  {
>  	misc_deregister(&sa1100dog_miscdev);
> +	clk_disable_unprepare(clk);
> +	clk_put(clk);
>  }
>
>  module_init(sa1100dog_init);
>

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

* Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
  2016-09-19 22:36     ` Russell King - ARM Linux
@ 2016-09-20  4:37       ` Guenter Roeck
  2016-09-20  6:18         ` Robert Jarzmik
  0 siblings, 1 reply; 19+ messages in thread
From: Guenter Roeck @ 2016-09-20  4:37 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Robert Jarzmik, Daniel Mack, Haojian Zhuang, Michael Turquette,
	Stephen Boyd, Daniel Lezcano, Thomas Gleixner, Wim Van Sebroeck,
	linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

On 09/19/2016 03:36 PM, Russell King - ARM Linux wrote:
> On Mon, Sep 19, 2016 at 01:08:16PM -0700, Guenter Roeck wrote:
>> On Mon, Sep 19, 2016 at 09:12:14PM +0200, Robert Jarzmik wrote:
>>> The OS timer rate used for the watchdog can now be fetched from the
>>> standard clock API. This will remove the last user of
>>> get_clock_tick_rate() in both pxa and sa11x0 architectures.
>>>
>>> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
>>
>> Did you test this ? Potential problem, if built into the kernel, could be that
>> the clocks might not be ready by the time the driver is instantiated. Unless
>> this is converted to a platform driver, it won't be able to handle a
>> -EPROBE_DEFER from the clock subsystem.
>
> Really not a problem at all.  The OSTIMER0 is required for the system
> tick, and if that's not present, the kernel will be without any kind
> of time keeping, so a missing watchdog driver is the least of the
> problems.
>
> Therefore, both PXA and SA11x0 register their clocks really early to
> ensure that OSTIMER0 is available by the time_init() stage, which is
> way before driver probe time.
>

You are right. And, at least in qemu, it actually works.

Thanks,
Guenter

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

* Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
  2016-09-20  4:37       ` Guenter Roeck
@ 2016-09-20  6:18         ` Robert Jarzmik
  0 siblings, 0 replies; 19+ messages in thread
From: Robert Jarzmik @ 2016-09-20  6:18 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Russell King - ARM Linux, Daniel Mack, Haojian Zhuang,
	Michael Turquette, Stephen Boyd, Daniel Lezcano, Thomas Gleixner,
	Wim Van Sebroeck, linux-arm-kernel, linux-kernel, linux-clk,
	linux-watchdog

Guenter Roeck <linux@roeck-us.net> writes:

> On 09/19/2016 03:36 PM, Russell King - ARM Linux wrote:
>> On Mon, Sep 19, 2016 at 01:08:16PM -0700, Guenter Roeck wrote:
>>> On Mon, Sep 19, 2016 at 09:12:14PM +0200, Robert Jarzmik wrote:
>>>> The OS timer rate used for the watchdog can now be fetched from the
>>>> standard clock API. This will remove the last user of
>>>> get_clock_tick_rate() in both pxa and sa11x0 architectures.
>>>>
>>>> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
>>>
>>> Did you test this ? Potential problem, if built into the kernel, could be that
>>> the clocks might not be ready by the time the driver is instantiated. Unless
>>> this is converted to a platform driver, it won't be able to handle a
>>> -EPROBE_DEFER from the clock subsystem.
>>
>> Really not a problem at all.  The OSTIMER0 is required for the system
>> tick, and if that's not present, the kernel will be without any kind
>> of time keeping, so a missing watchdog driver is the least of the
>> problems.
>>
>> Therefore, both PXA and SA11x0 register their clocks really early to
>> ensure that OSTIMER0 is available by the time_init() stage, which is
>> way before driver probe time.
>>
>
> You are right. And, at least in qemu, it actually works.
Hi Guenter,

Yes, it was tested on pxa25x (lubbock) and pxa27x (mainstone).

Cheers.

-- 
Robert

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

* Re: [PATCH 0/4] kill get_clock_tick_rate()
  2016-09-19 19:12 [PATCH 0/4] kill get_clock_tick_rate() Robert Jarzmik
                   ` (3 preceding siblings ...)
  2016-09-19 19:12 ` [PATCH 4/4] ARM: " Robert Jarzmik
@ 2016-09-26 19:29 ` Robert Jarzmik
  2016-09-27 18:46   ` Robert Jarzmik
  4 siblings, 1 reply; 19+ messages in thread
From: Robert Jarzmik @ 2016-09-26 19:29 UTC (permalink / raw)
  To: Russell King
  Cc: Daniel Mack, Haojian Zhuang, Michael Turquette, Stephen Boyd,
	Daniel Lezcano, Thomas Gleixner, Wim Van Sebroeck,
	linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

Robert Jarzmik <robert.jarzmik@free.fr> writes:

> Hi,
>
> This serie aims at killing get_clock_tick_rate() from pxa and sa1100 and replace
> it by clock API calls.
>
> I'd like to have this reviewed and acked afterwards at least by :
>  - Russell for the mach-sa1100 and sa1100_wdt.c
>  - Stephen or Michael for the clk-pxa25x.c
>  - Thomas or Daniel for the clocksource part
>  - Wim for sa1100_wdt.c
>
> If the review converges, I'd also like to take it through the pxa/for-next tree,
> or alternatively Russell's tree if there is a dependency I'm not seeing, for
> v4.10 cycle.

Hi Russell,

Would you have time within the next 2 weeks to give this serie a review and
maybe an Ack from the sa1100 impacted parts (that would be patches 2, 3 and 4) ?

I can also resend the serie if it's easier in your workflow.

Cheers.

--
Robert

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

* Re: [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate
  2016-09-19 19:12 ` [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate Robert Jarzmik
  2016-09-19 19:48   ` Daniel Lezcano
@ 2016-09-26 21:57   ` Russell King - ARM Linux
  1 sibling, 0 replies; 19+ messages in thread
From: Russell King - ARM Linux @ 2016-09-26 21:57 UTC (permalink / raw)
  To: Robert Jarzmik
  Cc: Daniel Mack, Haojian Zhuang, Michael Turquette, Stephen Boyd,
	Daniel Lezcano, Thomas Gleixner, Wim Van Sebroeck,
	linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

On Mon, Sep 19, 2016 at 09:12:13PM +0200, Robert Jarzmik wrote:
> As both pxa and sa1100 provide a clock to the timer, the rate can be
> inferred from the clock rather than hard encoded in a functional call.
> 
> This patch changes the pxa timer to have a mandatory clock which is used
> as the timer rate.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

Acked-by: Russell King <rmk+kernel@armlinux.org.uk>

Thanks.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
  2016-09-19 19:12 ` [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Robert Jarzmik
  2016-09-19 20:08   ` Guenter Roeck
  2016-09-20  4:35   ` Guenter Roeck
@ 2016-09-26 21:58   ` Russell King - ARM Linux
  2016-09-27 19:13   ` Wim Van Sebroeck
  3 siblings, 0 replies; 19+ messages in thread
From: Russell King - ARM Linux @ 2016-09-26 21:58 UTC (permalink / raw)
  To: Robert Jarzmik
  Cc: Daniel Mack, Haojian Zhuang, Michael Turquette, Stephen Boyd,
	Daniel Lezcano, Thomas Gleixner, Wim Van Sebroeck,
	linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

On Mon, Sep 19, 2016 at 09:12:14PM +0200, Robert Jarzmik wrote:
> The OS timer rate used for the watchdog can now be fetched from the
> standard clock API. This will remove the last user of
> get_clock_tick_rate() in both pxa and sa11x0 architectures.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

Acked-by: Russell King <rmk+kernel@armlinux.org.uk>

Thanks.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH 4/4] ARM: sa11x0/pxa: get rid of get_clock_tick_rate
  2016-09-19 19:12 ` [PATCH 4/4] ARM: " Robert Jarzmik
  2016-09-19 19:58   ` Daniel Lezcano
@ 2016-09-26 21:58   ` Russell King - ARM Linux
  1 sibling, 0 replies; 19+ messages in thread
From: Russell King - ARM Linux @ 2016-09-26 21:58 UTC (permalink / raw)
  To: Robert Jarzmik
  Cc: Daniel Mack, Haojian Zhuang, Michael Turquette, Stephen Boyd,
	Daniel Lezcano, Thomas Gleixner, Wim Van Sebroeck,
	linux-arm-kernel, linux-kernel, linux-clk, linux-watchdog

On Mon, Sep 19, 2016 at 09:12:15PM +0200, Robert Jarzmik wrote:
> The last user of this function is gone, so remove it. The clock API
> should now be used to get clock rates.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

Acked-by: Russell King <rmk+kernel@armlinux.org.uk>

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH 0/4] kill get_clock_tick_rate()
  2016-09-26 19:29 ` [PATCH 0/4] kill get_clock_tick_rate() Robert Jarzmik
@ 2016-09-27 18:46   ` Robert Jarzmik
  0 siblings, 0 replies; 19+ messages in thread
From: Robert Jarzmik @ 2016-09-27 18:46 UTC (permalink / raw)
  To: Russell King, Stephen Boyd, Daniel Lezcano, Guenter Roeck
  Cc: Daniel Mack, Haojian Zhuang, Michael Turquette, Thomas Gleixner,
	Wim Van Sebroeck, linux-arm-kernel, linux-kernel, linux-clk,
	linux-watchdog

Robert Jarzmik <robert.jarzmik@free.fr> writes:
>> Hi,
>>
>> This serie aims at killing get_clock_tick_rate() from pxa and sa1100 and replace
>> it by clock API calls.
>>
>> I'd like to have this reviewed and acked afterwards at least by :
>>  - Russell for the mach-sa1100 and sa1100_wdt.c
>>  - Stephen or Michael for the clk-pxa25x.c
>>  - Thomas or Daniel for the clocksource part
>>  - Wim for sa1100_wdt.c

Thanks to all for tests and acks, queued to pxa/for-next.

Cheers.

--
Robert

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

* Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
  2016-09-19 19:12 ` [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Robert Jarzmik
                     ` (2 preceding siblings ...)
  2016-09-26 21:58   ` Russell King - ARM Linux
@ 2016-09-27 19:13   ` Wim Van Sebroeck
  3 siblings, 0 replies; 19+ messages in thread
From: Wim Van Sebroeck @ 2016-09-27 19:13 UTC (permalink / raw)
  To: Robert Jarzmik
  Cc: Daniel Mack, Haojian Zhuang, Russell King, Michael Turquette,
	Stephen Boyd, Daniel Lezcano, Thomas Gleixner, linux-arm-kernel,
	linux-kernel, linux-clk, linux-watchdog

Hi Robert,

> The OS timer rate used for the watchdog can now be fetched from the
> standard clock API. This will remove the last user of
> get_clock_tick_rate() in both pxa and sa11x0 architectures.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

Acked-by: Wim Van Sebroeck <wim@iguana.be>

Kind regards,
Wim.

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

end of thread, other threads:[~2016-09-27 19:44 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19 19:12 [PATCH 0/4] kill get_clock_tick_rate() Robert Jarzmik
2016-09-19 19:12 ` [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator Robert Jarzmik
2016-09-19 19:23   ` Stephen Boyd
2016-09-19 19:12 ` [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate Robert Jarzmik
2016-09-19 19:48   ` Daniel Lezcano
2016-09-26 21:57   ` Russell King - ARM Linux
2016-09-19 19:12 ` [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Robert Jarzmik
2016-09-19 20:08   ` Guenter Roeck
2016-09-19 22:36     ` Russell King - ARM Linux
2016-09-20  4:37       ` Guenter Roeck
2016-09-20  6:18         ` Robert Jarzmik
2016-09-20  4:35   ` Guenter Roeck
2016-09-26 21:58   ` Russell King - ARM Linux
2016-09-27 19:13   ` Wim Van Sebroeck
2016-09-19 19:12 ` [PATCH 4/4] ARM: " Robert Jarzmik
2016-09-19 19:58   ` Daniel Lezcano
2016-09-26 21:58   ` Russell King - ARM Linux
2016-09-26 19:29 ` [PATCH 0/4] kill get_clock_tick_rate() Robert Jarzmik
2016-09-27 18:46   ` Robert Jarzmik

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