pci.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. #ifndef __ASM_S390_PCI_H
  2. #define __ASM_S390_PCI_H
  3. /* must be set before including asm-generic/pci.h */
  4. #define PCI_DMA_BUS_IS_PHYS (0)
  5. /* must be set before including pci_clp.h */
  6. #define PCI_BAR_COUNT 6
  7. #include <asm-generic/pci.h>
  8. #include <asm-generic/pci-dma-compat.h>
  9. #include <asm/pci_clp.h>
  10. #include <asm/pci_debug.h>
  11. #define PCIBIOS_MIN_IO 0x1000
  12. #define PCIBIOS_MIN_MEM 0x10000000
  13. #define pcibios_assign_all_busses() (0)
  14. void __iomem *pci_iomap(struct pci_dev *, int, unsigned long);
  15. void pci_iounmap(struct pci_dev *, void __iomem *);
  16. int pci_domain_nr(struct pci_bus *);
  17. int pci_proc_domain(struct pci_bus *);
  18. #define ZPCI_BUS_NR 0 /* default bus number */
  19. #define ZPCI_DEVFN 0 /* default device number */
  20. /* PCI Function Controls */
  21. #define ZPCI_FC_FN_ENABLED 0x80
  22. #define ZPCI_FC_ERROR 0x40
  23. #define ZPCI_FC_BLOCKED 0x20
  24. #define ZPCI_FC_DMA_ENABLED 0x10
  25. struct zpci_fmb {
  26. u32 format : 8;
  27. u32 dma_valid : 1;
  28. u32 : 23;
  29. u32 samples;
  30. u64 last_update;
  31. /* hardware counters */
  32. u64 ld_ops;
  33. u64 st_ops;
  34. u64 stb_ops;
  35. u64 rpcit_ops;
  36. u64 dma_rbytes;
  37. u64 dma_wbytes;
  38. /* software counters */
  39. atomic64_t allocated_pages;
  40. atomic64_t mapped_pages;
  41. atomic64_t unmapped_pages;
  42. } __packed __aligned(16);
  43. struct msi_map {
  44. unsigned long irq;
  45. struct msi_desc *msi;
  46. struct hlist_node msi_chain;
  47. };
  48. #define ZPCI_NR_MSI_VECS 64
  49. #define ZPCI_MSI_MASK (ZPCI_NR_MSI_VECS - 1)
  50. enum zpci_state {
  51. ZPCI_FN_STATE_RESERVED,
  52. ZPCI_FN_STATE_STANDBY,
  53. ZPCI_FN_STATE_CONFIGURED,
  54. ZPCI_FN_STATE_ONLINE,
  55. NR_ZPCI_FN_STATES,
  56. };
  57. struct zpci_bar_struct {
  58. u32 val; /* bar start & 3 flag bits */
  59. u8 size; /* order 2 exponent */
  60. u16 map_idx; /* index into bar mapping array */
  61. };
  62. /* Private data per function */
  63. struct zpci_dev {
  64. struct pci_dev *pdev;
  65. struct pci_bus *bus;
  66. struct list_head entry; /* list of all zpci_devices, needed for hotplug, etc. */
  67. enum zpci_state state;
  68. u32 fid; /* function ID, used by sclp */
  69. u32 fh; /* function handle, used by insn's */
  70. u16 pchid; /* physical channel ID */
  71. u8 pfgid; /* function group ID */
  72. u16 domain;
  73. /* IRQ stuff */
  74. u64 msi_addr; /* MSI address */
  75. struct zdev_irq_map *irq_map;
  76. struct msi_map *msi_map[ZPCI_NR_MSI_VECS];
  77. unsigned int aisb; /* number of the summary bit */
  78. /* DMA stuff */
  79. unsigned long *dma_table;
  80. spinlock_t dma_table_lock;
  81. int tlb_refresh;
  82. spinlock_t iommu_bitmap_lock;
  83. unsigned long *iommu_bitmap;
  84. unsigned long iommu_size;
  85. unsigned long iommu_pages;
  86. unsigned int next_bit;
  87. struct zpci_bar_struct bars[PCI_BAR_COUNT];
  88. u64 start_dma; /* Start of available DMA addresses */
  89. u64 end_dma; /* End of available DMA addresses */
  90. u64 dma_mask; /* DMA address space mask */
  91. /* Function measurement block */
  92. struct zpci_fmb *fmb;
  93. u16 fmb_update; /* update interval */
  94. enum pci_bus_speed max_bus_speed;
  95. struct dentry *debugfs_dev;
  96. struct dentry *debugfs_perf;
  97. };
  98. struct pci_hp_callback_ops {
  99. int (*create_slot) (struct zpci_dev *zdev);
  100. void (*remove_slot) (struct zpci_dev *zdev);
  101. };
  102. static inline bool zdev_enabled(struct zpci_dev *zdev)
  103. {
  104. return (zdev->fh & (1UL << 31)) ? true : false;
  105. }
  106. /* -----------------------------------------------------------------------------
  107. Prototypes
  108. ----------------------------------------------------------------------------- */
  109. /* Base stuff */
  110. struct zpci_dev *zpci_alloc_device(void);
  111. int zpci_create_device(struct zpci_dev *);
  112. int zpci_enable_device(struct zpci_dev *);
  113. int zpci_disable_device(struct zpci_dev *);
  114. void zpci_stop_device(struct zpci_dev *);
  115. void zpci_free_device(struct zpci_dev *);
  116. int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
  117. int zpci_unregister_ioat(struct zpci_dev *, u8);
  118. /* CLP */
  119. int clp_find_pci_devices(void);
  120. int clp_add_pci_device(u32, u32, int);
  121. int clp_enable_fh(struct zpci_dev *, u8);
  122. int clp_disable_fh(struct zpci_dev *);
  123. /* MSI */
  124. struct msi_desc *__irq_get_msi_desc(unsigned int);
  125. int zpci_msi_set_mask_bits(struct msi_desc *, u32, u32);
  126. int zpci_setup_msi_irq(struct zpci_dev *, struct msi_desc *, unsigned int, int);
  127. void zpci_teardown_msi_irq(struct zpci_dev *, struct msi_desc *);
  128. int zpci_msihash_init(void);
  129. void zpci_msihash_exit(void);
  130. #ifdef CONFIG_PCI
  131. /* Error handling and recovery */
  132. void zpci_event_error(void *);
  133. void zpci_event_availability(void *);
  134. #else /* CONFIG_PCI */
  135. static inline void zpci_event_error(void *e) {}
  136. static inline void zpci_event_availability(void *e) {}
  137. #endif /* CONFIG_PCI */
  138. /* Helpers */
  139. struct zpci_dev *get_zdev(struct pci_dev *);
  140. struct zpci_dev *get_zdev_by_fid(u32);
  141. bool zpci_fid_present(u32);
  142. /* sysfs */
  143. int zpci_sysfs_add_device(struct device *);
  144. void zpci_sysfs_remove_device(struct device *);
  145. /* DMA */
  146. int zpci_dma_init(void);
  147. void zpci_dma_exit(void);
  148. /* Hotplug */
  149. extern struct mutex zpci_list_lock;
  150. extern struct list_head zpci_list;
  151. extern unsigned int s390_pci_probe;
  152. void zpci_register_hp_ops(struct pci_hp_callback_ops *);
  153. void zpci_deregister_hp_ops(void);
  154. /* FMB */
  155. int zpci_fmb_enable_device(struct zpci_dev *);
  156. int zpci_fmb_disable_device(struct zpci_dev *);
  157. /* Debug */
  158. int zpci_debug_init(void);
  159. void zpci_debug_exit(void);
  160. void zpci_debug_init_device(struct zpci_dev *);
  161. void zpci_debug_exit_device(struct zpci_dev *);
  162. void zpci_debug_info(struct zpci_dev *, struct seq_file *);
  163. #endif