162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci#ifndef __ASM_POWERPC_PCI_H
362306a36Sopenharmony_ci#define __ASM_POWERPC_PCI_H
462306a36Sopenharmony_ci#ifdef __KERNEL__
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci/*
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/types.h>
1062306a36Sopenharmony_ci#include <linux/slab.h>
1162306a36Sopenharmony_ci#include <linux/string.h>
1262306a36Sopenharmony_ci#include <linux/dma-map-ops.h>
1362306a36Sopenharmony_ci#include <linux/scatterlist.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#include <asm/machdep.h>
1662306a36Sopenharmony_ci#include <asm/io.h>
1762306a36Sopenharmony_ci#include <asm/pci-bridge.h>
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/* Return values for pci_controller_ops.probe_mode function */
2062306a36Sopenharmony_ci#define PCI_PROBE_NONE		-1	/* Don't look at this bus at all */
2162306a36Sopenharmony_ci#define PCI_PROBE_NORMAL	0	/* Do normal PCI probing */
2262306a36Sopenharmony_ci#define PCI_PROBE_DEVTREE	1	/* Instantiate from device tree */
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define PCIBIOS_MIN_IO		0x1000
2562306a36Sopenharmony_ci#define PCIBIOS_MIN_MEM		0x10000000
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci/* Values for the `which' argument to sys_pciconfig_iobase syscall.  */
2862306a36Sopenharmony_ci#define IOBASE_BRIDGE_NUMBER	0
2962306a36Sopenharmony_ci#define IOBASE_MEMORY		1
3062306a36Sopenharmony_ci#define IOBASE_IO		2
3162306a36Sopenharmony_ci#define IOBASE_ISA_IO		3
3262306a36Sopenharmony_ci#define IOBASE_ISA_MEM		4
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci/*
3562306a36Sopenharmony_ci * Set this to 1 if you want the kernel to re-assign all PCI
3662306a36Sopenharmony_ci * bus numbers (don't do that on ppc64 yet !)
3762306a36Sopenharmony_ci */
3862306a36Sopenharmony_ci#define pcibios_assign_all_busses() \
3962306a36Sopenharmony_ci	(pci_has_flag(PCI_REASSIGN_ALL_BUS))
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_cistatic inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
4262306a36Sopenharmony_ci{
4362306a36Sopenharmony_ci	if (ppc_md.pci_get_legacy_ide_irq)
4462306a36Sopenharmony_ci		return ppc_md.pci_get_legacy_ide_irq(dev, channel);
4562306a36Sopenharmony_ci	return channel ? 15 : 14;
4662306a36Sopenharmony_ci}
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#ifdef CONFIG_PCI
4962306a36Sopenharmony_civoid __init set_pci_dma_ops(const struct dma_map_ops *dma_ops);
5062306a36Sopenharmony_ci#else	/* CONFIG_PCI */
5162306a36Sopenharmony_ci#define set_pci_dma_ops(d)
5262306a36Sopenharmony_ci#endif
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#ifdef CONFIG_PPC64
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/*
5762306a36Sopenharmony_ci * We want to avoid touching the cacheline size or MWI bit.
5862306a36Sopenharmony_ci * pSeries firmware sets the cacheline size (which is not the cpu cacheline
5962306a36Sopenharmony_ci * size in all cases) and hardware treats MWI the same as memory write.
6062306a36Sopenharmony_ci */
6162306a36Sopenharmony_ci#define PCI_DISABLE_MWI
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#endif /* CONFIG_PPC64 */
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ciextern int pci_domain_nr(struct pci_bus *bus);
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci/* Decide whether to display the domain number in /proc */
6862306a36Sopenharmony_ciextern int pci_proc_domain(struct pci_bus *bus);
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_cistruct vm_area_struct;
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci/* Tell PCI code what kind of PCI resource mappings we support */
7362306a36Sopenharmony_ci#define HAVE_PCI_MMAP			1
7462306a36Sopenharmony_ci#define ARCH_GENERIC_PCI_MMAP_RESOURCE	1
7562306a36Sopenharmony_ci#define arch_can_pci_mmap_io()		1
7662306a36Sopenharmony_ci#define arch_can_pci_mmap_wc()		1
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ciextern int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val,
7962306a36Sopenharmony_ci			   size_t count);
8062306a36Sopenharmony_ciextern int pci_legacy_write(struct pci_bus *bus, loff_t port, u32 val,
8162306a36Sopenharmony_ci			   size_t count);
8262306a36Sopenharmony_ciextern int pci_mmap_legacy_page_range(struct pci_bus *bus,
8362306a36Sopenharmony_ci				      struct vm_area_struct *vma,
8462306a36Sopenharmony_ci				      enum pci_mmap_state mmap_state);
8562306a36Sopenharmony_ciextern void pci_adjust_legacy_attr(struct pci_bus *bus,
8662306a36Sopenharmony_ci				   enum pci_mmap_state mmap_type);
8762306a36Sopenharmony_ci#define HAVE_PCI_LEGACY	1
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ciextern void pcibios_claim_one_bus(struct pci_bus *b);
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ciextern void pcibios_finish_adding_to_bus(struct pci_bus *bus);
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ciextern void pcibios_resource_survey(void);
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ciextern struct pci_controller *init_phb_dynamic(struct device_node *dn);
9662306a36Sopenharmony_ciextern int remove_phb_dynamic(struct pci_controller *phb);
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ciextern struct pci_dev *of_create_pci_dev(struct device_node *node,
9962306a36Sopenharmony_ci					struct pci_bus *bus, int devfn);
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ciextern unsigned int pci_parse_of_flags(u32 addr0, int bridge);
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ciextern void of_scan_pci_bridge(struct pci_dev *dev);
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ciextern void of_scan_bus(struct device_node *node, struct pci_bus *bus);
10662306a36Sopenharmony_ciextern void of_rescan_bus(struct device_node *node, struct pci_bus *bus);
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_cistruct file;
10962306a36Sopenharmony_ciextern pgprot_t	pci_phys_mem_access_prot(struct file *file,
11062306a36Sopenharmony_ci					 unsigned long pfn,
11162306a36Sopenharmony_ci					 unsigned long size,
11262306a36Sopenharmony_ci					 pgprot_t prot);
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ciextern resource_size_t pcibios_io_space_offset(struct pci_controller *hose);
11562306a36Sopenharmony_ciextern void pcibios_setup_bus_self(struct pci_bus *bus);
11662306a36Sopenharmony_ciextern void pcibios_setup_phb_io_space(struct pci_controller *hose);
11762306a36Sopenharmony_ciextern void pcibios_scan_phb(struct pci_controller *hose);
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci#endif	/* __KERNEL__ */
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci#endif /* __ASM_POWERPC_PCI_H */
122