xref: /openbmc/linux/arch/microblaze/include/asm/pci.h (revision 830980a0)
1830980a0SMichal Simek /*
2830980a0SMichal Simek  * This program is free software; you can redistribute it and/or
3830980a0SMichal Simek  * modify it under the terms of the GNU General Public License
4830980a0SMichal Simek  * as published by the Free Software Foundation; either version
5830980a0SMichal Simek  * 2 of the License, or (at your option) any later version.
6830980a0SMichal Simek  *
7830980a0SMichal Simek  * Based on powerpc version
8830980a0SMichal Simek  */
9830980a0SMichal Simek 
10830980a0SMichal Simek #ifndef __ASM_MICROBLAZE_PCI_H
11830980a0SMichal Simek #define __ASM_MICROBLAZE_PCI_H
12830980a0SMichal Simek #ifdef __KERNEL__
13830980a0SMichal Simek 
14830980a0SMichal Simek #include <linux/types.h>
15830980a0SMichal Simek #include <linux/slab.h>
16830980a0SMichal Simek #include <linux/string.h>
17830980a0SMichal Simek #include <linux/dma-mapping.h>
18830980a0SMichal Simek #include <linux/pci.h>
19830980a0SMichal Simek 
20830980a0SMichal Simek #include <asm/scatterlist.h>
21830980a0SMichal Simek #include <asm/io.h>
22830980a0SMichal Simek #include <asm/prom.h>
23830980a0SMichal Simek #include <asm/pci-bridge.h>
24830980a0SMichal Simek 
25830980a0SMichal Simek #define PCIBIOS_MIN_IO		0x1000
26830980a0SMichal Simek #define PCIBIOS_MIN_MEM		0x10000000
27830980a0SMichal Simek 
28830980a0SMichal Simek struct pci_dev;
29830980a0SMichal Simek 
30830980a0SMichal Simek /* Values for the `which' argument to sys_pciconfig_iobase syscall.  */
31830980a0SMichal Simek #define IOBASE_BRIDGE_NUMBER	0
32830980a0SMichal Simek #define IOBASE_MEMORY		1
33830980a0SMichal Simek #define IOBASE_IO		2
34830980a0SMichal Simek #define IOBASE_ISA_IO		3
35830980a0SMichal Simek #define IOBASE_ISA_MEM		4
36830980a0SMichal Simek 
37830980a0SMichal Simek #define pcibios_scan_all_fns(a, b)	0
38830980a0SMichal Simek 
39830980a0SMichal Simek /*
40830980a0SMichal Simek  * Set this to 1 if you want the kernel to re-assign all PCI
41830980a0SMichal Simek  * bus numbers (don't do that on ppc64 yet !)
42830980a0SMichal Simek  */
43830980a0SMichal Simek #define pcibios_assign_all_busses() \
44830980a0SMichal Simek 	(pci_has_flag(PCI_REASSIGN_ALL_BUS))
45830980a0SMichal Simek 
46830980a0SMichal Simek static inline void pcibios_set_master(struct pci_dev *dev)
47830980a0SMichal Simek {
48830980a0SMichal Simek 	/* No special bus mastering setup handling */
49830980a0SMichal Simek }
50830980a0SMichal Simek 
51830980a0SMichal Simek static inline void pcibios_penalize_isa_irq(int irq, int active)
52830980a0SMichal Simek {
53830980a0SMichal Simek 	/* We don't do dynamic PCI IRQ allocation */
54830980a0SMichal Simek }
55830980a0SMichal Simek 
56830980a0SMichal Simek #ifdef CONFIG_PCI
57830980a0SMichal Simek extern void set_pci_dma_ops(struct dma_map_ops *dma_ops);
58830980a0SMichal Simek extern struct dma_map_ops *get_pci_dma_ops(void);
59830980a0SMichal Simek #else	/* CONFIG_PCI */
60830980a0SMichal Simek #define set_pci_dma_ops(d)
61830980a0SMichal Simek #define get_pci_dma_ops()	NULL
62830980a0SMichal Simek #endif
63830980a0SMichal Simek 
64830980a0SMichal Simek #ifdef CONFIG_PCI
65830980a0SMichal Simek static inline void pci_dma_burst_advice(struct pci_dev *pdev,
66830980a0SMichal Simek 					enum pci_dma_burst_strategy *strat,
67830980a0SMichal Simek 					unsigned long *strategy_parameter)
68830980a0SMichal Simek {
69830980a0SMichal Simek 	*strat = PCI_DMA_BURST_INFINITY;
70830980a0SMichal Simek 	*strategy_parameter = ~0UL;
71830980a0SMichal Simek }
72830980a0SMichal Simek #endif
73830980a0SMichal Simek 
74830980a0SMichal Simek extern int pci_domain_nr(struct pci_bus *bus);
75830980a0SMichal Simek 
76830980a0SMichal Simek /* Decide whether to display the domain number in /proc */
77830980a0SMichal Simek extern int pci_proc_domain(struct pci_bus *bus);
78830980a0SMichal Simek 
79830980a0SMichal Simek struct vm_area_struct;
80830980a0SMichal Simek /* Map a range of PCI memory or I/O space for a device into user space */
81830980a0SMichal Simek int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
82830980a0SMichal Simek 			enum pci_mmap_state mmap_state, int write_combine);
83830980a0SMichal Simek 
84830980a0SMichal Simek /* Tell drivers/pci/proc.c that we have pci_mmap_page_range() */
85830980a0SMichal Simek #define HAVE_PCI_MMAP	1
86830980a0SMichal Simek 
87830980a0SMichal Simek extern int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val,
88830980a0SMichal Simek 			   size_t count);
89830980a0SMichal Simek extern int pci_legacy_write(struct pci_bus *bus, loff_t port, u32 val,
90830980a0SMichal Simek 			   size_t count);
91830980a0SMichal Simek extern int pci_mmap_legacy_page_range(struct pci_bus *bus,
92830980a0SMichal Simek 				      struct vm_area_struct *vma,
93830980a0SMichal Simek 				      enum pci_mmap_state mmap_state);
94830980a0SMichal Simek 
95830980a0SMichal Simek #define HAVE_PCI_LEGACY	1
96830980a0SMichal Simek 
97830980a0SMichal Simek /* pci_unmap_{page,single} is a nop so... */
98830980a0SMichal Simek #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
99830980a0SMichal Simek #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
100830980a0SMichal Simek #define pci_unmap_addr(PTR, ADDR_NAME)		(0)
101830980a0SMichal Simek #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)	do { } while (0)
102830980a0SMichal Simek #define pci_unmap_len(PTR, LEN_NAME)		(0)
103830980a0SMichal Simek #define pci_unmap_len_set(PTR, LEN_NAME, VAL)	do { } while (0)
104830980a0SMichal Simek 
105830980a0SMichal Simek /* The PCI address space does equal the physical memory
106830980a0SMichal Simek  * address space (no IOMMU).  The IDE and SCSI device layers use
107830980a0SMichal Simek  * this boolean for bounce buffer decisions.
108830980a0SMichal Simek  */
109830980a0SMichal Simek #define PCI_DMA_BUS_IS_PHYS     (1)
110830980a0SMichal Simek 
111830980a0SMichal Simek extern void pcibios_resource_to_bus(struct pci_dev *dev,
112830980a0SMichal Simek 			struct pci_bus_region *region,
113830980a0SMichal Simek 			struct resource *res);
114830980a0SMichal Simek 
115830980a0SMichal Simek extern void pcibios_bus_to_resource(struct pci_dev *dev,
116830980a0SMichal Simek 			struct resource *res,
117830980a0SMichal Simek 			struct pci_bus_region *region);
118830980a0SMichal Simek 
119830980a0SMichal Simek static inline struct resource *pcibios_select_root(struct pci_dev *pdev,
120830980a0SMichal Simek 			struct resource *res)
121830980a0SMichal Simek {
122830980a0SMichal Simek 	struct resource *root = NULL;
123830980a0SMichal Simek 
124830980a0SMichal Simek 	if (res->flags & IORESOURCE_IO)
125830980a0SMichal Simek 		root = &ioport_resource;
126830980a0SMichal Simek 	if (res->flags & IORESOURCE_MEM)
127830980a0SMichal Simek 		root = &iomem_resource;
128830980a0SMichal Simek 
129830980a0SMichal Simek 	return root;
130830980a0SMichal Simek }
131830980a0SMichal Simek 
132830980a0SMichal Simek extern void pcibios_claim_one_bus(struct pci_bus *b);
133830980a0SMichal Simek 
134830980a0SMichal Simek extern void pcibios_finish_adding_to_bus(struct pci_bus *bus);
135830980a0SMichal Simek 
136830980a0SMichal Simek extern void pcibios_resource_survey(void);
137830980a0SMichal Simek 
138830980a0SMichal Simek extern struct pci_controller *init_phb_dynamic(struct device_node *dn);
139830980a0SMichal Simek extern int remove_phb_dynamic(struct pci_controller *phb);
140830980a0SMichal Simek 
141830980a0SMichal Simek extern struct pci_dev *of_create_pci_dev(struct device_node *node,
142830980a0SMichal Simek 					struct pci_bus *bus, int devfn);
143830980a0SMichal Simek 
144830980a0SMichal Simek extern void of_scan_pci_bridge(struct device_node *node,
145830980a0SMichal Simek 				struct pci_dev *dev);
146830980a0SMichal Simek 
147830980a0SMichal Simek extern void of_scan_bus(struct device_node *node, struct pci_bus *bus);
148830980a0SMichal Simek extern void of_rescan_bus(struct device_node *node, struct pci_bus *bus);
149830980a0SMichal Simek 
150830980a0SMichal Simek extern int pci_read_irq_line(struct pci_dev *dev);
151830980a0SMichal Simek 
152830980a0SMichal Simek extern int pci_bus_find_capability(struct pci_bus *bus,
153830980a0SMichal Simek 						unsigned int devfn, int cap);
154830980a0SMichal Simek 
155830980a0SMichal Simek struct file;
156830980a0SMichal Simek extern pgprot_t	pci_phys_mem_access_prot(struct file *file,
157830980a0SMichal Simek 					 unsigned long pfn,
158830980a0SMichal Simek 					 unsigned long size,
159830980a0SMichal Simek 					 pgprot_t prot);
160830980a0SMichal Simek 
161830980a0SMichal Simek #define HAVE_ARCH_PCI_RESOURCE_TO_USER
162830980a0SMichal Simek extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
163830980a0SMichal Simek 				 const struct resource *rsrc,
164830980a0SMichal Simek 				 resource_size_t *start, resource_size_t *end);
165830980a0SMichal Simek 
166830980a0SMichal Simek extern void pcibios_setup_bus_devices(struct pci_bus *bus);
167830980a0SMichal Simek extern void pcibios_setup_bus_self(struct pci_bus *bus);
168830980a0SMichal Simek 
169830980a0SMichal Simek #endif	/* __KERNEL__ */
170830980a0SMichal Simek #endif /* __ASM_MICROBLAZE_PCI_H */
171