xref: /openbmc/linux/arch/powerpc/include/asm/pci-bridge.h (revision 542070baf4a0fe9de14cc2c4ca3ff1b43f14f90f)
1b8b572e1SStephen Rothwell #ifndef _ASM_POWERPC_PCI_BRIDGE_H
2b8b572e1SStephen Rothwell #define _ASM_POWERPC_PCI_BRIDGE_H
3b8b572e1SStephen Rothwell #ifdef __KERNEL__
4b8b572e1SStephen Rothwell /*
5b8b572e1SStephen Rothwell  * This program is free software; you can redistribute it and/or
6b8b572e1SStephen Rothwell  * modify it under the terms of the GNU General Public License
7b8b572e1SStephen Rothwell  * as published by the Free Software Foundation; either version
8b8b572e1SStephen Rothwell  * 2 of the License, or (at your option) any later version.
9b8b572e1SStephen Rothwell  */
10b8b572e1SStephen Rothwell #include <linux/pci.h>
11b8b572e1SStephen Rothwell #include <linux/list.h>
12b8b572e1SStephen Rothwell #include <linux/ioport.h>
13f4ffd5e5SRob Herring #include <asm-generic/pci-bridge.h>
14b8b572e1SStephen Rothwell 
15ff9df8c8SDaniel Axtens /* Return values for pci_controller_ops.probe_mode function */
16ff9df8c8SDaniel Axtens #define PCI_PROBE_NONE		-1	/* Don't look at this bus at all */
17ff9df8c8SDaniel Axtens #define PCI_PROBE_NORMAL	0	/* Do normal PCI probing */
18ff9df8c8SDaniel Axtens #define PCI_PROBE_DEVTREE	1	/* Instantiate from device tree */
19ff9df8c8SDaniel Axtens 
20b8b572e1SStephen Rothwell struct device_node;
21b8b572e1SStephen Rothwell 
22b8b572e1SStephen Rothwell /*
23e02def5bSDaniel Axtens  * PCI controller operations
24e02def5bSDaniel Axtens  */
25e02def5bSDaniel Axtens struct pci_controller_ops {
26e02def5bSDaniel Axtens 	void		(*dma_dev_setup)(struct pci_dev *dev);
27b122c954SDaniel Axtens 	void		(*dma_bus_setup)(struct pci_bus *bus);
28ff9df8c8SDaniel Axtens 
29ff9df8c8SDaniel Axtens 	int		(*probe_mode)(struct pci_bus *);
30b31e79f8SDaniel Axtens 
31b31e79f8SDaniel Axtens 	/* Called when pci_enable_device() is called. Returns true to
32b31e79f8SDaniel Axtens 	 * allow assignment/enabling of the device. */
33b31e79f8SDaniel Axtens 	bool		(*enable_device_hook)(struct pci_dev *);
34*542070baSDaniel Axtens 
35*542070baSDaniel Axtens 	/* Called during PCI resource reassignment */
36*542070baSDaniel Axtens 	resource_size_t (*window_alignment)(struct pci_bus *, unsigned long type);
37e02def5bSDaniel Axtens };
38e02def5bSDaniel Axtens 
39e02def5bSDaniel Axtens /*
40b8b572e1SStephen Rothwell  * Structure of a PCI controller (host bridge)
41b8b572e1SStephen Rothwell  */
42b8b572e1SStephen Rothwell struct pci_controller {
43b8b572e1SStephen Rothwell 	struct pci_bus *bus;
44b8b572e1SStephen Rothwell 	char is_dynamic;
45b8b572e1SStephen Rothwell #ifdef CONFIG_PPC64
46b8b572e1SStephen Rothwell 	int node;
47b8b572e1SStephen Rothwell #endif
48b8b572e1SStephen Rothwell 	struct device_node *dn;
49b8b572e1SStephen Rothwell 	struct list_head list_node;
50b8b572e1SStephen Rothwell 	struct device *parent;
51b8b572e1SStephen Rothwell 
52b8b572e1SStephen Rothwell 	int first_busno;
53b8b572e1SStephen Rothwell 	int last_busno;
54b8b572e1SStephen Rothwell 	int self_busno;
55be8e60d8SYinghai Lu 	struct resource busn;
56b8b572e1SStephen Rothwell 
57b8b572e1SStephen Rothwell 	void __iomem *io_base_virt;
58b8b572e1SStephen Rothwell #ifdef CONFIG_PPC64
59b8b572e1SStephen Rothwell 	void *io_base_alloc;
60b8b572e1SStephen Rothwell #endif
61b8b572e1SStephen Rothwell 	resource_size_t io_base_phys;
62b8b572e1SStephen Rothwell 	resource_size_t pci_io_size;
63b8b572e1SStephen Rothwell 
64e9f82cb7SBenjamin Herrenschmidt 	/* Some machines have a special region to forward the ISA
65e9f82cb7SBenjamin Herrenschmidt 	 * "memory" cycles such as VGA memory regions. Left to 0
66e9f82cb7SBenjamin Herrenschmidt 	 * if unsupported
67e9f82cb7SBenjamin Herrenschmidt 	 */
68e9f82cb7SBenjamin Herrenschmidt 	resource_size_t	isa_mem_phys;
69e9f82cb7SBenjamin Herrenschmidt 	resource_size_t	isa_mem_size;
70e9f82cb7SBenjamin Herrenschmidt 
71e02def5bSDaniel Axtens 	struct pci_controller_ops controller_ops;
72b8b572e1SStephen Rothwell 	struct pci_ops *ops;
73b8b572e1SStephen Rothwell 	unsigned int __iomem *cfg_addr;
74b8b572e1SStephen Rothwell 	void __iomem *cfg_data;
75b8b572e1SStephen Rothwell 
76b8b572e1SStephen Rothwell 	/*
77b8b572e1SStephen Rothwell 	 * Used for variants of PCI indirect handling and possible quirks:
78b8b572e1SStephen Rothwell 	 *  SET_CFG_TYPE - used on 4xx or any PHB that does explicit type0/1
79b8b572e1SStephen Rothwell 	 *  EXT_REG - provides access to PCI-e extended registers
8025985edcSLucas De Marchi 	 *  SURPRESS_PRIMARY_BUS - we suppress the setting of PCI_PRIMARY_BUS
81b8b572e1SStephen Rothwell 	 *   on Freescale PCI-e controllers since they used the PCI_PRIMARY_BUS
82b8b572e1SStephen Rothwell 	 *   to determine which bus number to match on when generating type0
83b8b572e1SStephen Rothwell 	 *   config cycles
84b8b572e1SStephen Rothwell 	 *  NO_PCIE_LINK - the Freescale PCI-e controllers have issues with
85b8b572e1SStephen Rothwell 	 *   hanging if we don't have link and try to do config cycles to
86b8b572e1SStephen Rothwell 	 *   anything but the PHB.  Only allow talking to the PHB if this is
87b8b572e1SStephen Rothwell 	 *   set.
88b8b572e1SStephen Rothwell 	 *  BIG_ENDIAN - cfg_addr is a big endian register
89b8b572e1SStephen Rothwell 	 *  BROKEN_MRM - the 440EPx/GRx chips have an errata that causes hangs on
90b8b572e1SStephen Rothwell 	 *   the PLB4.  Effectively disable MRM commands by setting this.
9134642bbbSKumar Gala 	 *  FSL_CFG_REG_LINK - Freescale controller version in which the PCIe
9234642bbbSKumar Gala 	 *   link status is in a RC PCIe cfg register (vs being a SoC register)
93b8b572e1SStephen Rothwell 	 */
94b8b572e1SStephen Rothwell #define PPC_INDIRECT_TYPE_SET_CFG_TYPE		0x00000001
95b8b572e1SStephen Rothwell #define PPC_INDIRECT_TYPE_EXT_REG		0x00000002
96b8b572e1SStephen Rothwell #define PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS	0x00000004
97b8b572e1SStephen Rothwell #define PPC_INDIRECT_TYPE_NO_PCIE_LINK		0x00000008
98b8b572e1SStephen Rothwell #define PPC_INDIRECT_TYPE_BIG_ENDIAN		0x00000010
99b8b572e1SStephen Rothwell #define PPC_INDIRECT_TYPE_BROKEN_MRM		0x00000020
10034642bbbSKumar Gala #define PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK	0x00000040
101b8b572e1SStephen Rothwell 	u32 indirect_type;
102b8b572e1SStephen Rothwell 	/* Currently, we limit ourselves to 1 IO range and 3 mem
103b8b572e1SStephen Rothwell 	 * ranges since the common pci_bus structure can't handle more
104b8b572e1SStephen Rothwell 	 */
105b8b572e1SStephen Rothwell 	struct resource	io_resource;
106b8b572e1SStephen Rothwell 	struct resource mem_resources[3];
1073fd47f06SBenjamin Herrenschmidt 	resource_size_t mem_offset[3];
108b8b572e1SStephen Rothwell 	int global_number;		/* PCI domain number */
10989d93347SBecky Bruce 
11089d93347SBecky Bruce 	resource_size_t dma_window_base_cur;
11189d93347SBecky Bruce 	resource_size_t dma_window_size;
11289d93347SBecky Bruce 
113b8b572e1SStephen Rothwell #ifdef CONFIG_PPC64
114b8b572e1SStephen Rothwell 	unsigned long buid;
115cca87d30SGavin Shan 	struct pci_dn *pci_data;
11634642bbbSKumar Gala #endif	/* CONFIG_PPC64 */
117b8b572e1SStephen Rothwell 
118b8b572e1SStephen Rothwell 	void *private_data;
119b8b572e1SStephen Rothwell };
120b8b572e1SStephen Rothwell 
121b8b572e1SStephen Rothwell /* These are used for config access before all the PCI probing
122b8b572e1SStephen Rothwell    has been done. */
123b8b572e1SStephen Rothwell extern int early_read_config_byte(struct pci_controller *hose, int bus,
124b8b572e1SStephen Rothwell 			int dev_fn, int where, u8 *val);
125b8b572e1SStephen Rothwell extern int early_read_config_word(struct pci_controller *hose, int bus,
126b8b572e1SStephen Rothwell 			int dev_fn, int where, u16 *val);
127b8b572e1SStephen Rothwell extern int early_read_config_dword(struct pci_controller *hose, int bus,
128b8b572e1SStephen Rothwell 			int dev_fn, int where, u32 *val);
129b8b572e1SStephen Rothwell extern int early_write_config_byte(struct pci_controller *hose, int bus,
130b8b572e1SStephen Rothwell 			int dev_fn, int where, u8 val);
131b8b572e1SStephen Rothwell extern int early_write_config_word(struct pci_controller *hose, int bus,
132b8b572e1SStephen Rothwell 			int dev_fn, int where, u16 val);
133b8b572e1SStephen Rothwell extern int early_write_config_dword(struct pci_controller *hose, int bus,
134b8b572e1SStephen Rothwell 			int dev_fn, int where, u32 val);
135b8b572e1SStephen Rothwell 
136b8b572e1SStephen Rothwell extern int early_find_capability(struct pci_controller *hose, int bus,
137b8b572e1SStephen Rothwell 				 int dev_fn, int cap);
138b8b572e1SStephen Rothwell 
139b8b572e1SStephen Rothwell extern void setup_indirect_pci(struct pci_controller* hose,
140b8b572e1SStephen Rothwell 			       resource_size_t cfg_addr,
141b8b572e1SStephen Rothwell 			       resource_size_t cfg_data, u32 flags);
14289c2dd62SKumar Gala 
14350d8f87dSRojhalat Ibrahim extern int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
14450d8f87dSRojhalat Ibrahim 				int offset, int len, u32 *val);
14550d8f87dSRojhalat Ibrahim 
1466d5f6a0eSKim Phillips extern int __indirect_read_config(struct pci_controller *hose,
1476d5f6a0eSKim Phillips 				  unsigned char bus_number, unsigned int devfn,
1486d5f6a0eSKim Phillips 				  int offset, int len, u32 *val);
1496d5f6a0eSKim Phillips 
15050d8f87dSRojhalat Ibrahim extern int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
15150d8f87dSRojhalat Ibrahim 				 int offset, int len, u32 val);
15250d8f87dSRojhalat Ibrahim 
15389c2dd62SKumar Gala static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
15489c2dd62SKumar Gala {
15589c2dd62SKumar Gala 	return bus->sysdata;
15689c2dd62SKumar Gala }
15789c2dd62SKumar Gala 
15898d9f30cSBenjamin Herrenschmidt #ifndef CONFIG_PPC64
15998d9f30cSBenjamin Herrenschmidt 
16098d9f30cSBenjamin Herrenschmidt extern int pci_device_from_OF_node(struct device_node *node,
16198d9f30cSBenjamin Herrenschmidt 				   u8 *bus, u8 *devfn);
16298d9f30cSBenjamin Herrenschmidt extern void pci_create_OF_bus_map(void);
16398d9f30cSBenjamin Herrenschmidt 
16489c2dd62SKumar Gala static inline int isa_vaddr_is_ioport(void __iomem *address)
16589c2dd62SKumar Gala {
16689c2dd62SKumar Gala 	/* No specific ISA handling on ppc32 at this stage, it
16789c2dd62SKumar Gala 	 * all goes through PCI
16889c2dd62SKumar Gala 	 */
16989c2dd62SKumar Gala 	return 0;
17089c2dd62SKumar Gala }
17189c2dd62SKumar Gala 
172b8b572e1SStephen Rothwell #else	/* CONFIG_PPC64 */
173b8b572e1SStephen Rothwell 
174b8b572e1SStephen Rothwell /*
175b8b572e1SStephen Rothwell  * PCI stuff, for nodes representing PCI devices, pointed to
176b8b572e1SStephen Rothwell  * by device_node->data.
177b8b572e1SStephen Rothwell  */
178b8b572e1SStephen Rothwell struct iommu_table;
179b8b572e1SStephen Rothwell 
180b8b572e1SStephen Rothwell struct pci_dn {
181cca87d30SGavin Shan 	int     flags;
182cca87d30SGavin Shan 
183b8b572e1SStephen Rothwell 	int	busno;			/* pci bus number */
184b8b572e1SStephen Rothwell 	int	devfn;			/* pci device and function number */
185c035ff1dSGavin Shan 	int	vendor_id;		/* Vendor ID */
186c035ff1dSGavin Shan 	int	device_id;		/* Device ID */
187c035ff1dSGavin Shan 	int	class_code;		/* Device class code */
188b8b572e1SStephen Rothwell 
189cca87d30SGavin Shan 	struct  pci_dn *parent;
190b8b572e1SStephen Rothwell 	struct  pci_controller *phb;	/* for pci devices */
191b8b572e1SStephen Rothwell 	struct	iommu_table *iommu_table;	/* for phb's or bridges */
192b8b572e1SStephen Rothwell 	struct	device_node *node;	/* back-pointer to the device_node */
193b8b572e1SStephen Rothwell 
194b8b572e1SStephen Rothwell 	int	pci_ext_config_space;	/* for pci devices */
195b8b572e1SStephen Rothwell 
196b8b572e1SStephen Rothwell 	struct	pci_dev *pcidev;	/* back-pointer to the pci device */
197184cd4a3SBenjamin Herrenschmidt #ifdef CONFIG_EEH
1982a0352faSGavin Shan 	struct eeh_dev *edev;		/* eeh device */
199b8b572e1SStephen Rothwell #endif
200184cd4a3SBenjamin Herrenschmidt #define IODA_INVALID_PE		(-1)
201184cd4a3SBenjamin Herrenschmidt #ifdef CONFIG_PPC_POWERNV
202184cd4a3SBenjamin Herrenschmidt 	int	pe_number;
203184cd4a3SBenjamin Herrenschmidt #endif
204cca87d30SGavin Shan 	struct list_head child_list;
205cca87d30SGavin Shan 	struct list_head list;
206b8b572e1SStephen Rothwell };
207b8b572e1SStephen Rothwell 
208b8b572e1SStephen Rothwell /* Get the pointer to a device_node's pci_dn */
209b8b572e1SStephen Rothwell #define PCI_DN(dn)	((struct pci_dn *) (dn)->data)
210b8b572e1SStephen Rothwell 
211cca87d30SGavin Shan extern struct pci_dn *pci_get_pdn_by_devfn(struct pci_bus *bus,
212cca87d30SGavin Shan 					   int devfn);
213b72c1f65SBenjamin Herrenschmidt extern struct pci_dn *pci_get_pdn(struct pci_dev *pdev);
2142eb4afb6SKumar Gala extern void *update_dn_pci_info(struct device_node *dn, void *data);
215b8b572e1SStephen Rothwell 
216b8b572e1SStephen Rothwell static inline int pci_device_from_OF_node(struct device_node *np,
217b8b572e1SStephen Rothwell 					  u8 *bus, u8 *devfn)
218b8b572e1SStephen Rothwell {
219b8b572e1SStephen Rothwell 	if (!PCI_DN(np))
220b8b572e1SStephen Rothwell 		return -ENODEV;
221b8b572e1SStephen Rothwell 	*bus = PCI_DN(np)->busno;
222b8b572e1SStephen Rothwell 	*devfn = PCI_DN(np)->devfn;
223b8b572e1SStephen Rothwell 	return 0;
224b8b572e1SStephen Rothwell }
225b8b572e1SStephen Rothwell 
2262a0352faSGavin Shan #if defined(CONFIG_EEH)
227e8e9b34cSGavin Shan static inline struct eeh_dev *pdn_to_eeh_dev(struct pci_dn *pdn)
228e8e9b34cSGavin Shan {
229e8e9b34cSGavin Shan 	return pdn ? pdn->edev : NULL;
230e8e9b34cSGavin Shan }
231f8f7d63fSGavin Shan #else
232e8e9b34cSGavin Shan #define pdn_to_eeh_dev(x)	(NULL)
2332a0352faSGavin Shan #endif
2342a0352faSGavin Shan 
235b8b572e1SStephen Rothwell /** Find the bus corresponding to the indicated device node */
236b8b572e1SStephen Rothwell extern struct pci_bus *pcibios_find_pci_bus(struct device_node *dn);
237b8b572e1SStephen Rothwell 
238b8b572e1SStephen Rothwell /** Remove all of the PCI devices under this bus */
239b8b572e1SStephen Rothwell extern void pcibios_remove_pci_devices(struct pci_bus *bus);
240b8b572e1SStephen Rothwell 
241b8b572e1SStephen Rothwell /** Discover new pci devices under this bus, and add them */
242b8b572e1SStephen Rothwell extern void pcibios_add_pci_devices(struct pci_bus *bus);
243b8b572e1SStephen Rothwell 
244b8b572e1SStephen Rothwell 
245b8b572e1SStephen Rothwell extern void isa_bridge_find_early(struct pci_controller *hose);
246b8b572e1SStephen Rothwell 
247b8b572e1SStephen Rothwell static inline int isa_vaddr_is_ioport(void __iomem *address)
248b8b572e1SStephen Rothwell {
249b8b572e1SStephen Rothwell 	/* Check if address hits the reserved legacy IO range */
250b8b572e1SStephen Rothwell 	unsigned long ea = (unsigned long)address;
251b8b572e1SStephen Rothwell 	return ea >= ISA_IO_BASE && ea < ISA_IO_END;
252b8b572e1SStephen Rothwell }
253b8b572e1SStephen Rothwell 
254b8b572e1SStephen Rothwell extern int pcibios_unmap_io_space(struct pci_bus *bus);
255b8b572e1SStephen Rothwell extern int pcibios_map_io_space(struct pci_bus *bus);
256b8b572e1SStephen Rothwell 
257b8b572e1SStephen Rothwell #ifdef CONFIG_NUMA
258b8b572e1SStephen Rothwell #define PHB_SET_NODE(PHB, NODE)		((PHB)->node = (NODE))
259b8b572e1SStephen Rothwell #else
260b8b572e1SStephen Rothwell #define PHB_SET_NODE(PHB, NODE)		((PHB)->node = -1)
261b8b572e1SStephen Rothwell #endif
262b8b572e1SStephen Rothwell 
263b8b572e1SStephen Rothwell #endif	/* CONFIG_PPC64 */
264b8b572e1SStephen Rothwell 
265b8b572e1SStephen Rothwell /* Get the PCI host controller for an OF device */
266b8b572e1SStephen Rothwell extern struct pci_controller *pci_find_hose_for_OF_device(
267b8b572e1SStephen Rothwell 			struct device_node* node);
268b8b572e1SStephen Rothwell 
269b8b572e1SStephen Rothwell /* Fill up host controller resources from the OF node */
270b8b572e1SStephen Rothwell extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
271b8b572e1SStephen Rothwell 			struct device_node *dev, int primary);
272b8b572e1SStephen Rothwell 
273b8b572e1SStephen Rothwell /* Allocate & free a PCI host bridge structure */
274b8b572e1SStephen Rothwell extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev);
275b8b572e1SStephen Rothwell extern void pcibios_free_controller(struct pci_controller *phb);
276b8b572e1SStephen Rothwell 
277b8b572e1SStephen Rothwell #ifdef CONFIG_PCI
278b8b572e1SStephen Rothwell extern int pcibios_vaddr_is_ioport(void __iomem *address);
279b8b572e1SStephen Rothwell #else
280b8b572e1SStephen Rothwell static inline int pcibios_vaddr_is_ioport(void __iomem *address)
281b8b572e1SStephen Rothwell {
282b8b572e1SStephen Rothwell 	return 0;
283b8b572e1SStephen Rothwell }
284b8b572e1SStephen Rothwell #endif	/* CONFIG_PCI */
285b8b572e1SStephen Rothwell 
286e02def5bSDaniel Axtens /*
287e02def5bSDaniel Axtens  * Shims to prefer pci_controller version over ppc_md where available.
288e02def5bSDaniel Axtens  */
289e02def5bSDaniel Axtens static inline void pci_dma_dev_setup(struct pci_dev *dev)
290e02def5bSDaniel Axtens {
291e02def5bSDaniel Axtens 	struct pci_controller *phb = pci_bus_to_host(dev->bus);
292e02def5bSDaniel Axtens 
293e02def5bSDaniel Axtens 	if (phb->controller_ops.dma_dev_setup)
294e02def5bSDaniel Axtens 		phb->controller_ops.dma_dev_setup(dev);
295e02def5bSDaniel Axtens 	else if (ppc_md.pci_dma_dev_setup)
296e02def5bSDaniel Axtens 		ppc_md.pci_dma_dev_setup(dev);
297e02def5bSDaniel Axtens }
298e02def5bSDaniel Axtens 
299b122c954SDaniel Axtens static inline void pci_dma_bus_setup(struct pci_bus *bus)
300b122c954SDaniel Axtens {
301b122c954SDaniel Axtens 	struct pci_controller *phb = pci_bus_to_host(bus);
302b122c954SDaniel Axtens 
303b122c954SDaniel Axtens 	if (phb->controller_ops.dma_bus_setup)
304b122c954SDaniel Axtens 		phb->controller_ops.dma_bus_setup(bus);
305b122c954SDaniel Axtens 	else if (ppc_md.pci_dma_bus_setup)
306b122c954SDaniel Axtens 		ppc_md.pci_dma_bus_setup(bus);
307b122c954SDaniel Axtens }
308b122c954SDaniel Axtens 
309ff9df8c8SDaniel Axtens static inline int pci_probe_mode(struct pci_bus *bus)
310ff9df8c8SDaniel Axtens {
311ff9df8c8SDaniel Axtens 	struct pci_controller *phb = pci_bus_to_host(bus);
312ff9df8c8SDaniel Axtens 
313ff9df8c8SDaniel Axtens 	if (phb->controller_ops.probe_mode)
314ff9df8c8SDaniel Axtens 		return phb->controller_ops.probe_mode(bus);
315ff9df8c8SDaniel Axtens 	if (ppc_md.pci_probe_mode)
316ff9df8c8SDaniel Axtens 		return ppc_md.pci_probe_mode(bus);
317ff9df8c8SDaniel Axtens 	return PCI_PROBE_NORMAL;
318ff9df8c8SDaniel Axtens }
319ff9df8c8SDaniel Axtens 
320b31e79f8SDaniel Axtens static inline bool pcibios_enable_device_hook(struct pci_dev *dev)
321b31e79f8SDaniel Axtens {
322b31e79f8SDaniel Axtens 	struct pci_controller *phb = pci_bus_to_host(dev->bus);
323b31e79f8SDaniel Axtens 
324b31e79f8SDaniel Axtens 	if (phb->controller_ops.enable_device_hook)
325b31e79f8SDaniel Axtens 		return phb->controller_ops.enable_device_hook(dev);
326b31e79f8SDaniel Axtens 	if (ppc_md.pcibios_enable_device_hook)
327b31e79f8SDaniel Axtens 		return ppc_md.pcibios_enable_device_hook(dev);
328b31e79f8SDaniel Axtens 	return true;
329b31e79f8SDaniel Axtens }
330b31e79f8SDaniel Axtens 
331*542070baSDaniel Axtens static inline resource_size_t pci_window_alignment(struct pci_bus *bus,
332*542070baSDaniel Axtens 						   unsigned long type)
333*542070baSDaniel Axtens {
334*542070baSDaniel Axtens 	struct pci_controller *phb = pci_bus_to_host(bus);
335*542070baSDaniel Axtens 
336*542070baSDaniel Axtens 	if (phb->controller_ops.window_alignment)
337*542070baSDaniel Axtens 		return phb->controller_ops.window_alignment(bus, type);
338*542070baSDaniel Axtens 	if (ppc_md.pcibios_window_alignment)
339*542070baSDaniel Axtens 		return ppc_md.pcibios_window_alignment(bus, type);
340*542070baSDaniel Axtens 
341*542070baSDaniel Axtens 	/*
342*542070baSDaniel Axtens 	 * PCI core will figure out the default
343*542070baSDaniel Axtens 	 * alignment: 4KiB for I/O and 1MiB for
344*542070baSDaniel Axtens 	 * memory window.
345*542070baSDaniel Axtens 	 */
346*542070baSDaniel Axtens 	return 1;
347*542070baSDaniel Axtens }
348*542070baSDaniel Axtens 
349b8b572e1SStephen Rothwell #endif	/* __KERNEL__ */
350b8b572e1SStephen Rothwell #endif	/* _ASM_POWERPC_PCI_BRIDGE_H */
351