18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci#ifndef __ASM_POWERPC_PCI_H
38c2ecf20Sopenharmony_ci#define __ASM_POWERPC_PCI_H
48c2ecf20Sopenharmony_ci#ifdef __KERNEL__
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci/*
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/types.h>
108c2ecf20Sopenharmony_ci#include <linux/slab.h>
118c2ecf20Sopenharmony_ci#include <linux/string.h>
128c2ecf20Sopenharmony_ci#include <linux/dma-map-ops.h>
138c2ecf20Sopenharmony_ci#include <linux/scatterlist.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <asm/machdep.h>
168c2ecf20Sopenharmony_ci#include <asm/io.h>
178c2ecf20Sopenharmony_ci#include <asm/prom.h>
188c2ecf20Sopenharmony_ci#include <asm/pci-bridge.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* Return values for pci_controller_ops.probe_mode function */
218c2ecf20Sopenharmony_ci#define PCI_PROBE_NONE		-1	/* Don't look at this bus at all */
228c2ecf20Sopenharmony_ci#define PCI_PROBE_NORMAL	0	/* Do normal PCI probing */
238c2ecf20Sopenharmony_ci#define PCI_PROBE_DEVTREE	1	/* Instantiate from device tree */
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define PCIBIOS_MIN_IO		0x1000
268c2ecf20Sopenharmony_ci#define PCIBIOS_MIN_MEM		0x10000000
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* Values for the `which' argument to sys_pciconfig_iobase syscall.  */
298c2ecf20Sopenharmony_ci#define IOBASE_BRIDGE_NUMBER	0
308c2ecf20Sopenharmony_ci#define IOBASE_MEMORY		1
318c2ecf20Sopenharmony_ci#define IOBASE_IO		2
328c2ecf20Sopenharmony_ci#define IOBASE_ISA_IO		3
338c2ecf20Sopenharmony_ci#define IOBASE_ISA_MEM		4
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/*
368c2ecf20Sopenharmony_ci * Set this to 1 if you want the kernel to re-assign all PCI
378c2ecf20Sopenharmony_ci * bus numbers (don't do that on ppc64 yet !)
388c2ecf20Sopenharmony_ci */
398c2ecf20Sopenharmony_ci#define pcibios_assign_all_busses() \
408c2ecf20Sopenharmony_ci	(pci_has_flag(PCI_REASSIGN_ALL_BUS))
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
438c2ecf20Sopenharmony_cistatic inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
448c2ecf20Sopenharmony_ci{
458c2ecf20Sopenharmony_ci	if (ppc_md.pci_get_legacy_ide_irq)
468c2ecf20Sopenharmony_ci		return ppc_md.pci_get_legacy_ide_irq(dev, channel);
478c2ecf20Sopenharmony_ci	return channel ? 15 : 14;
488c2ecf20Sopenharmony_ci}
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI
518c2ecf20Sopenharmony_ciextern void set_pci_dma_ops(const struct dma_map_ops *dma_ops);
528c2ecf20Sopenharmony_ci#else	/* CONFIG_PCI */
538c2ecf20Sopenharmony_ci#define set_pci_dma_ops(d)
548c2ecf20Sopenharmony_ci#endif
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/*
598c2ecf20Sopenharmony_ci * We want to avoid touching the cacheline size or MWI bit.
608c2ecf20Sopenharmony_ci * pSeries firmware sets the cacheline size (which is not the cpu cacheline
618c2ecf20Sopenharmony_ci * size in all cases) and hardware treats MWI the same as memory write.
628c2ecf20Sopenharmony_ci */
638c2ecf20Sopenharmony_ci#define PCI_DISABLE_MWI
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#endif /* CONFIG_PPC64 */
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ciextern int pci_domain_nr(struct pci_bus *bus);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci/* Decide whether to display the domain number in /proc */
708c2ecf20Sopenharmony_ciextern int pci_proc_domain(struct pci_bus *bus);
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cistruct vm_area_struct;
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci/* Tell PCI code what kind of PCI resource mappings we support */
758c2ecf20Sopenharmony_ci#define HAVE_PCI_MMAP			1
768c2ecf20Sopenharmony_ci#define ARCH_GENERIC_PCI_MMAP_RESOURCE	1
778c2ecf20Sopenharmony_ci#define arch_can_pci_mmap_io()		1
788c2ecf20Sopenharmony_ci#define arch_can_pci_mmap_wc()		1
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ciextern int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val,
818c2ecf20Sopenharmony_ci			   size_t count);
828c2ecf20Sopenharmony_ciextern int pci_legacy_write(struct pci_bus *bus, loff_t port, u32 val,
838c2ecf20Sopenharmony_ci			   size_t count);
848c2ecf20Sopenharmony_ciextern int pci_mmap_legacy_page_range(struct pci_bus *bus,
858c2ecf20Sopenharmony_ci				      struct vm_area_struct *vma,
868c2ecf20Sopenharmony_ci				      enum pci_mmap_state mmap_state);
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define HAVE_PCI_LEGACY	1
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ciextern void pcibios_claim_one_bus(struct pci_bus *b);
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ciextern void pcibios_finish_adding_to_bus(struct pci_bus *bus);
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ciextern void pcibios_resource_survey(void);
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ciextern struct pci_controller *init_phb_dynamic(struct device_node *dn);
978c2ecf20Sopenharmony_ciextern int remove_phb_dynamic(struct pci_controller *phb);
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ciextern struct pci_dev *of_create_pci_dev(struct device_node *node,
1008c2ecf20Sopenharmony_ci					struct pci_bus *bus, int devfn);
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ciextern unsigned int pci_parse_of_flags(u32 addr0, int bridge);
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ciextern void of_scan_pci_bridge(struct pci_dev *dev);
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ciextern void of_scan_bus(struct device_node *node, struct pci_bus *bus);
1078c2ecf20Sopenharmony_ciextern void of_rescan_bus(struct device_node *node, struct pci_bus *bus);
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_cistruct file;
1108c2ecf20Sopenharmony_ciextern pgprot_t	pci_phys_mem_access_prot(struct file *file,
1118c2ecf20Sopenharmony_ci					 unsigned long pfn,
1128c2ecf20Sopenharmony_ci					 unsigned long size,
1138c2ecf20Sopenharmony_ci					 pgprot_t prot);
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ciextern resource_size_t pcibios_io_space_offset(struct pci_controller *hose);
1168c2ecf20Sopenharmony_ciextern void pcibios_setup_bus_self(struct pci_bus *bus);
1178c2ecf20Sopenharmony_ciextern void pcibios_setup_phb_io_space(struct pci_controller *hose);
1188c2ecf20Sopenharmony_ciextern void pcibios_scan_phb(struct pci_controller *hose);
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#endif	/* __KERNEL__ */
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ciextern struct pci_dev *pnv_pci_get_gpu_dev(struct pci_dev *npdev);
1238c2ecf20Sopenharmony_ciextern struct pci_dev *pnv_pci_get_npu_dev(struct pci_dev *gpdev, int index);
1248c2ecf20Sopenharmony_ciextern int pnv_npu2_init(struct pci_controller *hose);
1258c2ecf20Sopenharmony_ciextern int pnv_npu2_map_lpar_dev(struct pci_dev *gpdev, unsigned int lparid,
1268c2ecf20Sopenharmony_ci		unsigned long msr);
1278c2ecf20Sopenharmony_ciextern int pnv_npu2_unmap_lpar_dev(struct pci_dev *gpdev);
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#endif /* __ASM_POWERPC_PCI_H */
130