2011-09-19 17:45:05 +00:00
|
|
|
#ifndef __POWERNV_PCI_H
|
|
|
|
#define __POWERNV_PCI_H
|
|
|
|
|
|
|
|
struct pci_dn;
|
|
|
|
|
|
|
|
enum pnv_phb_type {
|
2013-04-25 19:20:57 +00:00
|
|
|
PNV_PHB_P5IOC2 = 0,
|
|
|
|
PNV_PHB_IODA1 = 1,
|
|
|
|
PNV_PHB_IODA2 = 2,
|
2011-09-19 17:45:05 +00:00
|
|
|
};
|
|
|
|
|
2011-11-29 18:22:53 +00:00
|
|
|
/* Precise PHB model for error management */
|
|
|
|
enum pnv_phb_model {
|
|
|
|
PNV_PHB_MODEL_UNKNOWN,
|
|
|
|
PNV_PHB_MODEL_P5IOC2,
|
|
|
|
PNV_PHB_MODEL_P7IOC,
|
2013-04-25 19:20:57 +00:00
|
|
|
PNV_PHB_MODEL_PHB3,
|
2011-11-29 18:22:53 +00:00
|
|
|
};
|
|
|
|
|
2013-09-06 01:00:03 +00:00
|
|
|
#define PNV_PCI_DIAG_BUF_SIZE 8192
|
2012-08-20 03:49:15 +00:00
|
|
|
#define PNV_IODA_PE_DEV (1 << 0) /* PE has single PCI device */
|
|
|
|
#define PNV_IODA_PE_BUS (1 << 1) /* PE has primary PCI bus */
|
|
|
|
#define PNV_IODA_PE_BUS_ALL (1 << 2) /* PE has subordinate buses */
|
2011-11-29 18:22:53 +00:00
|
|
|
|
2011-11-15 17:29:08 +00:00
|
|
|
/* Data associated with a PE, including IOMMU tracking etc.. */
|
2013-04-25 19:21:00 +00:00
|
|
|
struct pnv_phb;
|
2011-11-15 17:29:08 +00:00
|
|
|
struct pnv_ioda_pe {
|
2012-08-20 03:49:15 +00:00
|
|
|
unsigned long flags;
|
2013-04-25 19:21:00 +00:00
|
|
|
struct pnv_phb *phb;
|
2012-08-20 03:49:15 +00:00
|
|
|
|
2011-11-15 17:29:08 +00:00
|
|
|
/* A PE can be associated with a single device or an
|
|
|
|
* entire bus (& children). In the former case, pdev
|
|
|
|
* is populated, in the later case, pbus is.
|
|
|
|
*/
|
|
|
|
struct pci_dev *pdev;
|
|
|
|
struct pci_bus *pbus;
|
|
|
|
|
|
|
|
/* Effective RID (device RID for a device PE and base bus
|
|
|
|
* RID with devfn 0 for a bus PE)
|
|
|
|
*/
|
|
|
|
unsigned int rid;
|
|
|
|
|
|
|
|
/* PE number */
|
|
|
|
unsigned int pe_number;
|
|
|
|
|
|
|
|
/* "Weight" assigned to the PE for the sake of DMA resource
|
|
|
|
* allocations
|
|
|
|
*/
|
|
|
|
unsigned int dma_weight;
|
|
|
|
|
|
|
|
/* "Base" iommu table, ie, 4K TCEs, 32-bit DMA */
|
|
|
|
int tce32_seg;
|
|
|
|
int tce32_segcount;
|
|
|
|
struct iommu_table tce32_table;
|
2013-08-28 08:37:43 +00:00
|
|
|
phys_addr_t tce_inval_reg_phys;
|
2011-11-15 17:29:08 +00:00
|
|
|
|
2014-02-11 00:32:38 +00:00
|
|
|
/* 64-bit TCE bypass region */
|
|
|
|
bool tce_bypass_enabled;
|
|
|
|
uint64_t tce_bypass_base;
|
2011-11-15 17:29:08 +00:00
|
|
|
|
|
|
|
/* MSIs. MVE index is identical for for 32 and 64 bit MSI
|
|
|
|
* and -1 if not supported. (It's actually identical to the
|
|
|
|
* PE number)
|
|
|
|
*/
|
|
|
|
int mve_number;
|
|
|
|
|
|
|
|
/* Link in list of PE#s */
|
2012-08-20 03:49:15 +00:00
|
|
|
struct list_head dma_link;
|
|
|
|
struct list_head list;
|
2011-11-15 17:29:08 +00:00
|
|
|
};
|
|
|
|
|
2013-06-20 05:21:06 +00:00
|
|
|
/* IOC dependent EEH operations */
|
|
|
|
#ifdef CONFIG_EEH
|
|
|
|
struct pnv_eeh_ops {
|
|
|
|
int (*post_init)(struct pci_controller *hose);
|
|
|
|
int (*set_option)(struct eeh_pe *pe, int option);
|
|
|
|
int (*get_state)(struct eeh_pe *pe);
|
|
|
|
int (*reset)(struct eeh_pe *pe, int option);
|
|
|
|
int (*get_log)(struct eeh_pe *pe, int severity,
|
|
|
|
char *drv_log, unsigned long len);
|
|
|
|
int (*configure_bridge)(struct eeh_pe *pe);
|
|
|
|
int (*next_error)(struct eeh_pe **pe);
|
|
|
|
};
|
|
|
|
#endif /* CONFIG_EEH */
|
|
|
|
|
2014-04-24 08:00:09 +00:00
|
|
|
#define PNV_PHB_FLAG_EEH (1 << 0)
|
|
|
|
|
2011-09-19 17:45:05 +00:00
|
|
|
struct pnv_phb {
|
|
|
|
struct pci_controller *hose;
|
|
|
|
enum pnv_phb_type type;
|
2011-11-29 18:22:53 +00:00
|
|
|
enum pnv_phb_model model;
|
2013-06-20 05:21:06 +00:00
|
|
|
u64 hub_id;
|
2011-09-19 17:45:05 +00:00
|
|
|
u64 opal_id;
|
2014-04-24 08:00:09 +00:00
|
|
|
int flags;
|
2011-09-19 17:45:05 +00:00
|
|
|
void __iomem *regs;
|
2012-08-20 03:49:18 +00:00
|
|
|
int initialized;
|
2011-09-19 17:45:05 +00:00
|
|
|
spinlock_t lock;
|
|
|
|
|
2013-06-20 05:21:06 +00:00
|
|
|
#ifdef CONFIG_EEH
|
|
|
|
struct pnv_eeh_ops *eeh_ops;
|
|
|
|
#endif
|
|
|
|
|
2013-06-20 10:13:25 +00:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
2014-04-24 08:00:18 +00:00
|
|
|
int has_dbgfs;
|
2013-06-20 10:13:25 +00:00
|
|
|
struct dentry *dbgfs;
|
|
|
|
#endif
|
|
|
|
|
2011-09-19 17:45:06 +00:00
|
|
|
#ifdef CONFIG_PCI_MSI
|
|
|
|
unsigned int msi_base;
|
|
|
|
unsigned int msi32_support;
|
2013-03-05 21:12:37 +00:00
|
|
|
struct msi_bitmap msi_bmp;
|
2011-09-19 17:45:06 +00:00
|
|
|
#endif
|
|
|
|
int (*msi_setup)(struct pnv_phb *phb, struct pci_dev *dev,
|
2013-04-25 19:20:59 +00:00
|
|
|
unsigned int hwirq, unsigned int virq,
|
|
|
|
unsigned int is_64, struct msi_msg *msg);
|
2011-09-19 17:45:05 +00:00
|
|
|
void (*dma_dev_setup)(struct pnv_phb *phb, struct pci_dev *pdev);
|
2014-02-11 00:32:38 +00:00
|
|
|
int (*dma_set_mask)(struct pnv_phb *phb, struct pci_dev *pdev,
|
|
|
|
u64 dma_mask);
|
2011-09-19 17:45:05 +00:00
|
|
|
void (*fixup_phb)(struct pci_controller *hose);
|
|
|
|
u32 (*bdfn_to_pe)(struct pnv_phb *phb, struct pci_bus *bus, u32 devfn);
|
2013-05-10 06:59:18 +00:00
|
|
|
void (*shutdown)(struct pnv_phb *phb);
|
2011-09-19 17:45:05 +00:00
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
struct iommu_table iommu_table;
|
|
|
|
} p5ioc2;
|
2011-11-15 17:29:08 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
/* Global bridge info */
|
|
|
|
unsigned int total_pe;
|
2013-11-04 08:32:47 +00:00
|
|
|
unsigned int reserved_pe;
|
2011-11-15 17:29:08 +00:00
|
|
|
unsigned int m32_size;
|
|
|
|
unsigned int m32_segsize;
|
|
|
|
unsigned int m32_pci_base;
|
|
|
|
unsigned int io_size;
|
|
|
|
unsigned int io_segsize;
|
|
|
|
unsigned int io_pci_base;
|
|
|
|
|
|
|
|
/* PE allocation bitmap */
|
|
|
|
unsigned long *pe_alloc;
|
|
|
|
|
|
|
|
/* M32 & IO segment maps */
|
|
|
|
unsigned int *m32_segmap;
|
|
|
|
unsigned int *io_segmap;
|
|
|
|
struct pnv_ioda_pe *pe_array;
|
|
|
|
|
2013-04-25 19:20:59 +00:00
|
|
|
/* IRQ chip */
|
|
|
|
int irq_chip_init;
|
|
|
|
struct irq_chip irq_chip;
|
|
|
|
|
2012-08-20 03:49:15 +00:00
|
|
|
/* Sorted list of used PE's based
|
|
|
|
* on the sequence of creation
|
|
|
|
*/
|
|
|
|
struct list_head pe_list;
|
|
|
|
|
2011-11-15 17:29:08 +00:00
|
|
|
/* Reverse map of PEs, will have to extend if
|
|
|
|
* we are to support more than 256 PEs, indexed
|
|
|
|
* bus { bus, devfn }
|
|
|
|
*/
|
|
|
|
unsigned char pe_rmap[0x10000];
|
|
|
|
|
|
|
|
/* 32-bit TCE tables allocation */
|
|
|
|
unsigned long tce32_count;
|
|
|
|
|
|
|
|
/* Total "weight" for the sake of DMA resources
|
|
|
|
* allocation
|
|
|
|
*/
|
|
|
|
unsigned int dma_weight;
|
|
|
|
unsigned int dma_pe_count;
|
|
|
|
|
|
|
|
/* Sorted list of used PE's, sorted at
|
|
|
|
* boot for resource allocation purposes
|
|
|
|
*/
|
2012-08-20 03:49:15 +00:00
|
|
|
struct list_head pe_dma_list;
|
2011-11-15 17:29:08 +00:00
|
|
|
} ioda;
|
2011-09-19 17:45:05 +00:00
|
|
|
};
|
2011-11-29 18:22:53 +00:00
|
|
|
|
2013-12-20 19:06:01 +00:00
|
|
|
/* PHB and hub status structure */
|
2011-11-29 18:22:53 +00:00
|
|
|
union {
|
|
|
|
unsigned char blob[PNV_PCI_DIAG_BUF_SIZE];
|
|
|
|
struct OpalIoP7IOCPhbErrorData p7ioc;
|
2013-11-22 08:28:45 +00:00
|
|
|
struct OpalIoPhb3ErrorData phb3;
|
2013-12-20 19:06:01 +00:00
|
|
|
struct OpalIoP7IOCErrorData hub_diag;
|
2011-11-29 18:22:53 +00:00
|
|
|
} diag;
|
2013-12-20 19:06:01 +00:00
|
|
|
|
2011-09-19 17:45:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct pci_ops pnv_pci_ops;
|
2013-06-20 05:21:06 +00:00
|
|
|
#ifdef CONFIG_EEH
|
|
|
|
extern struct pnv_eeh_ops ioda_eeh_ops;
|
|
|
|
#endif
|
2011-09-19 17:45:05 +00:00
|
|
|
|
2013-11-22 08:28:45 +00:00
|
|
|
void pnv_pci_dump_phb_diag_data(struct pci_controller *hose,
|
|
|
|
unsigned char *log_buff);
|
2013-06-27 05:46:48 +00:00
|
|
|
int pnv_pci_cfg_read(struct device_node *dn,
|
|
|
|
int where, int size, u32 *val);
|
|
|
|
int pnv_pci_cfg_write(struct device_node *dn,
|
|
|
|
int where, int size, u32 val);
|
2011-09-19 17:45:05 +00:00
|
|
|
extern void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
|
|
|
|
void *tce_mem, u64 tce_size,
|
|
|
|
u64 dma_offset);
|
|
|
|
extern void pnv_pci_init_p5ioc2_hub(struct device_node *np);
|
2011-11-15 17:29:08 +00:00
|
|
|
extern void pnv_pci_init_ioda_hub(struct device_node *np);
|
2013-04-25 19:20:57 +00:00
|
|
|
extern void pnv_pci_init_ioda2_phb(struct device_node *np);
|
2013-04-25 19:21:00 +00:00
|
|
|
extern void pnv_pci_ioda_tce_invalidate(struct iommu_table *tbl,
|
2013-10-11 07:23:53 +00:00
|
|
|
__be64 *startp, __be64 *endp, bool rm);
|
2014-04-24 08:00:24 +00:00
|
|
|
extern void pnv_pci_reset_secondary_bus(struct pci_dev *dev);
|
2013-05-10 06:59:18 +00:00
|
|
|
|
2011-09-19 17:45:05 +00:00
|
|
|
#endif /* __POWERNV_PCI_H */
|