xref: /openbmc/linux/arch/arm/include/asm/mach/pci.h (revision 4c1ca831)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  *  arch/arm/include/asm/mach/pci.h
4  *
5  *  Copyright (C) 2000 Russell King
6  */
7 
8 #ifndef __ASM_MACH_PCI_H
9 #define __ASM_MACH_PCI_H
10 
11 #include <linux/ioport.h>
12 
13 struct pci_sys_data;
14 struct pci_ops;
15 struct pci_bus;
16 struct pci_host_bridge;
17 struct device;
18 
19 struct hw_pci {
20 	struct pci_ops	*ops;
21 	int		nr_controllers;
22 	void		**private_data;
23 	int		(*setup)(int nr, struct pci_sys_data *);
24 	int		(*scan)(int nr, struct pci_host_bridge *);
25 	void		(*preinit)(void);
26 	void		(*postinit)(void);
27 	u8		(*swizzle)(struct pci_dev *dev, u8 *pin);
28 	int		(*map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
29 };
30 
31 /*
32  * Per-controller structure
33  */
34 struct pci_sys_data {
35 	struct list_head node;
36 	int		busnr;		/* primary bus number			*/
37 	u64		mem_offset;	/* bus->cpu memory mapping offset	*/
38 	unsigned long	io_offset;	/* bus->cpu IO mapping offset		*/
39 	struct pci_bus	*bus;		/* PCI bus				*/
40 	struct list_head resources;	/* root bus resources (apertures)       */
41 	struct resource io_res;
42 	char		io_res_name[12];
43 					/* Bridge swizzling			*/
44 	u8		(*swizzle)(struct pci_dev *, u8 *);
45 					/* IRQ mapping				*/
46 	int		(*map_irq)(const struct pci_dev *, u8, u8);
47 	void		*private_data;	/* platform controller private data	*/
48 };
49 
50 /*
51  * Call this with your hw_pci struct to initialise the PCI system.
52  */
53 void pci_common_init_dev(struct device *, struct hw_pci *);
54 
55 /*
56  * Compatibility wrapper for older platforms that do not care about
57  * passing the parent device.
58  */
59 static inline void pci_common_init(struct hw_pci *hw)
60 {
61 	pci_common_init_dev(NULL, hw);
62 }
63 
64 /*
65  * Setup early fixed I/O mapping.
66  */
67 #if defined(CONFIG_PCI)
68 extern void pci_map_io_early(unsigned long pfn);
69 #else
70 static inline void pci_map_io_early(unsigned long pfn) {}
71 #endif
72 
73 /*
74  * PCI controllers
75  */
76 extern struct pci_ops iop3xx_ops;
77 extern int iop3xx_pci_setup(int nr, struct pci_sys_data *);
78 extern void iop3xx_pci_preinit(void);
79 extern void iop3xx_pci_preinit_cond(void);
80 
81 extern struct pci_ops dc21285_ops;
82 extern int dc21285_setup(int nr, struct pci_sys_data *);
83 extern void dc21285_preinit(void);
84 extern void dc21285_postinit(void);
85 
86 #endif /* __ASM_MACH_PCI_H */
87