msi.h 2.6 KB
Newer Older
1 2 3
#ifndef LINUX_MSI_H
#define LINUX_MSI_H

4
#include <linux/kobject.h>
5 6
#include <linux/list.h>

7 8 9 10 11 12
struct msi_msg {
	u32	address_lo;	/* low 32 bits of msi message address */
	u32	address_hi;	/* high 32 bits of msi message address */
	u32	data;		/* 16 bits of msi message data */
};

13
extern int pci_msi_ignore_mask;
S
Satoru Takeuchi 已提交
14
/* Helper functions */
15
struct irq_data;
16
struct msi_desc;
17 18 19 20
void mask_msi_irq(struct irq_data *data);
void unmask_msi_irq(struct irq_data *data);
void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg);
21

22 23
u32 __msix_mask_irq(struct msi_desc *desc, u32 flag);
u32 __msi_mask_irq(struct msi_desc *desc, u32 mask, u32 flag);
24 25 26

struct msi_desc {
	struct {
27
		__u8	is_msix	: 1;
28 29
		__u8	multiple: 3;	/* log2 num of messages allocated */
		__u8	multi_cap : 3;	/* log2 num of messages supported */
30 31 32 33
		__u8	maskbit	: 1;	/* mask-pending bit supported ? */
		__u8	is_64	: 1;	/* Address size: 0=32bit 1=64bit */
		__u16	entry_nr;	/* specific enabled entry */
		unsigned default_irq;	/* default pre-assigned irq */
34
	} msi_attrib;
35

36
	u32 masked;			/* mask bits */
37
	unsigned int irq;
38
	unsigned int nvec_used;		/* number of messages */
39
	struct list_head list;
40

41 42 43 44
	union {
		void __iomem *mask_base;
		u8 mask_pos;
	};
45 46
	struct pci_dev *dev;

47 48
	/* Last set MSI message */
	struct msi_msg msg;
49 50
};

51
void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
52 53 54 55 56 57 58 59 60 61 62 63
void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg);

/* Conversion helpers. Should be removed after merging */
static inline void __write_msi_msg(struct msi_desc *entry, struct msi_msg *msg)
{
	__pci_write_msi_msg(entry, msg);
}
static inline void write_msi_msg(int irq, struct msi_msg *msg)
{
	pci_write_msi_msg(irq, msg);
}
64

65
/*
66 67 68
 * The arch hooks to setup up msi irqs. Those functions are
 * implemented as weak symbols so that they /can/ be overriden by
 * architecture specific code if needed.
69
 */
70
int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc);
71
void arch_teardown_msi_irq(unsigned int irq);
72 73
int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
void arch_teardown_msi_irqs(struct pci_dev *dev);
74
void arch_restore_msi_irqs(struct pci_dev *dev);
75 76

void default_teardown_msi_irqs(struct pci_dev *dev);
77
void default_restore_msi_irqs(struct pci_dev *dev);
78

79
struct msi_controller {
80 81
	struct module *owner;
	struct device *dev;
82 83
	struct device_node *of_node;
	struct list_head list;
84

85
	int (*setup_irq)(struct msi_controller *chip, struct pci_dev *dev,
86
			 struct msi_desc *desc);
87
	void (*teardown_irq)(struct msi_controller *chip, unsigned int irq);
88 89
};

90
#endif /* LINUX_MSI_H */