1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
27f30491cSTony Luck #ifndef _ASM_IA64_HW_IRQ_H
37f30491cSTony Luck #define _ASM_IA64_HW_IRQ_H
47f30491cSTony Luck
57f30491cSTony Luck /*
67f30491cSTony Luck * Copyright (C) 2001-2003 Hewlett-Packard Co
77f30491cSTony Luck * David Mosberger-Tang <davidm@hpl.hp.com>
87f30491cSTony Luck */
97f30491cSTony Luck
107f30491cSTony Luck #include <linux/interrupt.h>
117f30491cSTony Luck #include <linux/sched.h>
127f30491cSTony Luck #include <linux/types.h>
137f30491cSTony Luck #include <linux/profile.h>
147f30491cSTony Luck
157f30491cSTony Luck #include <asm/ptrace.h>
167f30491cSTony Luck #include <asm/smp.h>
177f30491cSTony Luck
187f30491cSTony Luck typedef u8 ia64_vector;
197f30491cSTony Luck
207f30491cSTony Luck /*
217f30491cSTony Luck * 0 special
227f30491cSTony Luck *
237f30491cSTony Luck * 1,3-14 are reserved from firmware
247f30491cSTony Luck *
257f30491cSTony Luck * 16-255 (vectored external interrupts) are available
267f30491cSTony Luck *
277f30491cSTony Luck * 15 spurious interrupt (see IVR)
287f30491cSTony Luck *
297f30491cSTony Luck * 16 lowest priority, 255 highest priority
307f30491cSTony Luck *
317f30491cSTony Luck * 15 classes of 16 interrupts each.
327f30491cSTony Luck */
337f30491cSTony Luck #define IA64_MIN_VECTORED_IRQ 16
347f30491cSTony Luck #define IA64_MAX_VECTORED_IRQ 255
357f30491cSTony Luck #define IA64_NUM_VECTORS 256
367f30491cSTony Luck
377f30491cSTony Luck #define AUTO_ASSIGN -1
387f30491cSTony Luck
397f30491cSTony Luck #define IA64_SPURIOUS_INT_VECTOR 0x0f
407f30491cSTony Luck
417f30491cSTony Luck /*
427f30491cSTony Luck * Vectors 0x10-0x1f are used for low priority interrupts, e.g. CMCI.
437f30491cSTony Luck */
447f30491cSTony Luck #define IA64_CPEP_VECTOR 0x1c /* corrected platform error polling vector */
457f30491cSTony Luck #define IA64_CMCP_VECTOR 0x1d /* corrected machine-check polling vector */
467f30491cSTony Luck #define IA64_CPE_VECTOR 0x1e /* corrected platform error interrupt vector */
477f30491cSTony Luck #define IA64_CMC_VECTOR 0x1f /* corrected machine-check interrupt vector */
487f30491cSTony Luck /*
497f30491cSTony Luck * Vectors 0x20-0x2f are reserved for legacy ISA IRQs.
507f30491cSTony Luck * Use vectors 0x30-0xe7 as the default device vector range for ia64.
517f30491cSTony Luck * Platforms may choose to reduce this range in platform_irq_setup, but the
527f30491cSTony Luck * platform range must fall within
537f30491cSTony Luck * [IA64_DEF_FIRST_DEVICE_VECTOR..IA64_DEF_LAST_DEVICE_VECTOR]
547f30491cSTony Luck */
557f30491cSTony Luck extern int ia64_first_device_vector;
567f30491cSTony Luck extern int ia64_last_device_vector;
577f30491cSTony Luck
58*df41017eSChristoph Hellwig #ifdef CONFIG_SMP
5909b366b7SKenji Kaneshige /* Reserve the lower priority vector than device vectors for "move IRQ" IPI */
6009b366b7SKenji Kaneshige #define IA64_IRQ_MOVE_VECTOR 0x30 /* "move IRQ" IPI */
6109b366b7SKenji Kaneshige #define IA64_DEF_FIRST_DEVICE_VECTOR 0x31
6209b366b7SKenji Kaneshige #else
637f30491cSTony Luck #define IA64_DEF_FIRST_DEVICE_VECTOR 0x30
6409b366b7SKenji Kaneshige #endif
657f30491cSTony Luck #define IA64_DEF_LAST_DEVICE_VECTOR 0xe7
667f30491cSTony Luck #define IA64_FIRST_DEVICE_VECTOR ia64_first_device_vector
677f30491cSTony Luck #define IA64_LAST_DEVICE_VECTOR ia64_last_device_vector
687f30491cSTony Luck #define IA64_MAX_DEVICE_VECTORS (IA64_DEF_LAST_DEVICE_VECTOR - IA64_DEF_FIRST_DEVICE_VECTOR + 1)
697f30491cSTony Luck #define IA64_NUM_DEVICE_VECTORS (IA64_LAST_DEVICE_VECTOR - IA64_FIRST_DEVICE_VECTOR + 1)
707f30491cSTony Luck
717f30491cSTony Luck #define IA64_MCA_RENDEZ_VECTOR 0xe8 /* MCA rendez interrupt */
727f30491cSTony Luck #define IA64_TIMER_VECTOR 0xef /* use highest-prio group 15 interrupt for timer */
737f30491cSTony Luck #define IA64_MCA_WAKEUP_VECTOR 0xf0 /* MCA wakeup (must be >MCA_RENDEZ_VECTOR) */
747f30491cSTony Luck #define IA64_IPI_LOCAL_TLB_FLUSH 0xfc /* SMP flush local TLB */
757f30491cSTony Luck #define IA64_IPI_RESCHEDULE 0xfd /* SMP reschedule */
767f30491cSTony Luck #define IA64_IPI_VECTOR 0xfe /* inter-processor interrupt vector */
777f30491cSTony Luck
787f30491cSTony Luck /* Used for encoding redirected irqs */
797f30491cSTony Luck
807f30491cSTony Luck #define IA64_IRQ_REDIRECTED (1 << 31)
817f30491cSTony Luck
827f30491cSTony Luck /* IA64 inter-cpu interrupt related definitions */
837f30491cSTony Luck
847f30491cSTony Luck #define IA64_IPI_DEFAULT_BASE_ADDR 0xfee00000
857f30491cSTony Luck
867f30491cSTony Luck /* Delivery modes for inter-cpu interrupts */
877f30491cSTony Luck enum {
887f30491cSTony Luck IA64_IPI_DM_INT = 0x0, /* pend an external interrupt */
897f30491cSTony Luck IA64_IPI_DM_PMI = 0x2, /* pend a PMI */
907f30491cSTony Luck IA64_IPI_DM_NMI = 0x4, /* pend an NMI (vector 2) */
917f30491cSTony Luck IA64_IPI_DM_INIT = 0x5, /* pend an INIT interrupt */
927f30491cSTony Luck IA64_IPI_DM_EXTINT = 0x7, /* pend an 8259-compatible interrupt. */
937f30491cSTony Luck };
947f30491cSTony Luck
957f30491cSTony Luck extern __u8 isa_irq_to_vector_map[16];
967f30491cSTony Luck #define isa_irq_to_vector(x) isa_irq_to_vector_map[(x)]
977f30491cSTony Luck
987f30491cSTony Luck struct irq_cfg {
997f30491cSTony Luck ia64_vector vector;
1007f30491cSTony Luck cpumask_t domain;
1017f30491cSTony Luck cpumask_t old_domain;
1027f30491cSTony Luck unsigned move_cleanup_count;
1037f30491cSTony Luck u8 move_in_progress : 1;
1047f30491cSTony Luck };
1057f30491cSTony Luck extern spinlock_t vector_lock;
1067f30491cSTony Luck extern struct irq_cfg irq_cfg[NR_IRQS];
1077f30491cSTony Luck #define irq_to_domain(x) irq_cfg[(x)].domain
1087f30491cSTony Luck DECLARE_PER_CPU(int[IA64_NUM_VECTORS], vector_irq);
1097f30491cSTony Luck
110fb824f48SThomas Gleixner extern struct irq_chip irq_type_ia64_lsapic; /* CPU-internal interrupt controller */
1117f30491cSTony Luck
1127f30491cSTony Luck #define ia64_register_ipi ia64_native_register_ipi
1137f30491cSTony Luck #define assign_irq_vector ia64_native_assign_irq_vector
1147f30491cSTony Luck #define free_irq_vector ia64_native_free_irq_vector
1157f30491cSTony Luck #define ia64_resend_irq ia64_native_resend_irq
1167f30491cSTony Luck
1177f30491cSTony Luck extern void ia64_native_register_ipi(void);
1187f30491cSTony Luck extern int bind_irq_vector(int irq, int vector, cpumask_t domain);
1197f30491cSTony Luck extern int ia64_native_assign_irq_vector (int irq); /* allocate a free vector */
1207f30491cSTony Luck extern void ia64_native_free_irq_vector (int vector);
1217f30491cSTony Luck extern int reserve_irq_vector (int vector);
1227f30491cSTony Luck extern void __setup_vector_irq(int cpu);
1237f30491cSTony Luck extern void ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect);
1247f30491cSTony Luck extern void destroy_and_reserve_irq (unsigned int irq);
1257f30491cSTony Luck
126*df41017eSChristoph Hellwig #ifdef CONFIG_SMP
1277f30491cSTony Luck extern int irq_prepare_move(int irq, int cpu);
1287f30491cSTony Luck extern void irq_complete_move(unsigned int irq);
1297f30491cSTony Luck #else
irq_prepare_move(int irq,int cpu)1307f30491cSTony Luck static inline int irq_prepare_move(int irq, int cpu) { return 0; }
irq_complete_move(unsigned int irq)1317f30491cSTony Luck static inline void irq_complete_move(unsigned int irq) {}
1327f30491cSTony Luck #endif
1337f30491cSTony Luck
ia64_native_resend_irq(unsigned int vector)1347f30491cSTony Luck static inline void ia64_native_resend_irq(unsigned int vector)
1357f30491cSTony Luck {
13605933aacSChristoph Hellwig ia64_send_ipi(smp_processor_id(), vector, IA64_IPI_DM_INT, 0);
1377f30491cSTony Luck }
1387f30491cSTony Luck
1397f30491cSTony Luck /*
1407f30491cSTony Luck * Next follows the irq descriptor interface. On IA-64, each CPU supports 256 interrupt
1417f30491cSTony Luck * vectors. On smaller systems, there is a one-to-one correspondence between interrupt
1427f30491cSTony Luck * vectors and the Linux irq numbers. However, larger systems may have multiple interrupt
1437f30491cSTony Luck * domains meaning that the translation from vector number to irq number depends on the
1447f30491cSTony Luck * interrupt domain that a CPU belongs to. This API abstracts such platform-dependent
1457f30491cSTony Luck * differences and provides a uniform means to translate between vector and irq numbers
1467f30491cSTony Luck * and to obtain the irq descriptor for a given irq number.
1477f30491cSTony Luck */
1487f30491cSTony Luck
1497f30491cSTony Luck /* Extract the IA-64 vector that corresponds to IRQ. */
1507f30491cSTony Luck static inline ia64_vector
irq_to_vector(int irq)1517f30491cSTony Luck irq_to_vector (int irq)
1527f30491cSTony Luck {
15305933aacSChristoph Hellwig return irq_cfg[irq].vector;
1547f30491cSTony Luck }
1557f30491cSTony Luck
1567f30491cSTony Luck /*
1577f30491cSTony Luck * Convert the local IA-64 vector to the corresponding irq number. This translation is
1587f30491cSTony Luck * done in the context of the interrupt domain that the currently executing CPU belongs
1597f30491cSTony Luck * to.
1607f30491cSTony Luck */
1617f30491cSTony Luck static inline unsigned int
local_vector_to_irq(ia64_vector vec)1627f30491cSTony Luck local_vector_to_irq (ia64_vector vec)
1637f30491cSTony Luck {
16405933aacSChristoph Hellwig return __this_cpu_read(vector_irq[vec]);
1657f30491cSTony Luck }
1667f30491cSTony Luck
1677f30491cSTony Luck #endif /* _ASM_IA64_HW_IRQ_H */
168