Lines Matching +full:clk +full:- +full:delay +full:- +full:cycles
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* linux/arch/arm/mach-exynos4/mct.c
7 * Exynos4 MCT(Multi-Core Timer) support
13 #include <linux/clk.h>
16 #include <linux/delay.h>
161 * exynos4_read_count_64 - Read all 64-bits of the global counter
163 * This will read all 64-bits of the global counter taking care to make sure
165 * slow (hundreds of nanoseconds) so you should use the 32-bit (lower half
168 * Returns the number of cycles in the global counter.
185 * exynos4_read_count_32 - Read the lower 32-bits of the global counter
187 * This will read just the lower 32-bits of the global counter. This is marked
190 * Returns the number of cycles in the global counter (lower 32 bits).
208 .name = "mct-frc",
227 "cycles_t needs to move to 32-bit for ARM64 usage"); in exynos4_read_current_timer()
261 static void exynos4_mct_comp0_start(bool periodic, unsigned long cycles) in exynos4_mct_comp0_start() argument
270 exynos4_mct_write(cycles, EXYNOS4_MCT_G_COMP0_ADD_INCR); in exynos4_mct_comp0_start()
273 comp_cycle = exynos4_read_count_64() + cycles; in exynos4_mct_comp0_start()
283 static int exynos4_comp_set_next_event(unsigned long cycles, in exynos4_comp_set_next_event() argument
286 exynos4_mct_comp0_start(false, cycles); in exynos4_comp_set_next_event()
301 cycles_per_jiffy = (((unsigned long long)NSEC_PER_SEC / HZ * evt->mult) in mct_set_state_periodic()
302 >> evt->shift); in mct_set_state_periodic()
309 .name = "mct-comp",
327 evt->event_handler(evt); in exynos4_mct_comp_isr()
352 unsigned long offset = mevt->base + MCT_L_TCON_OFFSET; in exynos4_mct_tick_stop()
361 static void exynos4_mct_tick_start(unsigned long cycles, in exynos4_mct_tick_start() argument
368 tmp = (1 << 31) | cycles; /* MCT_L_UPDATE_ICNTB */ in exynos4_mct_tick_start()
371 exynos4_mct_write(tmp, mevt->base + MCT_L_ICNTB_OFFSET); in exynos4_mct_tick_start()
374 exynos4_mct_write(0x1, mevt->base + MCT_L_INT_ENB_OFFSET); in exynos4_mct_tick_start()
376 tmp = readl_relaxed(reg_base + mevt->base + MCT_L_TCON_OFFSET); in exynos4_mct_tick_start()
379 exynos4_mct_write(tmp, mevt->base + MCT_L_TCON_OFFSET); in exynos4_mct_tick_start()
385 if (readl_relaxed(reg_base + mevt->base + MCT_L_INT_CSTAT_OFFSET) & 1) in exynos4_mct_tick_clear()
386 exynos4_mct_write(0x1, mevt->base + MCT_L_INT_CSTAT_OFFSET); in exynos4_mct_tick_clear()
389 static int exynos4_tick_set_next_event(unsigned long cycles, in exynos4_tick_set_next_event() argument
395 exynos4_mct_tick_start(cycles, mevt); in exynos4_tick_set_next_event()
415 cycles_per_jiffy = (((unsigned long long)NSEC_PER_SEC / HZ * evt->mult) in set_state_periodic()
416 >> evt->shift); in set_state_periodic()
425 struct clock_event_device *evt = &mevt->evt; in exynos4_mct_tick_isr()
432 if (!clockevent_state_periodic(&mevt->evt)) in exynos4_mct_tick_isr()
437 evt->event_handler(evt); in exynos4_mct_tick_isr()
446 struct clock_event_device *evt = &mevt->evt; in exynos4_mct_starting_cpu()
448 mevt->base = EXYNOS4_MCT_L_BASE(cpu); in exynos4_mct_starting_cpu()
449 snprintf(mevt->name, sizeof(mevt->name), "mct_tick%d", cpu); in exynos4_mct_starting_cpu()
451 evt->name = mevt->name; in exynos4_mct_starting_cpu()
452 evt->cpumask = cpumask_of(cpu); in exynos4_mct_starting_cpu()
453 evt->set_next_event = exynos4_tick_set_next_event; in exynos4_mct_starting_cpu()
454 evt->set_state_periodic = set_state_periodic; in exynos4_mct_starting_cpu()
455 evt->set_state_shutdown = set_state_shutdown; in exynos4_mct_starting_cpu()
456 evt->set_state_oneshot = set_state_shutdown; in exynos4_mct_starting_cpu()
457 evt->set_state_oneshot_stopped = set_state_shutdown; in exynos4_mct_starting_cpu()
458 evt->tick_resume = set_state_shutdown; in exynos4_mct_starting_cpu()
459 evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; in exynos4_mct_starting_cpu()
460 evt->rating = 500; /* use value higher than ARM arch timer */ in exynos4_mct_starting_cpu()
462 exynos4_mct_write(TICK_BASE_CNT, mevt->base + MCT_L_TCNTB_OFFSET); in exynos4_mct_starting_cpu()
466 if (evt->irq == -1) in exynos4_mct_starting_cpu()
467 return -EIO; in exynos4_mct_starting_cpu()
469 irq_force_affinity(evt->irq, cpumask_of(cpu)); in exynos4_mct_starting_cpu()
470 enable_irq(evt->irq); in exynos4_mct_starting_cpu()
484 struct clock_event_device *evt = &mevt->evt; in exynos4_mct_dying_cpu()
486 evt->set_state_shutdown(evt); in exynos4_mct_dying_cpu()
488 if (evt->irq != -1) in exynos4_mct_dying_cpu()
489 disable_irq_nosync(evt->irq); in exynos4_mct_dying_cpu()
490 exynos4_mct_write(0x1, mevt->base + MCT_L_INT_CSTAT_OFFSET); in exynos4_mct_dying_cpu()
500 struct clk *mct_clk, *tick_clk; in exynos4_timer_resources()
529 pcpu_mevt->evt.irq = -1; in exynos4_timer_resources()
535 pcpu_mevt->name, pcpu_mevt)) { in exynos4_timer_resources()
536 pr_err("exynos-mct: cannot register IRQ (cpu%d)\n", in exynos4_timer_resources()
541 pcpu_mevt->evt.irq = mct_irq; in exynos4_timer_resources()
563 if (pcpu_mevt->evt.irq != -1) { in exynos4_timer_resources()
564 free_irq(pcpu_mevt->evt.irq, pcpu_mevt); in exynos4_timer_resources()
565 pcpu_mevt->evt.irq = -1; in exynos4_timer_resources()
612 TIMER_OF_DECLARE(exynos4210, "samsung,exynos4210-mct", mct_init_spi);
613 TIMER_OF_DECLARE(exynos4412, "samsung,exynos4412-mct", mct_init_ppi);