Lines Matching +full:cpu +full:- +full:cfg
1 // SPDX-License-Identifier: GPL-2.0-only
7 #include <linux/cpu.h>
28 unsigned int cpu; member
133 * is_hpet_enabled - Check whether the legacy HPET timer interrupt is enabled
143 u32 i, id, period, cfg, status, channels, l, h; in _hpet_print_config() local
151 cfg = hpet_readl(HPET_CFG); in _hpet_print_config()
153 pr_info("CFG: 0x%x, STATUS: 0x%x\n", cfg, status); in _hpet_print_config()
210 hd.hd_irq[i] = hc->irq; in hpet_reserve_platform_timers()
212 switch (hc->mode) { in hpet_reserve_platform_timers()
215 hc->mode = HPET_MODE_DEVICE; in hpet_reserve_platform_timers()
219 hpet_reserve_timer(&hd, hc->num); in hpet_reserve_platform_timers()
235 if (hc->mode == HPET_MODE_UNUSED) { in hpet_select_device_channel()
236 hc->mode = HPET_MODE_DEVICE; in hpet_select_device_channel()
250 u32 cfg = hpet_readl(HPET_CFG); in hpet_stop_counter() local
252 cfg &= ~HPET_CFG_ENABLE; in hpet_stop_counter()
253 hpet_writel(cfg, HPET_CFG); in hpet_stop_counter()
264 unsigned int cfg = hpet_readl(HPET_CFG); in hpet_start_counter() local
266 cfg |= HPET_CFG_ENABLE; in hpet_start_counter()
267 hpet_writel(cfg, HPET_CFG); in hpet_start_counter()
290 unsigned int cfg = hpet_readl(HPET_CFG); in hpet_enable_legacy_int() local
292 cfg |= HPET_CFG_LEGACY; in hpet_enable_legacy_int()
293 hpet_writel(cfg, HPET_CFG); in hpet_enable_legacy_int()
299 unsigned int channel = clockevent_to_channel(evt)->num; in hpet_clkevt_set_state_periodic()
300 unsigned int cfg, cmp, now; in hpet_clkevt_set_state_periodic() local
304 delta = ((uint64_t)(NSEC_PER_SEC / HZ)) * evt->mult; in hpet_clkevt_set_state_periodic()
305 delta >>= evt->shift; in hpet_clkevt_set_state_periodic()
308 cfg = hpet_readl(HPET_Tn_CFG(channel)); in hpet_clkevt_set_state_periodic()
309 cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC | HPET_TN_SETVAL | in hpet_clkevt_set_state_periodic()
311 hpet_writel(cfg, HPET_Tn_CFG(channel)); in hpet_clkevt_set_state_periodic()
318 * (See AMD-8111 HyperTransport I/O Hub Data Sheet, in hpet_clkevt_set_state_periodic()
330 unsigned int channel = clockevent_to_channel(evt)->num; in hpet_clkevt_set_state_oneshot()
331 unsigned int cfg; in hpet_clkevt_set_state_oneshot() local
333 cfg = hpet_readl(HPET_Tn_CFG(channel)); in hpet_clkevt_set_state_oneshot()
334 cfg &= ~HPET_TN_PERIODIC; in hpet_clkevt_set_state_oneshot()
335 cfg |= HPET_TN_ENABLE | HPET_TN_32BIT; in hpet_clkevt_set_state_oneshot()
336 hpet_writel(cfg, HPET_Tn_CFG(channel)); in hpet_clkevt_set_state_oneshot()
343 unsigned int channel = clockevent_to_channel(evt)->num; in hpet_clkevt_set_state_shutdown()
344 unsigned int cfg; in hpet_clkevt_set_state_shutdown() local
346 cfg = hpet_readl(HPET_Tn_CFG(channel)); in hpet_clkevt_set_state_shutdown()
347 cfg &= ~HPET_TN_ENABLE; in hpet_clkevt_set_state_shutdown()
348 hpet_writel(cfg, HPET_Tn_CFG(channel)); in hpet_clkevt_set_state_shutdown()
363 unsigned int channel = clockevent_to_channel(evt)->num; in hpet_clkevt_set_next_event()
393 res = (s32)(cnt - hpet_readl(HPET_COUNTER)); in hpet_clkevt_set_next_event()
395 return res < HPET_MIN_CYCLES ? -ETIME : 0; in hpet_clkevt_set_next_event()
400 struct clock_event_device *evt = &hc->evt; in hpet_init_clockevent()
402 evt->rating = rating; in hpet_init_clockevent()
403 evt->irq = hc->irq; in hpet_init_clockevent()
404 evt->name = hc->name; in hpet_init_clockevent()
405 evt->cpumask = cpumask_of(hc->cpu); in hpet_init_clockevent()
406 evt->set_state_oneshot = hpet_clkevt_set_state_oneshot; in hpet_init_clockevent()
407 evt->set_next_event = hpet_clkevt_set_next_event; in hpet_init_clockevent()
408 evt->set_state_shutdown = hpet_clkevt_set_state_shutdown; in hpet_init_clockevent()
410 evt->features = CLOCK_EVT_FEAT_ONESHOT; in hpet_init_clockevent()
411 if (hc->boot_cfg & HPET_TN_PERIODIC) { in hpet_init_clockevent()
412 evt->features |= CLOCK_EVT_FEAT_PERIODIC; in hpet_init_clockevent()
413 evt->set_state_periodic = hpet_clkevt_set_state_periodic; in hpet_init_clockevent()
420 * Start HPET with the boot CPU's cpumask and make it global after in hpet_legacy_clockevent_register()
423 hc->cpu = boot_cpu_data.cpu_index; in hpet_legacy_clockevent_register()
424 strscpy(hc->name, "hpet", sizeof(hc->name)); in hpet_legacy_clockevent_register()
427 hc->evt.tick_resume = hpet_clkevt_legacy_resume; in hpet_legacy_clockevent_register()
457 hc->evt.features |= CLOCK_EVT_FEAT_PERIODIC; in hpet_legacy_clockevent_register()
458 hc->evt.set_state_periodic = hpet_clkevt_set_state_periodic; in hpet_legacy_clockevent_register()
463 clockevents_config_and_register(&hc->evt, hpet_freq, in hpet_legacy_clockevent_register()
465 global_clock_event = &hc->evt; in hpet_legacy_clockevent_register()
476 unsigned int cfg; in hpet_msi_unmask() local
478 cfg = hpet_readl(HPET_Tn_CFG(hc->num)); in hpet_msi_unmask()
479 cfg |= HPET_TN_ENABLE | HPET_TN_FSB; in hpet_msi_unmask()
480 hpet_writel(cfg, HPET_Tn_CFG(hc->num)); in hpet_msi_unmask()
486 unsigned int cfg; in hpet_msi_mask() local
488 cfg = hpet_readl(HPET_Tn_CFG(hc->num)); in hpet_msi_mask()
489 cfg &= ~(HPET_TN_ENABLE | HPET_TN_FSB); in hpet_msi_mask()
490 hpet_writel(cfg, HPET_Tn_CFG(hc->num)); in hpet_msi_mask()
495 hpet_writel(msg->data, HPET_Tn_ROUTE(hc->num)); in hpet_msi_write()
496 hpet_writel(msg->address_lo, HPET_Tn_ROUTE(hc->num) + 4); in hpet_msi_write()
505 .name = "HPET-MSI",
520 irq_domain_set_info(domain, virq, arg->hwirq, info->chip, NULL, in hpet_msi_init()
521 handle_edge_irq, arg->data, "edge"); in hpet_msi_init()
558 domain_info->data = (void *)(long)hpet_id; in hpet_create_irq_domain()
578 hpet_msi_controller.name = "IR-HPET-MSI"; in hpet_create_irq_domain()
592 return (int)(long)info->data; in hpet_dev_id()
612 struct irq_data *data = irq_get_irq_data(hc->irq); in hpet_clkevt_msi_resume()
625 struct clock_event_device *evt = &hc->evt; in hpet_msi_interrupt_handler()
627 if (!evt->event_handler) { in hpet_msi_interrupt_handler()
628 pr_info("Spurious interrupt HPET channel %d\n", hc->num); in hpet_msi_interrupt_handler()
632 evt->event_handler(evt); in hpet_msi_interrupt_handler()
638 if (request_irq(hc->irq, hpet_msi_interrupt_handler, in hpet_setup_msi_irq()
640 hc->name, hc)) in hpet_setup_msi_irq()
641 return -1; in hpet_setup_msi_irq()
643 disable_irq(hc->irq); in hpet_setup_msi_irq()
644 irq_set_affinity(hc->irq, cpumask_of(hc->cpu)); in hpet_setup_msi_irq()
645 enable_irq(hc->irq); in hpet_setup_msi_irq()
647 pr_debug("%s irq %u for MSI\n", hc->name, hc->irq); in hpet_setup_msi_irq()
652 /* Invoked from the hotplug callback on @cpu */
653 static void init_one_hpet_msi_clockevent(struct hpet_channel *hc, int cpu) in init_one_hpet_msi_clockevent() argument
655 struct clock_event_device *evt = &hc->evt; in init_one_hpet_msi_clockevent()
657 hc->cpu = cpu; in init_one_hpet_msi_clockevent()
658 per_cpu(cpu_hpet_channel, cpu) = hc; in init_one_hpet_msi_clockevent()
662 evt->tick_resume = hpet_clkevt_msi_resume; in init_one_hpet_msi_clockevent()
675 if (hc->mode != HPET_MODE_CLOCKEVT || hc->in_use) in hpet_get_unused_clockevent()
677 hc->in_use = 1; in hpet_get_unused_clockevent()
683 static int hpet_cpuhp_online(unsigned int cpu) in hpet_cpuhp_online() argument
688 init_one_hpet_msi_clockevent(hc, cpu); in hpet_cpuhp_online()
692 static int hpet_cpuhp_dead(unsigned int cpu) in hpet_cpuhp_dead() argument
694 struct hpet_channel *hc = per_cpu(cpu_hpet_channel, cpu); in hpet_cpuhp_dead()
698 free_irq(hc->irq, hc); in hpet_cpuhp_dead()
699 hc->in_use = 0; in hpet_cpuhp_dead()
700 per_cpu(cpu_hpet_channel, cpu) = NULL; in hpet_cpuhp_dead()
710 /* No point if MSI is disabled or CPU has an Always Running APIC Timer */ in hpet_select_clockevents()
724 if (hc->mode != HPET_MODE_UNUSED) in hpet_select_clockevents()
728 if (!(hc->boot_cfg & HPET_TN_FSB_CAP)) in hpet_select_clockevents()
731 sprintf(hc->name, "hpet%d", i); in hpet_select_clockevents()
733 irq = hpet_assign_irq(hpet_domain, hc, hc->num); in hpet_select_clockevents()
737 hc->irq = irq; in hpet_select_clockevents()
738 hc->mode = HPET_MODE_CLOCKEVT; in hpet_select_clockevents()
744 pr_info("%d channels of %d reserved for per-cpu timers\n", in hpet_select_clockevents()
772 * other CPUs can use the counter value read by the first CPU in the group.
774 * This special feature is only enabled on x86-64 systems. It is unlikely
775 * that 32-bit x86 systems will have enough CPUs to require this feature
776 * with its associated locking overhead. We also need 64-bit atomic read.
779 * single atomic 64-bit read. It is explicitly assumed that arch_spinlock_t
831 * -------------- in read_hpet()
833 * its value is up-to-date. in read_hpet()
850 * For UP or 32-bit.
874 * config register reads a non-0xffffffff value to make sure that the
877 * A counting loop is safe, as the HPET access takes thousands of CPU cycles.
879 * On non-SB700 based machines this check is only done once and has no
914 } while ((now - start) < 200000UL); in hpet_counting()
945 * - ACPI tables
946 * - Enablement of intel_idle
947 * - Command line arguments which limit intel_idle C-state support
951 * fact that it is impossible to reliably query TSC and CPU frequency via
961 * dysfunctional in deeper C-states.
965 * and per CPU timer interrupts.
982 /* Check whether PC10 is enabled in PKG C-state limit */ in hpet_is_pc10_damaged()
998 * hpet_enable - Try to setup the HPET timer. Returns 1 on success.
1002 u32 hpet_period, cfg, id, irq; in hpet_enable() local
1059 cfg = hpet_readl(HPET_CFG); in hpet_enable()
1060 hpet_base.boot_cfg = cfg; in hpet_enable()
1061 cfg &= ~(HPET_CFG_ENABLE | HPET_CFG_LEGACY); in hpet_enable()
1062 hpet_writel(cfg, HPET_CFG); in hpet_enable()
1063 if (cfg) in hpet_enable()
1064 pr_warn("Global config: Unknown bits %#x\n", cfg); in hpet_enable()
1068 hc->num = i; in hpet_enable()
1070 cfg = hpet_readl(HPET_Tn_CFG(i)); in hpet_enable()
1071 hc->boot_cfg = cfg; in hpet_enable()
1072 irq = (cfg & Tn_INT_ROUTE_CNF_MASK) >> Tn_INT_ROUTE_CNF_SHIFT; in hpet_enable()
1073 hc->irq = irq; in hpet_enable()
1075 cfg &= ~(HPET_TN_ENABLE | HPET_TN_LEVEL | HPET_TN_FSB); in hpet_enable()
1076 hpet_writel(cfg, HPET_Tn_CFG(i)); in hpet_enable()
1078 cfg &= ~(HPET_TN_PERIODIC | HPET_TN_PERIODIC_CAP in hpet_enable()
1081 if (cfg) in hpet_enable()
1082 pr_warn("Channel #%u config: Unknown bits %#x\n", i, cfg); in hpet_enable()
1126 * 2) Reserve up to num_possible_cpus() channels as per CPU clockevents
1136 return -ENODEV; in hpet_late_init()
1143 return -ENODEV; in hpet_late_init()
1172 u32 cfg; in hpet_disable() local
1178 cfg = hpet_base.boot_cfg; in hpet_disable()
1179 cfg &= ~HPET_CFG_ENABLE; in hpet_disable()
1180 hpet_writel(cfg, HPET_CFG); in hpet_disable()
1199 * 1) Update Interrupt - generate an interrupt, every second, when the
1201 * 2) Alarm Interrupt - generate an interrupt at a specific time of day
1202 * 3) Periodic Interrupt - generate periodic interrupt, with frequencies
1203 * 2Hz-8192Hz (2Hz-64Hz for non-root user) (all frequencies in powers of 2)
1236 return (s32)(c2 - c1) < 0; in hpet_cnt_ahead()
1245 return -ENODEV; in hpet_register_irq_handler()
1247 return -EBUSY; in hpet_register_irq_handler()
1277 unsigned int cfg, cnt, delta; in hpet_rtc_timer_init() local
1287 clc = (uint64_t) evt->mult * NSEC_PER_SEC; in hpet_rtc_timer_init()
1288 clc >>= evt->shift + DEFAULT_RTC_SHIFT; in hpet_rtc_timer_init()
1303 cfg = hpet_readl(HPET_T1_CFG); in hpet_rtc_timer_init()
1304 cfg &= ~HPET_TN_PERIODIC; in hpet_rtc_timer_init()
1305 cfg |= HPET_TN_ENABLE | HPET_TN_32BIT; in hpet_rtc_timer_init()
1306 hpet_writel(cfg, HPET_T1_CFG); in hpet_rtc_timer_init()
1316 u32 cfg = hpet_readl(HPET_T1_CFG); in hpet_disable_rtc_channel() local
1318 cfg &= ~HPET_TN_ENABLE; in hpet_disable_rtc_channel()
1319 hpet_writel(cfg, HPET_T1_CFG); in hpet_disable_rtc_channel()
1350 hpet_prev_update_sec = -1; in hpet_set_rtc_irq_bit()
1384 clc = (uint64_t) evt->mult * NSEC_PER_SEC; in hpet_set_periodic_freq()
1386 clc >>= evt->shift; in hpet_set_periodic_freq()
1404 int lost_ints = -1; in hpet_rtc_timer_reinit()