Lines Matching +full:armv7 +full:- +full:timer

1 // SPDX-License-Identifier: GPL-2.0-only
88 * Architected system timer support.
96 struct arch_timer *timer = to_arch_timer(clk); in arch_timer_reg_write() local
99 writel_relaxed(val, timer->base + CNTP_CTL); in arch_timer_reg_write()
102 writel_relaxed(val, timer->base + CNTP_TVAL); in arch_timer_reg_write()
106 struct arch_timer *timer = to_arch_timer(clk); in arch_timer_reg_write() local
109 writel_relaxed(val, timer->base + CNTV_CTL); in arch_timer_reg_write()
112 writel_relaxed(val, timer->base + CNTV_TVAL); in arch_timer_reg_write()
127 struct arch_timer *timer = to_arch_timer(clk); in arch_timer_reg_read() local
130 val = readl_relaxed(timer->base + CNTP_CTL); in arch_timer_reg_read()
133 val = readl_relaxed(timer->base + CNTP_TVAL); in arch_timer_reg_read()
137 struct arch_timer *timer = to_arch_timer(clk); in arch_timer_reg_read() local
140 val = readl_relaxed(timer->base + CNTV_CTL); in arch_timer_reg_read()
143 val = readl_relaxed(timer->base + CNTV_TVAL); in arch_timer_reg_read()
223 _retries--; \
269 _retries--; \
270 } while (unlikely((_new - _old) >> 5) && _retries); \
344 * (7ff -> 000 -> 800) and forward (7ff -> fff -> 800), ignore register values
354 _retries--; \
373 return read_sysreg(cntp_cval_el0) - sun50i_a64_read_cntpct_el0(); in sun50i_a64_read_cntp_tval_el0()
378 return read_sysreg(cntv_cval_el0) - sun50i_a64_read_cntvct_el0(); in sun50i_a64_read_cntv_tval_el0()
427 .id = "fsl,erratum-a008585",
440 .id = "hisilicon,erratum-161010101",
473 .id = "allwinner,erratum-unknown1",
502 return of_property_read_bool(np, wa->id); in arch_timer_check_dt_erratum()
509 return this_cpu_has_cap((uintptr_t)wa->id); in arch_timer_check_local_cap_erratum()
518 const struct ate_acpi_oem_info *info = wa->id; in arch_timer_check_acpi_oem_erratum()
523 if (!memcmp(info->oem_id, table->oem_id, ACPI_OEM_ID_SIZE) && in arch_timer_check_acpi_oem_erratum()
524 !memcmp(info->oem_table_id, table->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) && in arch_timer_check_acpi_oem_erratum()
525 info->oem_revision == table->oem_revision) in arch_timer_check_acpi_oem_erratum()
565 if (wa->read_cntvct_el0 || wa->read_cntpct_el0) in arch_timer_enable_workaround()
570 * out-of-line counter accessor. We may change our mind pretty in arch_timer_enable_workaround()
571 * late in the game (with a per-CPU erratum, for example), so in arch_timer_enable_workaround()
574 if (wa->read_cntvct_el0) { in arch_timer_enable_workaround()
577 } else if (wa->disable_compat_vdso && vdso_default != VDSO_CLOCKMODE_NONE) { in arch_timer_enable_workaround()
613 wa->desc, __wa->desc); in arch_timer_check_ool_workaround()
620 local ? "local" : "global", wa->desc); in arch_timer_check_ool_workaround()
647 evt->event_handler(evt); in timer_handler()
756 clk->features = CLOCK_EVT_FEAT_ONESHOT; in __arch_timer_setup()
759 typeof(clk->set_next_event) sne; in __arch_timer_setup()
764 clk->features |= CLOCK_EVT_FEAT_C3STOP; in __arch_timer_setup()
765 clk->name = "arch_sys_timer"; in __arch_timer_setup()
766 clk->rating = 450; in __arch_timer_setup()
767 clk->cpumask = cpumask_of(smp_processor_id()); in __arch_timer_setup()
768 clk->irq = arch_timer_ppi[arch_timer_uses_ppi]; in __arch_timer_setup()
771 clk->set_state_shutdown = arch_timer_shutdown_virt; in __arch_timer_setup()
772 clk->set_state_oneshot_stopped = arch_timer_shutdown_virt; in __arch_timer_setup()
778 clk->set_state_shutdown = arch_timer_shutdown_phys; in __arch_timer_setup()
779 clk->set_state_oneshot_stopped = arch_timer_shutdown_phys; in __arch_timer_setup()
786 clk->set_next_event = sne; in __arch_timer_setup()
788 clk->features |= CLOCK_EVT_FEAT_DYNIRQ; in __arch_timer_setup()
789 clk->name = "arch_mem_timer"; in __arch_timer_setup()
790 clk->rating = 400; in __arch_timer_setup()
791 clk->cpumask = cpu_possible_mask; in __arch_timer_setup()
793 clk->set_state_shutdown = arch_timer_shutdown_virt_mem; in __arch_timer_setup()
794 clk->set_state_oneshot_stopped = arch_timer_shutdown_virt_mem; in __arch_timer_setup()
795 clk->set_next_event = in __arch_timer_setup()
798 clk->set_state_shutdown = arch_timer_shutdown_phys_mem; in __arch_timer_setup()
799 clk->set_state_oneshot_stopped = arch_timer_shutdown_phys_mem; in __arch_timer_setup()
800 clk->set_next_event = in __arch_timer_setup()
805 clk->set_state_shutdown(clk); in __arch_timer_setup()
830 if (pos > 1 && !(evt_stream_div & (1 << (pos - 2)))) in arch_timer_configure_evtstream()
831 pos--; in arch_timer_configure_evtstream()
906 return -EINVAL; in validate_timer_rate()
908 /* Arch timer frequency < 1MHz can cause trouble */ in validate_timer_rate()
915 * For historical reasons, when probing with DT we use whichever (non-zero)
917 * probed has a clock-frequency property, this overrides the HW register.
925 if (of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) in arch_timer_of_configure_rate()
928 /* Check the timer frequency. */ in arch_timer_of_configure_rate()
935 pr_info("%s%s%s timer(s) running at %lu.%02luMHz (%s%s%s).\n", in arch_timer_banner()
1028 pr_debug("disable IRQ%d cpu #%d\n", clk->irq, smp_processor_id()); in arch_timer_stop()
1034 clk->set_state_shutdown(clk); in arch_timer_stop()
1097 err = -ENOMEM; in arch_timer_register()
1137 /* Register and immediately configure the timer on the boot CPU */ in arch_timer_register()
1168 return -ENOMEM; in arch_timer_mem_register()
1170 t->base = base; in arch_timer_mem_register()
1171 t->evt.irq = irq; in arch_timer_mem_register()
1172 __arch_timer_setup(ARCH_TIMER_TYPE_MEM, &t->evt); in arch_timer_mem_register()
1179 ret = request_irq(irq, func, IRQF_TIMER, "arch_mem_timer", &t->evt); in arch_timer_mem_register()
1181 pr_err("Failed to request mem timer irq\n"); in arch_timer_mem_register()
1189 { .compatible = "arm,armv7-timer", },
1190 { .compatible = "arm,armv8-timer", },
1195 { .compatible = "arm,armv7-timer-mem", },
1205 /* We have two timers, and both device-tree nodes are probed. */ in arch_timer_needs_of_probing()
1210 * Only one type of timer is probed, in arch_timer_needs_of_probing()
1211 * check if we have another type of timer node in device-tree. in arch_timer_needs_of_probing()
1234 * arch_timer_select_ppi() - Select suitable PPI for the current system.
1236 * If HYP mode is available, we know that the physical timer
1238 * that a guest can use the virtual timer instead.
1245 * If no interrupt provided for virtual timer, we'll have to
1246 * stick to the physical timer. It'd better be accessible...
1291 arch_timer_c3stop = !of_property_read_bool(np, "always-on"); in arch_timer_of_init()
1297 * If we cannot rely on firmware initializing the timer registers then in arch_timer_of_init()
1301 of_property_read_bool(np, "arm,cpu-registers-not-fw-configured")) in arch_timer_of_init()
1308 return -EINVAL; in arch_timer_of_init()
1313 "arm,no-tick-in-suspend"); in arch_timer_of_init()
1324 TIMER_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init);
1325 TIMER_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init);
1333 base = ioremap(frame->cntbase, frame->size); in arch_timer_mem_frame_get_cntfrq()
1335 pr_err("Unable to map frame @ %pa\n", &frame->cntbase); in arch_timer_mem_frame_get_cntfrq()
1354 cntctlbase = ioremap(timer_mem->cntctlbase, timer_mem->size); in arch_timer_mem_find_best_frame()
1357 &timer_mem->cntctlbase); in arch_timer_mem_find_best_frame()
1371 frame = &timer_mem->frame[i]; in arch_timer_mem_find_best_frame()
1372 if (!frame->valid) in arch_timer_mem_find_best_frame()
1404 irq = frame->virt_irq; in arch_timer_mem_frame_register()
1406 irq = frame->phys_irq; in arch_timer_mem_frame_register()
1411 return -EINVAL; in arch_timer_mem_frame_register()
1414 if (!request_mem_region(frame->cntbase, frame->size, in arch_timer_mem_frame_register()
1416 return -EBUSY; in arch_timer_mem_frame_register()
1418 base = ioremap(frame->cntbase, frame->size); in arch_timer_mem_frame_register()
1421 return -ENXIO; in arch_timer_mem_frame_register()
1442 int ret = -EINVAL; in arch_timer_mem_of_init()
1447 return -ENOMEM; in arch_timer_mem_of_init()
1451 timer_mem->cntctlbase = res.start; in arch_timer_mem_of_init()
1452 timer_mem->size = resource_size(&res); in arch_timer_mem_of_init()
1458 if (of_property_read_u32(frame_node, "frame-number", &n)) { in arch_timer_mem_of_init()
1459 pr_err(FW_BUG "Missing frame-number.\n"); in arch_timer_mem_of_init()
1464 pr_err(FW_BUG "Wrong frame-number, only 0-%u are permitted.\n", in arch_timer_mem_of_init()
1465 ARCH_TIMER_MEM_MAX_FRAMES - 1); in arch_timer_mem_of_init()
1469 frame = &timer_mem->frame[n]; in arch_timer_mem_of_init()
1471 if (frame->valid) { in arch_timer_mem_of_init()
1472 pr_err(FW_BUG "Duplicated frame-number.\n"); in arch_timer_mem_of_init()
1481 frame->cntbase = res.start; in arch_timer_mem_of_init()
1482 frame->size = resource_size(&res); in arch_timer_mem_of_init()
1484 frame->virt_irq = irq_of_parse_and_map(frame_node, in arch_timer_mem_of_init()
1486 frame->phys_irq = irq_of_parse_and_map(frame_node, in arch_timer_mem_of_init()
1489 frame->valid = true; in arch_timer_mem_of_init()
1494 pr_err("Unable to find a suitable frame in timer @ %pa\n", in arch_timer_mem_of_init()
1495 &timer_mem->cntctlbase); in arch_timer_mem_of_init()
1496 ret = -EINVAL; in arch_timer_mem_of_init()
1510 TIMER_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem",
1522 frame = &timer_mem->frame[i]; in arch_timer_mem_verify_cntfrq()
1524 if (!frame->valid) in arch_timer_mem_verify_cntfrq()
1532 &frame->cntbase, in arch_timer_mem_verify_cntfrq()
1535 return -EINVAL; in arch_timer_mem_verify_cntfrq()
1543 struct arch_timer_mem *timers, *timer; in arch_timer_mem_acpi_init() local
1550 return -ENOMEM; in arch_timer_mem_acpi_init()
1558 * in a timer expose the combination of feature we want. in arch_timer_mem_acpi_init()
1561 timer = &timers[i]; in arch_timer_mem_acpi_init()
1563 frame = arch_timer_mem_find_best_frame(timer); in arch_timer_mem_acpi_init()
1567 ret = arch_timer_mem_verify_cntfrq(timer); in arch_timer_mem_acpi_init()
1578 pr_err("Unable to find a suitable frame in timer @ %pa\n", in arch_timer_mem_acpi_init()
1579 &timer->cntctlbase); in arch_timer_mem_acpi_init()
1589 /* Initialize per-processor generic timer and memory-mapped timer(if present) */
1596 return -EINVAL; in arch_timer_acpi_init()
1630 return -EINVAL; in arch_timer_acpi_init()
1633 /* Always-on capability */ in arch_timer_acpi_init()
1645 pr_err("Failed to initialize memory-mapped timer.\n"); in arch_timer_acpi_init()