Skip to content

Commit e700e41

Browse files
Marc Zyngierkgene
authored andcommitted
ARM: EXYNOS4: convert MCT to percpu interrupt API
MCT recently gained per cpu interrupts, and missed the fact that ARM has moved to a genirq based implementation. This patch converts the driver to the new API. Boot tested on Origen. Cc: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
1 parent d8633c1 commit e700e41

1 file changed

Lines changed: 27 additions & 13 deletions

File tree

  • arch/arm/mach-exynos4

‎arch/arm/mach-exynos4/mct.c‎

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct mct_clock_event_device {
4444
char name[10];
4545
};
4646

47-
struct mct_clock_event_device mct_tick[NR_CPUS];
47+
static DEFINE_PER_CPU(struct mct_clock_event_device, percpu_mct_tick);
4848

4949
static void exynos4_mct_write(unsigned int value, void *addr)
5050
{
@@ -302,7 +302,7 @@ static void exynos4_mct_tick_start(unsigned long cycles,
302302
static int exynos4_tick_set_next_event(unsigned long cycles,
303303
struct clock_event_device *evt)
304304
{
305-
struct mct_clock_event_device *mevt = &mct_tick[smp_processor_id()];
305+
struct mct_clock_event_device *mevt = this_cpu_ptr(&percpu_mct_tick);
306306

307307
exynos4_mct_tick_start(cycles, mevt);
308308

@@ -312,7 +312,7 @@ static int exynos4_tick_set_next_event(unsigned long cycles,
312312
static inline void exynos4_tick_set_mode(enum clock_event_mode mode,
313313
struct clock_event_device *evt)
314314
{
315-
struct mct_clock_event_device *mevt = &mct_tick[smp_processor_id()];
315+
struct mct_clock_event_device *mevt = this_cpu_ptr(&percpu_mct_tick);
316316

317317
exynos4_mct_tick_stop(mevt);
318318

@@ -376,14 +376,16 @@ static struct irqaction mct_tick1_event_irq = {
376376

377377
static void exynos4_mct_tick_init(struct clock_event_device *evt)
378378
{
379+
struct mct_clock_event_device *mevt;
379380
unsigned int cpu = smp_processor_id();
380381

381-
mct_tick[cpu].evt = evt;
382+
mevt = this_cpu_ptr(&percpu_mct_tick);
383+
mevt->evt = evt;
382384

383-
mct_tick[cpu].base = EXYNOS4_MCT_L_BASE(cpu);
384-
sprintf(mct_tick[cpu].name, "mct_tick%d", cpu);
385+
mevt->base = EXYNOS4_MCT_L_BASE(cpu);
386+
sprintf(mevt->name, "mct_tick%d", cpu);
385387

386-
evt->name = mct_tick[cpu].name;
388+
evt->name = mevt->name;
387389
evt->cpumask = cpumask_of(cpu);
388390
evt->set_next_event = exynos4_tick_set_next_event;
389391
evt->set_mode = exynos4_tick_set_mode;
@@ -398,21 +400,21 @@ static void exynos4_mct_tick_init(struct clock_event_device *evt)
398400

399401
clockevents_register_device(evt);
400402

401-
exynos4_mct_write(0x1, mct_tick[cpu].base + MCT_L_TCNTB_OFFSET);
403+
exynos4_mct_write(0x1, mevt->base + MCT_L_TCNTB_OFFSET);
402404

403405
if (mct_int_type == MCT_INT_SPI) {
404406
if (cpu == 0) {
405-
mct_tick0_event_irq.dev_id = &mct_tick[cpu];
407+
mct_tick0_event_irq.dev_id = mevt;
406408
evt->irq = IRQ_MCT_L0;
407409
setup_irq(IRQ_MCT_L0, &mct_tick0_event_irq);
408410
} else {
409-
mct_tick1_event_irq.dev_id = &mct_tick[cpu];
411+
mct_tick1_event_irq.dev_id = mevt;
410412
evt->irq = IRQ_MCT_L1;
411413
setup_irq(IRQ_MCT_L1, &mct_tick1_event_irq);
412414
irq_set_affinity(IRQ_MCT_L1, cpumask_of(1));
413415
}
414416
} else {
415-
gic_enable_ppi(IRQ_MCT_LOCALTIMER);
417+
enable_percpu_irq(IRQ_MCT_LOCALTIMER, 0);
416418
}
417419
}
418420

@@ -427,9 +429,11 @@ int __cpuinit local_timer_setup(struct clock_event_device *evt)
427429
void local_timer_stop(struct clock_event_device *evt)
428430
{
429431
evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
430-
disable_irq(evt->irq);
432+
if (mct_int_type == MCT_INT_SPI)
433+
disable_irq(evt->irq);
434+
else
435+
disable_percpu_irq(IRQ_MCT_LOCALTIMER);
431436
}
432-
433437
#endif /* CONFIG_LOCAL_TIMERS */
434438

435439
static void __init exynos4_timer_resources(void)
@@ -438,6 +442,16 @@ static void __init exynos4_timer_resources(void)
438442
mct_clk = clk_get(NULL, "xtal");
439443

440444
clk_rate = clk_get_rate(mct_clk);
445+
446+
if (mct_int_type == MCT_INT_PPI) {
447+
int err;
448+
449+
err = request_percpu_irq(IRQ_MCT_LOCALTIMER,
450+
exynos4_mct_tick_isr, "MCT",
451+
&percpu_mct_tick);
452+
WARN(err, "MCT: can't request IRQ %d (%d)\n",
453+
IRQ_MCT_LOCALTIMER, err);
454+
}
441455
}
442456

443457
static void __init exynos4_timer_init(void)

0 commit comments

Comments
 (0)