mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-30 10:06:43 +07:00
17e6b00ac4
Pull irq updates from Thomas Gleixner: "This updated pull request does not contain the last few GIC related patches which were reported to cause a regression. There is a fix available, but I let it breed for a couple of days first. The irq departement provides: - new infrastructure to support non PCI based MSI interrupts - a couple of new irq chip drivers - the usual pile of fixlets and updates to irq chip drivers - preparatory changes for removal of the irq argument from interrupt flow handlers - preparatory changes to remove IRQF_VALID" * 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (129 commits) irqchip/imx-gpcv2: IMX GPCv2 driver for wakeup sources irqchip: Add bcm2836 interrupt controller for Raspberry Pi 2 irqchip: Add documentation for the bcm2836 interrupt controller irqchip/bcm2835: Add support for being used as a second level controller irqchip/bcm2835: Refactor handle_IRQ() calls out of MAKE_HWIRQ PCI: xilinx: Fix typo in function name irqchip/gic: Ensure gic_cpu_if_up/down() programs correct GIC instance irqchip/gic: Only allow the primary GIC to set the CPU map PCI/MSI: pci-xgene-msi: Consolidate chained IRQ handler install/remove unicore32/irq: Prepare puv3_gpio_handler for irq argument removal tile/pci_gx: Prepare trio_handle_level_irq for irq argument removal m68k/irq: Prepare irq handlers for irq argument removal C6X/megamode-pic: Prepare megamod_irq_cascade for irq argument removal blackfin: Prepare irq handlers for irq argument removal arc/irq: Prepare idu_cascade_isr for irq argument removal sparc/irq: Use access helper irq_data_get_affinity_mask() sparc/irq: Use helper irq_data_get_irq_handler_data() parisc/irq: Use access helper irq_data_get_affinity_mask() mn10300/irq: Use access helper irq_data_get_affinity_mask() irqchip/i8259: Prepare i8259_irq_dispatch for irq argument removal ...
136 lines
3.3 KiB
C
136 lines
3.3 KiB
C
/* MN10300 clockevents
|
|
*
|
|
* Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
|
|
* Written by Mark Salter (msalter@redhat.com)
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public Licence
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the Licence, or (at your option) any later version.
|
|
*/
|
|
#include <linux/clockchips.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/percpu.h>
|
|
#include <linux/smp.h>
|
|
#include <asm/timex.h>
|
|
#include "internal.h"
|
|
|
|
#ifdef CONFIG_SMP
|
|
#if (CONFIG_NR_CPUS > 2) && !defined(CONFIG_GEENERIC_CLOCKEVENTS_BROADCAST)
|
|
#error "This doesn't scale well! Need per-core local timers."
|
|
#endif
|
|
#else /* CONFIG_SMP */
|
|
#define stop_jiffies_counter1()
|
|
#define reload_jiffies_counter1(x)
|
|
#define TMJC1IRQ TMJCIRQ
|
|
#endif
|
|
|
|
|
|
static int next_event(unsigned long delta,
|
|
struct clock_event_device *evt)
|
|
{
|
|
unsigned int cpu = smp_processor_id();
|
|
|
|
if (cpu == 0) {
|
|
stop_jiffies_counter();
|
|
reload_jiffies_counter(delta - 1);
|
|
} else {
|
|
stop_jiffies_counter1();
|
|
reload_jiffies_counter1(delta - 1);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static DEFINE_PER_CPU(struct clock_event_device, mn10300_clockevent_device);
|
|
static DEFINE_PER_CPU(struct irqaction, timer_irq);
|
|
|
|
static irqreturn_t timer_interrupt(int irq, void *dev_id)
|
|
{
|
|
struct clock_event_device *cd;
|
|
unsigned int cpu = smp_processor_id();
|
|
|
|
if (cpu == 0)
|
|
stop_jiffies_counter();
|
|
else
|
|
stop_jiffies_counter1();
|
|
|
|
cd = &per_cpu(mn10300_clockevent_device, cpu);
|
|
cd->event_handler(cd);
|
|
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
static void event_handler(struct clock_event_device *dev)
|
|
{
|
|
}
|
|
|
|
static inline void setup_jiffies_interrupt(int irq,
|
|
struct irqaction *action)
|
|
{
|
|
u16 tmp;
|
|
setup_irq(irq, action);
|
|
set_intr_level(irq, NUM2GxICR_LEVEL(CONFIG_TIMER_IRQ_LEVEL));
|
|
GxICR(irq) |= GxICR_ENABLE | GxICR_DETECT | GxICR_REQUEST;
|
|
tmp = GxICR(irq);
|
|
}
|
|
|
|
int __init init_clockevents(void)
|
|
{
|
|
struct clock_event_device *cd;
|
|
struct irqaction *iact;
|
|
unsigned int cpu = smp_processor_id();
|
|
|
|
cd = &per_cpu(mn10300_clockevent_device, cpu);
|
|
|
|
if (cpu == 0) {
|
|
stop_jiffies_counter();
|
|
cd->irq = TMJCIRQ;
|
|
} else {
|
|
stop_jiffies_counter1();
|
|
cd->irq = TMJC1IRQ;
|
|
}
|
|
|
|
cd->name = "Timestamp";
|
|
cd->features = CLOCK_EVT_FEAT_ONESHOT;
|
|
|
|
/* Calculate shift/mult. We want to spawn at least 1 second */
|
|
clockevents_calc_mult_shift(cd, MN10300_JCCLK, 1);
|
|
|
|
/* Calculate the min / max delta */
|
|
cd->max_delta_ns = clockevent_delta2ns(TMJCBR_MAX, cd);
|
|
cd->min_delta_ns = clockevent_delta2ns(100, cd);
|
|
|
|
cd->rating = 200;
|
|
cd->cpumask = cpumask_of(smp_processor_id());
|
|
cd->event_handler = event_handler;
|
|
cd->set_next_event = next_event;
|
|
|
|
iact = &per_cpu(timer_irq, cpu);
|
|
iact->flags = IRQF_SHARED | IRQF_TIMER;
|
|
iact->handler = timer_interrupt;
|
|
|
|
clockevents_register_device(cd);
|
|
|
|
#if defined(CONFIG_SMP) && !defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST)
|
|
/* setup timer irq affinity so it only runs on this cpu */
|
|
{
|
|
struct irq_data *data;
|
|
data = irq_get_irq_data(cd->irq);
|
|
cpumask_copy(irq_data_get_affinity_mask(data), cpumask_of(cpu));
|
|
iact->flags |= IRQF_NOBALANCING;
|
|
}
|
|
#endif
|
|
|
|
if (cpu == 0) {
|
|
reload_jiffies_counter(MN10300_JC_PER_HZ - 1);
|
|
iact->name = "CPU0 Timer";
|
|
} else {
|
|
reload_jiffies_counter1(MN10300_JC_PER_HZ - 1);
|
|
iact->name = "CPU1 Timer";
|
|
}
|
|
|
|
setup_jiffies_interrupt(cd->irq, iact);
|
|
|
|
return 0;
|
|
}
|