2 * Copyright (C) ST-Ericsson SA 2011
4 * License Terms: GNU General Public License v2
5 * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson
8 #include <linux/errno.h>
9 #include <linux/clksrc-dbx500-prcmu.h>
11 #include <linux/of_address.h>
12 #include <linux/platform_data/clocksource-nomadik-mtu.h>
14 #include <asm/smp_twd.h>
16 #include <mach/setup.h>
17 #include <mach/hardware.h>
18 #include <mach/irqs.h>
22 #ifdef CONFIG_HAVE_ARM_TWD
23 static DEFINE_TWD_LOCAL_TIMER(u8500_twd_local_timer
,
24 U8500_TWD_BASE
, IRQ_LOCALTIMER
);
26 static void __init
ux500_twd_init(void)
28 struct twd_local_timer
*twd_local_timer
;
31 /* Use this to switch local timer base if changed in new ASICs */
32 twd_local_timer
= &u8500_twd_local_timer
;
34 if (of_have_populated_dt())
35 twd_local_timer_of_register();
37 err
= twd_local_timer_register(twd_local_timer
);
39 pr_err("twd_local_timer_register failed %d\n", err
);
43 #define ux500_twd_init() do { } while(0)
46 const static struct of_device_id prcmu_timer_of_match
[] __initconst
= {
47 { .compatible
= "stericsson,db8500-prcmu-timer-4", },
51 void __init
ux500_timer_init(void)
53 void __iomem
*mtu_timer_base
;
54 void __iomem
*prcmu_timer_base
;
55 void __iomem
*tmp_base
;
56 struct device_node
*np
;
58 if (cpu_is_u8500_family() || cpu_is_ux540_family()) {
59 mtu_timer_base
= __io_address(U8500_MTU0_BASE
);
60 prcmu_timer_base
= __io_address(U8500_PRCMU_TIMER_4_BASE
);
65 /* TODO: Once MTU has been DT:ed place code above into else. */
66 if (of_have_populated_dt()) {
68 np
= of_find_matching_node(NULL
, prcmu_timer_of_match
);
73 tmp_base
= of_iomap(np
, 0);
77 prcmu_timer_base
= tmp_base
;
81 /* Doing it the old fashioned way. */
84 * Here we register the timerblocks active in the system.
85 * Localtimers (twd) is started when both cpu is up and running.
86 * MTU register a clocksource, clockevent and sched_clock.
87 * Since the MTU is located in the VAPE power domain
88 * it will be cleared in sleep which makes it unsuitable.
89 * We however need it as a timer tick (clockevent)
90 * during boot to calibrate delay until twd is started.
91 * RTC-RTT have problems as timer tick during boot since it is
92 * depending on delay which is not yet calibrated. RTC-RTT is in the
93 * always-on powerdomain and is used as clockevent instead of twd when
95 * The PRCMU timer 4 register a clocksource and
96 * sched_clock with higher rating then MTU since is always-on.
100 nmdk_timer_init(mtu_timer_base
, IRQ_MTU0
);
101 clksrc_dbx500_prcmu_init(prcmu_timer_base
);