Skip to content

Commit 7cd6392

Browse files
ezequielgarciadlezcano
authored andcommitted
clocksource: armada-370-xp: Introduce new compatibles
The Armada XP SoC clocksource driver cannot work without the 25 MHz fixed timer. Therefore it's appropriate to introduce a new compatible string and use it to set the 25 MHz fixed timer. The 'marvell,timer-25MHz' property will be marked as deprecated. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
1 parent 573145f commit 7cd6392

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

drivers/clocksource/time-armada-370-xp.c

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
*
1414
* Timer 0 is used as free-running clocksource, while timer 1 is
1515
* used as clock_event_device.
16+
*
17+
* ---
18+
* Clocksource driver for Armada 370 and Armada XP SoC.
19+
* This driver implements one compatible string for each SoC, given
20+
* each has its own characteristics:
21+
*
22+
* * Armada 370 has no 25 MHz fixed timer.
23+
*
24+
* * Armada XP cannot work properly without such 25 MHz fixed timer as
25+
* doing otherwise leads to using a clocksource whose frequency varies
26+
* when doing cpufreq frequency changes.
27+
*
28+
* See Documentation/devicetree/bindings/timer/marvell,armada-370-xp-timer.txt
1629
*/
1730

1831
#include <linux/init.h>
@@ -212,7 +225,7 @@ static struct local_timer_ops armada_370_xp_local_timer_ops = {
212225
.stop = armada_370_xp_timer_stop,
213226
};
214227

215-
static void __init armada_370_xp_timer_init(struct device_node *np)
228+
static void __init armada_370_xp_timer_common_init(struct device_node *np)
216229
{
217230
u32 clr = 0, set = 0;
218231
int res;
@@ -221,20 +234,10 @@ static void __init armada_370_xp_timer_init(struct device_node *np)
221234
WARN_ON(!timer_base);
222235
local_base = of_iomap(np, 1);
223236

224-
if (of_find_property(np, "marvell,timer-25Mhz", NULL)) {
225-
/* The fixed 25MHz timer is available so let's use it */
237+
if (timer25Mhz)
226238
set = TIMER0_25MHZ;
227-
timer_clk = 25000000;
228-
} else {
229-
unsigned long rate = 0;
230-
struct clk *clk = of_clk_get(np, 0);
231-
WARN_ON(IS_ERR(clk));
232-
rate = clk_get_rate(clk);
233-
timer_clk = rate / TIMER_DIVIDER;
234-
239+
else
235240
clr = TIMER0_25MHZ;
236-
timer25Mhz = false;
237-
}
238241
timer_ctrl_clrset(clr, set);
239242
local_timer_ctrl_clrset(clr, set);
240243

@@ -288,5 +291,26 @@ static void __init armada_370_xp_timer_init(struct device_node *np)
288291
#endif
289292
}
290293
}
291-
CLOCKSOURCE_OF_DECLARE(armada_370_xp, "marvell,armada-370-xp-timer",
292-
armada_370_xp_timer_init);
294+
295+
static void __init armada_xp_timer_init(struct device_node *np)
296+
{
297+
/* The fixed 25MHz timer is required, timer25Mhz is true by default */
298+
timer_clk = 25000000;
299+
300+
armada_370_xp_timer_common_init(np);
301+
}
302+
CLOCKSOURCE_OF_DECLARE(armada_xp, "marvell,armada-xp-timer",
303+
armada_xp_timer_init);
304+
305+
static void __init armada_370_timer_init(struct device_node *np)
306+
{
307+
struct clk *clk = of_clk_get(np, 0);
308+
309+
WARN_ON(IS_ERR(clk));
310+
timer_clk = clk_get_rate(clk) / TIMER_DIVIDER;
311+
timer25Mhz = false;
312+
313+
armada_370_xp_timer_common_init(np);
314+
}
315+
CLOCKSOURCE_OF_DECLARE(armada_370, "marvell,armada-370-timer",
316+
armada_370_timer_init);

0 commit comments

Comments
 (0)