2 * MSI hooks for standard x86 apic
11 * Shifts for APIC-based data
14 #define MSI_DATA_VECTOR_SHIFT 0
15 #define MSI_DATA_VECTOR(v) (((u8)v) << MSI_DATA_VECTOR_SHIFT)
17 #define MSI_DATA_DELIVERY_SHIFT 8
18 #define MSI_DATA_DELIVERY_FIXED (0 << MSI_DATA_DELIVERY_SHIFT)
19 #define MSI_DATA_DELIVERY_LOWPRI (1 << MSI_DATA_DELIVERY_SHIFT)
21 #define MSI_DATA_LEVEL_SHIFT 14
22 #define MSI_DATA_LEVEL_DEASSERT (0 << MSI_DATA_LEVEL_SHIFT)
23 #define MSI_DATA_LEVEL_ASSERT (1 << MSI_DATA_LEVEL_SHIFT)
25 #define MSI_DATA_TRIGGER_SHIFT 15
26 #define MSI_DATA_TRIGGER_EDGE (0 << MSI_DATA_TRIGGER_SHIFT)
27 #define MSI_DATA_TRIGGER_LEVEL (1 << MSI_DATA_TRIGGER_SHIFT)
30 * Shift/mask fields for APIC-based bus address
33 #define MSI_TARGET_CPU_SHIFT 4
34 #define MSI_ADDR_HEADER 0xfee00000
36 #define MSI_ADDR_DESTID_MASK 0xfff0000f
37 #define MSI_ADDR_DESTID_CPU(cpu) ((cpu) << MSI_TARGET_CPU_SHIFT)
39 #define MSI_ADDR_DESTMODE_SHIFT 2
40 #define MSI_ADDR_DESTMODE_PHYS (0 << MSI_ADDR_DESTMODE_SHIFT)
41 #define MSI_ADDR_DESTMODE_LOGIC (1 << MSI_ADDR_DESTMODE_SHIFT)
43 #define MSI_ADDR_REDIRECTION_SHIFT 3
44 #define MSI_ADDR_REDIRECTION_CPU (0 << MSI_ADDR_REDIRECTION_SHIFT)
45 #define MSI_ADDR_REDIRECTION_LOWPRI (1 << MSI_ADDR_REDIRECTION_SHIFT)
47 static struct irq_chip ia64_msi_chip;
50 static void ia64_set_msi_irq_affinity(unsigned int irq, cpumask_t cpu_mask)
55 read_msi_msg(irq, &msg);
57 addr = msg.address_lo;
58 addr &= MSI_ADDR_DESTID_MASK;
59 addr |= MSI_ADDR_DESTID_CPU(cpu_physical_id(first_cpu(cpu_mask)));
60 msg.address_lo = addr;
62 write_msi_msg(irq, &msg);
63 set_native_irq_info(irq, cpu_mask);
65 #endif /* CONFIG_SMP */
67 int ia64_setup_msi_irq(unsigned int irq, struct pci_dev *pdev)
70 unsigned long dest_phys_id;
73 dest_phys_id = cpu_physical_id(first_cpu(cpu_online_map));
79 MSI_ADDR_DESTMODE_PHYS |
80 MSI_ADDR_REDIRECTION_CPU |
81 MSI_ADDR_DESTID_CPU(dest_phys_id);
84 MSI_DATA_TRIGGER_EDGE |
85 MSI_DATA_LEVEL_ASSERT |
86 MSI_DATA_DELIVERY_FIXED |
87 MSI_DATA_VECTOR(vector);
89 write_msi_msg(irq, &msg);
90 set_irq_chip_and_handler(irq, &ia64_msi_chip, handle_edge_irq);
95 void ia64_teardown_msi_irq(unsigned int irq)
100 static void ia64_ack_msi_irq(unsigned int irq)
102 move_native_irq(irq);
106 static int ia64_msi_retrigger_irq(unsigned int irq)
108 unsigned int vector = irq;
109 ia64_resend_irq(vector);
115 * Generic ops used on most IA64 platforms.
117 static struct irq_chip ia64_msi_chip = {
119 .mask = mask_msi_irq,
120 .unmask = unmask_msi_irq,
121 .ack = ia64_ack_msi_irq,
123 .set_affinity = ia64_set_msi_irq_affinity,
125 .retrigger = ia64_msi_retrigger_irq,
129 int arch_setup_msi_irq(unsigned int irq, struct pci_dev *pdev)
131 if (platform_setup_msi_irq)
132 return platform_setup_msi_irq(irq, pdev);
134 return ia64_setup_msi_irq(irq, pdev);
137 void arch_teardown_msi_irq(unsigned int irq)
139 if (platform_teardown_msi_irq)
140 return platform_teardown_msi_irq(irq);
142 return ia64_teardown_msi_irq(irq);