Paul Mackerras | 047ea78 | 2005-11-19 20:17:32 +1100 | [diff] [blame] | 1 | #ifndef _ASM_POWERPC_PCI_BRIDGE_H |
| 2 | #define _ASM_POWERPC_PCI_BRIDGE_H |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 3 | #ifdef __KERNEL__ |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 4 | /* |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version |
| 8 | * 2 of the License, or (at your option) any later version. |
| 9 | */ |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 10 | #include <linux/pci.h> |
Kumar Gala | a4c9e32 | 2007-06-27 13:09:43 -0500 | [diff] [blame] | 11 | #include <linux/list.h> |
| 12 | #include <linux/ioport.h> |
Rob Herring | f4ffd5e | 2011-06-29 11:46:54 -0500 | [diff] [blame] | 13 | #include <asm-generic/pci-bridge.h> |
Kumar Gala | a4c9e32 | 2007-06-27 13:09:43 -0500 | [diff] [blame] | 14 | |
Stephen Rothwell | 44ef339 | 2007-12-10 14:33:21 +1100 | [diff] [blame] | 15 | struct device_node; |
| 16 | |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 17 | /* |
Daniel Axtens | e02def5 | 2015-03-31 16:00:42 +1100 | [diff] [blame] | 18 | * PCI controller operations |
| 19 | */ |
| 20 | struct pci_controller_ops { |
| 21 | void (*dma_dev_setup)(struct pci_dev *dev); |
Daniel Axtens | b122c95 | 2015-03-31 16:00:43 +1100 | [diff] [blame] | 22 | void (*dma_bus_setup)(struct pci_bus *bus); |
Daniel Axtens | ff9df8c | 2015-03-31 16:00:44 +1100 | [diff] [blame] | 23 | |
| 24 | int (*probe_mode)(struct pci_bus *); |
Daniel Axtens | b31e79f | 2015-03-31 16:00:45 +1100 | [diff] [blame] | 25 | |
| 26 | /* Called when pci_enable_device() is called. Returns true to |
| 27 | * allow assignment/enabling of the device. */ |
| 28 | bool (*enable_device_hook)(struct pci_dev *); |
Daniel Axtens | 542070b | 2015-03-31 16:00:46 +1100 | [diff] [blame] | 29 | |
Michael Neuling | abeeed6 | 2015-05-27 16:07:00 +1000 | [diff] [blame] | 30 | void (*disable_device)(struct pci_dev *); |
| 31 | |
Michael Neuling | 10e7963 | 2015-05-27 16:06:57 +1000 | [diff] [blame] | 32 | void (*release_device)(struct pci_dev *); |
| 33 | |
Daniel Axtens | 542070b | 2015-03-31 16:00:46 +1100 | [diff] [blame] | 34 | /* Called during PCI resource reassignment */ |
| 35 | resource_size_t (*window_alignment)(struct pci_bus *, unsigned long type); |
Daniel Axtens | cd16c7b | 2015-03-31 16:00:47 +1100 | [diff] [blame] | 36 | void (*reset_secondary_bus)(struct pci_dev *dev); |
Daniel Axtens | e059b10 | 2015-04-14 14:27:54 +1000 | [diff] [blame] | 37 | |
| 38 | #ifdef CONFIG_PCI_MSI |
| 39 | int (*setup_msi_irqs)(struct pci_dev *dev, |
| 40 | int nvec, int type); |
| 41 | void (*teardown_msi_irqs)(struct pci_dev *dev); |
| 42 | #endif |
Daniel Axtens | 3405c25 | 2015-04-28 15:12:06 +1000 | [diff] [blame] | 43 | |
| 44 | int (*dma_set_mask)(struct pci_dev *dev, u64 dma_mask); |
Andrew Donnellan | 53522982 | 2015-08-07 13:45:54 +1000 | [diff] [blame] | 45 | u64 (*dma_get_required_mask)(struct pci_dev *dev); |
Michael Neuling | 7a8e6bb | 2015-05-27 16:06:59 +1000 | [diff] [blame] | 46 | |
| 47 | void (*shutdown)(struct pci_controller *); |
Daniel Axtens | e02def5 | 2015-03-31 16:00:42 +1100 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | /* |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 51 | * Structure of a PCI controller (host bridge) |
| 52 | */ |
| 53 | struct pci_controller { |
| 54 | struct pci_bus *bus; |
Kumar Gala | a4c9e32 | 2007-06-27 13:09:43 -0500 | [diff] [blame] | 55 | char is_dynamic; |
Stephen Rothwell | 7211991 | 2007-12-11 11:00:13 +1100 | [diff] [blame] | 56 | #ifdef CONFIG_PPC64 |
| 57 | int node; |
| 58 | #endif |
Stephen Rothwell | 44ef339 | 2007-12-10 14:33:21 +1100 | [diff] [blame] | 59 | struct device_node *dn; |
Kumar Gala | a4c9e32 | 2007-06-27 13:09:43 -0500 | [diff] [blame] | 60 | struct list_head list_node; |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 61 | struct device *parent; |
| 62 | |
| 63 | int first_busno; |
| 64 | int last_busno; |
| 65 | int self_busno; |
Yinghai Lu | be8e60d | 2012-05-17 18:51:12 -0700 | [diff] [blame] | 66 | struct resource busn; |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 67 | |
| 68 | void __iomem *io_base_virt; |
Stephen Rothwell | 7211991 | 2007-12-11 11:00:13 +1100 | [diff] [blame] | 69 | #ifdef CONFIG_PPC64 |
| 70 | void *io_base_alloc; |
| 71 | #endif |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 72 | resource_size_t io_base_phys; |
Benjamin Herrenschmidt | 13dccb9 | 2007-12-11 14:48:18 +1100 | [diff] [blame] | 73 | resource_size_t pci_io_size; |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 74 | |
Benjamin Herrenschmidt | e9f82cb | 2008-10-14 11:55:31 +1100 | [diff] [blame] | 75 | /* Some machines have a special region to forward the ISA |
| 76 | * "memory" cycles such as VGA memory regions. Left to 0 |
| 77 | * if unsupported |
| 78 | */ |
| 79 | resource_size_t isa_mem_phys; |
| 80 | resource_size_t isa_mem_size; |
| 81 | |
Daniel Axtens | e02def5 | 2015-03-31 16:00:42 +1100 | [diff] [blame] | 82 | struct pci_controller_ops controller_ops; |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 83 | struct pci_ops *ops; |
Stephen Rothwell | 70fbb93 | 2007-12-21 15:23:48 +1100 | [diff] [blame] | 84 | unsigned int __iomem *cfg_addr; |
| 85 | void __iomem *cfg_data; |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * Used for variants of PCI indirect handling and possible quirks: |
| 89 | * SET_CFG_TYPE - used on 4xx or any PHB that does explicit type0/1 |
| 90 | * EXT_REG - provides access to PCI-e extended registers |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 91 | * SURPRESS_PRIMARY_BUS - we suppress the setting of PCI_PRIMARY_BUS |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 92 | * on Freescale PCI-e controllers since they used the PCI_PRIMARY_BUS |
| 93 | * to determine which bus number to match on when generating type0 |
| 94 | * config cycles |
Kumar Gala | 62c66c8 | 2007-07-11 13:22:41 -0500 | [diff] [blame] | 95 | * NO_PCIE_LINK - the Freescale PCI-e controllers have issues with |
| 96 | * hanging if we don't have link and try to do config cycles to |
| 97 | * anything but the PHB. Only allow talking to the PHB if this is |
| 98 | * set. |
Kumar Gala | 2e56ff2 | 2007-07-19 16:07:35 -0500 | [diff] [blame] | 99 | * BIG_ENDIAN - cfg_addr is a big endian register |
Josh Boyer | 5ce4b59 | 2008-06-17 19:01:38 -0400 | [diff] [blame] | 100 | * BROKEN_MRM - the 440EPx/GRx chips have an errata that causes hangs on |
| 101 | * the PLB4. Effectively disable MRM commands by setting this. |
Kumar Gala | 34642bb | 2013-03-13 14:07:15 -0500 | [diff] [blame] | 102 | * FSL_CFG_REG_LINK - Freescale controller version in which the PCIe |
| 103 | * link status is in a RC PCIe cfg register (vs being a SoC register) |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 104 | */ |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 105 | #define PPC_INDIRECT_TYPE_SET_CFG_TYPE 0x00000001 |
| 106 | #define PPC_INDIRECT_TYPE_EXT_REG 0x00000002 |
| 107 | #define PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS 0x00000004 |
| 108 | #define PPC_INDIRECT_TYPE_NO_PCIE_LINK 0x00000008 |
| 109 | #define PPC_INDIRECT_TYPE_BIG_ENDIAN 0x00000010 |
Josh Boyer | 5ce4b59 | 2008-06-17 19:01:38 -0400 | [diff] [blame] | 110 | #define PPC_INDIRECT_TYPE_BROKEN_MRM 0x00000020 |
Kumar Gala | 34642bb | 2013-03-13 14:07:15 -0500 | [diff] [blame] | 111 | #define PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK 0x00000040 |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 112 | u32 indirect_type; |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 113 | /* Currently, we limit ourselves to 1 IO range and 3 mem |
| 114 | * ranges since the common pci_bus structure can't handle more |
| 115 | */ |
| 116 | struct resource io_resource; |
| 117 | struct resource mem_resources[3]; |
Benjamin Herrenschmidt | 3fd47f0 | 2013-05-06 13:40:40 +1000 | [diff] [blame] | 118 | resource_size_t mem_offset[3]; |
Kumar Gala | 5516b54 | 2007-06-27 01:17:57 -0500 | [diff] [blame] | 119 | int global_number; /* PCI domain number */ |
Becky Bruce | 89d9334 | 2009-04-20 11:26:48 -0500 | [diff] [blame] | 120 | |
| 121 | resource_size_t dma_window_base_cur; |
| 122 | resource_size_t dma_window_size; |
| 123 | |
Stephen Rothwell | 7211991 | 2007-12-11 11:00:13 +1100 | [diff] [blame] | 124 | #ifdef CONFIG_PPC64 |
| 125 | unsigned long buid; |
Gavin Shan | cca87d3 | 2015-03-17 16:15:02 +1100 | [diff] [blame] | 126 | struct pci_dn *pci_data; |
Kumar Gala | 34642bb | 2013-03-13 14:07:15 -0500 | [diff] [blame] | 127 | #endif /* CONFIG_PPC64 */ |
Stephen Rothwell | 7211991 | 2007-12-11 11:00:13 +1100 | [diff] [blame] | 128 | |
| 129 | void *private_data; |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 130 | }; |
| 131 | |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 132 | /* These are used for config access before all the PCI probing |
| 133 | has been done. */ |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 134 | extern int early_read_config_byte(struct pci_controller *hose, int bus, |
| 135 | int dev_fn, int where, u8 *val); |
| 136 | extern int early_read_config_word(struct pci_controller *hose, int bus, |
| 137 | int dev_fn, int where, u16 *val); |
| 138 | extern int early_read_config_dword(struct pci_controller *hose, int bus, |
| 139 | int dev_fn, int where, u32 *val); |
| 140 | extern int early_write_config_byte(struct pci_controller *hose, int bus, |
| 141 | int dev_fn, int where, u8 val); |
| 142 | extern int early_write_config_word(struct pci_controller *hose, int bus, |
| 143 | int dev_fn, int where, u16 val); |
| 144 | extern int early_write_config_dword(struct pci_controller *hose, int bus, |
| 145 | int dev_fn, int where, u32 val); |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 146 | |
Kumar Gala | 38805e5 | 2007-07-10 23:37:45 -0500 | [diff] [blame] | 147 | extern int early_find_capability(struct pci_controller *hose, int bus, |
| 148 | int dev_fn, int cap); |
| 149 | |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 150 | extern void setup_indirect_pci(struct pci_controller* hose, |
Valentine Barshak | d94bad8 | 2007-10-08 22:51:24 +1000 | [diff] [blame] | 151 | resource_size_t cfg_addr, |
| 152 | resource_size_t cfg_data, u32 flags); |
Kumar Gala | 89c2dd6 | 2009-08-25 16:20:45 +0000 | [diff] [blame] | 153 | |
Rojhalat Ibrahim | 50d8f87 | 2013-04-08 10:15:28 +0200 | [diff] [blame] | 154 | extern int indirect_read_config(struct pci_bus *bus, unsigned int devfn, |
| 155 | int offset, int len, u32 *val); |
| 156 | |
Kim Phillips | 6d5f6a0 | 2015-01-22 19:05:06 -0600 | [diff] [blame] | 157 | extern int __indirect_read_config(struct pci_controller *hose, |
| 158 | unsigned char bus_number, unsigned int devfn, |
| 159 | int offset, int len, u32 *val); |
| 160 | |
Rojhalat Ibrahim | 50d8f87 | 2013-04-08 10:15:28 +0200 | [diff] [blame] | 161 | extern int indirect_write_config(struct pci_bus *bus, unsigned int devfn, |
| 162 | int offset, int len, u32 val); |
| 163 | |
Kumar Gala | 89c2dd6 | 2009-08-25 16:20:45 +0000 | [diff] [blame] | 164 | static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus) |
| 165 | { |
| 166 | return bus->sysdata; |
| 167 | } |
| 168 | |
Benjamin Herrenschmidt | 98d9f30c8 | 2011-04-11 11:37:07 +1000 | [diff] [blame] | 169 | #ifndef CONFIG_PPC64 |
| 170 | |
| 171 | extern int pci_device_from_OF_node(struct device_node *node, |
| 172 | u8 *bus, u8 *devfn); |
| 173 | extern void pci_create_OF_bus_map(void); |
| 174 | |
Kumar Gala | 89c2dd6 | 2009-08-25 16:20:45 +0000 | [diff] [blame] | 175 | static inline int isa_vaddr_is_ioport(void __iomem *address) |
| 176 | { |
| 177 | /* No specific ISA handling on ppc32 at this stage, it |
| 178 | * all goes through PCI |
| 179 | */ |
| 180 | return 0; |
| 181 | } |
| 182 | |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 183 | #else /* CONFIG_PPC64 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | |
| 185 | /* |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 186 | * PCI stuff, for nodes representing PCI devices, pointed to |
| 187 | * by device_node->data. |
| 188 | */ |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 189 | struct iommu_table; |
| 190 | |
| 191 | struct pci_dn { |
Gavin Shan | cca87d3 | 2015-03-17 16:15:02 +1100 | [diff] [blame] | 192 | int flags; |
Gavin Shan | a8b2f82 | 2015-03-25 16:23:52 +0800 | [diff] [blame] | 193 | #define PCI_DN_FLAG_IOV_VF 0x01 |
Gavin Shan | cca87d3 | 2015-03-17 16:15:02 +1100 | [diff] [blame] | 194 | |
Linas Vepstas | 7684b40 | 2005-11-03 18:55:19 -0600 | [diff] [blame] | 195 | int busno; /* pci bus number */ |
Linas Vepstas | 7684b40 | 2005-11-03 18:55:19 -0600 | [diff] [blame] | 196 | int devfn; /* pci device and function number */ |
Gavin Shan | c035ff1 | 2015-03-17 16:15:04 +1100 | [diff] [blame] | 197 | int vendor_id; /* Vendor ID */ |
| 198 | int device_id; /* Device ID */ |
| 199 | int class_code; /* Device class code */ |
Benjamin Herrenschmidt | b5166cc | 2005-11-15 16:05:33 +1100 | [diff] [blame] | 200 | |
Gavin Shan | cca87d3 | 2015-03-17 16:15:02 +1100 | [diff] [blame] | 201 | struct pci_dn *parent; |
Linas Vepstas | c2e221e | 2007-05-23 04:18:04 +1000 | [diff] [blame] | 202 | struct pci_controller *phb; /* for pci devices */ |
Alexey Kardashevskiy | b348aa6 | 2015-06-05 16:35:08 +1000 | [diff] [blame] | 203 | struct iommu_table_group *table_group; /* for phb's or bridges */ |
Linas Vepstas | c2e221e | 2007-05-23 04:18:04 +1000 | [diff] [blame] | 204 | struct device_node *node; /* back-pointer to the device_node */ |
| 205 | |
| 206 | int pci_ext_config_space; /* for pci devices */ |
| 207 | |
Alistair Popple | 94973b2 | 2015-12-17 13:43:11 +1100 | [diff] [blame] | 208 | struct pci_dev *pcidev; /* back-pointer to the pci device */ |
Benjamin Herrenschmidt | 184cd4a | 2011-11-15 17:29:08 +0000 | [diff] [blame] | 209 | #ifdef CONFIG_EEH |
Gavin Shan | 2a0352f | 2012-03-20 21:30:27 +0000 | [diff] [blame] | 210 | struct eeh_dev *edev; /* eeh device */ |
Linas Vepstas | c2e221e | 2007-05-23 04:18:04 +1000 | [diff] [blame] | 211 | #endif |
Benjamin Herrenschmidt | 184cd4a | 2011-11-15 17:29:08 +0000 | [diff] [blame] | 212 | #define IODA_INVALID_PE (-1) |
| 213 | #ifdef CONFIG_PPC_POWERNV |
| 214 | int pe_number; |
Wei Yang | 6e628c7 | 2015-03-25 16:23:55 +0800 | [diff] [blame] | 215 | #ifdef CONFIG_PCI_IOV |
| 216 | u16 vfs_expanded; /* number of VFs IOV BAR expanded */ |
Wei Yang | 781a868 | 2015-03-25 16:23:57 +0800 | [diff] [blame] | 217 | u16 num_vfs; /* number of VFs enabled*/ |
| 218 | int offset; /* PE# for the first VF PE */ |
Wei Yang | 5b88ec2 | 2015-03-25 16:23:58 +0800 | [diff] [blame] | 219 | #define M64_PER_IOV 4 |
| 220 | int m64_per_iov; |
Wei Yang | 781a868 | 2015-03-25 16:23:57 +0800 | [diff] [blame] | 221 | #define IODA_INVALID_M64 (-1) |
Wei Yang | 02639b0 | 2015-03-25 16:23:59 +0800 | [diff] [blame] | 222 | int m64_wins[PCI_SRIOV_NUM_BARS][M64_PER_IOV]; |
Wei Yang | 6e628c7 | 2015-03-25 16:23:55 +0800 | [diff] [blame] | 223 | #endif /* CONFIG_PCI_IOV */ |
Benjamin Herrenschmidt | 184cd4a | 2011-11-15 17:29:08 +0000 | [diff] [blame] | 224 | #endif |
Gavin Shan | cca87d3 | 2015-03-17 16:15:02 +1100 | [diff] [blame] | 225 | struct list_head child_list; |
| 226 | struct list_head list; |
Paul Mackerras | 1635317 | 2005-09-06 13:17:54 +1000 | [diff] [blame] | 227 | }; |
| 228 | |
| 229 | /* Get the pointer to a device_node's pci_dn */ |
| 230 | #define PCI_DN(dn) ((struct pci_dn *) (dn)->data) |
| 231 | |
Gavin Shan | cca87d3 | 2015-03-17 16:15:02 +1100 | [diff] [blame] | 232 | extern struct pci_dn *pci_get_pdn_by_devfn(struct pci_bus *bus, |
| 233 | int devfn); |
Benjamin Herrenschmidt | b72c1f6 | 2013-05-21 22:58:21 +0000 | [diff] [blame] | 234 | extern struct pci_dn *pci_get_pdn(struct pci_dev *pdev); |
Gavin Shan | a8b2f82 | 2015-03-25 16:23:52 +0800 | [diff] [blame] | 235 | extern struct pci_dn *add_dev_pci_data(struct pci_dev *pdev); |
| 236 | extern void remove_dev_pci_data(struct pci_dev *pdev); |
Gavin Shan | cca87d3 | 2015-03-17 16:15:02 +1100 | [diff] [blame] | 237 | extern void *update_dn_pci_info(struct device_node *dn, void *data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
Paul Mackerras | 40ef8cb | 2005-10-10 22:50:37 +1000 | [diff] [blame] | 239 | static inline int pci_device_from_OF_node(struct device_node *np, |
| 240 | u8 *bus, u8 *devfn) |
| 241 | { |
| 242 | if (!PCI_DN(np)) |
| 243 | return -ENODEV; |
| 244 | *bus = PCI_DN(np)->busno; |
| 245 | *devfn = PCI_DN(np)->devfn; |
| 246 | return 0; |
| 247 | } |
| 248 | |
Gavin Shan | 2a0352f | 2012-03-20 21:30:27 +0000 | [diff] [blame] | 249 | #if defined(CONFIG_EEH) |
Gavin Shan | e8e9b34 | 2015-03-17 16:15:05 +1100 | [diff] [blame] | 250 | static inline struct eeh_dev *pdn_to_eeh_dev(struct pci_dn *pdn) |
| 251 | { |
| 252 | return pdn ? pdn->edev : NULL; |
| 253 | } |
Gavin Shan | f8f7d63 | 2012-09-07 22:44:22 +0000 | [diff] [blame] | 254 | #else |
Gavin Shan | e8e9b34 | 2015-03-17 16:15:05 +1100 | [diff] [blame] | 255 | #define pdn_to_eeh_dev(x) (NULL) |
Gavin Shan | 2a0352f | 2012-03-20 21:30:27 +0000 | [diff] [blame] | 256 | #endif |
| 257 | |
Linas Vepstas | 2bf6a8f | 2005-11-03 18:52:16 -0600 | [diff] [blame] | 258 | /** Find the bus corresponding to the indicated device node */ |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 259 | extern struct pci_bus *pcibios_find_pci_bus(struct device_node *dn); |
Linas Vepstas | 2bf6a8f | 2005-11-03 18:52:16 -0600 | [diff] [blame] | 260 | |
Linas Vepstas | 2bf6a8f | 2005-11-03 18:52:16 -0600 | [diff] [blame] | 261 | /** Remove all of the PCI devices under this bus */ |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 262 | extern void pcibios_remove_pci_devices(struct pci_bus *bus); |
Linas Vepstas | 2bf6a8f | 2005-11-03 18:52:16 -0600 | [diff] [blame] | 263 | |
| 264 | /** Discover new pci devices under this bus, and add them */ |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 265 | extern void pcibios_add_pci_devices(struct pci_bus *bus); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | |
Benjamin Herrenschmidt | b5166cc | 2005-11-15 16:05:33 +1100 | [diff] [blame] | 267 | |
Benjamin Herrenschmidt | 3d5134e | 2007-06-04 15:15:36 +1000 | [diff] [blame] | 268 | extern void isa_bridge_find_early(struct pci_controller *hose); |
| 269 | |
Benjamin Herrenschmidt | 6dfbde2 | 2007-07-26 14:07:13 +1000 | [diff] [blame] | 270 | static inline int isa_vaddr_is_ioport(void __iomem *address) |
| 271 | { |
| 272 | /* Check if address hits the reserved legacy IO range */ |
| 273 | unsigned long ea = (unsigned long)address; |
| 274 | return ea >= ISA_IO_BASE && ea < ISA_IO_END; |
| 275 | } |
| 276 | |
Benjamin Herrenschmidt | 3d5134e | 2007-06-04 15:15:36 +1000 | [diff] [blame] | 277 | extern int pcibios_unmap_io_space(struct pci_bus *bus); |
| 278 | extern int pcibios_map_io_space(struct pci_bus *bus); |
| 279 | |
Anton Blanchard | 357518f | 2006-06-10 20:53:06 +1000 | [diff] [blame] | 280 | #ifdef CONFIG_NUMA |
| 281 | #define PHB_SET_NODE(PHB, NODE) ((PHB)->node = (NODE)) |
| 282 | #else |
| 283 | #define PHB_SET_NODE(PHB, NODE) ((PHB)->node = -1) |
| 284 | #endif |
| 285 | |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 286 | #endif /* CONFIG_PPC64 */ |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 287 | |
| 288 | /* Get the PCI host controller for an OF device */ |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 289 | extern struct pci_controller *pci_find_hose_for_OF_device( |
| 290 | struct device_node* node); |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 291 | |
| 292 | /* Fill up host controller resources from the OF node */ |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 293 | extern void pci_process_bridge_OF_ranges(struct pci_controller *hose, |
| 294 | struct device_node *dev, int primary); |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 295 | |
Benjamin Herrenschmidt | 5131d4d | 2007-11-16 18:42:18 +1100 | [diff] [blame] | 296 | /* Allocate & free a PCI host bridge structure */ |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 297 | extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev); |
Benjamin Herrenschmidt | 5131d4d | 2007-11-16 18:42:18 +1100 | [diff] [blame] | 298 | extern void pcibios_free_controller(struct pci_controller *phb); |
| 299 | |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 300 | #ifdef CONFIG_PCI |
Benjamin Herrenschmidt | 6dfbde2 | 2007-07-26 14:07:13 +1000 | [diff] [blame] | 301 | extern int pcibios_vaddr_is_ioport(void __iomem *address); |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 302 | #else |
Benjamin Herrenschmidt | 6dfbde2 | 2007-07-26 14:07:13 +1000 | [diff] [blame] | 303 | static inline int pcibios_vaddr_is_ioport(void __iomem *address) |
| 304 | { |
| 305 | return 0; |
| 306 | } |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 307 | #endif /* CONFIG_PCI */ |
Kumar Gala | 5531e41 | 2007-06-27 00:16:25 -0500 | [diff] [blame] | 308 | |
Stephen Rothwell | 7cd1de6 | 2007-12-06 18:02:28 +1100 | [diff] [blame] | 309 | #endif /* __KERNEL__ */ |
| 310 | #endif /* _ASM_POWERPC_PCI_BRIDGE_H */ |