* [PATCH 1/2] ARM: move SPEAr to use common mult/shift calculation code
@ 2010-05-28 17:33 Linus Walleij
2010-07-12 8:00 ` Linus Walleij
2010-07-19 13:11 ` shiraz hashim
0 siblings, 2 replies; 4+ messages in thread
From: Linus Walleij @ 2010-05-28 17:33 UTC (permalink / raw)
To: linux-arm-kernel
Since the infrastructure for determining shift/mult values from a
clock rate and a minimum programmable rate is now in the kernel,
lets remove this custom code.
Cc: Viresh KUMAR <viresh.kumar@st.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
Viresh: I cannot test this change, but I have compiled it against
spear600_defconfig. You'd have to test it and Acked-by: it before
I do anything else with it. Try to think about what a minimum range
would be for the generic SPEAr platform...
---
arch/arm/plat-spear/time.c | 47 ++++++-------------------------------------
1 files changed, 7 insertions(+), 40 deletions(-)
diff --git a/arch/arm/plat-spear/time.c b/arch/arm/plat-spear/time.c
index a1025d3..ab21165 100644
--- a/arch/arm/plat-spear/time.c
+++ b/arch/arm/plat-spear/time.c
@@ -58,6 +58,11 @@
#define INT_STATUS 0x1
+/*
+ * Minimum clocksource/clockevent timer range in seconds
+ */
+#define SPEAR_MIN_RANGE 4
+
static __iomem void *gpt_base;
static struct clk *gpt_clk;
@@ -66,44 +71,6 @@ static void clockevent_set_mode(enum clock_event_mode mode,
static int clockevent_next_event(unsigned long evt,
struct clock_event_device *clk_event_dev);
-/*
- * Following clocksource_set_clock and clockevent_set_clock picked
- * from arch/mips/kernel/time.c
- */
-
-void __init clocksource_set_clock(struct clocksource *cs, unsigned int clock)
-{
- u64 temp;
- u32 shift;
-
- /* Find a shift value */
- for (shift = 32; shift > 0; shift--) {
- temp = (u64) NSEC_PER_SEC << shift;
- do_div(temp, clock);
- if ((temp >> 32) == 0)
- break;
- }
- cs->shift = shift;
- cs->mult = (u32) temp;
-}
-
-void __init clockevent_set_clock(struct clock_event_device *cd,
- unsigned int clock)
-{
- u64 temp;
- u32 shift;
-
- /* Find a shift value */
- for (shift = 32; shift > 0; shift--) {
- temp = (u64) clock << shift;
- do_div(temp, NSEC_PER_SEC);
- if ((temp >> 32) == 0)
- break;
- }
- cd->shift = shift;
- cd->mult = (u32) temp;
-}
-
static cycle_t clocksource_read_cycles(struct clocksource *cs)
{
return (cycle_t) readw(gpt_base + COUNT(CLKSRC));
@@ -138,7 +105,7 @@ static void spear_clocksource_init(void)
val |= CTRL_ENABLE ;
writew(val, gpt_base + CR(CLKSRC));
- clocksource_set_clock(&clksrc, tick_rate);
+ clocksource_calc_mult_shift(&clksrc, tick_rate, SPEAR_MIN_RANGE);
/* register the clocksource */
clocksource_register(&clksrc);
@@ -233,7 +200,7 @@ static void __init spear_clockevent_init(void)
tick_rate = clk_get_rate(gpt_clk);
tick_rate >>= CTRL_PRESCALER16;
- clockevent_set_clock(&clkevt, tick_rate);
+ clockevents_calc_mult_shift(&clkevt, tick_rate, SPEAR_MIN_RANGE);
clkevt.max_delta_ns = clockevent_delta2ns(0xfff0,
&clkevt);
--
1.6.3.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 1/2] ARM: move SPEAr to use common mult/shift calculation code
2010-05-28 17:33 [PATCH 1/2] ARM: move SPEAr to use common mult/shift calculation code Linus Walleij
@ 2010-07-12 8:00 ` Linus Walleij
2010-07-19 13:11 ` shiraz hashim
1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2010-07-12 8:00 UTC (permalink / raw)
To: linux-arm-kernel
Ping on this patch, if it looks OK then please ACK it.
Yours,
Linus Walleij
2010/5/28 Linus Walleij <linus.walleij@stericsson.com>:
> Since the infrastructure for determining shift/mult values from a
> clock rate and a minimum programmable rate is now in the kernel,
> lets remove this custom code.
>
> Cc: Viresh KUMAR <viresh.kumar@st.com>
> Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
> ---
> Viresh: I cannot test this change, but I have compiled it against
> spear600_defconfig. You'd have to test it and Acked-by: it before
> I do anything else with it. Try to think about what a minimum range
> would be for the generic SPEAr platform...
> ---
> ?arch/arm/plat-spear/time.c | ? 47 ++++++-------------------------------------
> ?1 files changed, 7 insertions(+), 40 deletions(-)
>
> diff --git a/arch/arm/plat-spear/time.c b/arch/arm/plat-spear/time.c
> index a1025d3..ab21165 100644
> --- a/arch/arm/plat-spear/time.c
> +++ b/arch/arm/plat-spear/time.c
> @@ -58,6 +58,11 @@
>
> ?#define INT_STATUS ? ? ? ? ? ? 0x1
>
> +/*
> + * Minimum clocksource/clockevent timer range in seconds
> + */
> +#define SPEAR_MIN_RANGE 4
> +
> ?static __iomem void *gpt_base;
> ?static struct clk *gpt_clk;
>
> @@ -66,44 +71,6 @@ static void clockevent_set_mode(enum clock_event_mode mode,
> ?static int clockevent_next_event(unsigned long evt,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct clock_event_device *clk_event_dev);
>
> -/*
> - * Following clocksource_set_clock and clockevent_set_clock picked
> - * from arch/mips/kernel/time.c
> - */
> -
> -void __init clocksource_set_clock(struct clocksource *cs, unsigned int clock)
> -{
> - ? ? ? u64 temp;
> - ? ? ? u32 shift;
> -
> - ? ? ? /* Find a shift value */
> - ? ? ? for (shift = 32; shift > 0; shift--) {
> - ? ? ? ? ? ? ? temp = (u64) NSEC_PER_SEC << shift;
> - ? ? ? ? ? ? ? do_div(temp, clock);
> - ? ? ? ? ? ? ? if ((temp >> 32) == 0)
> - ? ? ? ? ? ? ? ? ? ? ? break;
> - ? ? ? }
> - ? ? ? cs->shift = shift;
> - ? ? ? cs->mult = (u32) temp;
> -}
> -
> -void __init clockevent_set_clock(struct clock_event_device *cd,
> - ? ? ? unsigned int clock)
> -{
> - ? ? ? u64 temp;
> - ? ? ? u32 shift;
> -
> - ? ? ? /* Find a shift value */
> - ? ? ? for (shift = 32; shift > 0; shift--) {
> - ? ? ? ? ? ? ? temp = (u64) clock << shift;
> - ? ? ? ? ? ? ? do_div(temp, NSEC_PER_SEC);
> - ? ? ? ? ? ? ? if ((temp >> 32) == 0)
> - ? ? ? ? ? ? ? ? ? ? ? break;
> - ? ? ? }
> - ? ? ? cd->shift = shift;
> - ? ? ? cd->mult = (u32) temp;
> -}
> -
> ?static cycle_t clocksource_read_cycles(struct clocksource *cs)
> ?{
> ? ? ? ?return (cycle_t) readw(gpt_base + COUNT(CLKSRC));
> @@ -138,7 +105,7 @@ static void spear_clocksource_init(void)
> ? ? ? ?val |= CTRL_ENABLE ;
> ? ? ? ?writew(val, gpt_base + CR(CLKSRC));
>
> - ? ? ? clocksource_set_clock(&clksrc, tick_rate);
> + ? ? ? clocksource_calc_mult_shift(&clksrc, tick_rate, SPEAR_MIN_RANGE);
>
> ? ? ? ?/* register the clocksource */
> ? ? ? ?clocksource_register(&clksrc);
> @@ -233,7 +200,7 @@ static void __init spear_clockevent_init(void)
> ? ? ? ?tick_rate = clk_get_rate(gpt_clk);
> ? ? ? ?tick_rate >>= CTRL_PRESCALER16;
>
> - ? ? ? clockevent_set_clock(&clkevt, tick_rate);
> + ? ? ? clockevents_calc_mult_shift(&clkevt, tick_rate, SPEAR_MIN_RANGE);
>
> ? ? ? ?clkevt.max_delta_ns = clockevent_delta2ns(0xfff0,
> ? ? ? ? ? ? ? ? ? ? ? ?&clkevt);
> --
> 1.6.3.3
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ARM: move SPEAr to use common mult/shift calculation code
2010-05-28 17:33 [PATCH 1/2] ARM: move SPEAr to use common mult/shift calculation code Linus Walleij
2010-07-12 8:00 ` Linus Walleij
@ 2010-07-19 13:11 ` shiraz hashim
2010-07-19 18:19 ` Linus Walleij
1 sibling, 1 reply; 4+ messages in thread
From: shiraz hashim @ 2010-07-19 13:11 UTC (permalink / raw)
To: linux-arm-kernel
Hello Viresh, Linus
On Fri, May 28, 2010 at 11:03 PM, Linus Walleij
<linus.walleij@stericsson.com> wrote:
> Since the infrastructure for determining shift/mult values from a
> clock rate and a minimum programmable rate is now in the kernel,
> lets remove this custom code.
>
> Cc: Viresh KUMAR <viresh.kumar@st.com>
> Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
> ---
> Viresh: I cannot test this change, but I have compiled it against
> spear600_defconfig. You'd have to test it and Acked-by: it before
> I do anything else with it. Try to think about what a minimum range
> would be for the generic SPEAr platform...
I have applied the patch and tested the same, it works fine on spear platforms.
The timer on spear platforms is 16 bit only (say with min. functional
freq as 187500 HZ.).
With these values the resolution of the timer is not much so what
should be the good value
of SPEAR_MIN_RANGE.
Tested-by: Shiraz Hashim <shiraz.hashim@st.com>
--
regards
Shiraz Hashim
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ARM: move SPEAr to use common mult/shift calculation code
2010-07-19 13:11 ` shiraz hashim
@ 2010-07-19 18:19 ` Linus Walleij
0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2010-07-19 18:19 UTC (permalink / raw)
To: linux-arm-kernel
2010/7/19 shiraz hashim <shiraz.linux.kernel@gmail.com>:
> The timer on spear platforms is 16 bit only (say with min. functional
> freq as 187500 HZ.).
> With these values the resolution of the timer is not much so what
> should be the good value
> of SPEAR_MIN_RANGE.
I've set it to 4 seconds, it will scale properly to assure the system
will get as much resolution as possible while still being able to
sleep for 4 seconds. 187 kHz is quite slow anyway.
> Tested-by: Shiraz Hashim <shiraz.hashim@st.com>
Thanks!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-07-19 18:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-28 17:33 [PATCH 1/2] ARM: move SPEAr to use common mult/shift calculation code Linus Walleij
2010-07-12 8:00 ` Linus Walleij
2010-07-19 13:11 ` shiraz hashim
2010-07-19 18:19 ` 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).