pci.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. #define PCIBIOS_MIN_IO 0x1000
  11. #define PCIBIOS_MIN_MEM 0x10000000
  12. #define pcibios_assign_all_busses() (0)
  13. void __iomem *pci_iomap(struct pci_dev *, int, unsigned long);
  14. void pci_iounmap(struct pci_dev *, void __iomem *);
  15. int pci_domain_nr(struct pci_bus *);
  16. int pci_proc_domain(struct pci_bus *);
  17. /* MSI arch hooks */
  18. #define arch_setup_msi_irqs arch_setup_msi_irqs
  19. #define arch_teardown_msi_irqs arch_teardown_msi_irqs
  20. #define ZPCI_BUS_NR 0 /* default bus number */
  21. #define ZPCI_DEVFN 0 /* default device number */
  22. /* PCI Function Controls */
  23. #define ZPCI_FC_FN_ENABLED 0x80
  24. #define ZPCI_FC_ERROR 0x40
  25. #define ZPCI_FC_BLOCKED 0x20
  26. #define ZPCI_FC_DMA_ENABLED 0x10
  27. struct msi_map {
  28. unsigned long irq;
  29. struct msi_desc *msi;
  30. struct hlist_node msi_chain;
  31. };
  32. #define ZPCI_NR_MSI_VECS 64
  33. #define ZPCI_MSI_MASK (ZPCI_NR_MSI_VECS - 1)
  34. enum zpci_state {
  35. ZPCI_FN_STATE_RESERVED,
  36. ZPCI_FN_STATE_STANDBY,
  37. ZPCI_FN_STATE_CONFIGURED,
  38. ZPCI_FN_STATE_ONLINE,
  39. NR_ZPCI_FN_STATES,
  40. };
  41. struct zpci_bar_struct {
  42. u32 val; /* bar start & 3 flag bits */
  43. u8 size; /* order 2 exponent */
  44. u16 map_idx; /* index into bar mapping array */
  45. };
  46. /* Private data per function */
  47. struct zpci_dev {
  48. struct pci_dev *pdev;
  49. struct pci_bus *bus;
  50. struct list_head entry; /* list of all zpci_devices, needed for hotplug, etc. */
  51. enum zpci_state state;
  52. u32 fid; /* function ID, used by sclp */
  53. u32 fh; /* function handle, used by insn's */
  54. u16 pchid; /* physical channel ID */
  55. u8 pfgid; /* function group ID */
  56. u16 domain;
  57. /* IRQ stuff */
  58. u64 msi_addr; /* MSI address */
  59. struct zdev_irq_map *irq_map;
  60. struct msi_map *msi_map[ZPCI_NR_MSI_VECS];
  61. unsigned int aisb; /* number of the summary bit */
  62. /* DMA stuff */
  63. unsigned long *dma_table;
  64. spinlock_t dma_table_lock;
  65. int tlb_refresh;
  66. spinlock_t iommu_bitmap_lock;
  67. unsigned long *iommu_bitmap;
  68. unsigned long iommu_size;
  69. unsigned long iommu_pages;
  70. unsigned int next_bit;
  71. struct zpci_bar_struct bars[PCI_BAR_COUNT];
  72. u64 start_dma; /* Start of available DMA addresses */
  73. u64 end_dma; /* End of available DMA addresses */
  74. u64 dma_mask; /* DMA address space mask */
  75. enum pci_bus_speed max_bus_speed;
  76. };
  77. struct pci_hp_callback_ops {
  78. int (*create_slot) (struct zpci_dev *zdev);
  79. void (*remove_slot) (struct zpci_dev *zdev);
  80. };
  81. static inline bool zdev_enabled(struct zpci_dev *zdev)
  82. {
  83. return (zdev->fh & (1UL << 31)) ? true : false;
  84. }
  85. /* -----------------------------------------------------------------------------
  86. Prototypes
  87. ----------------------------------------------------------------------------- */
  88. /* Base stuff */
  89. struct zpci_dev *zpci_alloc_device(void);
  90. int zpci_create_device(struct zpci_dev *);
  91. int zpci_enable_device(struct zpci_dev *);
  92. void zpci_stop_device(struct zpci_dev *);
  93. void zpci_free_device(struct zpci_dev *);
  94. int zpci_scan_device(struct zpci_dev *);
  95. int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
  96. int zpci_unregister_ioat(struct zpci_dev *, u8);
  97. /* CLP */
  98. int clp_find_pci_devices(void);
  99. int clp_add_pci_device(u32, u32, int);
  100. int clp_enable_fh(struct zpci_dev *, u8);
  101. int clp_disable_fh(struct zpci_dev *);
  102. /* MSI */
  103. struct msi_desc *__irq_get_msi_desc(unsigned int);
  104. int zpci_msi_set_mask_bits(struct msi_desc *, u32, u32);
  105. int zpci_setup_msi_irq(struct zpci_dev *, struct msi_desc *, unsigned int, int);
  106. void zpci_teardown_msi_irq(struct zpci_dev *, struct msi_desc *);
  107. int zpci_msihash_init(void);
  108. void zpci_msihash_exit(void);
  109. /* Error handling and recovery */
  110. void zpci_event_error(void *);
  111. void zpci_event_availability(void *);
  112. /* Helpers */
  113. struct zpci_dev *get_zdev(struct pci_dev *);
  114. struct zpci_dev *get_zdev_by_fid(u32);
  115. bool zpci_fid_present(u32);
  116. /* sysfs */
  117. int zpci_sysfs_add_device(struct device *);
  118. void zpci_sysfs_remove_device(struct device *);
  119. /* DMA */
  120. int zpci_dma_init(void);
  121. void zpci_dma_exit(void);
  122. /* Hotplug */
  123. extern struct mutex zpci_list_lock;
  124. extern struct list_head zpci_list;
  125. extern struct pci_hp_callback_ops hotplug_ops;
  126. extern unsigned int pci_probe;
  127. #endif