pci.h 5.4 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3
#ifndef __ASM_S390_PCI_H
#define __ASM_S390_PCI_H

J
Jan Glauber 已提交
4
/* must be set before including asm-generic/pci.h */
L
Linus Torvalds 已提交
5
#define PCI_DMA_BUS_IS_PHYS (0)
J
Jan Glauber 已提交
6 7
/* must be set before including pci_clp.h */
#define PCI_BAR_COUNT	6
L
Linus Torvalds 已提交
8

J
Jan Glauber 已提交
9 10
#include <asm-generic/pci.h>
#include <asm-generic/pci-dma-compat.h>
J
Jan Glauber 已提交
11
#include <asm/pci_clp.h>
12
#include <asm/pci_debug.h>
L
Linus Torvalds 已提交
13

J
Jan Glauber 已提交
14 15 16 17 18 19 20 21 22 23
#define PCIBIOS_MIN_IO		0x1000
#define PCIBIOS_MIN_MEM		0x10000000

#define pcibios_assign_all_busses()	(0)

void __iomem *pci_iomap(struct pci_dev *, int, unsigned long);
void pci_iounmap(struct pci_dev *, void __iomem *);
int pci_domain_nr(struct pci_bus *);
int pci_proc_domain(struct pci_bus *);

24 25 26 27
/* MSI arch hooks */
#define arch_setup_msi_irqs	arch_setup_msi_irqs
#define arch_teardown_msi_irqs	arch_teardown_msi_irqs

J
Jan Glauber 已提交
28 29 30 31 32 33 34 35 36
#define ZPCI_BUS_NR			0	/* default bus number */
#define ZPCI_DEVFN			0	/* default device number */

/* PCI Function Controls */
#define ZPCI_FC_FN_ENABLED		0x80
#define ZPCI_FC_ERROR			0x40
#define ZPCI_FC_BLOCKED			0x20
#define ZPCI_FC_DMA_ENABLED		0x10

37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
struct zpci_fmb {
	u32 format	:  8;
	u32 dma_valid	:  1;
	u32		: 23;
	u32 samples;
	u64 last_update;
	/* hardware counters */
	u64 ld_ops;
	u64 st_ops;
	u64 stb_ops;
	u64 rpcit_ops;
	u64 dma_rbytes;
	u64 dma_wbytes;
	/* software counters */
	atomic64_t allocated_pages;
	atomic64_t mapped_pages;
	atomic64_t unmapped_pages;
} __packed __aligned(16);

56 57 58 59 60 61
struct msi_map {
	unsigned long irq;
	struct msi_desc *msi;
	struct hlist_node msi_chain;
};

62 63 64
#define ZPCI_MSI_VEC_BITS	11
#define ZPCI_MSI_VEC_MAX	(1 << ZPCI_MSI_VEC_BITS)
#define ZPCI_MSI_VEC_MASK	(ZPCI_MSI_VEC_MAX - 1)
65

J
Jan Glauber 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
enum zpci_state {
	ZPCI_FN_STATE_RESERVED,
	ZPCI_FN_STATE_STANDBY,
	ZPCI_FN_STATE_CONFIGURED,
	ZPCI_FN_STATE_ONLINE,
	NR_ZPCI_FN_STATES,
};

struct zpci_bar_struct {
	u32		val;		/* bar start & 3 flag bits */
	u8		size;		/* order 2 exponent */
	u16		map_idx;	/* index into bar mapping array */
};

/* Private data per function */
struct zpci_dev {
	struct pci_dev	*pdev;
	struct pci_bus	*bus;
	struct list_head entry;		/* list of all zpci_devices, needed for hotplug, etc. */

	enum zpci_state state;
	u32		fid;		/* function ID, used by sclp */
	u32		fh;		/* function handle, used by insn's */
	u16		pchid;		/* physical channel ID */
	u8		pfgid;		/* function group ID */
	u16		domain;

93 94 95
	/* IRQ stuff */
	u64		msi_addr;	/* MSI address */
	struct zdev_irq_map *irq_map;
96 97
	struct msi_map *msi_map;
	struct airq_iv *aibv;		/* adapter interrupt bit vector */
98 99
	unsigned int	aisb;		/* number of the summary bit */

J
Jan Glauber 已提交
100 101 102 103 104 105 106 107 108 109 110
	/* DMA stuff */
	unsigned long	*dma_table;
	spinlock_t	dma_table_lock;
	int		tlb_refresh;

