2006-04-11 10:17:48 +08:00
|
|
|
/*
|
|
|
|
* MSI hooks for standard x86 apic
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/irq.h>
|
2006-06-26 20:00:02 +08:00
|
|
|
#include <asm/smp.h>
|
2006-04-11 10:17:48 +08:00
|
|
|
|
|
|
|
#include "msi.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Shifts for APIC-based data
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MSI_DATA_VECTOR_SHIFT 0
|
|
|
|
#define MSI_DATA_VECTOR(v) (((u8)v) << MSI_DATA_VECTOR_SHIFT)
|
|
|
|
|
|
|
|
#define MSI_DATA_DELIVERY_SHIFT 8
|
|
|
|
#define MSI_DATA_DELIVERY_FIXED (0 << MSI_DATA_DELIVERY_SHIFT)
|
|
|
|
#define MSI_DATA_DELIVERY_LOWPRI (1 << MSI_DATA_DELIVERY_SHIFT)
|
|
|
|
|
|
|
|
#define MSI_DATA_LEVEL_SHIFT 14
|
|
|
|
#define MSI_DATA_LEVEL_DEASSERT (0 << MSI_DATA_LEVEL_SHIFT)
|
|
|
|
#define MSI_DATA_LEVEL_ASSERT (1 << MSI_DATA_LEVEL_SHIFT)
|
|
|
|
|
|
|
|
#define MSI_DATA_TRIGGER_SHIFT 15
|
|
|
|
#define MSI_DATA_TRIGGER_EDGE (0 << MSI_DATA_TRIGGER_SHIFT)
|
|
|
|
#define MSI_DATA_TRIGGER_LEVEL (1 << MSI_DATA_TRIGGER_SHIFT)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Shift/mask fields for APIC-based bus address
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MSI_ADDR_HEADER 0xfee00000
|
|
|
|
|
|
|
|
#define MSI_ADDR_DESTID_MASK 0xfff0000f
|
|
|
|
#define MSI_ADDR_DESTID_CPU(cpu) ((cpu) << MSI_TARGET_CPU_SHIFT)
|
|
|
|
|
|
|
|
#define MSI_ADDR_DESTMODE_SHIFT 2
|
|
|
|
#define MSI_ADDR_DESTMODE_PHYS (0 << MSI_ADDR_DESTMODE_SHIFT)
|
|
|
|
#define MSI_ADDR_DESTMODE_LOGIC (1 << MSI_ADDR_DESTMODE_SHIFT)
|
|
|
|
|
|
|
|
#define MSI_ADDR_REDIRECTION_SHIFT 3
|
|
|
|
#define MSI_ADDR_REDIRECTION_CPU (0 << MSI_ADDR_REDIRECTION_SHIFT)
|
|
|
|
#define MSI_ADDR_REDIRECTION_LOWPRI (1 << MSI_ADDR_REDIRECTION_SHIFT)
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-10-04 17:16:34 +08:00
|
|
|
msi_target_apic(unsigned int irq, cpumask_t cpu_mask, struct msi_msg *msg)
|
2006-04-11 10:17:48 +08:00
|
|
|
{
|
2006-10-04 17:16:34 +08:00
|
|
|
u32 addr = msg->address_lo;
|
2006-04-11 10:17:48 +08:00
|
|
|
|
|
|
|
addr &= MSI_ADDR_DESTID_MASK;
|
2006-10-04 17:16:34 +08:00
|
|
|
addr |= MSI_ADDR_DESTID_CPU(cpu_physical_id(first_cpu(cpu_mask)));
|
2006-04-11 10:17:48 +08:00
|
|
|
|
2006-10-04 17:16:34 +08:00
|
|
|
msg->address_lo = addr;
|
2006-04-11 10:17:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
msi_setup_apic(struct pci_dev *pdev, /* unused in generic */
|
2006-10-04 17:16:34 +08:00
|
|
|
unsigned int irq,
|
|
|
|
struct msi_msg *msg)
|
2006-04-11 10:17:48 +08:00
|
|
|
{
|
|
|
|
unsigned long dest_phys_id;
|
2006-10-04 17:16:34 +08:00
|
|
|
unsigned int vector;
|
2006-04-11 10:17:48 +08:00
|
|
|
|
|
|
|
dest_phys_id = cpu_physical_id(first_cpu(cpu_online_map));
|
2006-10-04 17:16:34 +08:00
|
|
|
vector = irq;
|
2006-04-11 10:17:48 +08:00
|
|
|
|
2006-10-04 17:16:34 +08:00
|
|
|
msg->address_hi = 0;
|
|
|
|
msg->address_lo =
|
|
|
|
MSI_ADDR_HEADER |
|
|
|
|
MSI_ADDR_DESTMODE_PHYS |
|
|
|
|
MSI_ADDR_REDIRECTION_CPU |
|
|
|
|
MSI_ADDR_DESTID_CPU(dest_phys_id);
|
2006-04-11 10:17:48 +08:00
|
|
|
|
2006-10-04 17:16:34 +08:00
|
|
|
msg->data =
|
|
|
|
MSI_DATA_TRIGGER_EDGE |
|
2006-04-11 10:17:48 +08:00
|
|
|
MSI_DATA_LEVEL_ASSERT |
|
|
|
|
MSI_DATA_DELIVERY_FIXED |
|
|
|
|
MSI_DATA_VECTOR(vector);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-04 17:16:34 +08:00
|
|
|
msi_teardown_apic(unsigned int irq)
|
2006-04-11 10:17:48 +08:00
|
|
|
{
|
|
|
|
return; /* no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic ops used on most IA archs/platforms. Set with msi_register()
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct msi_ops msi_apic_ops = {
|
2006-10-04 17:16:34 +08:00
|
|
|
.needs_64bit_address = 0,
|
2006-04-11 10:17:48 +08:00
|
|
|
.setup = msi_setup_apic,
|
|
|
|
.teardown = msi_teardown_apic,
|
|
|
|
.target = msi_target_apic,
|
|
|
|
};
|