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>
12 #include <asm/smp_twd.h>
16 #include <mach/setup.h>
17 #include <mach/hardware.h>
18 #include <mach/irqs.h>
20 #ifdef CONFIG_HAVE_ARM_TWD
21 static DEFINE_TWD_LOCAL_TIMER(u5500_twd_local_timer,
22 U5500_TWD_BASE, IRQ_LOCALTIMER);
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 twd_local_timer = cpu_is_u5500() ? &u5500_twd_local_timer :
32 &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 static void __init ux500_timer_init(void)
48 void __iomem *mtu_timer_base;
49 void __iomem *prcmu_timer_base;
52 mtu_timer_base = __io_address(U5500_MTU0_BASE);
53 prcmu_timer_base = __io_address(U5500_PRCMU_TIMER_3_BASE);
54 } else if (cpu_is_u8500_family()) {
55 mtu_timer_base = __io_address(U8500_MTU0_BASE);
56 prcmu_timer_base = __io_address(U8500_PRCMU_TIMER_4_BASE);
62 * Here we register the timerblocks active in the system.
63 * Localtimers (twd) is started when both cpu is up and running.
64 * MTU register a clocksource, clockevent and sched_clock.
65 * Since the MTU is located in the VAPE power domain
66 * it will be cleared in sleep which makes it unsuitable.
67 * We however need it as a timer tick (clockevent)
68 * during boot to calibrate delay until twd is started.
69 * RTC-RTT have problems as timer tick during boot since it is
70 * depending on delay which is not yet calibrated. RTC-RTT is in the
71 * always-on powerdomain and is used as clockevent instead of twd when
73 * The PRCMU timer 4(3 for DB5500) register a clocksource and
74 * sched_clock with higher rating then MTU since is always-on.
78 nmdk_timer_init(mtu_timer_base);
79 clksrc_dbx500_prcmu_init(prcmu_timer_base);
83 static void ux500_timer_reset(void)
89 struct sys_timer ux500_timer = {
90 .init = ux500_timer_init,
91 .resume = ux500_timer_reset,