Lines Matching +full:local +full:- +full:timers
1 // SPDX-License-Identifier: GPL-2.0-only
28 #include <linux/arm-smccc.h>
76 [ARCH_TIMER_PHYS_SECURE_PPI] = "sec-phys",
79 [ARCH_TIMER_HYP_PPI] = "hyp-phys",
80 [ARCH_TIMER_HYP_VIRT_PPI] = "hyp-virt",
108 * 2) a roll-over time of not less than 40 years
117 return clamp_val(ilog2(min_cycles - 1) + 1, 56, 64); in arch_counter_get_width()
132 writel_relaxed((u32)val, timer->base + CNTP_CTL); in arch_timer_reg_write()
139 writeq_relaxed(val, timer->base + CNTP_CVAL_LO); in arch_timer_reg_write()
148 writel_relaxed((u32)val, timer->base + CNTV_CTL); in arch_timer_reg_write()
152 writeq_relaxed(val, timer->base + CNTV_CVAL_LO); in arch_timer_reg_write()
172 val = readl_relaxed(timer->base + CNTP_CTL); in arch_timer_reg_read()
181 val = readl_relaxed(timer->base + CNTV_CTL); in arch_timer_reg_read()
262 _retries--; \
298 _retries--; \
299 } while (unlikely((_new - _old) >> 5) && _retries); \
363 * (7ff -> 000 -> 800) and forward (7ff -> fff -> 800), ignore register values
373 _retries--; \
441 .id = "fsl,erratum-a008585",
452 .id = "hisilicon,erratum-161010101",
483 .id = "allwinner,erratum-unknown1",
510 return of_property_read_bool(np, wa->id); in arch_timer_check_dt_erratum()
517 return this_cpu_has_cap((uintptr_t)wa->id); in arch_timer_check_local_cap_erratum()
526 const struct ate_acpi_oem_info *info = wa->id; in arch_timer_check_acpi_oem_erratum()
531 if (!memcmp(info->oem_id, table->oem_id, ACPI_OEM_ID_SIZE) && in arch_timer_check_acpi_oem_erratum()
532 !memcmp(info->oem_table_id, table->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) && in arch_timer_check_acpi_oem_erratum()
533 info->oem_revision == table->oem_revision) in arch_timer_check_acpi_oem_erratum()
562 bool local) in arch_timer_enable_workaround() argument
566 if (local) { in arch_timer_enable_workaround()
573 if (wa->read_cntvct_el0 || wa->read_cntpct_el0) in arch_timer_enable_workaround()
578 * out-of-line counter accessor. We may change our mind pretty in arch_timer_enable_workaround()
579 * late in the game (with a per-CPU erratum, for example), so in arch_timer_enable_workaround()
582 if (wa->read_cntvct_el0) { in arch_timer_enable_workaround()
585 } else if (wa->disable_compat_vdso && vdso_default != VDSO_CLOCKMODE_NONE) { in arch_timer_enable_workaround()
596 bool local = false; in arch_timer_check_ool_workaround() local
604 local = true; in arch_timer_check_ool_workaround()
621 wa->desc, __wa->desc); in arch_timer_check_ool_workaround()
626 arch_timer_enable_workaround(wa, local); in arch_timer_check_ool_workaround()
628 local ? "local" : "global", wa->desc); in arch_timer_check_ool_workaround()
655 evt->event_handler(evt); in timer_handler()
760 cnt_hi = readl_relaxed(t->base + offset_lo + 4); in arch_counter_get_cnt_mem()
761 cnt_lo = readl_relaxed(t->base + offset_lo); in arch_counter_get_cnt_mem()
762 tmp_hi = readl_relaxed(t->base + offset_lo + 4); in arch_counter_get_cnt_mem()
807 * XGene-1 implements CVAL in terms of TVAL, meaning in __arch_timer_check_delta()
831 clk->features = CLOCK_EVT_FEAT_ONESHOT; in __arch_timer_setup()
834 typeof(clk->set_next_event) sne; in __arch_timer_setup()
839 clk->features |= CLOCK_EVT_FEAT_C3STOP; in __arch_timer_setup()
840 clk->name = "arch_sys_timer"; in __arch_timer_setup()
841 clk->rating = 450; in __arch_timer_setup()
842 clk->cpumask = cpumask_of(smp_processor_id()); in __arch_timer_setup()
843 clk->irq = arch_timer_ppi[arch_timer_uses_ppi]; in __arch_timer_setup()
846 clk->set_state_shutdown = arch_timer_shutdown_virt; in __arch_timer_setup()
847 clk->set_state_oneshot_stopped = arch_timer_shutdown_virt; in __arch_timer_setup()
853 clk->set_state_shutdown = arch_timer_shutdown_phys; in __arch_timer_setup()
854 clk->set_state_oneshot_stopped = arch_timer_shutdown_phys; in __arch_timer_setup()
861 clk->set_next_event = sne; in __arch_timer_setup()
864 clk->features |= CLOCK_EVT_FEAT_DYNIRQ; in __arch_timer_setup()
865 clk->name = "arch_mem_timer"; in __arch_timer_setup()
866 clk->rating = 400; in __arch_timer_setup()
867 clk->cpumask = cpu_possible_mask; in __arch_timer_setup()
869 clk->set_state_shutdown = arch_timer_shutdown_virt_mem; in __arch_timer_setup()
870 clk->set_state_oneshot_stopped = arch_timer_shutdown_virt_mem; in __arch_timer_setup()
871 clk->set_next_event = in __arch_timer_setup()
874 clk->set_state_shutdown = arch_timer_shutdown_phys_mem; in __arch_timer_setup()
875 clk->set_state_oneshot_stopped = arch_timer_shutdown_phys_mem; in __arch_timer_setup()
876 clk->set_next_event = in __arch_timer_setup()
883 clk->set_state_shutdown(clk); in __arch_timer_setup()
896 divider -= 8; in arch_timer_evtstrm_enable()
924 lsb = fls(evt_stream_div) - 1; in arch_timer_configure_evtstream()
925 if (lsb > 0 && (evt_stream_div & BIT(lsb - 1))) in arch_timer_configure_evtstream()
936 /* Disable user access to the timers and both counters */ in arch_counter_set_user_access()
1002 return -EINVAL; in validate_timer_rate()
1011 * For historical reasons, when probing with DT we use whichever (non-zero)
1013 * probed has a clock-frequency property, this overrides the HW register.
1021 if (of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) in arch_timer_of_configure_rate()
1120 pr_debug("disable IRQ%d cpu #%d\n", clk->irq, smp_processor_id()); in arch_timer_stop()
1126 clk->set_state_shutdown(clk); in arch_timer_stop()
1189 err = -ENOMEM; in arch_timer_register()
1259 return -ENOMEM; in arch_timer_mem_register()
1261 arch_timer_mem->base = base; in arch_timer_mem_register()
1262 arch_timer_mem->evt.irq = irq; in arch_timer_mem_register()
1263 __arch_timer_setup(ARCH_TIMER_TYPE_MEM, &arch_timer_mem->evt); in arch_timer_mem_register()
1270 ret = request_irq(irq, func, IRQF_TIMER, "arch_mem_timer", &arch_timer_mem->evt); in arch_timer_mem_register()
1281 { .compatible = "arm,armv7-timer", },
1282 { .compatible = "arm,armv8-timer", },
1287 { .compatible = "arm,armv7-timer-mem", },
1297 /* We have two timers, and both device-tree nodes are probed. */ in arch_timer_needs_of_probing()
1303 * check if we have another type of timer node in device-tree. in arch_timer_needs_of_probing()
1326 * arch_timer_select_ppi() - Select suitable PPI for the current system.
1377 has_names = of_property_read_bool(np, "interrupt-names"); in arch_timer_of_init()
1393 arch_timer_c3stop = !of_property_read_bool(np, "always-on"); in arch_timer_of_init()
1400 * we should use the physical timers instead. in arch_timer_of_init()
1403 of_property_read_bool(np, "arm,cpu-registers-not-fw-configured")) in arch_timer_of_init()
1410 return -EINVAL; in arch_timer_of_init()
1415 "arm,no-tick-in-suspend"); in arch_timer_of_init()
1426 TIMER_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init);
1427 TIMER_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init);
1435 base = ioremap(frame->cntbase, frame->size); in arch_timer_mem_frame_get_cntfrq()
1437 pr_err("Unable to map frame @ %pa\n", &frame->cntbase); in arch_timer_mem_frame_get_cntfrq()
1456 cntctlbase = ioremap(timer_mem->cntctlbase, timer_mem->size); in arch_timer_mem_find_best_frame()
1459 &timer_mem->cntctlbase); in arch_timer_mem_find_best_frame()
1473 frame = &timer_mem->frame[i]; in arch_timer_mem_find_best_frame()
1474 if (!frame->valid) in arch_timer_mem_find_best_frame()
1506 irq = frame->virt_irq; in arch_timer_mem_frame_register()
1508 irq = frame->phys_irq; in arch_timer_mem_frame_register()
1513 return -EINVAL; in arch_timer_mem_frame_register()
1516 if (!request_mem_region(frame->cntbase, frame->size, in arch_timer_mem_frame_register()
1518 return -EBUSY; in arch_timer_mem_frame_register()
1520 base = ioremap(frame->cntbase, frame->size); in arch_timer_mem_frame_register()
1523 return -ENXIO; in arch_timer_mem_frame_register()
1543 int ret = -EINVAL; in arch_timer_mem_of_init()
1548 return -ENOMEM; in arch_timer_mem_of_init()
1552 timer_mem->cntctlbase = res.start; in arch_timer_mem_of_init()
1553 timer_mem->size = resource_size(&res); in arch_timer_mem_of_init()
1559 if (of_property_read_u32(frame_node, "frame-number", &n)) { in arch_timer_mem_of_init()
1560 pr_err(FW_BUG "Missing frame-number.\n"); in arch_timer_mem_of_init()
1565 pr_err(FW_BUG "Wrong frame-number, only 0-%u are permitted.\n", in arch_timer_mem_of_init()
1566 ARCH_TIMER_MEM_MAX_FRAMES - 1); in arch_timer_mem_of_init()
1570 frame = &timer_mem->frame[n]; in arch_timer_mem_of_init()
1572 if (frame->valid) { in arch_timer_mem_of_init()
1573 pr_err(FW_BUG "Duplicated frame-number.\n"); in arch_timer_mem_of_init()
1582 frame->cntbase = res.start; in arch_timer_mem_of_init()
1583 frame->size = resource_size(&res); in arch_timer_mem_of_init()
1585 frame->virt_irq = irq_of_parse_and_map(frame_node, in arch_timer_mem_of_init()
1587 frame->phys_irq = irq_of_parse_and_map(frame_node, in arch_timer_mem_of_init()
1590 frame->valid = true; in arch_timer_mem_of_init()
1596 &timer_mem->cntctlbase); in arch_timer_mem_of_init()
1597 ret = -EINVAL; in arch_timer_mem_of_init()
1611 TIMER_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem",
1623 frame = &timer_mem->frame[i]; in arch_timer_mem_verify_cntfrq()
1625 if (!frame->valid) in arch_timer_mem_verify_cntfrq()
1633 &frame->cntbase, in arch_timer_mem_verify_cntfrq()
1636 return -EINVAL; in arch_timer_mem_verify_cntfrq()
1644 struct arch_timer_mem *timers, *timer; in arch_timer_mem_acpi_init() local
1648 timers = kcalloc(platform_timer_count, sizeof(*timers), in arch_timer_mem_acpi_init()
1650 if (!timers) in arch_timer_mem_acpi_init()
1651 return -ENOMEM; in arch_timer_mem_acpi_init()
1653 ret = acpi_arch_timer_mem_init(timers, &timer_count); in arch_timer_mem_acpi_init()
1662 timer = &timers[i]; in arch_timer_mem_acpi_init()
1670 pr_err("Disabling MMIO timers due to CNTFRQ mismatch\n"); in arch_timer_mem_acpi_init()
1680 &timer->cntctlbase); in arch_timer_mem_acpi_init()
1686 kfree(timers); in arch_timer_mem_acpi_init()
1690 /* Initialize per-processor generic timer and memory-mapped timer(if present) */
1697 return -EINVAL; in arch_timer_acpi_init()
1731 return -EINVAL; in arch_timer_acpi_init()
1734 /* Always-on capability */ in arch_timer_acpi_init()
1746 pr_err("Failed to initialize memory-mapped timer.\n"); in arch_timer_acpi_init()
1761 return -EOPNOTSUPP; in kvm_arch_ptp_get_crosststamp()
1772 return -EOPNOTSUPP; in kvm_arch_ptp_get_crosststamp()