pci.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 <linux/pci.h>
  8. #include <asm-generic/pci.h>
  9. #include <asm-generic/pci-dma-compat.h>
  10. #include <asm/pci_clp.h>
  11. #include <asm/pci_debug.h>
  12. #define PCIBIOS_MIN_IO 0x1000
  13. #define PCIBIOS_MIN_MEM 0x10000000
  14. #define pcibios_assign_all_busses() (0)
  15. void __iomem *pci_iomap(struct pci_dev *, int, unsigned long);
  16. void pci_iounmap(struct pci_dev *, void __iomem *);
  17. int pci_domain_nr(struct pci_bus *);
  18. int pci_proc_domain(struct pci_bus *);
  19. #define ZPCI_BUS_NR 0 /* default bus number */
  20. #define ZPCI_DEVFN 0 /* default device number */
  21. /* PCI Function Controls */
  22. #define ZPCI_FC_FN_ENABLED 0x80
  23. #define ZPCI_FC_ERROR 0x40
  24. #define ZPCI_FC_BLOCKED 0x20
  25. #define ZPCI_FC_DMA_ENABLED 0x10
  26. struct zpci_fmb {
  27. u32 format : 8;
  28. u32 dma_valid : 1;
  29. u32 : 23;
  30. u32 samples;
  31. u64 last_update;
  32. /* hardware counters */
  33. u64 ld_ops;
  34. u64 st_ops;
  35. u64 stb_ops;
  36. u64 rpcit_ops;
  37. u64 dma_rbytes;
  38. u64 dma_wbytes;
  39. /* software counters */
  40. atomic64_t allocated_pages;
  41. atomic64_t mapped_pages;
  42. atomic64_t unmapped_pages;
  43. } __packed __aligned(16);
  44. #define ZPCI_MSI_VEC_BITS 11
  45. #define ZPCI_MSI_VEC_MAX (1 << ZPCI_MSI_VEC_BITS)
  46. #define ZPCI_MSI_VEC_MASK (ZPCI_MSI_VEC_MAX - 1)
  47. enum zpci_state {
  48. ZPCI_FN_STATE_RESERVED,
  49. ZPCI_FN_STATE_STANDBY,
  50. ZPCI_FN_STATE_CONFIGURED,
  51. ZPCI_FN_STATE_ONLINE,
  52. NR_ZPCI_FN_STATES,
  53. };
  54. struct zpci_bar_struct {
  55. struct resource *res; /* bus resource */
  56. u32 val; /* bar start & 3 flag bits */
  57. u16 map_idx; /* index into bar mapping array */
  58. u8 size; /* order 2 exponent */
  59. };
  60. /* Private data per function */
  61. struct zpci_dev {
  62. struct pci_dev *pdev;
  63. struct pci_bus *bus;
  64. struct list_head entry; /* list of all zpci_devices, needed for hotplug, etc. */
  65. enum zpci_state state;
  66. u32 fid; /* function ID, used by sclp */
  67. u32 fh; /* function handle, used by insn's */
  68. u16 vfn; /* virtual function number */
  69. u16 pchid; /* physical channel ID */
  70. u8 pfgid; /* function group ID */
  71. u8 pft; /* pci function type */
  72. u16 domain;
  73. u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */
  74. u32 uid; /* user defined id */
  75. u8 util_str[CLP_UTIL_STR_LEN]; /* utility string */
  76. /* IRQ stuff */
  77. u64 msi_addr; /* MSI address */
  78. struct airq_iv *aibv; /* adapter interrupt bit vector */
  79. unsigned int aisb; /* number of the summary bit */
  80. /* DMA stuff */
  81. unsigned long *dma_table;
  82. spinlock_t dma_table_lock;
  83. int tlb_refresh;
  84. spinlock_t iommu_bitmap_lock;
  85. unsigned long *iommu_bitmap;
  86. unsigned long iommu_size;
  87. unsigned long iommu_pages;
  88. unsigned int next_bit;
  89. char res_name[16];
  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. };
  101. static inline bool zdev_enabled(struct zpci_dev *zdev)
  102. {
  103. return (zdev->fh & (1UL << 31)) ? true : false;
  104. }
  105. extern const struct attribute_group *zpci_attr_groups[];
  106. /* -----------------------------------------------------------------------------
  107. Prototypes
  108. ----------------------------------------------------------------------------- */
  109. /* Base stuff */
  110. int zpci_create_device(struct zpci_dev *);
  111. int zpci_enable_device(struct zpci_dev *);
  112. int zpci_disable_device(struct zpci_dev *);
  113. void zpci_stop_device(struct zpci_dev *);
  114. int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
  115. int zpci_unregister_ioat(struct zpci_dev *, u8);
  116. /* CLP */
  117. int clp_scan_pci_devices(void);
  118. int clp_rescan_pci_devices(void);
  119. int clp_rescan_pci_devices_simple(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. #ifdef CONFIG_PCI
  124. /* Error handling and recovery */
  125. void zpci_event_error(void *);
  126. void zpci_event_availability(void *);
  127. void zpci_rescan(void);
  128. bool zpci_is_enabled(void);
  129. #else /* CONFIG_PCI */
  130. static inline void zpci_event_error(void *e) {}
  131. static inline void zpci_event_availability(void *e) {}
  132. static inline void zpci_rescan(void) {}
  133. #endif /* CONFIG_PCI */
  134. #ifdef CONFIG_HOTPLUG_PCI_S390
  135. int zpci_init_slot(struct zpci_dev *);
  136. void zpci_exit_slot(struct zpci_dev *);
  137. #else /* CONFIG_HOTPLUG_PCI_S390 */
  138. static inline int zpci_init_slot(struct zpci_dev *zdev)
  139. {
  140. return 0;
  141. }
  142. static inline void zpci_exit_slot(struct zpci_dev *zdev) {}
  143. #endif /* CONFIG_HOTPLUG_PCI_S390 */
  144. /* Helpers */
  145. struct zpci_dev *get_zdev(struct pci_dev *);
  146. struct zpci_dev *get_zdev_by_fid(u32);
  147. /* DMA */
  148. int zpci_dma_init(void);
  149. void zpci_dma_exit(void);
  150. /* FMB */
  151. int zpci_fmb_enable_device(struct zpci_dev *);
  152. int zpci_fmb_disable_device(struct zpci_dev *);
  153. /* Debug */
  154. int zpci_debug_init(void);
  155. void zpci_debug_exit(void);
  156. void zpci_debug_init_device(struct zpci_dev *);
  157. void zpci_debug_exit_device(struct zpci_dev *);
  158. void zpci_debug_info(struct zpci_dev *, struct seq_file *);
  159. #endif