aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2016-09-01 12:33:46 -0400
committerThomas Gleixner <tglx@linutronix.de>2016-09-01 12:33:46 -0400
commit0cb7bf61b1e9f05027de58c80f9b46a714d24e35 (patch)
tree41fb55cf62d07b425122f9a8b96412c0d8eb99c5 /drivers/clocksource
parentaa877175e7a9982233ed8f10cb4bfddd78d82741 (diff)
parent3eab887a55424fc2c27553b7bfe32330df83f7b8 (diff)
Merge branch 'linus' into smp/hotplug
Apply upstream changes to avoid conflicts with pending patches.
Diffstat (limited to 'drivers/clocksource')
-rw-r--r--drivers/clocksource/arm_arch_timer.c26
-rw-r--r--drivers/clocksource/bcm_kona_timer.c16
-rw-r--r--drivers/clocksource/mips-gic-timer.c2
-rw-r--r--drivers/clocksource/pxa_timer.c2
-rw-r--r--drivers/clocksource/sun4i_timer.c9
-rw-r--r--drivers/clocksource/time-armada-370-xp.c1
-rw-r--r--drivers/clocksource/time-pistachio.c8
-rw-r--r--drivers/clocksource/timer-atmel-pit.c6
8 files changed, 54 insertions, 16 deletions
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 28bce3f4f81d..57700541f951 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -8,6 +8,9 @@
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11
12#define pr_fmt(fmt) "arm_arch_timer: " fmt
13
11#include <linux/init.h> 14#include <linux/init.h>
12#include <linux/kernel.h> 15#include <linux/kernel.h>
13#include <linux/device.h> 16#include <linux/device.h>
@@ -370,16 +373,33 @@ static bool arch_timer_has_nonsecure_ppi(void)
370 arch_timer_ppi[PHYS_NONSECURE_PPI]); 373 arch_timer_ppi[PHYS_NONSECURE_PPI]);
371} 374}
372 375
376static u32 check_ppi_trigger(int irq)
377{
378 u32 flags = irq_get_trigger_type(irq);
379
380 if (flags != IRQF_TRIGGER_HIGH && flags != IRQF_TRIGGER_LOW) {
381 pr_warn("WARNING: Invalid trigger for IRQ%d, assuming level low\n", irq);
382 pr_warn("WARNING: Please fix your firmware\n");
383 flags = IRQF_TRIGGER_LOW;
384 }
385
386 return flags;
387}
388
373static int arch_timer_starting_cpu(unsigned int cpu) 389static int arch_timer_starting_cpu(unsigned int cpu)
374{ 390{
375 struct clock_event_device *clk = this_cpu_ptr(arch_timer_evt); 391 struct clock_event_device *clk = this_cpu_ptr(arch_timer_evt);
392 u32 flags;
376 393
377 __arch_timer_setup(ARCH_CP15_TIMER, clk); 394 __arch_timer_setup(ARCH_CP15_TIMER, clk);
378 395
379 enable_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi], 0); 396 flags = check_ppi_trigger(arch_timer_ppi[arch_timer_uses_ppi]);
397 enable_percpu_irq(arch_timer_ppi[arch_timer_uses_ppi], flags);
380 398
381 if (arch_timer_has_nonsecure_ppi()) 399 if (arch_timer_has_nonsecure_ppi()) {
382 enable_percpu_irq(arch_timer_ppi[PHYS_NONSECURE_PPI], 0); 400 flags = check_ppi_trigger(arch_timer_ppi[PHYS_NONSECURE_PPI]);
401 enable_percpu_irq(arch_timer_ppi[PHYS_NONSECURE_PPI], flags);
402 }
383 403
384 arch_counter_set_user_access(); 404 arch_counter_set_user_access();
385 if (evtstrm_enable) 405 if (evtstrm_enable)
diff --git a/drivers/clocksource/bcm_kona_timer.c b/drivers/clocksource/bcm_kona_timer.c
index 7e3fd375a627..92f6e4deee74 100644
--- a/drivers/clocksource/bcm_kona_timer.c
+++ b/drivers/clocksource/bcm_kona_timer.c
@@ -66,10 +66,10 @@ static void kona_timer_disable_and_clear(void __iomem *base)
66 66
67} 67}
68 68
69static void 69static int
70kona_timer_get_counter(void __iomem *timer_base, uint32_t *msw, uint32_t *lsw) 70kona_timer_get_counter(void __iomem *timer_base, uint32_t *msw, uint32_t *lsw)
71{ 71{
72 int loop_limit = 4; 72 int loop_limit = 3;
73 73
74 /* 74 /*
75 * Read 64-bit free running counter 75 * Read 64-bit free running counter
@@ -83,18 +83,19 @@ kona_timer_get_counter(void __iomem *timer_base, uint32_t *msw, uint32_t *lsw)
83 * if new hi-word is equal to previously read hi-word then stop. 83 * if new hi-word is equal to previously read hi-word then stop.
84 */ 84 */
85 85
86 while (--loop_limit) { 86 do {
87 *msw = readl(timer_base + KONA_GPTIMER_STCHI_OFFSET); 87 *msw = readl(timer_base + KONA_GPTIMER_STCHI_OFFSET);
88 *lsw = readl(timer_base + KONA_GPTIMER_STCLO_OFFSET); 88 *lsw = readl(timer_base + KONA_GPTIMER_STCLO_OFFSET);
89 if (*msw == readl(timer_base + KONA_GPTIMER_STCHI_OFFSET)) 89 if (*msw == readl(timer_base + KONA_GPTIMER_STCHI_OFFSET))
90 break; 90 break;
91 } 91 } while (--loop_limit);
92 if (!loop_limit) { 92 if (!loop_limit) {
93 pr_err("bcm_kona_timer: getting counter failed.\n"); 93 pr_err("bcm_kona_timer: getting counter failed.\n");
94 pr_err(" Timer will be impacted\n"); 94 pr_err(" Timer will be impacted\n");
95 return -ETIMEDOUT;
95 } 96 }
96 97
97 return; 98 return 0;
98} 99}
99 100
100static int kona_timer_set_next_event(unsigned long clc, 101static int kona_timer_set_next_event(unsigned long clc,
@@ -112,8 +113,11 @@ static int kona_timer_set_next_event(unsigned long clc,
112 113
113 uint32_t lsw, msw; 114 uint32_t lsw, msw;
114 uint32_t reg; 115 uint32_t reg;
116 int ret;
115 117
116 kona_timer_get_counter(timers.tmr_regs, &msw, &lsw); 118 ret = kona_timer_get_counter(timers.tmr_regs, &msw, &lsw);
119 if (ret)
120 return ret;
117 121
118 /* Load the "next" event tick value */ 122 /* Load the "next" event tick value */
119 writel(lsw + clc, timers.tmr_regs + KONA_GPTIMER_STCM0_OFFSET); 123 writel(lsw + clc, timers.tmr_regs + KONA_GPTIMER_STCM0_OFFSET);
diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c
index d91e8725917c..b4b3ab5a11ad 100644
--- a/drivers/clocksource/mips-gic-timer.c
+++ b/drivers/clocksource/mips-gic-timer.c
@@ -164,7 +164,7 @@ void __init gic_clocksource_init(unsigned int frequency)
164 gic_start_count(); 164 gic_start_count();
165} 165}
166 166
167static void __init gic_clocksource_of_init(struct device_node *node) 167static int __init gic_clocksource_of_init(struct device_node *node)
168{ 168{
169 struct clk *clk; 169 struct clk *clk;
170 int ret; 170 int ret;
diff --git a/drivers/clocksource/pxa_timer.c b/drivers/clocksource/pxa_timer.c
index 937e10b84d58..3e1cb512f3ce 100644
--- a/drivers/clocksource/pxa_timer.c
+++ b/drivers/clocksource/pxa_timer.c
@@ -21,6 +21,8 @@
21#include <linux/of_irq.h> 21#include <linux/of_irq.h>
22#include <linux/sched_clock.h> 22#include <linux/sched_clock.h>
23 23
24#include <clocksource/pxa.h>
25
24#include <asm/div64.h> 26#include <asm/div64.h>
25 27
26#define OSMR0 0x00 /* OS Timer 0 Match Register */ 28#define OSMR0 0x00 /* OS Timer 0 Match Register */
diff --git a/drivers/clocksource/sun4i_timer.c b/drivers/clocksource/sun4i_timer.c
index 97669ee4df2a..c83452cacb41 100644
--- a/drivers/clocksource/sun4i_timer.c
+++ b/drivers/clocksource/sun4i_timer.c
@@ -123,12 +123,16 @@ static struct clock_event_device sun4i_clockevent = {
123 .set_next_event = sun4i_clkevt_next_event, 123 .set_next_event = sun4i_clkevt_next_event,
124}; 124};
125 125
126static void sun4i_timer_clear_interrupt(void)
127{
128 writel(TIMER_IRQ_EN(0), timer_base + TIMER_IRQ_ST_REG);
129}
126 130
127static irqreturn_t sun4i_timer_interrupt(int irq, void *dev_id) 131static irqreturn_t sun4i_timer_interrupt(int irq, void *dev_id)
128{ 132{
129 struct clock_event_device *evt = (struct clock_event_device *)dev_id; 133 struct clock_event_device *evt = (struct clock_event_device *)dev_id;
130 134
131 writel(0x1, timer_base + TIMER_IRQ_ST_REG); 135 sun4i_timer_clear_interrupt();
132 evt->event_handler(evt); 136 evt->event_handler(evt);
133 137
134 return IRQ_HANDLED; 138 return IRQ_HANDLED;
@@ -208,6 +212,9 @@ static int __init sun4i_timer_init(struct device_node *node)
208 /* Make sure timer is stopped before playing with interrupts */ 212 /* Make sure timer is stopped before playing with interrupts */
209 sun4i_clkevt_time_stop(0); 213 sun4i_clkevt_time_stop(0);
210 214
215 /* clear timer0 interrupt */
216 sun4i_timer_clear_interrupt();
217
211 sun4i_clockevent.cpumask = cpu_possible_mask; 218 sun4i_clockevent.cpumask = cpu_possible_mask;
212 sun4i_clockevent.irq = irq; 219 sun4i_clockevent.irq = irq;
213 220
diff --git a/drivers/clocksource/time-armada-370-xp.c b/drivers/clocksource/time-armada-370-xp.c
index 719b478d136e..3c39e6f45971 100644
--- a/drivers/clocksource/time-armada-370-xp.c
+++ b/drivers/clocksource/time-armada-370-xp.c
@@ -338,7 +338,6 @@ static int __init armada_xp_timer_init(struct device_node *np)
338 struct clk *clk = of_clk_get_by_name(np, "fixed"); 338 struct clk *clk = of_clk_get_by_name(np, "fixed");
339 int ret; 339 int ret;
340 340
341 clk = of_clk_get(np, 0);
342 if (IS_ERR(clk)) { 341 if (IS_ERR(clk)) {
343 pr_err("Failed to get clock"); 342 pr_err("Failed to get clock");
344 return PTR_ERR(clk); 343 return PTR_ERR(clk);
diff --git a/drivers/clocksource/time-pistachio.c b/drivers/clocksource/time-pistachio.c
index a7d9a08e4b0e..a8e6c7df853d 100644
--- a/drivers/clocksource/time-pistachio.c
+++ b/drivers/clocksource/time-pistachio.c
@@ -202,10 +202,10 @@ static int __init pistachio_clksrc_of_init(struct device_node *node)
202 rate = clk_get_rate(fast_clk); 202 rate = clk_get_rate(fast_clk);
203 203
204 /* Disable irq's for clocksource usage */ 204 /* Disable irq's for clocksource usage */
205 gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 0); 205 gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 0);
206 gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 1); 206 gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 1);
207 gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 2); 207 gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 2);
208 gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 3); 208 gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 3);
209 209
210 /* Enable timer block */ 210 /* Enable timer block */
211 writel(TIMER_ME_GLOBAL, pcs_gpt.base); 211 writel(TIMER_ME_GLOBAL, pcs_gpt.base);
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index 1ffac0cb0cb7..3494bc5a21d5 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -261,6 +261,12 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
261 return PTR_ERR(data->mck); 261 return PTR_ERR(data->mck);
262 } 262 }
263 263
264 ret = clk_prepare_enable(data->mck);
265 if (ret) {
266 pr_err("Unable to enable mck\n");
267 return ret;
268 }
269
264 /* Get the interrupts property */ 270 /* Get the interrupts property */
265 data->irq = irq_of_parse_and_map(node, 0); 271 data->irq = irq_of_parse_and_map(node, 0);
266 if (!data->irq) { 272 if (!data->irq) {