msi.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef LINUX_MSI_H
  2. #define LINUX_MSI_H
  3. #include <linux/kobject.h>
  4. #include <linux/list.h>
  5. struct msi_msg {
  6. u32 address_lo; /* low 32 bits of msi message address */
  7. u32 address_hi; /* high 32 bits of msi message address */
  8. u32 data; /* 16 bits of msi message data */
  9. };
  10. /* Helper functions */
  11. struct irq_data;
  12. struct msi_desc;
  13. void mask_msi_irq(struct irq_data *data);
  14. void unmask_msi_irq(struct irq_data *data);
  15. void __read_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
  16. void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
  17. void __write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
  18. void read_msi_msg(unsigned int irq, struct msi_msg *msg);
  19. void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg);
  20. void write_msi_msg(unsigned int irq, struct msi_msg *msg);
  21. struct msi_desc {
  22. struct {
  23. __u8 is_msix : 1;
  24. __u8 multiple: 3; /* log2 number of messages */
  25. __u8 maskbit : 1; /* mask-pending bit supported ? */
  26. __u8 is_64 : 1; /* Address size: 0=32bit 1=64bit */
  27. __u8 pos; /* Location of the msi capability */
  28. __u16 entry_nr; /* specific enabled entry */
  29. unsigned default_irq; /* default pre-assigned irq */
  30. } msi_attrib;
  31. u32 masked; /* mask bits */
  32. unsigned int irq;
  33. unsigned int nvec_used; /* number of messages */
  34. struct list_head list;
  35. union {
  36. void __iomem *mask_base;
  37. u8 mask_pos;
  38. };
  39. struct pci_dev *dev;
  40. /* Last set MSI message */
  41. struct msi_msg msg;
  42. struct kobject kobj;
  43. };
  44. /*
  45. * The arch hooks to setup up msi irqs. Those functions are
  46. * implemented as weak symbols so that they /can/ be overriden by
  47. * architecture specific code if needed.
  48. */
  49. int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc);
  50. void arch_teardown_msi_irq(unsigned int irq);
  51. int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
  52. void arch_teardown_msi_irqs(struct pci_dev *dev);
  53. int arch_msi_check_device(struct pci_dev* dev, int nvec, int type);
  54. void arch_restore_msi_irqs(struct pci_dev *dev, int irq);
  55. void default_teardown_msi_irqs(struct pci_dev *dev);
  56. void default_restore_msi_irqs(struct pci_dev *dev, int irq);
  57. struct msi_chip {
  58. struct module *owner;
  59. struct device *dev;
  60. struct device_node *of_node;
  61. struct list_head list;
  62. int (*setup_irq)(struct msi_chip *chip, struct pci_dev *dev,
  63. struct msi_desc *desc);
  64. void (*teardown_irq)(struct msi_chip *chip, unsigned int irq);
  65. int (*check_device)(struct msi_chip *chip, struct pci_dev *dev,
  66. int nvec, int type);
  67. };
  68. #endif /* LINUX_MSI_H */