]> Pileus Git - ~andy/linux/blob - arch/arm/mach-ux500/timer.c
ARM: ux500: Reprogram timers upon resume
[~andy/linux] / arch / arm / mach-ux500 / timer.c
1 /*
2  * Copyright (C) ST-Ericsson SA 2011
3  *
4  * License Terms: GNU General Public License v2
5  * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson
6  */
7 #include <linux/io.h>
8 #include <linux/clksrc-dbx500-prcmu.h>
9
10 #include <asm/localtimer.h>
11
12 #include <plat/mtu.h>
13
14 #include <mach/setup.h>
15 #include <mach/hardware.h>
16
17 static void __init ux500_timer_init(void)
18 {
19         if (cpu_is_u5500()) {
20 #ifdef CONFIG_LOCAL_TIMERS
21                 twd_base = __io_address(U5500_TWD_BASE);
22 #endif
23                 mtu_base = __io_address(U5500_MTU0_BASE);
24                 clksrc_dbx500_timer_base = __io_address(U5500_PRCMU_TIMER_3_BASE);
25         } else if (cpu_is_u8500()) {
26 #ifdef CONFIG_LOCAL_TIMERS
27                 twd_base = __io_address(U8500_TWD_BASE);
28 #endif
29                 mtu_base = __io_address(U8500_MTU0_BASE);
30                 clksrc_dbx500_timer_base = __io_address(U8500_PRCMU_TIMER_4_BASE);
31         } else {
32                 ux500_unknown_soc();
33         }
34
35         /*
36          * Here we register the timerblocks active in the system.
37          * Localtimers (twd) is started when both cpu is up and running.
38          * MTU register a clocksource, clockevent and sched_clock.
39          * Since the MTU is located in the VAPE power domain
40          * it will be cleared in sleep which makes it unsuitable.
41          * We however need it as a timer tick (clockevent)
42          * during boot to calibrate delay until twd is started.
43          * RTC-RTT have problems as timer tick during boot since it is
44          * depending on delay which is not yet calibrated. RTC-RTT is in the
45          * always-on powerdomain and is used as clockevent instead of twd when
46          * sleeping.
47          * The PRCMU timer 4(3 for DB5500) register a clocksource and
48          * sched_clock with higher rating then MTU since is always-on.
49          *
50          */
51
52         nmdk_timer_init();
53         clksrc_dbx500_prcmu_init();
54 }
55
56 static void ux500_timer_reset(void)
57 {
58         nmdk_clkevt_reset();
59         nmdk_clksrc_reset();
60 }
61
62 struct sys_timer ux500_timer = {
63         .init           = ux500_timer_init,
64         .resume         = ux500_timer_reset,
65 };