xref: /openbmc/linux/arch/mips/include/asm/pci.h (revision b9f0bfd1)
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  */
6 #ifndef _ASM_PCI_H
7 #define _ASM_PCI_H
8 
9 #include <linux/mm.h>
10 
11 #ifdef __KERNEL__
12 
13 /*
14  * This file essentially defines the interface between board
15  * specific PCI code and MIPS common PCI code.	Should potentially put
16  * into include/asm/pci.h file.
17  */
18 
19 #include <linux/ioport.h>
20 #include <linux/list.h>
21 #include <linux/of.h>
22 
23 #ifdef CONFIG_PCI_DRIVERS_GENERIC
24 #define pci_remap_iospace pci_remap_iospace
25 #endif
26 
27 #ifdef CONFIG_PCI_DRIVERS_LEGACY
28 
29 /*
30  * Each pci channel is a top-level PCI bus seem by CPU.	 A machine  with
31  * multiple PCI channels may have multiple PCI host controllers or a
32  * single controller supporting multiple channels.
33  */
34 struct pci_controller {
35 	struct list_head list;
36 	struct pci_bus *bus;
37 	struct device_node *of_node;
38 
39 	struct pci_ops *pci_ops;
40 	struct resource *mem_resource;
41 	unsigned long mem_offset;
42 	struct resource *io_resource;
43 	unsigned long io_offset;
44 	unsigned long io_map_base;
45 
46 #ifndef CONFIG_PCI_DOMAINS_GENERIC
47 	unsigned int index;
48 	/* For compatibility with current (as of July 2003) pciutils
49 	   and XFree86. Eventually will be removed. */
50 	unsigned int need_domain_info;
51 #endif
52 
53 	/* Optional access methods for reading/writing the bus number
54 	   of the PCI controller */
55 	int (*get_busno)(void);
56 	void (*set_busno)(int busno);
57 };
58 
59 /*
60  * Used by boards to register their PCI busses before the actual scanning.
61  */
62 extern void register_pci_controller(struct pci_controller *hose);
63 
64 /*
65  * board supplied pci irq fixup routine
66  */
67 extern int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
68 
69 /* Do platform specific device initialization at pci_enable_device() time */
70 extern int pcibios_plat_dev_init(struct pci_dev *dev);
71 
72 extern char * (*pcibios_plat_setup)(char *str);
73 
74 #ifdef CONFIG_OF
75 /* this function parses memory ranges from a device node */
76 extern void pci_load_of_ranges(struct pci_controller *hose,
77 			       struct device_node *node);
78 #else
79 static inline void pci_load_of_ranges(struct pci_controller *hose,
80 				      struct device_node *node) {}
81 #endif
82 
83 #ifdef CONFIG_PCI_DOMAINS_GENERIC
84 static inline void set_pci_need_domain_info(struct pci_controller *hose,
85 					    int need_domain_info)
86 {
87 	/* nothing to do */
88 }
89 #elif defined(CONFIG_PCI_DOMAINS)
90 static inline void set_pci_need_domain_info(struct pci_controller *hose,
91 					    int need_domain_info)
92 {
93 	hose->need_domain_info = need_domain_info;
94 }
95 #endif /* CONFIG_PCI_DOMAINS */
96 
97 #endif
98 
99 /* Can be used to override the logic in pci_scan_bus for skipping
100    already-configured bus numbers - to be used for buggy BIOSes
101    or architectures with incomplete PCI setup by the loader */
102 static inline unsigned int pcibios_assign_all_busses(void)
103 {
104 	return 1;
105 }
106 
107 extern unsigned long PCIBIOS_MIN_IO;
108 extern unsigned long PCIBIOS_MIN_MEM;
109 
110 #define PCIBIOS_MIN_CARDBUS_IO	0x4000
111 
112 #define HAVE_PCI_MMAP
113 #define ARCH_GENERIC_PCI_MMAP_RESOURCE
114 
115 /*
116  * Dynamic DMA mapping stuff.
117  * MIPS has everything mapped statically.
118  */
119 
120 #include <linux/types.h>
121 #include <linux/slab.h>
122 #include <linux/scatterlist.h>
123 #include <linux/string.h>
124 #include <asm/io.h>
125 
126 #ifdef CONFIG_PCI_DOMAINS_GENERIC
127 static inline int pci_proc_domain(struct pci_bus *bus)
128 {
129 	return pci_domain_nr(bus);
130 }
131 #elif defined(CONFIG_PCI_DOMAINS)
132 #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
133 
134 static inline int pci_proc_domain(struct pci_bus *bus)
135 {
136 	struct pci_controller *hose = bus->sysdata;
137 	return hose->need_domain_info;
138 }
139 #endif /* CONFIG_PCI_DOMAINS */
140 
141 #endif /* __KERNEL__ */
142 
143 /* Do platform specific device initialization at pci_enable_device() time */
144 extern int pcibios_plat_dev_init(struct pci_dev *dev);
145 
146 /* Chances are this interrupt is wired PC-style ...  */
147 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
148 {
149 	return channel ? 15 : 14;
150 }
151 
152 #endif /* _ASM_PCI_H */
153