pci.h 5.3 KB

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