diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2014-12-24 08:11:55 -0500 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2015-06-22 04:36:57 -0400 |
commit | 72d72880612705143ad32cf4ede0d6ae27e8b975 (patch) | |
tree | 6c6c27f15e796e3addb8702f29e2dfbccc7a58ee | |
parent | aa6083ed50957f699596999affbb6eb9d7a8b72e (diff) |
ARCv2: SMP: clocksource: Enable Global Real Time counter
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
-rw-r--r-- | arch/arc/Kconfig | 5 | ||||
-rw-r--r-- | arch/arc/include/asm/mcip.h | 3 | ||||
-rw-r--r-- | arch/arc/kernel/mcip.c | 3 | ||||
-rw-r--r-- | arch/arc/kernel/time.c | 45 |
4 files changed, 56 insertions, 0 deletions
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index ef5ca5969eaf..1b684595e258 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig | |||
@@ -384,6 +384,11 @@ config ARC_HAS_RTC | |||
384 | default n | 384 | default n |
385 | depends on !SMP | 385 | depends on !SMP |
386 | 386 | ||
387 | config ARC_HAS_GRTC | ||
388 | bool "SMP synchronized 64-bit cycle counter" | ||
389 | default y | ||
390 | depends on SMP | ||
391 | |||
387 | config ARC_NUMBER_OF_INTERRUPTS | 392 | config ARC_NUMBER_OF_INTERRUPTS |
388 | int "Number of interrupts" | 393 | int "Number of interrupts" |
389 | range 8 240 | 394 | range 8 240 |
diff --git a/arch/arc/include/asm/mcip.h b/arch/arc/include/asm/mcip.h index 31f9bac77a27..52c11f0bb0e5 100644 --- a/arch/arc/include/asm/mcip.h +++ b/arch/arc/include/asm/mcip.h | |||
@@ -39,6 +39,9 @@ struct mcip_cmd { | |||
39 | #define CMD_DEBUG_SET_MASK 0x34 | 39 | #define CMD_DEBUG_SET_MASK 0x34 |
40 | #define CMD_DEBUG_SET_SELECT 0x36 | 40 | #define CMD_DEBUG_SET_SELECT 0x36 |
41 | 41 | ||
42 | #define CMD_GRTC_READ_LO 0x42 | ||
43 | #define CMD_GRTC_READ_HI 0x43 | ||
44 | |||
42 | #define CMD_IDU_ENABLE 0x71 | 45 | #define CMD_IDU_ENABLE 0x71 |
43 | #define CMD_IDU_DISABLE 0x72 | 46 | #define CMD_IDU_DISABLE 0x72 |
44 | #define CMD_IDU_SET_MODE 0x74 | 47 | #define CMD_IDU_SET_MODE 0x74 |
diff --git a/arch/arc/kernel/mcip.c b/arch/arc/kernel/mcip.c index 35921c3ab394..ad7e90b97f6e 100644 --- a/arch/arc/kernel/mcip.c +++ b/arch/arc/kernel/mcip.c | |||
@@ -154,4 +154,7 @@ void mcip_init_early_smp(void) | |||
154 | __mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, 0xf); | 154 | __mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, 0xf); |
155 | __mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xf, 0xf); | 155 | __mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xf, 0xf); |
156 | } | 156 | } |
157 | |||
158 | if (IS_ENABLED(CONFIG_ARC_HAS_GRTC) && !mp.grtc) | ||
159 | panic("kernel trying to use non-existent GRTC\n"); | ||
157 | } | 160 | } |
diff --git a/arch/arc/kernel/time.c b/arch/arc/kernel/time.c index da495478a40b..3364d2bbc515 100644 --- a/arch/arc/kernel/time.c +++ b/arch/arc/kernel/time.c | |||
@@ -45,6 +45,8 @@ | |||
45 | #include <asm/clk.h> | 45 | #include <asm/clk.h> |
46 | #include <asm/mach_desc.h> | 46 | #include <asm/mach_desc.h> |
47 | 47 | ||
48 | #include <asm/mcip.h> | ||
49 | |||
48 | /* Timer related Aux registers */ | 50 | /* Timer related Aux registers */ |
49 | #define ARC_REG_TIMER0_LIMIT 0x23 /* timer 0 limit */ | 51 | #define ARC_REG_TIMER0_LIMIT 0x23 /* timer 0 limit */ |
50 | #define ARC_REG_TIMER0_CTRL 0x22 /* timer 0 control */ | 52 | #define ARC_REG_TIMER0_CTRL 0x22 /* timer 0 control */ |
@@ -60,6 +62,48 @@ | |||
60 | 62 | ||
61 | /********** Clock Source Device *********/ | 63 | /********** Clock Source Device *********/ |
62 | 64 | ||
65 | #ifdef CONFIG_ARC_HAS_GRTC | ||
66 | |||
67 | static int arc_counter_setup(void) | ||
68 | { | ||
69 | return 1; | ||
70 | } | ||
71 | |||
72 | static cycle_t arc_counter_read(struct clocksource *cs) | ||
73 | { | ||
74 | unsigned long flags; | ||
75 | union { | ||
76 | #ifdef CONFIG_CPU_BIG_ENDIAN | ||
77 | struct { u32 h, l; }; | ||
78 | #else | ||
79 | struct { u32 l, h; }; | ||
80 | #endif | ||
81 | cycle_t full; | ||
82 | } stamp; | ||
83 | |||
84 | local_irq_save(flags); | ||
85 | |||
86 | __mcip_cmd(CMD_GRTC_READ_LO, 0); | ||
87 | stamp.l = read_aux_reg(ARC_REG_MCIP_READBACK); | ||
88 | |||
89 | __mcip_cmd(CMD_GRTC_READ_HI, 0); | ||
90 | stamp.h = read_aux_reg(ARC_REG_MCIP_READBACK); | ||
91 | |||
92 | local_irq_restore(flags); | ||
93 | |||
94 | return stamp.full; | ||
95 | } | ||
96 | |||
97 | static struct clocksource arc_counter = { | ||
98 | .name = "ARConnect GRTC", | ||
99 | .rating = 400, | ||
100 | .read = arc_counter_read, | ||
101 | .mask = CLOCKSOURCE_MASK(64), | ||
102 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
103 | }; | ||
104 | |||
105 | #else | ||
106 | |||
63 | #ifdef CONFIG_ARC_HAS_RTC | 107 | #ifdef CONFIG_ARC_HAS_RTC |
64 | 108 | ||
65 | #define AUX_RTC_CTRL 0x103 | 109 | #define AUX_RTC_CTRL 0x103 |
@@ -135,6 +179,7 @@ static struct clocksource arc_counter = { | |||
135 | }; | 179 | }; |
136 | 180 | ||
137 | #endif | 181 | #endif |
182 | #endif | ||
138 | 183 | ||
139 | /********** Clock Event Device *********/ | 184 | /********** Clock Event Device *********/ |
140 | 185 | ||