mvebu: backport mainline patches from kernel 3.13
[openwrt.git] / target / linux / mvebu / patches-3.10 / 0168-clocksource-armada-370-xp-Introduce-new-compatibles.patch
1 From 9cb47bf175645d15f97e6d964dd4a4f089275ef5 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Tue, 13 Aug 2013 11:43:13 -0300
4 Subject: [PATCH 168/203] clocksource: armada-370-xp: Introduce new compatibles
5
6 The Armada XP SoC clocksource driver cannot work without the 25 MHz
7 fixed timer. Therefore it's appropriate to introduce a new compatible
8 string and use it to set the 25 MHz fixed timer.
9
10 The 'marvell,timer-25MHz' property will be marked as deprecated.
11
12 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
13 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
14 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
15 ---
16  drivers/clocksource/time-armada-370-xp.c | 54 +++++++++++++++++++++++---------
17  1 file changed, 39 insertions(+), 15 deletions(-)
18
19 --- a/drivers/clocksource/time-armada-370-xp.c
20 +++ b/drivers/clocksource/time-armada-370-xp.c
21 @@ -13,6 +13,19 @@
22   *
23   * Timer 0 is used as free-running clocksource, while timer 1 is
24   * used as clock_event_device.
25 + *
26 + * ---
27 + * Clocksource driver for Armada 370 and Armada XP SoC.
28 + * This driver implements one compatible string for each SoC, given
29 + * each has its own characteristics:
30 + *
31 + *   * Armada 370 has no 25 MHz fixed timer.
32 + *
33 + *   * Armada XP cannot work properly without such 25 MHz fixed timer as
34 + *     doing otherwise leads to using a clocksource whose frequency varies
35 + *     when doing cpufreq frequency changes.
36 + *
37 + * See Documentation/devicetree/bindings/timer/marvell,armada-370-xp-timer.txt
38   */
39  
40  #include <linux/init.h>
41 @@ -212,7 +225,7 @@ static struct local_timer_ops armada_370
42         .stop   =  armada_370_xp_timer_stop,
43  };
44  
45 -static void __init armada_370_xp_timer_init(struct device_node *np)
46 +static void __init armada_370_xp_timer_common_init(struct device_node *np)
47  {
48         u32 clr = 0, set = 0;
49         int res;
50 @@ -221,20 +234,10 @@ static void __init armada_370_xp_timer_i
51         WARN_ON(!timer_base);
52         local_base = of_iomap(np, 1);
53  
54 -       if (of_find_property(np, "marvell,timer-25Mhz", NULL)) {
55 -               /* The fixed 25MHz timer is available so let's use it */
56 +       if (timer25Mhz)
57                 set = TIMER0_25MHZ;
58 -               timer_clk = 25000000;
59 -       } else {
60 -               unsigned long rate = 0;
61 -               struct clk *clk = of_clk_get(np, 0);
62 -               WARN_ON(IS_ERR(clk));
63 -               rate =  clk_get_rate(clk);
64 -               timer_clk = rate / TIMER_DIVIDER;
65 -
66 +       else
67                 clr = TIMER0_25MHZ;
68 -               timer25Mhz = false;
69 -       }
70         timer_ctrl_clrset(clr, set);
71         local_timer_ctrl_clrset(clr, set);
72  
73 @@ -288,5 +291,26 @@ static void __init armada_370_xp_timer_i
74  #endif
75         }
76  }
77 -CLOCKSOURCE_OF_DECLARE(armada_370_xp, "marvell,armada-370-xp-timer",
78 -                      armada_370_xp_timer_init);
79 +
80 +static void __init armada_xp_timer_init(struct device_node *np)
81 +{
82 +       /* The fixed 25MHz timer is required, timer25Mhz is true by default */
83 +       timer_clk = 25000000;
84 +
85 +       armada_370_xp_timer_common_init(np);
86 +}
87 +CLOCKSOURCE_OF_DECLARE(armada_xp, "marvell,armada-xp-timer",
88 +                      armada_xp_timer_init);
89 +
90 +static void __init armada_370_timer_init(struct device_node *np)
91 +{
92 +       struct clk *clk = of_clk_get(np, 0);
93 +
94 +       WARN_ON(IS_ERR(clk));
95 +       timer_clk = clk_get_rate(clk) / TIMER_DIVIDER;
96 +       timer25Mhz = false;
97 +
98 +       armada_370_xp_timer_common_init(np);
99 +}
100 +CLOCKSOURCE_OF_DECLARE(armada_370, "marvell,armada-370-timer",
101 +                      armada_370_timer_init);