	spinlock_t	iommu_bitmap_lock;
	unsigned long	*iommu_bitmap;
	unsigned long	iommu_size;
	unsigned long	iommu_pages;
	unsigned int	next_bit;

J
Jan Glauber 已提交
111 112
	struct zpci_bar_struct bars[PCI_BAR_COUNT];

J
Jan Glauber 已提交
113 114 115 116
	u64		start_dma;	/* Start of available DMA addresses */
	u64		end_dma;	/* End of available DMA addresses */
	u64		dma_mask;	/* DMA address space mask */

117 118 119 120
	/* Function measurement block */
	struct zpci_fmb *fmb;
	u16		fmb_update;	/* update interval */

J
Jan Glauber 已提交
121
	enum pci_bus_speed max_bus_speed;
122 123 124

	struct dentry	*debugfs_dev;
	struct dentry	*debugfs_perf;
J
Jan Glauber 已提交
125 126
};

127 128 129 130 131
struct pci_hp_callback_ops {
	int (*create_slot)	(struct zpci_dev *zdev);
	void (*remove_slot)	(struct zpci_dev *zdev);
};

J
Jan Glauber 已提交
132 133 134 135 136 137 138 139 140 141 142 143
static inline bool zdev_enabled(struct zpci_dev *zdev)
{
	return (zdev->fh & (1UL << 31)) ? true : false;
}

/* -----------------------------------------------------------------------------
  Prototypes
----------------------------------------------------------------------------- */
/* Base stuff */
struct zpci_dev *zpci_alloc_device(void);
int zpci_create_device(struct zpci_dev *);
int zpci_enable_device(struct zpci_dev *);
144
int zpci_disable_device(struct zpci_dev *);
J
Jan Glauber 已提交
145 146
void zpci_stop_device(struct zpci_dev *);
void zpci_free_device(struct zpci_dev *);
J
Jan Glauber 已提交
147 148
int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
int zpci_unregister_ioat(struct zpci_dev *, u8);
J
Jan Glauber 已提交
149

J
Jan Glauber 已提交
150 151 152 153 154 155
/* CLP */
int clp_find_pci_devices(void);
int clp_add_pci_device(u32, u32, int);
int clp_enable_fh(struct zpci_dev *, u8);
int clp_disable_fh(struct zpci_dev *);

156 157 158 159 160 161 162 163
/* MSI */
struct msi_desc *__irq_get_msi_desc(unsigned int);
int zpci_msi_set_mask_bits(struct msi_desc *, u32, u32);
int zpci_setup_msi_irq(struct zpci_dev *, struct msi_desc *, unsigned int, int);
void zpci_teardown_msi_irq(struct zpci_dev *, struct msi_desc *);
int zpci_msihash_init(void);
void zpci_msihash_exit(void);

164
#ifdef CONFIG_PCI
165 166 167
/* Error handling and recovery */
void zpci_event_error(void *);
void zpci_event_availability(void *);
168 169 170 171
#else /* CONFIG_PCI */
static inline void zpci_event_error(void *e) {}
static inline void zpci_event_availability(void *e) {}
#endif /* CONFIG_PCI */
172

J
Jan Glauber 已提交
173 174 175 176 177
/* Helpers */
struct zpci_dev *get_zdev(struct pci_dev *);
struct zpci_dev *get_zdev_by_fid(u32);
bool zpci_fid_present(u32);

178 179 180 181
/* sysfs */
int zpci_sysfs_add_device(struct device *);
void zpci_sysfs_remove_device(struct device *);

J
Jan Glauber 已提交
182 183 184 185
/* DMA */
int zpci_dma_init(void);
void zpci_dma_exit(void);

186 187 188
/* Hotplug */
extern struct mutex zpci_list_lock;
extern struct list_head zpci_list;
189
extern unsigned int s390_pci_probe;
190

191 192 193
void zpci_register_hp_ops(struct pci_hp_callback_ops *);
void zpci_deregister_hp_ops(void);

194 195 196 197 198 199 200 201 202 203 204
/* FMB */
int zpci_fmb_enable_device(struct zpci_dev *);
int zpci_fmb_disable_device(struct zpci_dev *);

/* Debug */
int zpci_debug_init(void);
void zpci_debug_exit(void);
void zpci_debug_init_device(struct zpci_dev *);
void zpci_debug_exit_device(struct zpci_dev *);
void zpci_debug_info(struct zpci_dev *, struct seq_file *);

J
Jan Glauber 已提交
205
#endif