Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1486777 > unrolled thread

[PATCH 0/4] kill get_clock_tick_rate()

Started byRobert Jarzmik <robert.jarzmik@free.fr>
First post2016-09-19 21:20 +0200
Last post2016-09-19 22:00 +0200
Articles 13 — 5 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/4] kill get_clock_tick_rate() Robert Jarzmik <robert.jarzmik@free.fr> - 2016-09-19 21:20 +0200
    [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate Robert Jarzmik <robert.jarzmik@free.fr> - 2016-09-19 21:20 +0200
      Re: [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock  rate Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-09-19 21:50 +0200
    [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator Robert Jarzmik <robert.jarzmik@free.fr> - 2016-09-19 21:20 +0200
      Re: [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator Stephen Boyd <sboyd@codeaurora.org> - 2016-09-19 21:30 +0200
    [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Robert Jarzmik <robert.jarzmik@free.fr> - 2016-09-19 21:30 +0200
      Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Guenter Roeck <linux@roeck-us.net> - 2016-09-19 22:10 +0200
        Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Russell King - ARM Linux <linux@armlinux.org.uk> - 2016-09-20 00:40 +0200
          Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Guenter Roeck <linux@roeck-us.net> - 2016-09-20 06:40 +0200
            Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Robert Jarzmik <robert.jarzmik@free.fr> - 2016-09-20 08:20 +0200
      Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate Guenter Roeck <linux@roeck-us.net> - 2016-09-20 06:40 +0200
    [PATCH 4/4] ARM: sa11x0/pxa: get rid of get_clock_tick_rate Robert Jarzmik <robert.jarzmik@free.fr> - 2016-09-19 21:30 +0200
      Re: [PATCH 4/4] ARM: sa11x0/pxa: get rid of get_clock_tick_rate Daniel Lezcano <daniel.lezcano@linaro.org> - 2016-09-19 22:00 +0200

#1486777 — [PATCH 0/4] kill get_clock_tick_rate()

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2016-09-19 21:20 +0200
Subject[PATCH 0/4] kill get_clock_tick_rate()
Message-ID<sjcgF-10E-3@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1486779 — [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2016-09-19 21:20 +0200
Subject[PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate
Message-ID<sjcgG-10E-7@gated-at.bofh.it>
In reply to#1486777
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

[toc] | [prev] | [next] | [standalone]


#1486802 — Re: [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate

FromDaniel Lezcano <daniel.lezcano@linaro.org>
Date2016-09-19 21:50 +0200
SubjectRe: [PATCH 2/4] ARM: sa11x0/pxa: acquire timer rate from the clock rate
Message-ID<sjcJI-1aU-31@gated-at.bofh.it>
In reply to#1486779
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>

[toc] | [prev] | [next] | [standalone]


#1486780 — [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2016-09-19 21:20 +0200
Subject[PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator
Message-ID<sjcgG-10E-21@gated-at.bofh.it>
In reply to#1486777
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

[toc] | [prev] | [next] | [standalone]


#1486791 — Re: [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-09-19 21:30 +0200
SubjectRe: [PATCH 1/4] clk: pxa25x: OSTIMER0 clocks from the main oscillator
Message-ID<sjcqm-149-29@gated-at.bofh.it>
In reply to#1486780
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

[toc] | [prev] | [next] | [standalone]


#1486786 — [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2016-09-19 21:30 +0200
Subject[PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
Message-ID<sjcqm-149-39@gated-at.bofh.it>
In reply to#1486777
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

[toc] | [prev] | [next] | [standalone]


#1486826 — Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate

FromGuenter Roeck <linux@roeck-us.net>
Date2016-09-19 22:10 +0200
SubjectRe: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
Message-ID<sjd33-1xh-17@gated-at.bofh.it>
In reply to#1486786
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

[toc] | [prev] | [next] | [standalone]


#1486927 — Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate

FromRussell King - ARM Linux <linux@armlinux.org.uk>
Date2016-09-20 00:40 +0200
SubjectRe: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
Message-ID<sjfoe-34D-23@gated-at.bofh.it>
In reply to#1486826
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.

[toc] | [prev] | [next] | [standalone]


#1487050 — Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate

FromGuenter Roeck <linux@roeck-us.net>
Date2016-09-20 06:40 +0200
SubjectRe: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
Message-ID<sjl0C-6HJ-13@gated-at.bofh.it>
In reply to#1486927
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

[toc] | [prev] | [next] | [standalone]


#1487080 — Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2016-09-20 08:20 +0200
SubjectRe: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
Message-ID<sjmzn-7Jp-5@gated-at.bofh.it>
In reply to#1487050
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

[toc] | [prev] | [next] | [standalone]


#1487048 — Re: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate

FromGuenter Roeck <linux@roeck-us.net>
Date2016-09-20 06:40 +0200
SubjectRe: [PATCH 3/4] watchdog: sa11x0/pxa: get rid of get_clock_tick_rate
Message-ID<sjl0C-6HJ-11@gated-at.bofh.it>
In reply to#1486786
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);
>

[toc] | [prev] | [next] | [standalone]


#1486787 — [PATCH 4/4] ARM: sa11x0/pxa: get rid of get_clock_tick_rate

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2016-09-19 21:30 +0200
Subject[PATCH 4/4] ARM: sa11x0/pxa: get rid of get_clock_tick_rate
Message-ID<sjcql-149-23@gated-at.bofh.it>
In reply to#1486777
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

[toc] | [prev] | [next] | [standalone]


#1486821 — Re: [PATCH 4/4] ARM: sa11x0/pxa: get rid of get_clock_tick_rate

FromDaniel Lezcano <daniel.lezcano@linaro.org>
Date2016-09-19 22:00 +0200
SubjectRe: [PATCH 4/4] ARM: sa11x0/pxa: get rid of get_clock_tick_rate
Message-ID<sjcTo-1ej-49@gated-at.bofh.it>
In reply to#1486787
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web