David S. Miller | 9fd8b64 | 2007-03-08 21:55:49 -0800 | [diff] [blame] | 1 | /* pci_impl.h: Helper definitions for PCI controller support. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
David S. Miller | 9fd8b64 | 2007-03-08 21:55:49 -0800 | [diff] [blame] | 3 | * Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef PCI_IMPL_H |
| 7 | #define PCI_IMPL_H |
| 8 | |
| 9 | #include <linux/types.h> |
| 10 | #include <linux/spinlock.h> |
David S. Miller | c57c2ff | 2007-05-08 00:43:56 -0700 | [diff] [blame^] | 11 | #include <linux/pci.h> |
| 12 | #include <linux/msi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <asm/io.h> |
David S. Miller | de8d28b | 2006-06-22 16:18:54 -0700 | [diff] [blame] | 14 | #include <asm/prom.h> |
David S. Miller | c57c2ff | 2007-05-08 00:43:56 -0700 | [diff] [blame^] | 15 | #include <asm/iommu.h> |
| 16 | |
| 17 | /* The abstraction used here is that there are PCI controllers, |
| 18 | * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules |
| 19 | * underneath. Each PCI bus module uses an IOMMU (shared by both |
| 20 | * PBMs of a controller, or per-PBM), and if a streaming buffer |
| 21 | * is present, each PCI bus module has it's own. (ie. the IOMMU |
| 22 | * might be shared between PBMs, the STC is never shared) |
| 23 | * Furthermore, each PCI bus module controls it's own autonomous |
| 24 | * PCI bus. |
| 25 | */ |
| 26 | |
| 27 | #define PCI_STC_FLUSHFLAG_INIT(STC) \ |
| 28 | (*((STC)->strbuf_flushflag) = 0UL) |
| 29 | #define PCI_STC_FLUSHFLAG_SET(STC) \ |
| 30 | (*((STC)->strbuf_flushflag) != 0UL) |
| 31 | |
| 32 | struct pci_controller_info; |
| 33 | |
| 34 | struct pci_pbm_info { |
| 35 | struct pci_pbm_info *next; |
| 36 | int index; |
| 37 | |
| 38 | /* PCI controller we sit under. */ |
| 39 | struct pci_controller_info *parent; |
| 40 | |
| 41 | /* Physical address base of controller registers. */ |
| 42 | unsigned long controller_regs; |
| 43 | |
| 44 | /* Physical address base of PBM registers. */ |
| 45 | unsigned long pbm_regs; |
| 46 | |
| 47 | /* Physical address of DMA sync register, if any. */ |
| 48 | unsigned long sync_reg; |
| 49 | |
| 50 | /* Opaque 32-bit system bus Port ID. */ |
| 51 | u32 portid; |
| 52 | |
| 53 | /* Opaque 32-bit handle used for hypervisor calls. */ |
| 54 | u32 devhandle; |
| 55 | |
| 56 | /* Chipset version information. */ |
| 57 | int chip_type; |
| 58 | #define PBM_CHIP_TYPE_SABRE 1 |
| 59 | #define PBM_CHIP_TYPE_PSYCHO 2 |
| 60 | #define PBM_CHIP_TYPE_SCHIZO 3 |
| 61 | #define PBM_CHIP_TYPE_SCHIZO_PLUS 4 |
| 62 | #define PBM_CHIP_TYPE_TOMATILLO 5 |
| 63 | int chip_version; |
| 64 | int chip_revision; |
| 65 | |
| 66 | /* Name used for top-level resources. */ |
| 67 | char *name; |
| 68 | |
| 69 | /* OBP specific information. */ |
| 70 | struct device_node *prom_node; |
| 71 | u64 ino_bitmap; |
| 72 | |
| 73 | /* PBM I/O and Memory space resources. */ |
| 74 | struct resource io_space; |
| 75 | struct resource mem_space; |
| 76 | |
| 77 | /* Base of PCI Config space, can be per-PBM or shared. */ |
| 78 | unsigned long config_space; |
| 79 | |
| 80 | /* State of 66MHz capabilities on this PBM. */ |
| 81 | int is_66mhz_capable; |
| 82 | int all_devs_66mhz; |
| 83 | |
| 84 | #ifdef CONFIG_PCI_MSI |
| 85 | /* MSI info. */ |
| 86 | u32 msiq_num; |
| 87 | u32 msiq_ent_count; |
| 88 | u32 msiq_first; |
| 89 | u32 msiq_first_devino; |
| 90 | u32 msi_num; |
| 91 | u32 msi_first; |
| 92 | u32 msi_data_mask; |
| 93 | u32 msix_data_width; |
| 94 | u64 msi32_start; |
| 95 | u64 msi64_start; |
| 96 | u32 msi32_len; |
| 97 | u32 msi64_len; |
| 98 | void *msi_queues; |
| 99 | unsigned long *msi_bitmap; |
| 100 | int (*setup_msi_irq)(unsigned int *virt_irq_p, struct pci_dev *pdev, |
| 101 | struct msi_desc *entry); |
| 102 | void (*teardown_msi_irq)(unsigned int virt_irq, struct pci_dev *pdev); |
| 103 | #endif /* !(CONFIG_PCI_MSI) */ |
| 104 | |
| 105 | /* This PBM's streaming buffer. */ |
| 106 | struct strbuf stc; |
| 107 | |
| 108 | /* IOMMU state, potentially shared by both PBM segments. */ |
| 109 | struct iommu *iommu; |
| 110 | |
| 111 | /* Now things for the actual PCI bus probes. */ |
| 112 | unsigned int pci_first_busno; |
| 113 | unsigned int pci_last_busno; |
| 114 | struct pci_bus *pci_bus; |
| 115 | void (*scan_bus)(struct pci_pbm_info *); |
| 116 | struct pci_ops *pci_ops; |
| 117 | }; |
| 118 | |
| 119 | struct pci_controller_info { |
| 120 | /* The PCI bus modules controlled by us. */ |
| 121 | struct pci_pbm_info pbm_A; |
| 122 | struct pci_pbm_info pbm_B; |
| 123 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
David S. Miller | 34768bc | 2007-05-07 23:06:27 -0700 | [diff] [blame] | 125 | extern struct pci_pbm_info *pci_pbm_root; |
David S. Miller | 1e8a8cc | 2007-02-28 23:38:38 -0800 | [diff] [blame] | 126 | extern unsigned long pci_memspace_mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
David S. Miller | 6c108f1 | 2007-05-07 23:49:01 -0700 | [diff] [blame] | 128 | extern int pci_num_pbms; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
| 130 | /* PCI bus scanning and fixup support. */ |
David S. Miller | c57c2ff | 2007-05-08 00:43:56 -0700 | [diff] [blame^] | 131 | extern void pci_iommu_table_init(struct iommu *iommu, int tsbsize, |
| 132 | u32 dma_offset, u32 dma_addr_mask); |
David S. Miller | cfa0652 | 2007-05-07 21:51:41 -0700 | [diff] [blame] | 133 | extern void pci_get_pbm_props(struct pci_pbm_info *pbm); |
David S. Miller | a2fb23a | 2007-02-28 23:35:04 -0800 | [diff] [blame] | 134 | extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm); |
David S. Miller | 9fd8b64 | 2007-03-08 21:55:49 -0800 | [diff] [blame] | 135 | extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
David S. Miller | 97b3cf0 | 2007-03-11 16:42:53 -0700 | [diff] [blame] | 137 | extern int pci_host_bridge_read_pci_cfg(struct pci_bus *bus_dev, |
| 138 | unsigned int devfn, |
| 139 | int where, int size, |
| 140 | u32 *value); |
| 141 | extern int pci_host_bridge_write_pci_cfg(struct pci_bus *bus_dev, |
| 142 | unsigned int devfn, |
| 143 | int where, int size, |
| 144 | u32 value); |
| 145 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | /* Error reporting support. */ |
David S. Miller | 6c108f1 | 2007-05-07 23:49:01 -0700 | [diff] [blame] | 147 | extern void pci_scan_for_target_abort(struct pci_pbm_info *, struct pci_bus *); |
| 148 | extern void pci_scan_for_master_abort(struct pci_pbm_info *, struct pci_bus *); |
| 149 | extern void pci_scan_for_parity_error(struct pci_pbm_info *, struct pci_bus *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | |
| 151 | /* Configuration space access. */ |
| 152 | extern void pci_config_read8(u8 *addr, u8 *ret); |
| 153 | extern void pci_config_read16(u16 *addr, u16 *ret); |
| 154 | extern void pci_config_read32(u32 *addr, u32 *ret); |
| 155 | extern void pci_config_write8(u8 *addr, u8 val); |
| 156 | extern void pci_config_write16(u16 *addr, u16 val); |
| 157 | extern void pci_config_write32(u32 *addr, u32 val); |
| 158 | |
| 159 | #endif /* !(PCI_IMPL_H) */ |